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
a4567795
Commit
a4567795
authored
Feb 14, 2022
by
Shucai Xiao
Browse files
fix issue that alias 0 instrution as program return values
parent
fa542e7c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
8 deletions
+39
-8
src/eliminate_contiguous.cpp
src/eliminate_contiguous.cpp
+7
-0
src/module.cpp
src/module.cpp
+2
-1
src/program.cpp
src/program.cpp
+1
-1
src/targets/gpu/lowering.cpp
src/targets/gpu/lowering.cpp
+29
-6
No files found.
src/eliminate_contiguous.cpp
View file @
a4567795
...
@@ -39,6 +39,13 @@ static bool try_compute_shape(instruction_ref ins,
...
@@ -39,6 +39,13 @@ static bool try_compute_shape(instruction_ref ins,
return
false
;
return
false
;
}
}
if
(
std
::
any_of
(
outputs
.
begin
(),
outputs
.
end
(),
[](
auto
o
)
{
return
o
->
name
()
==
"@return"
;
}))
{
return
false
;
}
for
(
auto
output
:
outputs
)
for
(
auto
output
:
outputs
)
{
{
auto
args
=
output
->
inputs
();
auto
args
=
output
->
inputs
();
...
...
src/module.cpp
View file @
a4567795
...
@@ -627,8 +627,9 @@ std::unordered_map<instruction_ref, std::string> module::print(
...
@@ -627,8 +627,9 @@ std::unordered_map<instruction_ref, std::string> module::print(
var_name
=
this
->
name
();
var_name
=
this
->
name
();
var_name
.
append
((
this
->
name
().
empty
()
?
"@"
:
":@"
));
var_name
.
append
((
this
->
name
().
empty
()
?
"@"
:
":@"
));
var_name
.
append
(
std
::
to_string
(
count
));
var_name
.
append
(
std
::
to_string
(
count
));
count
++
;
}
}
// make instruction index to be the line num in the printed module
count
++
;
names
.
emplace
(
ins
,
var_name
);
names
.
emplace
(
ins
,
var_name
);
print_func
(
ins
,
names
);
print_func
(
ins
,
names
);
...
...
src/program.cpp
View file @
a4567795
...
@@ -168,7 +168,7 @@ void program::compile(const target& t, compile_options options)
...
@@ -168,7 +168,7 @@ void program::compile(const target& t, compile_options options)
{
{
auto
index
=
std
::
distance
(
mod
->
begin
(),
dangling
);
auto
index
=
std
::
distance
(
mod
->
begin
(),
dangling
);
MIGRAPHX_THROW
(
"Dangling reference in module "
+
mod
->
name
()
+
" from instruction "
+
MIGRAPHX_THROW
(
"Dangling reference in module "
+
mod
->
name
()
+
" from instruction "
+
std
::
to_string
(
index
));
std
::
to_string
(
index
)
+
", ("
+
dangling
->
name
()
+
")"
);
}
}
mod
->
finalize
(
this
->
impl
->
ctx
);
mod
->
finalize
(
this
->
impl
->
ctx
);
}
}
...
...
src/targets/gpu/lowering.cpp
View file @
a4567795
...
@@ -81,15 +81,20 @@ struct miopen_apply
...
@@ -81,15 +81,20 @@ struct miopen_apply
if
(
this
->
last
->
name
()
==
"@return"
)
if
(
this
->
last
->
name
()
==
"@return"
)
{
{
const
auto
&
prog_outputs
=
last
->
inputs
();
const
auto
&
prog_outputs
=
last
->
inputs
();
std
::
vector
<
instruction_ref
>
outputs
_alias
(
prog_outputs
.
size
());
std
::
vector
<
instruction_ref
>
outputs
(
prog_outputs
.
size
());
std
::
transform
(
prog_outputs
.
begin
(),
std
::
transform
(
prog_outputs
.
begin
(),
prog_outputs
.
end
(),
prog_outputs
.
end
(),
outputs_alias
.
begin
(),
outputs
.
begin
(),
[](
const
auto
&
i
)
{
return
instruction
::
get_output_alias
(
i
);
});
[](
const
auto
&
i
)
{
auto
alias_ins
=
instruction
::
get_output_alias
(
i
);
auto
alias_s
=
alias_ins
->
get_shape
();
return
(
alias_s
.
type
()
==
shape
::
tuple_type
or
alias_s
.
elements
()
!=
i
->
get_shape
().
elements
())
?
i
:
alias_ins
;
}
);
std
::
size_t
index
=
0
;
std
::
size_t
index
=
0
;
for
(
auto
ins
:
outputs
_alias
)
for
(
auto
ins
:
outputs
)
{
{
prog_output_names
[
ins
]
=
mod
->
name
()
+
":#output_"
+
std
::
to_string
(
index
++
);
prog_output_names
[
ins
]
=
mod
->
name
()
+
":#output_"
+
std
::
to_string
(
index
++
);
}
}
...
@@ -265,9 +270,27 @@ struct miopen_apply
...
@@ -265,9 +270,27 @@ struct miopen_apply
}
}
auto
ins_alias
=
instruction
::
get_output_alias
(
ins
);
auto
ins_alias
=
instruction
::
get_output_alias
(
ins
);
if
(
last
->
name
()
==
"@return"
and
tag
.
empty
()
and
prog_output_names
.
count
(
ins_alias
)
>
0
)
if
(
last
->
name
()
==
"@return"
and
tag
.
empty
())
{
{
return
mod
->
add_parameter
(
prog_output_names
[
ins_alias
],
s
);
auto
alias_s
=
ins_alias
->
get_shape
();
if
(
alias_s
.
type
()
==
shape
::
tuple_type
or
alias_s
.
elements
()
!=
ins
->
get_shape
().
elements
())
{
if
(
prog_output_names
.
count
(
ins
)
>
0
)
{
auto
out_ins
=
mod
->
add_parameter
(
prog_output_names
[
ins
],
s
);
mod
->
insert_instruction
(
std
::
next
(
ins
),
make_op
(
"contiguous"
),
ins
,
out_ins
);
mod
->
replace_instruction
(
ins
,
out_ins
);
return
out_ins
;
}
}
else
{
if
(
prog_output_names
.
count
(
ins_alias
)
>
0
)
{
return
mod
->
add_parameter
(
prog_output_names
[
ins_alias
],
s
);
}
}
}
}
else
if
(
ins
==
last
and
tag
.
empty
())
else
if
(
ins
==
last
and
tag
.
empty
())
{
{
...
...
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