[PYTHON API]: handle input normalization for tensor without name (#9130)

* [PYTHON API]: handle input normalization for tensor without name

* remove extra empty line
This commit is contained in:
Ekaterina Aidova 2021-12-10 12:57:58 +03:00 committed by GitHub
parent 68d460a3bb
commit 4f77056892
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 8 deletions

View File

@ -25,13 +25,10 @@ def tensor_from_file(path: str) -> Tensor:
def normalize_inputs(py_dict: dict, py_types: dict) -> dict:
"""Normalize a dictionary of inputs to Tensors."""
for k, val in py_dict.items():
if not isinstance(k, (str, int)):
raise TypeError("Incompatible key type for tensor named: {}".format(k))
try:
if isinstance(k, int):
ov_type = list(py_types.values())[k]
elif isinstance(k, str):
ov_type = py_types[k]
else:
raise TypeError("Incompatible key type for tensor named: {}".format(k))
ov_type = py_types[k]
except KeyError:
raise KeyError("Port for tensor named {} was not found!".format(k))
py_dict[k] = (
@ -49,8 +46,9 @@ def get_input_types(obj: Union[InferRequestBase, ExecutableNetworkBase]) -> dict
return {n: input.get_element_type() for n in input.get_names()}
input_types: dict = {}
for input in obj.inputs:
input_types = {**input_types, **map_tensor_names_to_types(input)}
for idx, input in enumerate(obj.inputs):
input_types.update(map_tensor_names_to_types(input))
input_types[idx] = input.get_element_type()
return input_types