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
d4663c02
Commit
d4663c02
authored
Jul 05, 2023
by
Brian Pickrell
Browse files
Add dynamic input to prefix_scan_op
parent
e7471141
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
2 deletions
+33
-2
src/include/migraphx/op/prefix_scan_op.hpp
src/include/migraphx/op/prefix_scan_op.hpp
+7
-2
test/ref_ops_test.cpp
test/ref_ops_test.cpp
+26
-0
No files found.
src/include/migraphx/op/prefix_scan_op.hpp
View file @
d4663c02
...
@@ -60,8 +60,12 @@ struct prefix_scan_op : op_name<Derived>
...
@@ -60,8 +60,12 @@ struct prefix_scan_op : op_name<Derived>
shape
normalize_compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
shape
normalize_compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
{
check_shapes
{
inputs
,
*
this
}.
has
(
1
);
check_shapes
{
inputs
,
*
this
,
true
}.
has
(
1
);
auto
s
=
inputs
.
front
();
auto
s
=
inputs
.
front
();
if
(
s
.
dynamic
())
{
return
{
s
.
type
(),
s
.
max_lens
()};
}
if
(
s
.
broadcasted
())
if
(
s
.
broadcasted
())
{
{
return
{
s
.
type
(),
s
.
lens
()};
return
{
s
.
type
(),
s
.
lens
()};
...
@@ -72,8 +76,9 @@ struct prefix_scan_op : op_name<Derived>
...
@@ -72,8 +76,9 @@ struct prefix_scan_op : op_name<Derived>
}
}
}
}
argument
compute
(
const
shape
&
output_shape
,
std
::
vector
<
argument
>
args
)
const
argument
compute
(
const
dyn_output
&
dyn_out
,
std
::
vector
<
argument
>
args
)
const
{
{
shape
output_shape
(
dyn_out
.
computed_shape
);
argument
result
{
output_shape
};
argument
result
{
output_shape
};
auto
s
=
args
[
0
].
get_shape
();
auto
s
=
args
[
0
].
get_shape
();
if
(
s
==
output_shape
)
if
(
s
==
output_shape
)
...
...
test/ref_ops_test.cpp
View file @
d4663c02
...
@@ -5539,6 +5539,32 @@ TEST_CASE(prefix_scan_sum_1d)
...
@@ -5539,6 +5539,32 @@ TEST_CASE(prefix_scan_sum_1d)
EXPECT
(
results_vector
==
gold
);
EXPECT
(
results_vector
==
gold
);
}
}
TEST_CASE
(
prefix_scan_sum_dyn_1d
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
std
::
vector
<
migraphx
::
shape
::
dynamic_dimension
>
dd
{{
5
,
6
}};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
dd
};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"prefix_scan_sum"
,
{{
"axis"
,
0
},
{
"exclusive"
,
false
}}),
input
);
p
.
compile
(
migraphx
::
make_target
(
"ref"
));
std
::
vector
<
float
>
a
=
{
1
,
2
,
3
,
4
,
5
,
6
};
migraphx
::
parameter_map
params0
;
// auto input = migraphx::literal{s, {1, 2, 3, 4, 5, 6}};
migraphx
::
shape
input_fixed_shape0
{
migraphx
::
shape
::
float_type
,
{
6
}};
params0
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape0
,
a
.
data
());
auto
result
=
p
.
eval
(
params0
).
back
();
std
::
vector
<
float
>
results_vector
;
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
{
1.0
,
3.0
,
6.0
,
10.0
,
15.0
,
21.0
};
EXPECT
(
results_vector
==
gold
);
}
TEST_CASE
(
prefix_scan_sum_2d
)
TEST_CASE
(
prefix_scan_sum_2d
)
{
{
{
{
...
...
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