Skip to content

Commit 9230e83

Browse files
committed
Add unittest
Signed-off-by: Bogdan Pereanu <bogdan.pereanu@intel.com>
1 parent 220a1df commit 9230e83

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/core/tests/ov_tensor_test.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "openvino/op/parameter.hpp"
1818
#include "openvino/reference/utils/coordinate_transform.hpp"
1919
#include "openvino/runtime/allocator.hpp"
20+
#include "openvino/runtime/make_tensor.hpp"
2021
#include "openvino/runtime/remote_tensor.hpp"
2122
#include "openvino/runtime/tensor.hpp"
2223

@@ -953,6 +954,22 @@ TEST_F(OVTensorTest, createAllocationOverflow) {
953954
HasSubstr("Cannot allocate memory"));
954955
}
955956

957+
TEST_F(OVTensorTest, getTensorDataOffsetFromRoiTensor) {
958+
const ov::Tensor tensor(ov::element::f32, ov::Shape{3, 5, 32, 128});
959+
ov::Tensor roi_tensor;
960+
OV_ASSERT_NO_THROW(roi_tensor = ov::Tensor(tensor, {1, 2, 5, 64}, {2, 3, 10, 128}));
961+
size_t tensor_data_offset = ov::get_tensor_data_offset(ov::get_tensor_impl(roi_tensor));
962+
EXPECT_EQ(static_cast<const uint8_t*>(roi_tensor.data()),
963+
static_cast<const uint8_t*>(tensor.data()) + tensor_data_offset);
964+
}
965+
966+
TEST_F(OVTensorTest, getTensorDataOffsetFromGeneralTensor) {
967+
const ov::Tensor tensor(ov::element::f32, ov::Shape{3, 5, 32, 128});
968+
size_t tensor_data_offset = ov::get_tensor_data_offset(ov::get_tensor_impl(tensor));
969+
EXPECT_EQ(static_cast<const uint8_t*>(tensor.data()),
970+
static_cast<const uint8_t*>(tensor.data()) + tensor_data_offset);
971+
}
972+
956973
struct TestParams {
957974
ov::Shape src_shape;
958975
ov::Strides src_strides;

0 commit comments

Comments
 (0)