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
2cf7ae45
Commit
2cf7ae45
authored
Nov 03, 2022
by
charlie
Browse files
Fix eliminate_contiguous pass
parent
91e3efee
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
src/eliminate_contiguous.cpp
src/eliminate_contiguous.cpp
+9
-6
No files found.
src/eliminate_contiguous.cpp
View file @
2cf7ae45
...
@@ -140,17 +140,20 @@ static void remove_contiguous(const std::string& op_name, module& m, F f)
...
@@ -140,17 +140,20 @@ static void remove_contiguous(const std::string& op_name, module& m, F f)
}
}
}
}
// Perform evaluations in parallel
// Perform
static contiguous
evaluations in parallel
std
::
vector
<
argument
>
literals
(
const_instructions
.
size
());
std
::
vector
<
argument
>
literals
(
const_instructions
.
size
());
par_for
(
const_instructions
.
size
(),
1
,
[
&
](
const
auto
i
)
{
par_for
(
const_instructions
.
size
(),
1
,
[
&
](
const
auto
i
)
{
auto
c
=
op
::
contiguous
{};
auto
c
=
op
::
contiguous
{};
auto
prev
=
const_instructions
[
i
]
->
inputs
().
front
();
auto
prev
=
const_instructions
[
i
]
->
inputs
().
front
();
std
::
vector
<
shape
>
prev_shape
=
{
prev
->
get_shape
()};
// compute the output contiguous shape from the previous instruction shape
shape
computed_shape
=
c
.
compute_shape
({
prev
->
get_shape
()});
const
std
::
vector
<
argument
>&
prev_eval
=
{
prev
->
eval
()};
const
std
::
vector
<
argument
>&
prev_eval
=
{
prev
->
eval
()};
auto
co_shape
=
make_compute_output_shape
(
pack
(
c
,
prev_shape
,
prev_eval
));
// prev_eval should not be used in make_compute_output_shape() as computed_shape is static
literals
[
i
]
=
c
.
compute
(
co_shape
,
{
prev
->
eval
()});
auto
co_shape
=
make_compute_output_shape
(
pack
(
c
,
computed_shape
,
prev_eval
));
literals
[
i
]
=
c
.
compute
(
co_shape
,
prev_eval
);
});
});
// Replace static contiguous operations with a literal
for
(
size_t
i
=
0
;
i
<
const_instructions
.
size
();
i
++
)
for
(
size_t
i
=
0
;
i
<
const_instructions
.
size
();
i
++
)
{
{
auto
l
=
m
.
add_literal
(
literals
[
i
].
get_shape
(),
literals
[
i
].
data
());
auto
l
=
m
.
add_literal
(
literals
[
i
].
get_shape
(),
literals
[
i
].
data
());
...
...
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