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
4ba12b4f
Commit
4ba12b4f
authored
May 05, 2018
by
Paul
Browse files
Add insert instruction
parent
d3886685
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
+15
-4
include/rtg/program.hpp
include/rtg/program.hpp
+8
-0
src/program.cpp
src/program.cpp
+7
-4
No files found.
include/rtg/program.hpp
View file @
4ba12b4f
...
...
@@ -26,6 +26,14 @@ struct program
return
add_instruction
(
op
,
{
args
...});
}
instruction_ref
add_instruction
(
operation
op
,
std
::
vector
<
instruction_ref
>
args
);
template
<
class
...
Ts
>
instruction_ref
insert_instruction
(
instruction_ref
ins
,
operation
op
,
Ts
...
args
)
{
return
insert_instruction
(
ins
,
op
,
{
args
...});
}
instruction_ref
insert_instruction
(
instruction_ref
ins
,
operation
op
,
std
::
vector
<
instruction_ref
>
args
);
template
<
class
...
Ts
>
instruction_ref
add_literal
(
Ts
&&
...
xs
)
{
...
...
src/program.cpp
View file @
4ba12b4f
...
...
@@ -19,17 +19,20 @@ program& program::operator=(program&&) noexcept = default;
program
::~
program
()
noexcept
=
default
;
instruction_ref
program
::
add_instruction
(
operation
op
,
std
::
vector
<
instruction_ref
>
args
)
{
return
insert_instruction
(
impl
->
instructions
.
end
(),
std
::
move
(
op
),
std
::
move
(
args
));
}
instruction_ref
program
::
insert_instruction
(
instruction_ref
ins
,
operation
op
,
std
::
vector
<
instruction_ref
>
args
)
{
assert
(
std
::
all_of
(
args
.
begin
(),
args
.
end
(),
[
&
](
instruction_ref
x
)
{
return
has_instruction
(
x
);
})
&&
"Argument is not an exisiting instruction"
);
std
::
vector
<
shape
>
shapes
(
args
.
size
());
std
::
transform
(
args
.
begin
(),
args
.
end
(),
shapes
.
begin
(),
[](
instruction_ref
i
ns
)
{
return
i
ns
->
result
;
});
args
.
begin
(),
args
.
end
(),
shapes
.
begin
(),
[](
instruction_ref
i
)
{
return
i
->
result
;
});
shape
r
=
op
.
compute_shape
(
shapes
);
impl
->
instructions
.
push_back
({
op
,
r
,
args
});
assert
(
impl
->
instructions
.
back
().
arguments
==
args
);
auto
result
=
std
::
prev
(
impl
->
instructions
.
end
());
auto
result
=
impl
->
instructions
.
insert
(
ins
,
{
op
,
r
,
args
});
assert
(
result
->
arguments
==
args
);
for
(
auto
&&
arg
:
args
)
arg
->
output
.
push_back
(
result
);
return
result
;
...
...
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