[Python API] Move openvino.runtime.impl to openvino.runtime (#9096)

This commit is contained in:
Katarzyna Mitrus
2021-12-09 10:40:22 +01:00
committed by GitHub
parent 8b90349529
commit a787fade68
69 changed files with 202 additions and 246 deletions

View File

@@ -11,7 +11,7 @@ import numpy as np
from openvino.runtime import Core
from openvino.runtime.exceptions import UserInputError
from openvino.runtime.impl import Function, Node, PartialShape, Type
from openvino.runtime import Function, Node, PartialShape, Type
from openvino.runtime.utils.types import NumericData, get_shape, get_dtype
import tests

View File

@@ -6,7 +6,7 @@ import pytest
import numpy as np
from ..conftest import model_path, read_image
from openvino.runtime.impl import Function, ConstOutput, Shape
from openvino.runtime import Function, ConstOutput, Shape
from openvino.runtime import Core, Tensor
@@ -221,7 +221,7 @@ def test_inputs_docs(device):
exec_net = core.compile_model(func, device)
inputs = exec_net.inputs
input_0 = inputs[0]
expected_string = "openvino.impl.ConstOutput wraps ov::Output<Const ov::Node >"
expected_string = "openvino.runtime.ConstOutput wraps ov::Output<Const ov::Node >"
assert input_0.__doc__ == expected_string

View File

@@ -7,7 +7,7 @@ import pytest
import openvino.runtime.opset8 as ops
from openvino.runtime import Function, Tensor
from openvino.runtime.impl import Type, PartialShape, Shape
from openvino.runtime import Type, PartialShape, Shape
def test_test_descriptor_tensor():

View File

@@ -4,7 +4,7 @@
import os
from ..conftest import model_path
from openvino.runtime.impl import ConstOutput, Shape, PartialShape, Type
from openvino.runtime import ConstOutput, Shape, PartialShape, Type
from openvino.runtime import Core
@@ -36,7 +36,7 @@ def test_const_output_docs(device):
func = core.read_model(model=test_net_xml, weights=test_net_bin)
exec_net = core.compile_model(func, device)
node = exec_net.input(0)
exptected_string = "openvino.impl.ConstOutput wraps ov::Output<Const ov::Node >"
exptected_string = "openvino.runtime.ConstOutput wraps ov::Output<Const ov::Node >"
assert node.__doc__ == exptected_string

View File

@@ -10,24 +10,24 @@ import openvino.runtime as ov
@pytest.mark.parametrize("ov_type, numpy_dtype", [
(ov.impl.Type.f32, np.float32),
(ov.impl.Type.f64, np.float64),
(ov.impl.Type.f16, np.float16),
(ov.impl.Type.bf16, np.float16),
(ov.impl.Type.i8, np.int8),
(ov.impl.Type.u8, np.uint8),
(ov.impl.Type.i32, np.int32),
(ov.impl.Type.u32, np.uint32),
(ov.impl.Type.i16, np.int16),
(ov.impl.Type.u16, np.uint16),
(ov.impl.Type.i64, np.int64),
(ov.impl.Type.u64, np.uint64),
(ov.impl.Type.boolean, np.bool),
# (ov.impl.Type.u1, np.uint8),
(ov.Type.f32, np.float32),
(ov.Type.f64, np.float64),
(ov.Type.f16, np.float16),
(ov.Type.bf16, np.float16),
(ov.Type.i8, np.int8),
(ov.Type.u8, np.uint8),
(ov.Type.i32, np.int32),
(ov.Type.u32, np.uint32),
(ov.Type.i16, np.int16),
(ov.Type.u16, np.uint16),
(ov.Type.i64, np.int64),
(ov.Type.u64, np.uint64),
(ov.Type.boolean, np.bool),
# (ov.Type.u1, np.uint8),
])
def test_init_with_ngraph(ov_type, numpy_dtype):
ov_tensors = []
ov_tensors.append(Tensor(type=ov_type, shape=ov.impl.Shape([1, 3, 32, 32])))
ov_tensors.append(Tensor(type=ov_type, shape=ov.Shape([1, 3, 32, 32])))
ov_tensors.append(Tensor(type=ov_type, shape=[1, 3, 32, 32]))
assert np.all([list(ov_tensor.shape) == [1, 3, 32, 32] for ov_tensor in ov_tensors])
assert np.all(ov_tensor.element_type == ov_type for ov_tensor in ov_tensors)
@@ -36,22 +36,22 @@ def test_init_with_ngraph(ov_type, numpy_dtype):
@pytest.mark.parametrize("ov_type, numpy_dtype", [
(ov.impl.Type.f32, np.float32),
(ov.impl.Type.f64, np.float64),
(ov.impl.Type.f16, np.float16),
(ov.impl.Type.i8, np.int8),
(ov.impl.Type.u8, np.uint8),
(ov.impl.Type.i32, np.int32),
(ov.impl.Type.u32, np.uint32),
(ov.impl.Type.i16, np.int16),
(ov.impl.Type.u16, np.uint16),
(ov.impl.Type.i64, np.int64),
(ov.impl.Type.u64, np.uint64),
(ov.impl.Type.boolean, np.bool)
(ov.Type.f32, np.float32),
(ov.Type.f64, np.float64),
(ov.Type.f16, np.float16),
(ov.Type.i8, np.int8),
(ov.Type.u8, np.uint8),
(ov.Type.i32, np.int32),
(ov.Type.u32, np.uint32),
(ov.Type.i16, np.int16),
(ov.Type.u16, np.uint16),
(ov.Type.i64, np.int64),
(ov.Type.u64, np.uint64),
(ov.Type.boolean, np.bool)
])
def test_init_with_numpy_dtype(ov_type, numpy_dtype):
shape = (1, 3, 127, 127)
ov_shape = ov.impl.Shape(shape)
ov_shape = ov.Shape(shape)
ov_tensors = []
ov_tensors.append(Tensor(type=numpy_dtype, shape=shape))
ov_tensors.append(Tensor(type=np.dtype(numpy_dtype), shape=shape))
@@ -66,18 +66,18 @@ def test_init_with_numpy_dtype(ov_type, numpy_dtype):
@pytest.mark.parametrize("ov_type, numpy_dtype", [
(ov.impl.Type.f32, np.float32),
(ov.impl.Type.f64, np.float64),
(ov.impl.Type.f16, np.float16),
(ov.impl.Type.i8, np.int8),
(ov.impl.Type.u8, np.uint8),
(ov.impl.Type.i32, np.int32),
(ov.impl.Type.u32, np.uint32),
(ov.impl.Type.i16, np.int16),
(ov.impl.Type.u16, np.uint16),
(ov.impl.Type.i64, np.int64),
(ov.impl.Type.u64, np.uint64),
(ov.impl.Type.boolean, np.bool)
(ov.Type.f32, np.float32),
(ov.Type.f64, np.float64),
(ov.Type.f16, np.float16),
(ov.Type.i8, np.int8),
(ov.Type.u8, np.uint8),
(ov.Type.i32, np.int32),
(ov.Type.u32, np.uint32),
(ov.Type.i16, np.int16),
(ov.Type.u16, np.uint16),
(ov.Type.i64, np.int64),
(ov.Type.u64, np.uint64),
(ov.Type.boolean, np.bool)
])
def test_init_with_numpy_shared_memory(ov_type, numpy_dtype):
arr = read_image().astype(numpy_dtype)
@@ -96,18 +96,18 @@ def test_init_with_numpy_shared_memory(ov_type, numpy_dtype):
@pytest.mark.parametrize("ov_type, numpy_dtype", [
(ov.impl.Type.f32, np.float32),
(ov.impl.Type.f64, np.float64),
(ov.impl.Type.f16, np.float16),
(ov.impl.Type.i8, np.int8),
(ov.impl.Type.u8, np.uint8),
(ov.impl.Type.i32, np.int32),
(ov.impl.Type.u32, np.uint32),
(ov.impl.Type.i16, np.int16),
(ov.impl.Type.u16, np.uint16),
(ov.impl.Type.i64, np.int64),
(ov.impl.Type.u64, np.uint64),
(ov.impl.Type.boolean, np.bool)
(ov.Type.f32, np.float32),
(ov.Type.f64, np.float64),
(ov.Type.f16, np.float16),
(ov.Type.i8, np.int8),
(ov.Type.u8, np.uint8),
(ov.Type.i32, np.int32),
(ov.Type.u32, np.uint32),
(ov.Type.i16, np.int16),
(ov.Type.u16, np.uint16),
(ov.Type.i64, np.int64),
(ov.Type.u64, np.uint64),
(ov.Type.boolean, np.bool)
])
def test_init_with_numpy_copy_memory(ov_type, numpy_dtype):
arr = read_image().astype(numpy_dtype)
@@ -142,47 +142,47 @@ def test_init_with_roi_tensor():
@pytest.mark.parametrize("ov_type, numpy_dtype", [
(ov.impl.Type.f32, np.float32),
(ov.impl.Type.f64, np.float64),
(ov.impl.Type.f16, np.float16),
(ov.impl.Type.bf16, np.float16),
(ov.impl.Type.i8, np.int8),
(ov.impl.Type.u8, np.uint8),
(ov.impl.Type.i32, np.int32),
(ov.impl.Type.u32, np.uint32),
(ov.impl.Type.i16, np.int16),
(ov.impl.Type.u16, np.uint16),
(ov.impl.Type.i64, np.int64),
(ov.impl.Type.u64, np.uint64),
(ov.impl.Type.boolean, np.bool),
# (ov.impl.Type.u1, np.uint8),
(ov.Type.f32, np.float32),
(ov.Type.f64, np.float64),
(ov.Type.f16, np.float16),
(ov.Type.bf16, np.float16),
(ov.Type.i8, np.int8),
(ov.Type.u8, np.uint8),
(ov.Type.i32, np.int32),
(ov.Type.u32, np.uint32),
(ov.Type.i16, np.int16),
(ov.Type.u16, np.uint16),
(ov.Type.i64, np.int64),
(ov.Type.u64, np.uint64),
(ov.Type.boolean, np.bool),
# (ov.Type.u1, np.uint8),
])
def test_write_to_buffer(ov_type, numpy_dtype):
ov_tensor = Tensor(ov_type, ov.impl.Shape([1, 3, 32, 32]))
ov_tensor = Tensor(ov_type, ov.Shape([1, 3, 32, 32]))
ones_arr = np.ones([1, 3, 32, 32], numpy_dtype)
ov_tensor.data[:] = ones_arr
assert np.array_equal(ov_tensor.data, ones_arr)
@pytest.mark.parametrize("ov_type, numpy_dtype", [
(ov.impl.Type.f32, np.float32),
(ov.impl.Type.f64, np.float64),
(ov.impl.Type.f16, np.float16),
(ov.impl.Type.bf16, np.float16),
(ov.impl.Type.i8, np.int8),
(ov.impl.Type.u8, np.uint8),
(ov.impl.Type.i32, np.int32),
(ov.impl.Type.u32, np.uint32),
(ov.impl.Type.i16, np.int16),
(ov.impl.Type.u16, np.uint16),
(ov.impl.Type.i64, np.int64),
(ov.impl.Type.u64, np.uint64),
(ov.impl.Type.boolean, np.bool),
# (ov.impl.Type.u1, np.uint8),
(ov.Type.f32, np.float32),
(ov.Type.f64, np.float64),
(ov.Type.f16, np.float16),
(ov.Type.bf16, np.float16),
(ov.Type.i8, np.int8),
(ov.Type.u8, np.uint8),
(ov.Type.i32, np.int32),
(ov.Type.u32, np.uint32),
(ov.Type.i16, np.int16),
(ov.Type.u16, np.uint16),
(ov.Type.i64, np.int64),
(ov.Type.u64, np.uint64),
(ov.Type.boolean, np.bool),
# (ov.Type.u1, np.uint8),
])
def test_set_shape(ov_type, numpy_dtype):
shape = ov.impl.Shape([1, 3, 32, 32])
ref_shape = ov.impl.Shape([1, 3, 48, 48])
shape = ov.Shape([1, 3, 32, 32])
ref_shape = ov.Shape([1, 3, 48, 48])
ref_shape_np = [1, 3, 28, 28]
ov_tensor = Tensor(ov_type, shape)
ov_tensor.shape = ref_shape

View File

@@ -12,10 +12,10 @@ import openvino.runtime as ov
from openvino.pyopenvino import Variant
from openvino.runtime.exceptions import UserInputError
from openvino.runtime.impl import Function, PartialShape, Shape, Type, layout_helpers
from openvino.runtime import Function, PartialShape, Shape, Type, layout_helpers
from openvino.runtime import Tensor
from openvino.pyopenvino import DescriptorTensor
from openvino.runtime.impl.op import Parameter
from openvino.runtime.op import Parameter
from tests.runtime import get_runtime
from tests.test_ngraph.util import run_op_node

View File

@@ -4,7 +4,7 @@
import numpy as np
import openvino.runtime.opset8 as ov
from openvino.runtime.impl import Dimension, Function, PartialShape, Shape
from openvino.runtime import Dimension, Function, PartialShape, Shape
def test_dimension():

View File

@@ -9,7 +9,7 @@ from openvino.runtime.exceptions import UserInputError
import openvino.runtime.opset8 as ov
import openvino.runtime.opset1 as ov_opset1
import openvino.runtime.opset5 as ov_opset5
from openvino.runtime.impl import Type
from openvino.runtime import Type
np_types = [np.float32, np.int32]
integral_np_types = [

View File

@@ -4,7 +4,7 @@
import numpy as np
import openvino.runtime.opset8 as ov
from openvino.runtime.impl import Type
from openvino.runtime import Type
def test_ctc_loss_props():

View File

@@ -4,7 +4,7 @@
import numpy as np
import openvino.runtime.opset8 as ov
from openvino.runtime.impl import Type, Shape
from openvino.runtime import Type, Shape
from tests.runtime import get_runtime
from tests.test_ngraph.util import run_op_node

View File

@@ -3,7 +3,7 @@
import numpy as np
import openvino.runtime.opset8 as ov
from openvino.runtime.impl import Shape, Type
from openvino.runtime import Shape, Type
def test_log_softmax():

View File

@@ -10,8 +10,8 @@ import numpy as np
import pytest
import openvino.runtime.opset8 as ov
from openvino.runtime.impl import Function, PartialShape, Shape
from openvino.runtime.impl.passes import Manager
from openvino.runtime import Function, PartialShape, Shape
from openvino.runtime.passes import Manager
from tests.test_ngraph.util import count_ops_of_type
from openvino.runtime import Core

View File

@@ -6,8 +6,8 @@
import numpy as np
import openvino.runtime.opset8 as ov
from openvino.runtime.impl import AxisSet, Function, Shape, Type
from openvino.runtime.impl.op import Constant, Parameter
from openvino.runtime import AxisSet, Function, Shape, Type
from openvino.runtime.op import Constant, Parameter
from tests.runtime import get_runtime

View File

@@ -4,7 +4,7 @@
import numpy as np
import openvino.runtime.opset8 as ov
from openvino.runtime.impl import Type
from openvino.runtime import Type
def test_scatter_update_props():

View File

@@ -5,7 +5,7 @@ import numpy as np
import pytest
import openvino.runtime.opset8 as ov
from openvino.runtime.impl import Shape, Type
from openvino.runtime import Shape, Type
from tests.runtime import get_runtime
from tests.test_ngraph.util import run_op_node

View File

@@ -1,8 +1,8 @@
# Copyright (C) 2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from openvino.runtime.impl import PartialShape, Type
from openvino.runtime.impl.op.util import VariableInfo, Variable
from openvino.runtime import PartialShape, Type
from openvino.runtime.op.util import VariableInfo, Variable
def test_info_as_property():

View File

@@ -6,7 +6,7 @@ import pytest
import openvino.runtime as ov
import openvino.runtime.opset8 as ops
from openvino.runtime.impl import Function, Output, Type
from openvino.runtime import Function, Output, Type
from openvino.runtime.utils.decorators import custom_preprocess_function
from openvino.runtime import Core
from tests.runtime import get_runtime

View File

@@ -3,7 +3,7 @@
import numpy as np
import openvino.runtime.opset8 as ov
from openvino.runtime.impl import Shape, Type
from openvino.runtime import Shape, Type
def test_proposal_props():

View File

@@ -3,7 +3,7 @@
import numpy as np
import openvino.runtime.opset8 as ov
from openvino.runtime.impl import Shape, Type
from openvino.runtime import Shape, Type
def test_swish_props_with_beta():

View File

@@ -3,7 +3,7 @@
import numpy as np
import openvino.runtime as ov
from openvino.runtime.impl import Shape
from openvino.runtime import Shape
def test_get_constant_from_source_success():
@@ -12,7 +12,7 @@ def test_get_constant_from_source_success():
input2 = ov.opset8.parameter(Shape([25]), dtype=dtype, name="input_2")
shape_of = ov.opset8.shape_of(input2, name="shape_of")
reshape = ov.opset8.reshape(input1, shape_of, special_zero=True)
folded_const = ov.impl.util.get_constant_from_source(reshape.input(1).get_source_output())
folded_const = ov.util.get_constant_from_source(reshape.input(1).get_source_output())
assert folded_const is not None
assert folded_const.get_vector() == [25]
@@ -23,6 +23,6 @@ def test_get_constant_from_source_failed():
input1 = ov.opset8.parameter(Shape([5, 5]), dtype=dtype, name="input_1")
input2 = ov.opset8.parameter(Shape([1]), dtype=dtype, name="input_2")
reshape = ov.opset8.reshape(input1, input2, special_zero=True)
folded_const = ov.impl.util.get_constant_from_source(reshape.input(1).get_source_output())
folded_const = ov.util.get_constant_from_source(reshape.input(1).get_source_output())
assert folded_const is None