onnxruntime/nodejs/test/e2e/inference-session-run.ts
Yulong Wang 73bc6be5d1
build: split nodejs binding build and test to avoid timeout issue (#4188)
* split nodejs binding build and test

* enable nodejs tests
2020-06-10 19:16:32 -07:00

26 lines
1 KiB
TypeScript

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import * as path from 'path';
import {Tensor} from '../../lib';
import {InferenceSession} from '../../lib/inference-session';
import {SQUEEZENET_INPUT0_DATA, SQUEEZENET_OUTPUT0_DATA, TEST_DATA_ROOT} from '../test-utils';
import {assertTensorEqual} from '../test-utils';
describe('E2E Tests - InferenceSession.run()', async () => {
let session: InferenceSession|null = null;
const input0 = new Tensor('float32', SQUEEZENET_INPUT0_DATA, [1, 3, 224, 224]);
const expectedOutput0 = new Tensor('float32', SQUEEZENET_OUTPUT0_DATA, [1, 1000, 1, 1]);
before(async () => {
session = await InferenceSession.create(path.join(TEST_DATA_ROOT, 'squeezenet.onnx'));
});
it('multiple run() calls', async () => {
for (let i = 0; i < 1000; i++) {
const result = await session!.run({'data_0': input0}, ['softmaxout_1']);
assertTensorEqual(result.softmaxout_1, expectedOutput0);
}
}).timeout('120s');
});