Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
57d000b2
"git@developer.sourcefind.cn:gaoqiong/migraphx.git" did not exist on "8fbb7af90ae5c6801be7513084889600c310941f"
Commit
57d000b2
authored
Oct 31, 2022
by
Brian Pickrell
Browse files
add support for dynamic reduce ops in Onnx parsing
parent
6be7f1fb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
2 deletions
+31
-2
src/include/migraphx/shape.hpp
src/include/migraphx/shape.hpp
+6
-0
src/onnx/parse_reduce_op.cpp
src/onnx/parse_reduce_op.cpp
+1
-2
src/shape.cpp
src/shape.cpp
+9
-0
test/onnx/onnx_test.cpp
test/onnx/onnx_test.cpp
+15
-0
No files found.
src/include/migraphx/shape.hpp
View file @
57d000b2
...
@@ -136,6 +136,12 @@ struct shape
...
@@ -136,6 +136,12 @@ struct shape
const
std
::
vector
<
std
::
size_t
>&
lens
()
const
;
const
std
::
vector
<
std
::
size_t
>&
lens
()
const
;
const
std
::
vector
<
std
::
size_t
>&
strides
()
const
;
const
std
::
vector
<
std
::
size_t
>&
strides
()
const
;
/*!
* The number of dimensions in the shape.
* Same as the number of indices required to get a data value.
*/
std
::
size_t
ndim
()
const
;
/*!
/*!
* Return the number of elements in the tensor.
* Return the number of elements in the tensor.
*/
*/
...
...
src/onnx/parse_reduce_op.cpp
View file @
57d000b2
...
@@ -68,8 +68,7 @@ instruction_ref parse_reduce_oper(const std::string& op_name,
...
@@ -68,8 +68,7 @@ instruction_ref parse_reduce_oper(const std::string& op_name,
}
}
else
else
{
{
std
::
size_t
n_dim
=
args
.
front
()
->
get_shape
().
lens
().
size
();
axes
.
resize
(
args
.
front
()
->
get_shape
().
ndim
());
axes
.
resize
(
n_dim
);
std
::
iota
(
axes
.
begin
(),
axes
.
end
(),
0
);
std
::
iota
(
axes
.
begin
(),
axes
.
end
(),
0
);
}
}
}
}
...
...
src/shape.cpp
View file @
57d000b2
...
@@ -244,6 +244,15 @@ const std::vector<std::size_t>& shape::lens() const { return impl->m_lens; }
...
@@ -244,6 +244,15 @@ const std::vector<std::size_t>& shape::lens() const { return impl->m_lens; }
const
std
::
vector
<
std
::
size_t
>&
shape
::
strides
()
const
{
return
impl
->
m_strides
;
}
const
std
::
vector
<
std
::
size_t
>&
shape
::
strides
()
const
{
return
impl
->
m_strides
;
}
std
::
size_t
shape
::
ndim
()
const
{
if
(
this
->
dynamic
())
{
return
dyn_dims
().
size
();
}
return
lens
().
size
();
}
std
::
size_t
shape
::
elements
()
const
{
return
impl
->
elements
();
}
std
::
size_t
shape
::
elements
()
const
{
return
impl
->
elements
();
}
std
::
size_t
shape
::
bytes
()
const
std
::
size_t
shape
::
bytes
()
const
...
...
test/onnx/onnx_test.cpp
View file @
57d000b2
...
@@ -4241,6 +4241,21 @@ TEST_CASE(reducel1_test)
...
@@ -4241,6 +4241,21 @@ TEST_CASE(reducel1_test)
EXPECT(p == prog);
EXPECT(p == prog);
}
}
TEST_CASE(reducel1_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
// a shape with 4 dynamic dimensions
auto l0 = mm->add_parameter("x", migraphx::shape{migraphx::shape::float_type, {{3,3,0}, {3, 5, 0}, {4, 6, 5}, {5, 7, 6}}});
auto abs_l0 = mm->add_instruction(migraphx::make_op("abs"), l0);
auto sum_l0 = mm->add_instruction(migraphx::make_op("reduce_sum", {{"axes", {-2}}}), abs_l0);
mm->add_instruction(migraphx::make_op("squeeze", {{"axes", {-2}}}), sum_l0);
auto prog = optimize_onnx("reducel1_dyn_test.onnx");
EXPECT(p == prog);
}
TEST_CASE(reducel2_test)
TEST_CASE(reducel2_test)
{
{
migraphx::program p;
migraphx::program p;
...
...
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