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
d92520de
Commit
d92520de
authored
Nov 05, 2023
by
Paul
Browse files
Fix bug in pad operator from dimension reduction
parent
b0798343
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
7 deletions
+24
-7
src/targets/gpu/jit/pad.cpp
src/targets/gpu/jit/pad.cpp
+24
-7
No files found.
src/targets/gpu/jit/pad.cpp
View file @
d92520de
...
...
@@ -65,10 +65,32 @@ struct pad_compiler : compiler<pad_compiler>
operation
compile_op
(
context
&
ctx
,
const
std
::
vector
<
shape
>&
inputs
,
const
value
&
v
)
const
{
auto
padding
=
v
.
at
(
"pads"
).
to_vector
<
int64_t
>
();
auto
input_lens
=
inputs
.
front
().
lens
();
std
::
vector
<
size_t
>
offsets
(
input_lens
.
size
());
std
::
copy
(
padding
.
begin
(),
padding
.
begin
()
+
offsets
.
size
(),
offsets
.
begin
());
auto
offset_lens
=
input_lens
;
std
::
transform
(
input_lens
.
begin
(),
input_lens
.
end
(),
offsets
.
begin
(),
offset_lens
.
begin
(),
[
&
](
auto
input
,
auto
offset
)
{
return
input
+
offset
;
});
auto
vinputs
=
inputs
;
vinputs
.
push_back
(
inputs
.
front
().
with_lens
(
offset_lens
));
auto
rinputs
=
reduce_dims
(
vinputs
);
auto
rinput_lens
=
rinputs
.
front
().
lens
();
auto
roffset_lens
=
rinputs
.
back
().
lens
();
std
::
vector
<
size_t
>
roffsets
(
roffset_lens
.
size
());
std
::
transform
(
rinput_lens
.
begin
(),
rinput_lens
.
end
(),
roffset_lens
.
begin
(),
roffsets
.
begin
(),
[](
auto
input
,
auto
offset_dim
)
{
return
offset_dim
-
input
;
});
rinputs
.
pop_back
();
hip_compile_options
options
;
options
.
inputs
=
inputs
;
options
.
output
=
inputs
.
back
();
options
.
virtual_inputs
=
r
educe_dims
(
inputs
)
;
options
.
virtual_inputs
=
rinputs
;
options
.
kernel_name
=
"pad_kernel"
;
options
.
set_launch_params
(
v
,
compute_global_for
(
ctx
,
inputs
.
at
(
1
).
elements
()));
...
...
@@ -79,14 +101,9 @@ struct pad_compiler : compiler<pad_compiler>
if
(
float_equal
(
pad_val
,
std
::
numeric_limits
<
float
>::
max
()))
pad_val_string
=
"highest{}"
;
auto
padding
=
v
.
at
(
"pads"
).
to_vector
<
int64_t
>
();
auto
input_lens
=
inputs
.
front
().
lens
();
std
::
vector
<
size_t
>
offsets
(
input_lens
.
size
());
std
::
copy
(
padding
.
begin
(),
padding
.
begin
()
+
offsets
.
size
(),
offsets
.
begin
());
auto
src
=
interpolate_string
(
pointwise_kernel
,
{{
"pad_val"
,
to_string
(
pad_val_string
)},
{
"offsets"
,
to_string_range
(
offsets
)}});
{{
"pad_val"
,
to_string
(
pad_val_string
)},
{
"offsets"
,
to_string_range
(
r
offsets
)}});
return
compile_hip_code_object
(
src
,
options
);
}
...
...
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