Revert "Revert "Fixed cases if cast data from Tensor to compatible type (#18479)" (#18539)" (#18599)

This reverts commit 3daa387692.
This commit is contained in:
Ilya Churaev 2023-07-18 23:57:32 +04:00 committed by GitHub
parent f0abd468a2
commit ea84e73282
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -71,7 +71,7 @@ TEST_F(OVTensorTest, canAccessF16Tensor) {
EXPECT_NE(nullptr, t.data());
EXPECT_NO_THROW(t.data(ov::element::f16));
EXPECT_NO_THROW(t.data<ov::float16>());
EXPECT_THROW(t.data<ov::bfloat16>(), ov::Exception);
EXPECT_NO_THROW(t.data<ov::bfloat16>());
EXPECT_THROW(t.data<std::uint16_t>(), ov::Exception);
EXPECT_THROW(t.data<std::int16_t>(), ov::Exception);
}

View File

@ -36,7 +36,8 @@ public:
void* data(const element::Type& element_type) const override {
if (element_type != element::undefined && element_type != element::dynamic) {
OPENVINO_ASSERT(element_type == get_element_type(),
OPENVINO_ASSERT(element_type.bitwidth() == get_element_type().bitwidth() &&
element_type.is_real() == get_element_type().is_real(),
"Tensor data with element type ",
get_element_type(),
", is not representable as pointer to ",