mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-14 20:48:00 +00:00
optimize js package folder structure (#7989)
* put generated .js files into dist/ folder * format code
This commit is contained in:
parent
47d8977741
commit
1cc896c8ae
17 changed files with 44 additions and 38 deletions
6
js/common/.gitignore
vendored
6
js/common/.gitignore
vendored
|
|
@ -1,10 +1,4 @@
|
|||
node_modules/
|
||||
types/
|
||||
dist/
|
||||
|
||||
tsconfig.tsbuildinfo
|
||||
|
||||
lib/**/*.js
|
||||
lib/**/*.js.map
|
||||
|
||||
*.d.ts
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@
|
|||
|
||||
webpack.config.js
|
||||
tsconfig.json
|
||||
tsconfig.tsbuildinfo
|
||||
**/*.tsbuildinfo
|
||||
|
||||
*.tgz
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@
|
|||
"webpack-cli": "^4.7.0"
|
||||
},
|
||||
"main": "dist/ort-common.node.js",
|
||||
"types": "./types/index.d.ts",
|
||||
"types": "dist/lib/index.d.ts",
|
||||
"jsdelivr": "dist/ort-common.min.js",
|
||||
"unpkg": "dist/ort-common.min.js",
|
||||
"module": "./lib/index.js"
|
||||
"module": "dist/lib/index.js"
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declarationDir": "./types"
|
||||
"outDir": "dist/lib",
|
||||
},
|
||||
"include": ["lib"]
|
||||
}
|
||||
|
|
|
|||
4
js/node/.gitignore
vendored
4
js/node/.gitignore
vendored
|
|
@ -1,12 +1,10 @@
|
|||
node_modules/
|
||||
/build/
|
||||
/bin/
|
||||
/dist/
|
||||
/prebuilds/
|
||||
/types/
|
||||
|
||||
/lib/**/*.js
|
||||
/lib/**/*.js.map
|
||||
/script/**/*.js
|
||||
/script/**/*.js.map
|
||||
/test/**/*.js
|
||||
/test/**/*.js.map
|
||||
|
|
|
|||
|
|
@ -11,6 +11,6 @@
|
|||
|
||||
CMakeLists.txt
|
||||
tsconfig.json
|
||||
tsconfig.tsbuildinfo
|
||||
**/*.tsbuildinfo
|
||||
|
||||
*.tgz
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@
|
|||
"rebuildd": "tsc && node ./script/build --rebuild --config=Debug",
|
||||
"rebuildr": "tsc && node ./script/build --rebuild --config=RelWithDebInfo",
|
||||
"install": "prebuild-install -r napi || (tsc && node ./script/build)",
|
||||
"prepare": "tsc",
|
||||
"test": "mocha ./test/test-main",
|
||||
"prepare": "tsc --build script && tsc",
|
||||
"test": "tsc --build test && mocha ./test/test-main",
|
||||
"prepack": "node ./script/prepack"
|
||||
},
|
||||
"dependencies": {
|
||||
|
|
@ -50,8 +50,8 @@
|
|||
"typedoc": "^0.20.25",
|
||||
"typescript": "^4.2.4"
|
||||
},
|
||||
"main": "./lib/index.js",
|
||||
"types": "./types/lib/index.d.ts",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"os": [
|
||||
"win32",
|
||||
"darwin",
|
||||
|
|
|
|||
3
js/node/script/tsconfig.json
Normal file
3
js/node/script/tsconfig.json
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"extends": "../../tsconfig.tools.json"
|
||||
}
|
||||
|
|
@ -1,10 +1,9 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import {InferenceSession} from 'onnxruntime-common';
|
||||
import {InferenceSession, Tensor} from 'onnxruntime-common';
|
||||
import * as path from 'path';
|
||||
|
||||
import {Tensor} from '../../lib';
|
||||
import {SQUEEZENET_INPUT0_DATA, SQUEEZENET_OUTPUT0_DATA, TEST_DATA_ROOT} from '../test-utils';
|
||||
import {assertTensorEqual} from '../test-utils';
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,9 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
import assert from 'assert';
|
||||
import {InferenceSession} from 'onnxruntime-common';
|
||||
import {InferenceSession, Tensor} from 'onnxruntime-common';
|
||||
import * as path from 'path';
|
||||
|
||||
import {Tensor} from '../../lib';
|
||||
import {assertDataEqual, TEST_DATA_ROOT} from '../test-utils';
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
import {NODE_TESTS_ROOT, warmup} from './test-utils';
|
||||
|
||||
// require onnxruntime-node.
|
||||
require('..');
|
||||
|
||||
// warmup
|
||||
//
|
||||
// for unknown reason, the first call to native InferenceSession::Run() is very slow.
|
||||
|
|
|
|||
|
|
@ -2,10 +2,9 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
import * as fs from 'fs-extra';
|
||||
import {InferenceSession, Tensor} from 'onnxruntime-common';
|
||||
import * as path from 'path';
|
||||
|
||||
import {InferenceSession, Tensor} from '../lib';
|
||||
|
||||
import {assertTensorEqual, loadTensorFromFile, shouldSkipModel} from './test-utils';
|
||||
|
||||
export function run(testDataFolder: string): void {
|
||||
|
|
|
|||
|
|
@ -5,11 +5,9 @@ import assert from 'assert';
|
|||
import * as fs from 'fs-extra';
|
||||
import {jsonc} from 'jsonc';
|
||||
import * as onnx_proto from 'onnx-proto';
|
||||
import {Tensor} from 'onnxruntime-common';
|
||||
import {InferenceSession, Tensor} from 'onnxruntime-common';
|
||||
import * as path from 'path';
|
||||
|
||||
import {binding} from '../lib/binding';
|
||||
|
||||
export const TEST_ROOT = __dirname;
|
||||
export const TEST_DATA_ROOT = path.join(TEST_ROOT, 'testdata');
|
||||
|
||||
|
|
@ -72,13 +70,16 @@ export function createTestTensor(type: Tensor.Type, lengthOrDims?: number|number
|
|||
|
||||
// call the addon directly to make sure DLL is loaded
|
||||
export function warmup(): void {
|
||||
// we have test cases to verify correctness in other place, so do no check here.
|
||||
try {
|
||||
const session = new binding.InferenceSession();
|
||||
session.loadModel(path.join(TEST_DATA_ROOT, 'test_types_INT32.pb'), {});
|
||||
session.run({input: new Tensor(new Float32Array(5), [1, 5])}, {output: null}, {});
|
||||
} catch (e) {
|
||||
}
|
||||
describe('Warmup', async function() {
|
||||
// eslint-disable-next-line no-invalid-this
|
||||
this.timeout(0);
|
||||
// we have test cases to verify correctness in other place, so do no check here.
|
||||
try {
|
||||
const session = await InferenceSession.create(path.join(TEST_DATA_ROOT, 'test_types_INT32.pb'));
|
||||
await session.run({input: new Tensor(new Float32Array(5), [1, 5])}, {output: null}, {});
|
||||
} catch (e) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function assertFloatEqual(
|
||||
|
|
|
|||
3
js/node/test/tsconfig.json
Normal file
3
js/node/test/tsconfig.json
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"extends": "../../tsconfig.tools.json"
|
||||
}
|
||||
|
|
@ -3,10 +3,9 @@
|
|||
|
||||
import assert from 'assert';
|
||||
import * as fs from 'fs';
|
||||
import {InferenceSession} from 'onnxruntime-common';
|
||||
import {InferenceSession, Tensor, TypedTensor} from 'onnxruntime-common';
|
||||
import * as path from 'path';
|
||||
|
||||
import {Tensor, TypedTensor} from '../../../lib';
|
||||
import {assertTensorEqual} from '../../test-utils';
|
||||
|
||||
const SQUEEZENET_INPUT0_DATA = require(path.join(__dirname, '../../testdata/squeezenet.input0.json'));
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"module": "CommonJS",
|
||||
"declarationDir": "./types"
|
||||
"outDir": "dist"
|
||||
},
|
||||
"include": ["lib", "script", "test"]
|
||||
"include": ["lib"]
|
||||
}
|
||||
|
|
|
|||
8
js/tsconfig.tools.json
Normal file
8
js/tsconfig.tools.json
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"module": "CommonJS",
|
||||
"declaration": false,
|
||||
"sourceMap": false
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue