Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
N
ngraph
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ngraph
Commits
c1abb9a0
Commit
c1abb9a0
authored
Sep 20, 2019
by
Tomasz Dołbniak
Committed by
Michał Karzyński
Sep 20, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ONNX] ReverseSequence attributes validation (#3634)
parent
82622ac8
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
263 additions
and
0 deletions
+263
-0
reverse_sequence.cpp
src/ngraph/frontend/onnx_import/op/reverse_sequence.cpp
+12
-0
reverse_sequence_incorrect_batch_axis.prototxt
...odels/onnx/reverse_sequence_incorrect_batch_axis.prototxt
+75
-0
reverse_sequence_incorrect_time_axis.prototxt
...models/onnx/reverse_sequence_incorrect_time_axis.prototxt
+75
-0
reverse_sequence_time_and_batch_axis_equal.prototxt
.../onnx/reverse_sequence_time_and_batch_axis_equal.prototxt
+75
-0
onnx_import.in.cpp
test/onnx/onnx_import.in.cpp
+26
-0
No files found.
src/ngraph/frontend/onnx_import/op/reverse_sequence.cpp
View file @
c1abb9a0
...
@@ -42,6 +42,18 @@ namespace ngraph
...
@@ -42,6 +42,18 @@ namespace ngraph
const
auto
batch_axis
=
node
.
get_attribute_value
<
int64_t
>
(
"batch_axis"
,
1
);
const
auto
batch_axis
=
node
.
get_attribute_value
<
int64_t
>
(
"batch_axis"
,
1
);
const
auto
time_axis
=
node
.
get_attribute_value
<
int64_t
>
(
"time_axis"
,
0
);
const
auto
time_axis
=
node
.
get_attribute_value
<
int64_t
>
(
"time_axis"
,
0
);
NGRAPH_CHECK
(
batch_axis
==
0
||
batch_axis
==
1
,
"Allowed values of the 'batch_axis' attribute for ReverseSequence "
"operator are 0 and 1"
);
NGRAPH_CHECK
(
time_axis
==
0
||
time_axis
==
1
,
"Allowed values of the 'time_axis' attribute for ReverseSequence "
"operator are 0 and 1"
);
NGRAPH_CHECK
(
batch_axis
!=
time_axis
,
"'batch_axis' and 'time_axis' attributes of the ReverseSequence "
"operator can't point to the same dimension"
);
return
{
std
::
make_shared
<
ngraph
::
op
::
ReverseSequence
>
(
return
{
std
::
make_shared
<
ngraph
::
op
::
ReverseSequence
>
(
data
,
sequence_lengths_i32
,
batch_axis
,
time_axis
)};
data
,
sequence_lengths_i32
,
batch_axis
,
time_axis
)};
}
}
...
...
test/models/onnx/reverse_sequence_incorrect_batch_axis.prototxt
0 → 100644
View file @
c1abb9a0
ir_version: 3
producer_name: "nGraph ONNX Importer"
graph {
node {
input: "x"
input: "sequence_lengths"
output: "y"
op_type: "ReverseSequence"
attribute {
name: "batch_axis"
i: 2
type: INT
}
attribute {
name: "time_axis"
i: 0
type: INT
}
}
name: "reverse_sequence_graph"
input {
name: "x"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 4
}
dim {
dim_value: 4
}
dim {
dim_value: 4
}
}
}
}
}
input {
name: "sequence_lengths"
type {
tensor_type {
elem_type: 6
shape {
dim {
dim_value: 4
}
}
}
}
}
output {
name: "y"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 4
}
dim {
dim_value: 4
}
dim {
dim_value: 4
}
}
}
}
}
}
opset_import {
version: 10
}
test/models/onnx/reverse_sequence_incorrect_time_axis.prototxt
0 → 100644
View file @
c1abb9a0
ir_version: 3
producer_name: "nGraph ONNX Importer"
graph {
node {
input: "x"
input: "sequence_lengths"
output: "y"
op_type: "ReverseSequence"
attribute {
name: "batch_axis"
i: 0
type: INT
}
attribute {
name: "time_axis"
i: 2
type: INT
}
}
name: "reverse_sequence_graph"
input {
name: "x"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 4
}
dim {
dim_value: 4
}
dim {
dim_value: 4
}
}
}
}
}
input {
name: "sequence_lengths"
type {
tensor_type {
elem_type: 6
shape {
dim {
dim_value: 4
}
}
}
}
}
output {
name: "y"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 4
}
dim {
dim_value: 4
}
dim {
dim_value: 4
}
}
}
}
}
}
opset_import {
version: 10
}
test/models/onnx/reverse_sequence_time_and_batch_axis_equal.prototxt
0 → 100644
View file @
c1abb9a0
ir_version: 3
producer_name: "nGraph ONNX Importer"
graph {
node {
input: "x"
input: "sequence_lengths"
output: "y"
op_type: "ReverseSequence"
attribute {
name: "batch_axis"
i: 1
type: INT
}
attribute {
name: "time_axis"
i: 1
type: INT
}
}
name: "reverse_sequence_graph"
input {
name: "x"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 4
}
dim {
dim_value: 4
}
dim {
dim_value: 4
}
}
}
}
}
input {
name: "sequence_lengths"
type {
tensor_type {
elem_type: 6
shape {
dim {
dim_value: 4
}
}
}
}
}
output {
name: "y"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 4
}
dim {
dim_value: 4
}
dim {
dim_value: 4
}
}
}
}
}
}
opset_import {
version: 10
}
test/onnx/onnx_import.in.cpp
View file @
c1abb9a0
...
@@ -1634,3 +1634,29 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reverse_sequence_1_batch_0)
...
@@ -1634,3 +1634,29 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reverse_sequence_1_batch_0)
test_case
.
run
();
test_case
.
run
();
}
}
NGRAPH_TEST
(
onnx_
$
{
BACKEND_NAME
},
model_reverse_sequence_incorrect_batch_axis
)
{
EXPECT_THROW
(
onnx_import
::
import_onnx_model
(
file_util
::
path_join
(
SERIALIZED_ZOO
,
"onnx/reverse_sequence_incorrect_batch_axis.prototxt"
)),
ngraph_error
)
<<
"ReverseSequence batch_axis attribute can only equal 0 or 1. Value of '2' is not "
"accepted."
;
}
NGRAPH_TEST
(
onnx_
$
{
BACKEND_NAME
},
model_reverse_sequence_incorrect_time_axis
)
{
EXPECT_THROW
(
onnx_import
::
import_onnx_model
(
file_util
::
path_join
(
SERIALIZED_ZOO
,
"onnx/reverse_sequence_incorrect_time_axis.prototxt"
)),
ngraph_error
)
<<
"ReverseSequence time_axis attribute can only equal 0 or 1. Value of '2' is not "
"accepted."
;
}
NGRAPH_TEST
(
onnx_
$
{
BACKEND_NAME
},
model_reverse_sequence_time_and_batch_axis_equal
)
{
EXPECT_THROW
(
onnx_import
::
import_onnx_model
(
file_util
::
path_join
(
SERIALIZED_ZOO
,
"onnx/reverse_sequence_time_and_batch_axis_equal.prototxt"
)),
ngraph_error
)
<<
"ReverseSequence 'time_axis' and 'batch_axis' can't be equal."
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment