Skip to content

Commit

Permalink
some extra fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Retribution98 committed Jan 28, 2025
1 parent 8899e7d commit 6fffea0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 22 deletions.
14 changes: 4 additions & 10 deletions src/bindings/js/node/tests/e2e/demo-electron-app/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
const { app } = require('electron');
const { addon: ov } = require('openvino-node');
const { testModels, lengthFromShape } = require('../../utils.js');
const path = require('path');

const epsilon = 0.5; // To avoid very small numbers
const testModelFP32 = path.join('..', testModels.testModelFP32);
const pathToModel = '../tests/unit/test_models/test_model_fp32.xml';

main();

Expand All @@ -17,21 +15,17 @@ async function main() {
const core = new ov.Core();
console.log('Created OpenVINO Runtime Core');

const model = await core.readModel(testModelFP32.xml);
const model = await core.readModel(pathToModel);
console.log('Model read successfully:', model);
const compiledModel = await core.compileModel(model, 'CPU');
const inferRequest = compiledModel.createInferRequest();
console.log('Infer request created:', inferRequest);

const tensorData = Float32Array.from(
{ length: lengthFromShape(testModelFP32.inputShape) },
{ length: 3072 },
() => Math.random() + epsilon,
);
const tensor = new ov.Tensor(
ov.element.f32,
testModelFP32.inputShape,
tensorData,
);
const tensor = new ov.Tensor(ov.element.f32, [1, 3, 32, 32], tensorData);
console.log('Tensor created:', tensor);

const result = await inferRequest.inferAsync([tensor]);
Expand Down
13 changes: 6 additions & 7 deletions src/bindings/js/node/tests/unit/basic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const epsilon = 0.5;

describe('ov basic tests.', () => {
const { testModelFP32 } = testModels;
const testXml = testModelFP32.xml;
let core = null;
let model = null;
let compiledModel = null;
Expand All @@ -33,7 +32,7 @@ describe('ov basic tests.', () => {

beforeEach(() => {
core = new ov.Core();
model = core.readModelSync(testXml);
model = core.readModelSync(testModelFP32.xml);
compiledModel = core.compileModelSync(model, 'CPU');
modelLike = [model, compiledModel];
});
Expand Down Expand Up @@ -139,12 +138,12 @@ describe('ov basic tests.', () => {
});

it('compileModelSync(model_path, deviceName, config: {}) ', () => {
const cm = core.compileModelSync(testXml, 'CPU', tput);
const cm = core.compileModelSync(testModelFP32.xml, 'CPU', tput);
assert.equal(cm.inputs.length, 1);
});

it('compileModelSync(model:model_path, deviceName: string) ', () => {
const cm = core.compileModelSync(testXml, 'CPU');
const cm = core.compileModelSync(testModelFP32.xml, 'CPU');
assert.deepStrictEqual(cm.output(0).shape, [1, 10]);
});

Expand Down Expand Up @@ -200,13 +199,13 @@ describe('ov basic tests.', () => {
});

it('compileModel(model_path, deviceName, config: {}) ', () => {
core.compileModel(testXml, 'CPU', tput).then((cm) => {
core.compileModel(testModelFP32.xml, 'CPU', tput).then((cm) => {
assert.equal(cm.inputs.length, 1);
});
});

it('compileModel(model:model_path, deviceName: string) ', () => {
core.compileModel(testXml, 'CPU').then((cm) => {
core.compileModel(testModelFP32.xml, 'CPU').then((cm) => {
assert.deepStrictEqual(cm.output(0).shape, [1, 10]);
});
});
Expand Down Expand Up @@ -297,7 +296,7 @@ describe('ov basic tests.', () => {
() => Math.random() + epsilon,
);
const core = new ov.Core();
const model = core.readModelSync(testXml);
const model = core.readModelSync(testModelFP32.xml);
const compiledModel = core.compileModelSync(model, 'CPU');
userStream = compiledModel.exportModelSync();
const inferRequest = compiledModel.createInferRequest();
Expand Down
10 changes: 6 additions & 4 deletions src/bindings/js/node/tests/unit/compiled_model.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,24 @@ const { describe, it, before, beforeEach } = require('node:test');
const { testModels, isModelAvailable } = require('../utils.js');

describe('ov.CompiledModel tests', () => {
let testXml = null;
const { testModelFP32 } = testModels;
let core = null;
let compiledModel = null;

before(async () => {
const { testModelFP32 } = testModels;
await isModelAvailable(testModelFP32);
testXml = testModelFP32.xml;
core = new ov.Core();
});

beforeEach(() => {
const properties = {
AUTO_BATCH_TIMEOUT: '1',
};
compiledModel = core.compileModelSync(testXml, 'BATCH:CPU', properties);
compiledModel = core.compileModelSync(
testModelFP32.xml,
'BATCH:CPU',
properties
);
});

describe('getProperty()', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/bindings/js/node/tests/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ async function downloadTestModel(model) {
const { env } = process;
const proxyUrl = env.http_proxy || env.HTTP_PROXY || env.npm_config_proxy;

const modelExists = await checkIfPathExists(model.xml);
const modelExists = await checkIfPathExists(model.xml);
if (!modelExists) await downloadFile(
model.xmlURL,
path.dirname(model.xml),
Expand Down

0 comments on commit 6fffea0

Please sign in to comment.