Skip to content

Commit

Permalink
[ONNX] Fixed wrong type casting for u/int16 when it stored externally (
Browse files Browse the repository at this point in the history
…#28016)

### Details:
 - Fixed wrong type casting for u/int16
- Added more tests for correctness validation of a values from external
file

### Tickets:
 - 159142
  • Loading branch information
gkrivor authored Dec 16, 2024
1 parent 9651768 commit 659ff0d
Show file tree
Hide file tree
Showing 8 changed files with 507 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/frontends/onnx/frontend/src/core/tensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ class Tensor {
} else {
buffer = ext_data.load_external_data(m_model_dir);
}
return std::vector<T>(buffer->get_ptr<char>(), buffer->get_ptr<char>() + buffer->size());
return std::vector<T>(buffer->get_ptr<T>(), buffer->get_ptr<T>() + (buffer->size() / sizeof(T)));
}

const void* get_data_ptr() const {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
ir_version: 3
producer_name: "OpenVINO ONNX Frontend"
graph {
node {
input: "A"
input: "B"
output: "Y"
name: "add_node1"
op_type: "Add"
}
name: "test_graph"
initializer {
dims: 2
dims: 2
data_type: 5
name: "A"
external_data {
key: "location",
value: "tensors_data/tensor.data"
}
external_data {
key: "length",
value: "8"
}
data_location: 1
}
input {
name: "A"
type {
tensor_type {
elem_type: 5
shape {
dim {
dim_value: 2
}
dim {
dim_value: 2
}
}
}
}
}
input {
name: "B"
type {
tensor_type {
elem_type: 5
shape {
dim {
dim_value: 1
}
}
}
}
}
output {
name: "Y"
type {
tensor_type {
elem_type: 5
shape {
dim {
dim_value: 2
}
dim {
dim_value: 2
}
}
}
}
}
}
opset_import {
version: 4
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
ir_version: 3
producer_name: "OpenVINO ONNX Frontend"
graph {
node {
input: "A"
output: "Y"
name: "add_node1"
op_type: "Identity"
}
name: "test_graph"
initializer {
dims: 2
dims: 2
data_type: 22
name: "A"
external_data {
key: "location",
value: "tensors_data/tensor.data"
}
external_data {
key: "offset",
value: "2"
}
external_data {
key: "length",
value: "2"
}
data_location: 1
}
input {
name: "A"
type {
tensor_type {
elem_type: 22
shape {
dim {
dim_value: 2
}
dim {
dim_value: 2
}
}
}
}
}
output {
name: "Y"
type {
tensor_type {
elem_type: 22
shape {
dim {
dim_value: 2
}
dim {
dim_value: 2
}
}
}
}
}
}
opset_import {
version: 21
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
ir_version: 3
producer_name: "OpenVINO ONNX Frontend"
graph {
node {
input: "A"
input: "B"
output: "Y"
name: "add_node1"
op_type: "Add"
}
name: "test_graph"
initializer {
dims: 2
dims: 2
data_type: 3
name: "A"
external_data {
key: "location",
value: "tensors_data/tensor.data"
}
external_data {
key: "length",
value: "4"
}
data_location: 1
}
input {
name: "A"
type {
tensor_type {
elem_type: 3
shape {
dim {
dim_value: 2
}
dim {
dim_value: 2
}
}
}
}
}
input {
name: "B"
type {
tensor_type {
elem_type: 3
shape {
dim {
dim_value: 1
}
}
}
}
}
output {
name: "Y"
type {
tensor_type {
elem_type: 3
shape {
dim {
dim_value: 2
}
dim {
dim_value: 2
}
}
}
}
}
}
opset_import {
version: 4
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
ir_version: 3
producer_name: "OpenVINO ONNX Frontend"
graph {
node {
input: "A"
input: "B"
output: "Y"
name: "add_node1"
op_type: "Add"
}
name: "test_graph"
initializer {
dims: 2
dims: 2
data_type: 4
name: "A"
external_data {
key: "location",
value: "tensors_data/tensor.data"
}
external_data {
key: "length",
value: "8"
}
data_location: 1
}
input {
name: "A"
type {
tensor_type {
elem_type: 4
shape {
dim {
dim_value: 2
}
dim {
dim_value: 2
}
}
}
}
}
input {
name: "B"
type {
tensor_type {
elem_type: 4
shape {
dim {
dim_value: 1
}
}
}
}
}
output {
name: "Y"
type {
tensor_type {
elem_type: 4
shape {
dim {
dim_value: 2
}
dim {
dim_value: 2
}
}
}
}
}
}
opset_import {
version: 4
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
ir_version: 3
producer_name: "OpenVINO ONNX Frontend"
graph {
node {
input: "A"
output: "Y"
name: "add_node1"
op_type: "Identity"
}
name: "test_graph"
initializer {
dims: 2
dims: 2
data_type: 21
name: "A"
external_data {
key: "location",
value: "tensors_data/tensor.data"
}
external_data {
key: "offset",
value: "2"
}
external_data {
key: "length",
value: "2"
}
data_location: 1
}
input {
name: "A"
type {
tensor_type {
elem_type: 21
shape {
dim {
dim_value: 2
}
dim {
dim_value: 2
}
}
}
}
}
output {
name: "Y"
type {
tensor_type {
elem_type: 21
shape {
dim {
dim_value: 2
}
dim {
dim_value: 2
}
}
}
}
}
}
opset_import {
version: 21
}
Loading

0 comments on commit 659ff0d

Please sign in to comment.