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
3dce6fdb
Unverified
Commit
3dce6fdb
authored
Mar 24, 2020
by
Evgenya Stepyreva
Committed by
GitHub
Mar 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ Reshape ] Check shape_size(input_shape)==shape_size(output_shape) (#4476)
parent
28432321
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
1 deletion
+27
-1
reshape.cpp
src/ngraph/op/reshape.cpp
+11
-1
dyn_reshape.cpp
test/type_prop/dyn_reshape.cpp
+16
-0
No files found.
src/ngraph/op/reshape.cpp
View file @
3dce6fdb
...
@@ -201,7 +201,17 @@ void op::v1::Reshape::validate_and_infer_types()
...
@@ -201,7 +201,17 @@ void op::v1::Reshape::validate_and_infer_types()
if
(
!
(
zero_dims
&&
m_special_zero
)
&&
!
negative_dims
)
if
(
!
(
zero_dims
&&
m_special_zero
)
&&
!
negative_dims
)
{
{
set_output_type
(
0
,
get_input_element_type
(
0
),
const_shape
->
get_shape_val
());
auto
output_shape
=
const_shape
->
get_shape_val
();
if
(
get_input_partial_shape
(
0
).
is_static
())
{
NODE_VALIDATION_CHECK
(
this
,
shape_size
(
get_input_shape
(
0
))
==
shape_size
(
output_shape
),
"Requested output shape "
,
output_shape
,
" is incompatible with input shape "
,
get_input_shape
(
0
));
}
set_output_type
(
0
,
get_input_element_type
(
0
),
output_shape
);
}
}
else
else
{
{
...
...
test/type_prop/dyn_reshape.cpp
View file @
3dce6fdb
...
@@ -292,4 +292,20 @@ TEST(type_prop, reshape_v1_arg_rank_static_pattern_zero)
...
@@ -292,4 +292,20 @@ TEST(type_prop, reshape_v1_arg_rank_static_pattern_zero)
auto
reshape_v1_dynamic
=
make_shared
<
op
::
v1
::
Reshape
>
(
dynamic_arg
,
pattern
,
true
);
auto
reshape_v1_dynamic
=
make_shared
<
op
::
v1
::
Reshape
>
(
dynamic_arg
,
pattern
,
true
);
EXPECT_TRUE
(
reshape_v1_dynamic
->
get_output_partial_shape
(
0
).
same_scheme
(
EXPECT_TRUE
(
reshape_v1_dynamic
->
get_output_partial_shape
(
0
).
same_scheme
(
PartialShape
{
1
,
2
,
Dimension
::
dynamic
(),
32
}));
PartialShape
{
1
,
2
,
Dimension
::
dynamic
(),
32
}));
try
{
auto
static_shape_parameter
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
Shape
{
1
,
2
,
3
,
4
});
auto
reshape_output_pattern
=
op
::
Constant
::
create
(
element
::
i64
,
Shape
{
4
},
{
2
,
2
,
3
,
4
});
auto
reshape
=
make_shared
<
op
::
v1
::
Reshape
>
(
static_shape_parameter
,
reshape_output_pattern
,
true
);
FAIL
()
<<
"Expected failure on reshape construction"
;
}
catch
(
const
NodeValidationFailure
&
error
)
{
EXPECT_HAS_SUBSTRING
(
error
.
what
(),
std
::
string
(
"is incompatible with input shape"
));
}
catch
(...)
{
FAIL
()
<<
"Deduced type check failed for unexpected reason"
;
}
}
}
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