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
fa62ad24
"src/targets/vscode:/vscode.git/clone" did not exist on "311ae1d139f4852e6ff2bf0cefe5e10e26f4b421"
Commit
fa62ad24
authored
Aug 20, 2023
by
Paul
Browse files
Fix slice error when data input is constant
parent
24d9ecbe
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
1 deletion
+40
-1
src/onnx/parse_slice.cpp
src/onnx/parse_slice.cpp
+6
-1
test/onnx/gen_onnx.py
test/onnx/gen_onnx.py
+22
-0
test/onnx/onnx_test.cpp
test/onnx/onnx_test.cpp
+12
-0
No files found.
src/onnx/parse_slice.cpp
View file @
fa62ad24
...
...
@@ -44,6 +44,11 @@ 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 +137,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 @
fa62ad24
...
...
@@ -6413,6 +6413,28 @@ 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
():
...
...
test/onnx/onnx_test.cpp
View file @
fa62ad24
...
...
@@ -6294,6 +6294,18 @@ 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;
...
...
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