Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
89930b8d
Commit
89930b8d
authored
May 08, 2018
by
Paul
Browse files
Add missing header
parent
81eca52d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
17 deletions
+27
-17
include/rtg/erase.hpp
include/rtg/erase.hpp
+21
-0
include/rtg/instruction.hpp
include/rtg/instruction.hpp
+5
-15
src/program.cpp
src/program.cpp
+1
-2
No files found.
include/rtg/erase.hpp
0 → 100644
View file @
89930b8d
#ifndef RTG_GUARD_ERASE_HPP
#define RTG_GUARD_ERASE_HPP
namespace
rtg
{
template
<
class
R
,
class
T
>
auto
erase
(
R
&&
r
,
const
T
&
value
)
{
return
r
.
erase
(
std
::
remove
(
r
.
begin
(),
r
.
end
(),
value
),
r
.
end
());
}
template
<
class
R
,
class
P
>
auto
erase_if
(
R
&&
r
,
P
&&
pred
)
{
return
r
.
erase
(
std
::
remove_if
(
r
.
begin
(),
r
.
end
(),
pred
),
r
.
end
());
}
}
// namespace rtg
#endif
include/rtg/instruction.hpp
View file @
89930b8d
...
@@ -35,14 +35,13 @@ struct instruction
...
@@ -35,14 +35,13 @@ struct instruction
if
(
r
!=
result
)
if
(
r
!=
result
)
{
{
result
=
r
;
result
=
r
;
for
(
auto
&&
ins
:
output
)
for
(
auto
&&
ins
:
output
)
{
{
ins
->
replace
(
compute_shape
(
ins
->
op
,
ins
->
arguments
));
ins
->
replace
(
compute_shape
(
ins
->
op
,
ins
->
arguments
));
}
}
}
}
}
}
void
replace
(
std
::
vector
<
instruction_ref
>
args
)
void
replace
(
std
::
vector
<
instruction_ref
>
args
)
{
{
clear_arguments
();
clear_arguments
();
...
@@ -51,7 +50,7 @@ struct instruction
...
@@ -51,7 +50,7 @@ struct instruction
void
clear_arguments
()
void
clear_arguments
()
{
{
for
(
auto
&&
arg
:
arguments
)
for
(
auto
&&
arg
:
arguments
)
{
{
rtg
::
erase
(
arg
->
output
,
*
this
);
rtg
::
erase
(
arg
->
output
,
*
this
);
}
}
...
@@ -62,20 +61,11 @@ struct instruction
...
@@ -62,20 +61,11 @@ struct instruction
return
std
::
addressof
(
i
)
==
std
::
addressof
(
*
ref
);
return
std
::
addressof
(
i
)
==
std
::
addressof
(
*
ref
);
}
}
friend
bool
operator
==
(
instruction_ref
ref
,
const
instruction
&
i
)
friend
bool
operator
==
(
instruction_ref
ref
,
const
instruction
&
i
)
{
return
i
==
ref
;
}
{
return
i
==
ref
;
}
friend
bool
operator
!=
(
const
instruction
&
i
,
instruction_ref
ref
)
friend
bool
operator
!=
(
const
instruction
&
i
,
instruction_ref
ref
)
{
return
!
(
i
==
ref
);
}
{
return
!
(
i
==
ref
);
}
friend
bool
operator
!=
(
instruction_ref
ref
,
const
instruction
&
i
)
friend
bool
operator
!=
(
instruction_ref
ref
,
const
instruction
&
i
)
{
return
!
(
i
==
ref
);
}
{
return
!
(
i
==
ref
);
}
operation
op
;
operation
op
;
shape
result
;
shape
result
;
...
...
src/program.cpp
View file @
89930b8d
...
@@ -43,11 +43,10 @@ program::replace_instruction(instruction_ref ins, operation op, std::vector<inst
...
@@ -43,11 +43,10 @@ program::replace_instruction(instruction_ref ins, operation op, std::vector<inst
args
.
begin
(),
args
.
end
(),
[
&
](
instruction_ref
x
)
{
return
has_instruction
(
x
);
})
&&
args
.
begin
(),
args
.
end
(),
[
&
](
instruction_ref
x
)
{
return
has_instruction
(
x
);
})
&&
"Argument is not an exisiting instruction"
);
"Argument is not an exisiting instruction"
);
shape
r
=
compute_shape
(
op
,
args
);
shape
r
=
compute_shape
(
op
,
args
);
ins
->
replace
(
op
,
r
,
args
);
ins
->
replace
(
op
,
r
,
args
);
backreference
(
ins
);
backreference
(
ins
);
return
ins
;
return
ins
;
}
}
instruction_ref
program
::
add_literal
(
literal
l
)
instruction_ref
program
::
add_literal
(
literal
l
)
...
...
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