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.
Output const node python tests (openvinotoolkit#52)
* add python bindings tests for Output<const ov::None> * add proper tests * add new line
- Loading branch information
Showing
1 changed file
with
84 additions
and
0 deletions.
There are no files selected for viewing
84 changes: 84 additions & 0 deletions
84
runtime/bindings/python/tests/test_inference_engine/test_output_const_node.py
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,84 @@ | ||
# Copyright (C) 2021 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import os | ||
|
||
from ..conftest import model_path | ||
from openvino.impl import ConstOutput, Shape, PartialShape, Type | ||
|
||
from openvino import Core | ||
|
||
is_myriad = os.environ.get("TEST_DEVICE") == "MYRIAD" | ||
test_net_xml, test_net_bin = model_path(is_myriad) | ||
|
||
|
||
def model_path(is_myriad=False): | ||
path_to_repo = os.environ["MODELS_PATH"] | ||
if not is_myriad: | ||
test_xml = os.path.join(path_to_repo, "models", "test_model", "test_model_fp32.xml") | ||
test_bin = os.path.join(path_to_repo, "models", "test_model", "test_model_fp32.bin") | ||
else: | ||
test_xml = os.path.join(path_to_repo, "models", "test_model", "test_model_fp16.xml") | ||
test_bin = os.path.join(path_to_repo, "models", "test_model", "test_model_fp16.bin") | ||
return (test_xml, test_bin) | ||
|
||
|
||
def test_const_output_type(device): | ||
ie = Core() | ||
func = ie.read_model(model=test_net_xml, weights=test_net_bin) | ||
exec_net = ie.compile_model(func, device) | ||
node = exec_net.input(0) | ||
assert isinstance(node, ConstOutput) | ||
|
||
|
||
def test_const_output_docs(device): | ||
ie = Core() | ||
func = ie.read_model(model=test_net_xml, weights=test_net_bin) | ||
exec_net = ie.compile_model(func, device) | ||
node = exec_net.input(0) | ||
exptected_string = "openvino.impl.ConstOutput wraps ov::Output<Const ov::Node >" | ||
assert node.__doc__ == exptected_string | ||
|
||
|
||
def test_const_output_get_index(device): | ||
ie = Core() | ||
func = ie.read_model(model=test_net_xml, weights=test_net_bin) | ||
exec_net = ie.compile_model(func, device) | ||
node = exec_net.input("data") | ||
assert node.get_index() == 0 | ||
|
||
|
||
def test_const_output_get_element_type(device): | ||
ie = Core() | ||
func = ie.read_model(model=test_net_xml, weights=test_net_bin) | ||
exec_net = ie.compile_model(func, device) | ||
node = exec_net.input("data") | ||
assert node.get_element_type() == Type.f32 | ||
|
||
|
||
def test_const_output_get_shape(device): | ||
ie = Core() | ||
func = ie.read_model(model=test_net_xml, weights=test_net_bin) | ||
exec_net = ie.compile_model(func, device) | ||
node = exec_net.input("data") | ||
expected_shape = Shape([1, 3, 32, 32]) | ||
assert str(node.get_shape()) == str(expected_shape) | ||
|
||
|
||
def test_const_output_get_partial_shape(device): | ||
ie = Core() | ||
func = ie.read_model(model=test_net_xml, weights=test_net_bin) | ||
exec_net = ie.compile_model(func, device) | ||
node = exec_net.input("data") | ||
expected_partial_shape = PartialShape([1, 3, 32, 32]) | ||
assert node.get_partial_shape() == expected_partial_shape | ||
|
||
|
||
def test_const_output_get_target_inputs(device): | ||
ie = Core() | ||
func = ie.read_model(model=test_net_xml, weights=test_net_bin) | ||
exec_net = ie.compile_model(func, device) | ||
outputs = exec_net.outputs | ||
for node in outputs: | ||
assert isinstance(node.get_target_inputs(), set) | ||
|