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
e7752391
Commit
e7752391
authored
May 31, 2022
by
turneram
Browse files
Merge remote-tracking branch 'origin/develop' into bert-attention
parents
848c47db
6e94e607
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
6 deletions
+20
-6
examples/nlp/python_bert_squad/requirements_bertsquad.txt
examples/nlp/python_bert_squad/requirements_bertsquad.txt
+1
-1
src/eliminate_contiguous.cpp
src/eliminate_contiguous.cpp
+19
-5
No files found.
examples/nlp/python_bert_squad/requirements_bertsquad.txt
View file @
e7752391
tensorflow==2.
6.4
tensorflow==2.
7.2
onnxruntime
tokenizers
\ No newline at end of file
src/eliminate_contiguous.cpp
View file @
e7752391
...
...
@@ -6,6 +6,7 @@
#include <migraphx/stringutils.hpp>
#include <migraphx/op/contiguous.hpp>
#include <migraphx/op/identity.hpp>
#include <migraphx/par_for.hpp>
#include <utility>
namespace
migraphx
{
...
...
@@ -71,6 +72,8 @@ static bool try_compute_shape(instruction_ref ins,
void
eliminate_contiguous
::
apply
(
module
&
m
)
const
{
std
::
vector
<
instruction_ref
>
const_instruction
;
for
(
auto
ins
:
iterator_for
(
m
))
{
// return instruction should have inputs with standard shape
...
...
@@ -81,6 +84,7 @@ void eliminate_contiguous::apply(module& m) const
auto
args
=
ins
->
inputs
();
auto
new_args
=
args
;
auto
mod_args
=
ins
->
module_inputs
();
for
(
auto
arg
:
ins
->
inputs
())
{
if
(
arg
->
name
()
==
op_name
)
...
...
@@ -93,15 +97,25 @@ void eliminate_contiguous::apply(module& m) const
}
else
if
(
prev
->
can_eval
())
{
auto
c
=
op
::
contiguous
{};
auto
r
=
c
.
compute
(
c
.
compute_shape
({
prev
->
get_shape
()}),
{
prev
->
eval
()});
auto
l
=
m
.
add_literal
(
r
.
get_shape
(),
r
.
data
());
m
.
replace_instruction
(
arg
,
l
);
const_instruction
.
push_back
(
arg
);
}
}
}
}
// Perform evaluations in parallel
std
::
vector
<
argument
>
literals
(
const_instruction
.
size
());
par_for
(
const_instruction
.
size
(),
1
,
[
&
](
const
auto
i
)
{
auto
c
=
op
::
contiguous
{};
auto
prev
=
const_instruction
[
i
]
->
inputs
().
front
();
literals
[
i
]
=
c
.
compute
(
c
.
compute_shape
({
prev
->
get_shape
()}),
{
prev
->
eval
()});
});
for
(
size_t
i
=
0
;
i
<
const_instruction
.
size
();
i
++
)
{
auto
l
=
m
.
add_literal
(
literals
[
i
].
get_shape
(),
literals
[
i
].
data
());
m
.
replace_instruction
(
const_instruction
[
i
],
l
);
}
}
}
// namespace MIGRAPHX_INLINE_NS
...
...
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