From 13e2467f9f76d7c2719b76565d0d5c24c081f7af Mon Sep 17 00:00:00 2001 From: Ibiyemi Abiodun Date: Thu, 26 Sep 2024 00:26:00 -0400 Subject: [PATCH 1/7] use cuda by default --- src/backends/onnx.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/backends/onnx.js b/src/backends/onnx.js index 0bee3dce7..3d30087e9 100644 --- a/src/backends/onnx.js +++ b/src/backends/onnx.js @@ -26,7 +26,6 @@ export let ONNX; export const executionProviders = [ // 'webgpu', - 'wasm' ]; if (typeof process !== 'undefined' && process?.release?.name === 'node') { @@ -34,12 +33,14 @@ if (typeof process !== 'undefined' && process?.release?.name === 'node') { ONNX = ONNX_NODE.default ?? ONNX_NODE; // Add `cpu` execution provider, with higher precedence that `wasm`. - executionProviders.unshift('cpu'); + executionProviders.push('cuda', 'cpu'); } else { // Running in a browser-environment ONNX = ONNX_WEB.default ?? ONNX_WEB; + executionProviders.push('wasm'); + // SIMD for WebAssembly does not operate correctly in some recent versions of iOS (16.4.x). // As a temporary fix, we disable it for now. // For more information, see: https://github.com/microsoft/onnxruntime/issues/15644 From 1db9d2c6e7ff87ee9656f3ff5beeb9e59766e0f9 Mon Sep 17 00:00:00 2001 From: Ibiyemi Abiodun Date: Thu, 26 Sep 2024 00:28:05 -0400 Subject: [PATCH 2/7] bump onnxruntime-node version to 1.15 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 224682fb9..71fa56079 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "@huggingface/jinja": "^0.2.2" }, "optionalDependencies": { - "onnxruntime-node": "1.14.0" + "onnxruntime-node": "^1.15.0" }, "devDependencies": { "@types/jest": "^29.5.1", From a4d759ad82469ba6d0b8c9be46af0ff491966402 Mon Sep 17 00:00:00 2001 From: Ibiyemi Abiodun Date: Thu, 26 Sep 2024 00:29:34 -0400 Subject: [PATCH 3/7] hmm --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 71fa56079..e868eb833 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "@huggingface/jinja": "^0.2.2" }, "optionalDependencies": { - "onnxruntime-node": "^1.15.0" + "onnxruntime-node": "~1.15.0" }, "devDependencies": { "@types/jest": "^29.5.1", From 6928acd0dd908199c6366cd5dc41870063683bae Mon Sep 17 00:00:00 2001 From: Ibiyemi Abiodun Date: Thu, 26 Sep 2024 00:30:32 -0400 Subject: [PATCH 4/7] bump to 1.16 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e868eb833..421143135 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "@huggingface/jinja": "^0.2.2" }, "optionalDependencies": { - "onnxruntime-node": "~1.15.0" + "onnxruntime-node": "~1.16.0" }, "devDependencies": { "@types/jest": "^29.5.1", From 6e1e71bcdae9d97b4823f690dd1801dd6b32c02f Mon Sep 17 00:00:00 2001 From: Ibiyemi Abiodun Date: Thu, 26 Sep 2024 00:32:20 -0400 Subject: [PATCH 5/7] bump to 1.17 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 421143135..1b6bbc806 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "@huggingface/jinja": "^0.2.2" }, "optionalDependencies": { - "onnxruntime-node": "~1.16.0" + "onnxruntime-node": "~1.17.0" }, "devDependencies": { "@types/jest": "^29.5.1", From ae76a524e8340d09ded4788227806cd90712086b Mon Sep 17 00:00:00 2001 From: Ibiyemi Abiodun Date: Thu, 26 Sep 2024 00:34:58 -0400 Subject: [PATCH 6/7] bump to 1.19 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1b6bbc806..1b4f9754d 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "@huggingface/jinja": "^0.2.2" }, "optionalDependencies": { - "onnxruntime-node": "~1.17.0" + "onnxruntime-node": "~1.19.0" }, "devDependencies": { "@types/jest": "^29.5.1", From e3fcca9cd617e5f9b58a0c1a6f72fd83f0bf71a4 Mon Sep 17 00:00:00 2001 From: Ibiyemi Abiodun Date: Thu, 26 Sep 2024 00:36:21 -0400 Subject: [PATCH 7/7] patch tensor impl --- src/utils/tensor.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/utils/tensor.js b/src/utils/tensor.js index 469054cac..a9051c24b 100644 --- a/src/utils/tensor.js +++ b/src/utils/tensor.js @@ -56,16 +56,25 @@ export class Tensor { */ constructor(...args) { if (args[0] instanceof ONNXTensor) { + const tensor = args[0]; + // Create shallow copy - Object.assign(this, args[0]); + Object.assign(this, tensor); + // Object.assign() doesn't catch the data prop for some reason + this.data = tensor.data; } else { - // Create new tensor - Object.assign(this, new ONNXTensor( + const tensor = new ONNXTensor( /** @type {DataType} */(args[0]), /** @type {Exclude} */(args[1]), args[2] - )); + ); + + // Create new tensor + Object.assign(this, tensor); + + // Object.assign() doesn't catch the data prop for some reason + this.data = tensor.data; } return new Proxy(this, {