Skip to content

Commit a584297

Browse files
authored
feat!: remove deprecated XNNPACK_FP32 variants (#1599)
## Description Removes the 66 `XNNPACK_FP32` variants deprecated in #1519, plus the download-warning machinery (`deprecation.ts`) that only they used. ### Introduces a breaking change? - [x] Yes - [ ] No ### Type of change - [ ] Bug fix (change which fixes an issue) - [ ] New feature (change which adds functionality) - [ ] Documentation update (improves or adds clarity to existing documentation) - [x] Other (chores, tests, code style improvements etc.) ### Tested on - [ ] iOS - [ ] Android ### Testing instructions - `yarn typecheck` and `yarn workspace react-native-executorch test` ### Screenshots ### Related issues #1213 ### Checklist - [x] I have performed a self-review of my code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have updated the documentation accordingly - [x] My changes generate no new warnings ### Additional notes
1 parent 8e3310f commit a584297

6 files changed

Lines changed: 5 additions & 640 deletions

File tree

‎apps/benchmarks/scripts/fetch-variant-sizes.mjs‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@ function loadRegistry() {
5151
)
5252
.replace("} from './extensions/speech/tasks/whisperSpeechToText';", "} from './_stub.ts';")
5353
.replace("} from './constants';", "} from './constants.ts';")
54-
.replace(
55-
"import { registerDeprecation } from './deprecation';",
56-
"import { registerDeprecation } from './_stub.ts';"
57-
)
5854
// Type-only imports name files that are not copied into the scratch dir.
5955
// Node strips the annotations but still resolves the specifier, so they
6056
// have to go.
@@ -74,7 +70,6 @@ function loadRegistry() {
7470
"export const getRegisteredBackends = () => ['XnnpackBackend', 'CoreMLBackend', 'MLXBackend', 'VulkanBackend'];",
7571
"export const WHISPER_LANGUAGES = ['en'];",
7672
'export const WhisperSttModel = undefined;',
77-
'export const registerDeprecation = () => {};',
7873
'',
7974
].join('\n')
8075
);

‎packages/react-native-executorch/__tests__/api/modelVariants.test.ts‎

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ const modelPathsOf = (config: Node): string =>
3333
.sort()
3434
.join('|');
3535

36-
const modelUrlsOf = (config: Node): string[] =>
37-
typeof config.modelPath === 'string'
38-
? [config.modelPath]
39-
: Object.values(config.modelPaths as Node).map(String);
40-
4136
const isUpperKey = (key: string) => /^[A-Z0-9_]+$/.test(key);
4237

4338
/** Every group that names a `DEFAULT`, with the dotted path it sits at. */
@@ -342,79 +337,6 @@ describe('variant selection rules', () => {
342337
});
343338
});
344339

