Skip to content
This repository was archived by the owner on Jun 4, 2021. It is now read-only.

Commit 93b46ad

Browse files
committed
comsume official nodejs binding
1 parent 04561eb commit 93b46ad

33 files changed

+931
-7560
lines changed

.clang-format

-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,3 @@
22
Language: JavaScript
33
BasedOnStyle: Google
44
ColumnLimit: 120
5-
---
6-
Language: Cpp
7-
BasedOnStyle: LLVM
8-
ColumnLimit: 120

.gitignore

-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
/node_modules/
2-
/build/
3-
/bin/
42
/types/
53

64
/lib/*.js
75
/lib/*.js.map
8-
/scripts/*.js
9-
/scripts/*.js.map
106
/test/*.js
117
/test/*.js.map
12-
13-
/.vscode/ipch/

.npmignore

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
/.vscode/
2-
/bin/
3-
/build/
42
/deps/
5-
/onnxruntime/
6-
/scripts/
73
/src/
84
/test/
95

@@ -15,5 +11,4 @@
1511

1612
/.clang-format
1713
/.gitmodules
18-
/CMakeLists.txt
19-
/tsconfig.json
14+
/tsconfig.json

.vscode/c_cpp_properties.json

-22
This file was deleted.

.vscode/launch.json

+2-18
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,6 @@
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
66
"configurations": [
7-
{
8-
"name": "Debug Tests (Windows, C++)",
9-
"type": "cppvsdbg",
10-
"request": "launch",
11-
"program": "node.exe",
12-
"args": [
13-
"${workspaceFolder}/node_modules/mocha/bin/_mocha",
14-
"--timeout",
15-
"999999",
16-
"--colors",
17-
"${workspaceFolder}/test/test-main"
18-
],
19-
"stopAtEntry": false,
20-
"cwd": "${workspaceFolder}",
21-
"environment": [],
22-
"externalConsole": true
23-
},
247
{
258
"type": "node",
269
"request": "launch",
@@ -33,7 +16,8 @@
3316
"${workspaceFolder}/test/test-main"
3417
],
3518
"internalConsoleOptions": "openOnSessionStart",
36-
"sourceMaps": true
19+
"sourceMaps": true,
20+
"smartStep": true
3721
}
3822
]
3923
}

.vscode/settings.json

-55
This file was deleted.

CMakeLists.txt

-48
This file was deleted.

README.md

+6-8
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ npm install onnxjs-node
1515
## Supported Platforms
1616
OS |Arch |CPU/GPU |NAPI version |Node.js version | ONNXRuntime version
1717
---------|-----|--------|-------------|----------------|---------------------
18-
Windows | x64 | CPU | v3 | v8.11.2+ | v0.4.0
19-
Linux | x64 | CPU | v3 | v8.11.2+ | v0.4.0
20-
macOS | x64 | CPU | v3 | v8.11.2+ | v0.4.0
21-
Windows | x64 | GPU | v3 | v8.11.2+ | v0.4.0
22-
Linux | x64 | GPU | v3 | v8.11.2+ | v0.4.0
18+
Windows | x64 | CPU | v3 | v12.0.0+ | v1.4.0
19+
Linux | x64 | CPU | v3 | v12.0.0+ | v1.4.0
20+
macOS | x64 | CPU | v3 | v12.0.0+ | v1.4.0
21+
Windows | x64 | GPU | v3 | v12.0.0+ | v1.4.0
22+
Linux | x64 | GPU | v3 | v12.0.0+ | v1.4.0
2323

2424
## Usage
2525
There are 2 options to import `onnxjs-node`.
@@ -53,9 +53,7 @@ session = new onnx.InferenceSession({backendHint: 'wasm'}); // use WebAssembly
5353

5454
## Documentation
5555
- [ONNX.js Home](https://github.com/Microsoft/onnxjs)
56-
- [ONNXRuntime](https://github.com/Microsoft/onnxruntime)
57-
- [Nuget package: Microsoft.ML.OnnxRuntime](https://www.nuget.org/packages/Microsoft.ML.OnnxRuntime/)
58-
- [Nuget package: Microsoft.ML.OnnxRuntime.Gpu](https://www.nuget.org/packages/Microsoft.ML.OnnxRuntime.Gpu/)
56+
- [ONNXRuntime Node.js binding](https://github.com/Microsoft/onnxruntime/nodejs)
5957

6058
# License
6159
Copyright (c) fs-eire. All rights reserved.

lib/binding.ts

-25
This file was deleted.

lib/index.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,16 @@ if (typeof process !== 'undefined' && process && process.release && process.rele
1818
throw new Error(`onnxruntime node binding does not support non little-endian platform`);
1919
}
2020

21-
// force re-assign overwritten property 'InferenceSession'
22-
(onnxjs as any).InferenceSession = require('./inference-session-override').OnnxRuntimeInferenceSession;
21+
// create a new onnx object and assign property 'InferenceSession'
22+
const onnx: typeof onnxjs = Object.create(onnxjs);
23+
Object.defineProperty(onnx, 'InferenceSession', {
24+
enumerable: true,
25+
get: function() {
26+
return require('./inference-session-override').OnnxRuntimeInferenceSession;
27+
}
28+
});
29+
30+
(global as any).onnx = onnx;
2331
}
2432

25-
export = onnxjs;
33+
export = onnx;

0 commit comments

Comments
 (0)