Use uppercase options name for "delegate"
PiperOrigin-RevId: 496764089
This commit is contained in:
committed by
Copybara-Service
parent
a7b52d2c52
commit
d2f738793c
@@ -86,7 +86,7 @@ describe('convertBaseOptionsToProto()', () => {
|
||||
it('can enable CPU delegate', async () => {
|
||||
const baseOptionsProto = await convertBaseOptionsToProto({
|
||||
modelAssetBuffer: new Uint8Array(mockBytes),
|
||||
delegate: 'cpu',
|
||||
delegate: 'CPU',
|
||||
});
|
||||
expect(baseOptionsProto.toObject()).toEqual(mockBytesResult);
|
||||
});
|
||||
@@ -94,7 +94,7 @@ describe('convertBaseOptionsToProto()', () => {
|
||||
it('can enable GPU delegate', async () => {
|
||||
const baseOptionsProto = await convertBaseOptionsToProto({
|
||||
modelAssetBuffer: new Uint8Array(mockBytes),
|
||||
delegate: 'gpu',
|
||||
delegate: 'GPU',
|
||||
});
|
||||
expect(baseOptionsProto.toObject()).toEqual({
|
||||
...mockBytesResult,
|
||||
@@ -117,7 +117,7 @@ describe('convertBaseOptionsToProto()', () => {
|
||||
it('can reset delegate', async () => {
|
||||
let baseOptionsProto = await convertBaseOptionsToProto({
|
||||
modelAssetBuffer: new Uint8Array(mockBytes),
|
||||
delegate: 'gpu',
|
||||
delegate: 'GPU',
|
||||
});
|
||||
// Clear backend
|
||||
baseOptionsProto =
|
||||
|
||||
@@ -71,7 +71,7 @@ async function configureExternalFile(
|
||||
/** Configues the `acceleration` option. */
|
||||
function configureAcceleration(options: BaseOptions, proto: BaseOptionsProto) {
|
||||
const acceleration = proto.getAcceleration() ?? new Acceleration();
|
||||
if (options.delegate === 'gpu') {
|
||||
if (options.delegate === 'GPU') {
|
||||
acceleration.setGpu(new InferenceCalculatorOptions.Delegate.Gpu());
|
||||
} else {
|
||||
acceleration.setTflite(new InferenceCalculatorOptions.Delegate.TfLite());
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ export declare interface BaseOptions {
|
||||
modelAssetBuffer?: Uint8Array|undefined;
|
||||
|
||||
/** Overrides the default backend to use for the provided model. */
|
||||
delegate?: 'cpu'|'gpu'|undefined;
|
||||
delegate?: 'CPU'|'GPU'|undefined;
|
||||
}
|
||||
|
||||
/** Options to configure MediaPipe Tasks in general. */
|
||||
|
||||
Reference in New Issue
Block a user