forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OV JS] Enable CompiledModel set/get property() (openvinotoolkit#25808)
### Details: - add 2 methods: `CompiledModel::set_property()` and `CompiledModel::get_property()` - create TypeScript definition for new created methods - create unit tests for new functionalities (due to the issue that was mentioned [here](openvinotoolkit#24374 (comment)), it's more of a mock now and should be altered as soon as the issue is fixed) ### Tickets: - 134825
- Loading branch information
Showing
4 changed files
with
147 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// -*- coding: utf-8 -*- | ||
// Copyright (C) 2018-2024 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
const { addon: ov } = require('../..'); | ||
const assert = require('assert'); | ||
const { describe, it } = require('node:test'); | ||
const { getModelPath } = require('./utils.js'); | ||
|
||
const testXml = getModelPath().xml; | ||
const core = new ov.Core(); | ||
const properties = { | ||
"AUTO_BATCH_TIMEOUT": '1' | ||
}; | ||
const compiledModel = core.compileModelSync(testXml, 'BATCH:CPU', properties); | ||
|
||
describe('setProperty() / getProperty()', () => { | ||
|
||
describe('getProperty()', () => { | ||
it('returns the value of property from compiled model', () => { | ||
assert.strictEqual(compiledModel.getProperty('AUTO_BATCH_TIMEOUT'), '1'); | ||
}); | ||
it('throws an error when called without arguments', () => { | ||
assert.throws( | ||
() => compiledModel.getProperty(), | ||
/'getProperty' method called with incorrect parameters/ | ||
); | ||
}); | ||
it('throws an error when called with property name that does not exists', ()=>{ | ||
assert.throws( | ||
() => compiledModel.getProperty('PROPERTY_THAT_DOES_NOT_EXIST') | ||
); | ||
}); | ||
}); | ||
|
||
describe('setProperty()', () => { | ||
it('sets a properties for compiled model', () => { | ||
properties["AUTO_BATCH_TIMEOUT"] = '1000'; | ||
assert.doesNotThrow(() => compiledModel.setProperty(properties)); | ||
}); | ||
|
||
it('throws an error when called without an object argument', () => { | ||
assert.throws( | ||
() => compiledModel.setProperty(), | ||
/'setProperty' method called with incorrect parameters/ | ||
); | ||
}); | ||
it('throws an error when called with wrong argument', () => { | ||
assert.throws( | ||
() => compiledModel.setProperty(123), | ||
/'setProperty' method called with incorrect parameters/ | ||
); | ||
}); | ||
|
||
it('throws an error when called with multiple arguments', () => { | ||
assert.throws( | ||
() => compiledModel.setProperty({"PERFORMANCE_HINT": "THROUGHPUT"}, {"NUM_STREAMS": "AUTO"}), | ||
/'setProperty' method called with incorrect parameters/ | ||
); | ||
}); | ||
|
||
it('returns the set property of the compiled model', () => { | ||
properties["AUTO_BATCH_TIMEOUT"] = '123'; | ||
compiledModel.setProperty(properties); | ||
assert.strictEqual(compiledModel.getProperty('AUTO_BATCH_TIMEOUT'), 123); | ||
}); | ||
|
||
it('retains the last set property when set multiple times', () => { | ||
compiledModel.setProperty({"AUTO_BATCH_TIMEOUT": '321'}); | ||
compiledModel.setProperty({'AUTO_BATCH_TIMEOUT': '132'}); | ||
assert.strictEqual(compiledModel.getProperty('AUTO_BATCH_TIMEOUT'), 132); | ||
}); | ||
|
||
it('allows to pass empty object', () => { | ||
assert.doesNotThrow(() => compiledModel.setProperty({})); | ||
}); | ||
}); | ||
}); |