Skip to content

Commit dfebbe4

Browse files
fix consistancy
1 parent 5513373 commit dfebbe4

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

keras/src/backend/openvino/core.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -654,20 +654,18 @@ def convert_to_tensor(x, dtype=None, sparse=None, ragged=None):
654654
if dtype and dtype != x.dtype:
655655
x = cast(x, dtype)
656656
return x
657+
original_type = type(x)
657658
try:
658659
if dtype is None:
659-
dtype = getattr(x, "dtype", type(x))
660-
if dtype == np.dtype("bfloat16"):
661-
ov_type = OPENVINO_DTYPES["bfloat16"]
662-
else:
663-
ov_type = OPENVINO_DTYPES[standardize_dtype(dtype)]
660+
dtype = getattr(x, "dtype", original_type)
661+
ov_type = OPENVINO_DTYPES[standardize_dtype(dtype)]
664662
else:
665663
ov_type = OPENVINO_DTYPES[dtype]
666664
x = np.array(x)
667665
return OpenVINOKerasTensor(ov_opset.constant(x, ov_type).output(0))
668666
except Exception as e:
669667
raise TypeError(
670-
f"Cannot convert object of type {type(x)} "
668+
f"Cannot convert object of type {original_type} "
671669
f"to OpenVINOKerasTensor: {e}"
672670
)
673671

0 commit comments

Comments
 (0)