345-
describe('deprecated variants', () => {
346-
/** The devices a `DEFAULT` can resolve differently on. */
347-
const devices = [
348-
{ os: 'ios' as const },
349-
{ os: 'android' as const },
350-
{ os: 'ios' as const, isEmulator: true },
351-
{ os: 'ios' as const, backends: ['XnnpackBackend'] },
352-
{ os: 'android' as const, backends: ['XnnpackBackend'] },
353-
];
354-
355-
/**
356-
* Every group of the registry as resolved on `device`, with the notices of
357-
* the variants it deprecates. Read from the deprecation module the reloaded
358-
* registry registered them in.
359-
*/
360-
function deprecationsFor(device: Parameters<typeof registryFor>[0]) {
361-
const registry = registryFor(device);
362-
const { deprecationOf } = require('../../src/deprecation') as {
363-
deprecationOf: (modelPath: string) => string | undefined;
364-
};
365-
return variantGroups(registry).map(({ label, group }) => ({
366-
label,
367-
group,
368-
notices: new Map(
369-
namedVariants(group).flatMap(([key, config]) => {
370-
const notice = modelUrlsOf(config)
371-
.map(deprecationOf)
372-
.find((n) => n !== undefined);
373-
return notice === undefined ? [] : [[key, notice] as const];
374-
})
375-
),
376-
}));
377-
}
378-
379-
it('finds deprecated variants to check', () => {
380-
const count = deprecationsFor({ os: 'android' }).reduce(
381-
(n, { notices }) => n + notices.size,
382-
0
383-
);
384-
expect(count).toBeGreaterThan(0);
385-
});
386-
387-
it('never defaults to a deprecated variant, on any device', () => {
388-
const offenders = devices.flatMap((device) =>
389-
deprecationsFor(device)
390-
.filter(({ group, notices }) => notices.has(defaultKeyOf(group) ?? ''))
391-
.map(({ label, group }) => `${JSON.stringify(device)} ${label}: ${defaultKeyOf(group)}`)
392-
);
393-
394-
expect(offenders).toEqual([]);
395-
});
396-
397-
it('points every deprecated variant at a supported sibling', () => {
398-
const offenders = deprecationsFor({ os: 'android' }).flatMap(({ label, group, notices }) =>
399-
[...notices].flatMap(([key, notice]) => {
400-
const prefix = `models.${label}.`;
401-
const named = notice.match(/^(\S+) is deprecated.* Use (\S+), which/);
402-
const replacement = named?.[2]?.startsWith(prefix)
403-
? named[2].slice(prefix.length)
404-
: undefined;
405-
const ok =
406-
named?.[1] === `${prefix}${key}` &&
407-
replacement !== undefined &&
408-
isConfig(group[replacement]) &&
409-
!notices.has(replacement);
410-
return ok ? [] : [`${label}.${key}: ${notice}`];
411-
})
412-
);
413-
414-
expect(offenders).toEqual([]);
415-
});
416-
});
417-
418340
describe('feature map', () => {
419341
// `models.<task>.<MODEL>.DEFAULT` only reaches the accelerated export when
420342
// the app downloaded that backend, and `features` is the documented way to

‎packages/react-native-executorch/__tests__/fetcher/download.test.ts‎

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { isRnExecuTorchError } from '../../src/core/error';
2-
import { registerDeprecation } from '../../src/deprecation';
32
import { download } from '../../src/fetcher/fetcher';
43
import { setTelemetryEnabled } from '../../src/fetcher/telemetry';
54
import { until } from '../support/async';
@@ -109,22 +108,6 @@ describe('download — resolution', () => {
109108
});
110109
});
111110

112-
describe('download — deprecated models', () => {
113-
it('warns once per deprecated model, however often it is downloaded', async () => {
114-
const warn = jest.spyOn(console, 'warn').mockImplementation(() => {});
115-
const deprecatedUrl = 'https://huggingface.co/software-mansion/model/resolve/v1/old.pte';
116-
registerDeprecation(deprecatedUrl, 'old.pte is deprecated.');
117-
fakeNet.serve(deprecatedUrl);
118-
fakeNet.serve(URL_B);
119-
120-
await download({ modelPath: deprecatedUrl, tokenizerPath: URL_B });
121-
await download({ modelPath: deprecatedUrl });
122-
123-
expect(warn.mock.calls).toEqual([['[React Native ExecuTorch] old.pte is deprecated.']]);
124-
warn.mockRestore();
125-
});
126-
});
127-
128111
describe('download — caching', () => {
129112
it('serves a second call from the cache without a request', async () => {
130113
fakeNet.serve(URL_A);

‎packages/react-native-executorch/src/deprecation.ts‎

Lines changed: 0 additions & 45 deletions
This file was deleted.

‎packages/react-native-executorch/src/fetcher/fetcher.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
type BackgroundDownloadTask,
1010
} from './backgroundDownloader';
1111
import { RnExecuTorchError } from '../core/error';
12-
import { warnIfDeprecated } from '../deprecation';
1312

1413
const IS_ANDROID = Platform.OS === 'android';
1514

@@ -793,7 +792,6 @@ function substituteRemoteSources<T>(node: T, resolved: ReadonlyMap<string, strin
793792
*/
794793
export async function download<T>(source: T, options: DownloadOptions = {}): Promise<T> {
795794
const urls = [...collectRemoteSources(source)];
796-
warnIfDeprecated(urls);
797795

798796
// Nothing to fetch — every source is already a local path.
799797
if (urls.length === 0) {

0 commit comments

Comments
 (0)