Skip to content

Commit 6ecaf04

Browse files
authored
[ONNX] Fix empty external const case when offset is not zero (#32646)
### Details: - *Fix empty external const case when offset is not zero* ### Tickets: - *CVS-174765* Signed-off-by: Maxim Vafin <[email protected]>
1 parent d917ea5 commit 6ecaf04

File tree

3 files changed

+88
-1
lines changed

3 files changed

+88
-1
lines changed

src/frontends/onnx/frontend/src/utils/tensor_external_data.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Buffer<ov::AlignedBuffer> TensorExternalData::load_external_mem_data() const {
107107
}
108108
// Empty node will create a constant with zero shape and zero size external data.
109109
bool is_valid_buffer = m_offset && m_data_length;
110-
bool is_empty_buffer = (m_offset == 0) && (m_data_length == 0);
110+
bool is_empty_buffer = (m_data_length == 0);
111111
if (!(is_valid_buffer || is_empty_buffer)) {
112112
throw error::invalid_external_data{*this};
113113
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
ir_version: 3
2+
producer_name: "OpenVINO ONNX Frontend"
3+
graph {
4+
node {
5+
input: "A"
6+
input: "B"
7+
output: "C"
8+
op_type: "Reshape"
9+
}
10+
name: "compute_graph"
11+
initializer {
12+
dims: 0
13+
data_type: 7
14+
name: "B"
15+
external_data {
16+
key: "location",
17+
value: "*/_ORT_MEM_ADDR_/*"
18+
}
19+
external_data {
20+
key: "offset",
21+
value: "16"
22+
}
23+
external_data {
24+
key: "length",
25+
value: "0"
26+
}
27+
data_location: 1
28+
}
29+
input {
30+
name: "B"
31+
type {
32+
tensor_type {
33+
elem_type: 7
34+
shape {
35+
dim {
36+
dim_value: 0
37+
}
38+
}
39+
}
40+
}
41+
}
42+
input {
43+
name: "A"
44+
type {
45+
tensor_type {
46+
elem_type: 1
47+
shape {
48+
dim {
49+
dim_value: 1
50+
}
51+
dim {
52+
dim_value: 1
53+
}
54+
dim {
55+
dim_value: 1
56+
}
57+
}
58+
}
59+
}
60+
}
61+
output {
62+
name: "C"
63+
type {
64+
tensor_type {
65+
elem_type: 1
66+
shape {
67+
}
68+
}
69+
}
70+
}
71+
}
72+
opset_import {
73+
version: 21
74+
}

src/frontends/onnx/tests/onnx_reader_external_data.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,19 @@ TEST_P(OnnxFeMmapFixture, onnx_external_data_0_size) {
5353
test_case.run();
5454
}
5555

56+
TEST_P(OnnxFeMmapFixture, onnx_external_data_0_size_offset) {
57+
const auto path = test::utils::getModelFromTestModelZoo(string(TEST_ONNX_MODELS_DIRNAME) +
58+
"external_data/external_data_0_size_offset.onnx");
59+
Core core;
60+
core.set_property(enable_mmap(GetParam()));
61+
const auto model = core.read_model(path);
62+
auto test_case = test::TestCase(model);
63+
test_case.add_input<float>({4.f});
64+
test_case.add_expected_output<float>({}, {4.f});
65+
66+
test_case.run();
67+
}
68+
5669
// !!! Experimental feature, it may be changed or removed in the future !!!
5770
TEST_P(OnnxFeMmapFixture, onnx_external_data_enumerating) {
5871
const auto path =

0 commit comments

Comments
 (0)