OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[OV JS]: Add BigInt64/Uint64 support to Tensor and InferRequest (#32131)
piyush kumarf19bcccfafb4
diff --git a/src/bindings/js/node/lib/addon.ts b/src/bindings/js/node/lib/addon.tsindex c251ddeb968..1e01921036a 100644--- a/src/bindings/js/node/lib/addon.ts+++ b/src/bindings/js/node/lib/addon.ts@@ -6,7 +6,9 @@ type SupportedTypedArray =| Int32Array| Uint32Array| Float32Array- | Float64Array;+ | Float64Array+ | BigInt64Array+ | BigUint64Array;type elementTypeString =| "u8"diff --git a/src/bindings/js/node/tests/unit/infer_request.test.js b/src/bindings/js/node/tests/unit/infer_request.test.jsindex c63896b8661..513c71ffbf1 100644--- a/src/bindings/js/node/tests/unit/infer_request.test.js+++ b/src/bindings/js/node/tests/unit/infer_request.test.js@@ -131,6 +131,74 @@ describe("ov.InferRequest tests", () => {});});+ describe("BigInt InferRequest support", () => {+ let core, originalModel, compiledModel, inferRequest;++ before(async () => {+ const { addModel } = testModels;+ await isModelAvailable(addModel);+ core = new ov.Core();+ originalModel = core.readModelSync(addModel.xml);+ });++ beforeEach(() => {+ const model = originalModel.clone();++ const ppp = new ov.preprocess.PrePostProcessor(model);+ ppp.input(0).tensor().setElementType(ov.element.i64);+ ppp.input(1).tensor().setElementType(ov.element.i64);+ ppp.build();++ compiledModel = core.compileModelSync(model, "CPU");+ inferRequest = compiledModel.createInferRequest();+ });++ it("infers with BigInt64Array input using Tensor objects", () => {+ const shape0 = originalModel.input(0).getShape();+ const shape1 = originalModel.input(1).getShape();+ const size0 = shape0.reduce((a, b) => a * b, 1);+ const size1 = shape1.reduce((a, b) => a * b, 1);+ const inputData0 = new BigInt64Array(size0).fill(1n);+ const inputData1 = new BigInt64Array(size1).fill(2n);++ const tensor0 = new ov.Tensor(ov.element.i64, shape0, inputData0);+ const tensor1 = new ov.Tensor(ov.element.i64, shape1, inputData1);++ assert.doesNotThrow(() => {+ const result = inferRequest.infer([tensor0, tensor1]);+ assert.ok(result);+ const outputTensor = Object.values(result)[0];+ assert.ok(outputTensor instanceof ov.Tensor);+ });+ });++ it("infers with BigUint64Array input", () => {+ const model = originalModel.clone();+ const ppp = new ov.preprocess.PrePostProcessor(model);+ ppp.input(0).tensor().setElementType(ov.element.u64);+ ppp.input(1).tensor().setElementType(ov.element.u64);+ ppp.build();+ const compiledModelU64 = core.compileModelSync(model, "CPU");+ const inferRequestU64 = compiledModelU64.createInferRequest();++ const shape0 = originalModel.input(0).getShape();+ const shape1 = originalModel.input(1).getShape();+ const size0 = shape0.reduce((a, b) => a * b, 1);+ const size1 = shape1.reduce((a, b) => a * b, 1);+ const inputData0 = new BigUint64Array(size0).fill(1n);+ const inputData1 = new BigUint64Array(size1).fill(2n);++ const tensor0 = new ov.Tensor(ov.element.u64, shape0, inputData0);+ const tensor1 = new ov.Tensor(ov.element.u64, shape1, inputData1);++ assert.doesNotThrow(() => {+ const result = inferRequestU64.infer([tensor0, tensor1]);+ assert.ok(result);+ const outputTensor = Object.values(result)[0];+ assert.ok(outputTensor instanceof ov.Tensor);+ });+ });+ });describe("setters", () => {let inferRequest = null;beforeEach(() => {