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
c051ad5f
Unverified
Commit
c051ad5f
authored
Aug 21, 2023
by
Paul Fultz II
Committed by
GitHub
Aug 21, 2023
Browse files
Fix slice error when data input is constant (#2100)
parent
24d9ecbe
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
1 deletion
+40
-1
src/onnx/parse_slice.cpp
src/onnx/parse_slice.cpp
+3
-1
test/onnx/gen_onnx.py
test/onnx/gen_onnx.py
+24
-0
test/onnx/onnx_test.cpp
test/onnx/onnx_test.cpp
+13
-0
test/onnx/slice_constant_test.onnx
test/onnx/slice_constant_test.onnx
+0
-0
No files found.
src/onnx/parse_slice.cpp
View file @
c051ad5f
...
...
@@ -44,6 +44,8 @@ struct parse_slice : op_parser<parse_slice>
std
::
vector
<
int64_t
>
steps
;
std
::
vector
<
int64_t
>
raxes
;
void
always_insert
(
instruction_ref
arg
)
{
op_args
.
insert
(
op_args
.
begin
(),
arg
);
}
std
::
vector
<
int64_t
>
insert
(
instruction_ref
arg
)
{
std
::
vector
<
int64_t
>
result
;
...
...
@@ -132,7 +134,7 @@ struct parse_slice : op_parser<parse_slice>
}
// data input argument
sd
.
insert
(
args
.
at
(
0
));
sd
.
always_
insert
(
args
.
at
(
0
));
// If axes arg is not given, the default is all of them.
if
(
sd
.
op
.
axes
.
empty
()
and
sd
.
op_args
.
size
()
<
3
)
...
...
test/onnx/gen_onnx.py
View file @
c051ad5f
...
...
@@ -6414,6 +6414,30 @@ def slice_test():
return
([
node
],
[
x
],
[
y
])
@
onnx_test
()
def
slice_constant_test
():
y
=
helper
.
make_tensor_value_info
(
'1'
,
TensorProto
.
FLOAT
,
[
1
,
2
])
x_tensor
=
helper
.
make_tensor
(
name
=
'x_tensor'
,
data_type
=
TensorProto
.
FLOAT
,
dims
=
[
3
,
2
],
vals
=
[
0
,
1
,
2
,
3
,
4
,
5
])
x
=
onnx
.
helper
.
make_node
(
'Constant'
,
inputs
=
[],
outputs
=
[
'x'
],
value
=
x_tensor
)
node
=
onnx
.
helper
.
make_node
(
'Slice'
,
inputs
=
[
'x'
],
axes
=
[
0
,
1
],
starts
=
[
1
,
0
],
ends
=
[
2
,
2
],
outputs
=
[
'1'
])
return
([
x
,
node
],
[],
[
y
])
@
onnx_test
()
def
slice_dyn_test
():
x
=
helper
.
make_tensor_value_info
(
'0'
,
TensorProto
.
FLOAT
,
[
None
,
None
,
2
])
...
...
test/onnx/onnx_test.cpp
View file @
c051ad5f
...
...
@@ -6294,6 +6294,19 @@ TEST_CASE(slice_test)
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
slice_constant_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
2
}},
{
0
,
1
,
2
,
3
,
4
,
5
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"axes"
,
{
0
,
1
}},
{
"starts"
,
{
1
,
0
}},
{
"ends"
,
{
2
,
2
}}}),
l0
);
auto
prog
=
optimize_onnx
(
"slice_constant_test.onnx"
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
slice_dyn_test
)
{
migraphx
::
program
p
;
...
...
test/onnx/slice_constant_test.onnx
0 → 100644
View file @
c051ad5f
File added
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