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
cd96c1c8
Commit
cd96c1c8
authored
May 20, 2022
by
turneram
Browse files
Formatting
parent
37351ed6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
src/onnx/parse_attention.cpp
src/onnx/parse_attention.cpp
+4
-2
No files found.
src/onnx/parse_attention.cpp
View file @
cd96c1c8
...
@@ -65,7 +65,8 @@ struct parse_attention : op_parser<parse_attention>
...
@@ -65,7 +65,8 @@ struct parse_attention : op_parser<parse_attention>
migraphx
::
make_op
(
"reshape"
,
migraphx
::
make_op
(
"reshape"
,
{{
"dims"
,
{
batch_size
,
sequence_length
,
3
,
num_heads
,
head_size
}}}),
{{
"dims"
,
{
batch_size
,
sequence_length
,
3
,
num_heads
,
head_size
}}}),
add_gemms
);
add_gemms
);
auto
transqkv
=
info
.
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
2
,
0
,
3
,
1
,
4
}}}),
add_gemms
);
auto
transqkv
=
info
.
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
2
,
0
,
3
,
1
,
4
}}}),
add_gemms
);
// Q, K, V: each has size BxNxSxH
// Q, K, V: each has size BxNxSxH
auto
q_t
=
info
.
add_instruction
(
auto
q_t
=
info
.
add_instruction
(
...
@@ -99,7 +100,8 @@ struct parse_attention : op_parser<parse_attention>
...
@@ -99,7 +100,8 @@ struct parse_attention : op_parser<parse_attention>
auto
gemm4
=
info
.
add_instruction
(
migraphx
::
make_op
(
"dot"
),
softmax
,
v_t
);
auto
gemm4
=
info
.
add_instruction
(
migraphx
::
make_op
(
"dot"
),
softmax
,
v_t
);
// result is BxNxSxH, transpose to BxSxNxH and reshape to BxSxHiddenSize
// result is BxNxSxH, transpose to BxSxNxH and reshape to BxSxHiddenSize
gemm4
=
info
.
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
0
,
2
,
1
,
3
}}}),
gemm4
);
gemm4
=
info
.
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
0
,
2
,
1
,
3
}}}),
gemm4
);
return
info
.
add_instruction
(
return
info
.
add_instruction
(
make_op
(
"reshape"
,
{{
"dims"
,
{
batch_size
,
sequence_length
,
num_heads
*
head_size
}}}),
make_op
(
"reshape"
,
{{
"dims"
,
{
batch_size
,
sequence_length
,
num_heads
*
head_size
}}}),
gemm4
);
gemm4
);
...
...
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