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
bf3789fa
Commit
bf3789fa
authored
Aug 11, 2018
by
Paul
Browse files
Formatting
parent
d2d5fd19
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
16 deletions
+11
-16
src/include/migraph/instruction.hpp
src/include/migraph/instruction.hpp
+6
-9
src/include/migraph/program.hpp
src/include/migraph/program.hpp
+1
-2
src/program.cpp
src/program.cpp
+1
-2
test/eval_test.cpp
test/eval_test.cpp
+3
-3
No files found.
src/include/migraph/instruction.hpp
View file @
bf3789fa
...
@@ -75,8 +75,7 @@ struct instruction
...
@@ -75,8 +75,7 @@ struct instruction
bool
valid
(
instruction_ref
start
)
const
bool
valid
(
instruction_ref
start
)
const
{
{
return
valid
()
&&
return
valid
()
&&
std
::
all_of
(
arguments
.
begin
(),
arguments
.
end
(),
[
&
](
instruction_ref
i
)
{
std
::
all_of
(
arguments
.
begin
(),
arguments
.
end
(),
[
&
](
instruction_ref
i
)
{
auto
self
=
std
::
find
(
i
->
output
.
begin
(),
i
->
output
.
end
(),
*
this
);
auto
self
=
std
::
find
(
i
->
output
.
begin
(),
i
->
output
.
end
(),
*
this
);
return
self
!=
i
->
output
.
end
()
&&
return
self
!=
i
->
output
.
end
()
&&
std
::
distance
(
start
,
i
)
<
std
::
distance
(
start
,
*
self
);
std
::
distance
(
start
,
i
)
<
std
::
distance
(
start
,
*
self
);
...
@@ -106,12 +105,10 @@ struct instruction
...
@@ -106,12 +105,10 @@ struct instruction
}
}
}
}
return
result
==
computed
&&
return
result
==
computed
&&
std
::
all_of
(
output
.
begin
(),
std
::
all_of
(
output
.
begin
(),
output
.
end
(),
[
&
](
instruction_ref
i
)
{
output
.
end
(),
return
std
::
find
(
i
->
arguments
.
begin
(),
i
->
arguments
.
end
(),
*
this
)
!=
[
&
](
instruction_ref
i
)
{
i
->
arguments
.
end
();
return
std
::
find
(
i
->
arguments
.
begin
(),
i
->
arguments
.
end
(),
*
this
)
!=
});
i
->
arguments
.
end
();
});
}
}
friend
bool
operator
==
(
instruction_ref
ref
,
const
instruction
&
i
)
{
return
i
==
ref
;
}
friend
bool
operator
==
(
instruction_ref
ref
,
const
instruction
&
i
)
{
return
i
==
ref
;
}
...
@@ -126,7 +123,7 @@ struct instruction
...
@@ -126,7 +123,7 @@ struct instruction
output
.
push_back
(
ins
);
output
.
push_back
(
ins
);
}
}
template
<
class
T
>
template
<
class
T
>
void
remove_output
(
const
T
&
ins
)
void
remove_output
(
const
T
&
ins
)
{
{
migraph
::
erase
(
output
,
ins
);
migraph
::
erase
(
output
,
ins
);
...
...
src/include/migraph/program.hpp
View file @
bf3789fa
...
@@ -55,8 +55,7 @@ struct program
...
@@ -55,8 +55,7 @@ struct program
instruction_ref
instruction_ref
replace_instructions
(
instruction_ref
ins
,
instruction_ref
start
,
instruction_ref
last
);
replace_instructions
(
instruction_ref
ins
,
instruction_ref
start
,
instruction_ref
last
);
instruction_ref
instruction_ref
replace_instruction
(
instruction_ref
ins
,
instruction_ref
start
);
replace_instruction
(
instruction_ref
ins
,
instruction_ref
start
);
instruction_ref
remove_instruction
(
instruction_ref
ins
);
instruction_ref
remove_instruction
(
instruction_ref
ins
);
instruction_ref
remove_instructions
(
instruction_ref
first
,
instruction_ref
last
);
instruction_ref
remove_instructions
(
instruction_ref
first
,
instruction_ref
last
);
...
...
src/program.cpp
View file @
bf3789fa
...
@@ -77,8 +77,7 @@ program::replace_instructions(instruction_ref ins, instruction_ref start, instru
...
@@ -77,8 +77,7 @@ program::replace_instructions(instruction_ref ins, instruction_ref start, instru
return
rep
;
return
rep
;
}
}
instruction_ref
instruction_ref
program
::
replace_instruction
(
instruction_ref
ins
,
instruction_ref
start
)
program
::
replace_instruction
(
instruction_ref
ins
,
instruction_ref
start
)
{
{
assert
(
ins
!=
start
);
assert
(
ins
!=
start
);
return
replace_instructions
(
ins
,
start
,
std
::
next
(
start
));
return
replace_instructions
(
ins
,
start
,
std
::
next
(
start
));
...
...
test/eval_test.cpp
View file @
bf3789fa
...
@@ -122,9 +122,9 @@ void replace_ins_test()
...
@@ -122,9 +122,9 @@ void replace_ins_test()
{
{
migraph
::
program
p
;
migraph
::
program
p
;
auto
one
=
p
.
add_literal
(
1
);
auto
one
=
p
.
add_literal
(
1
);
auto
two
=
p
.
add_literal
(
2
);
auto
two
=
p
.
add_literal
(
2
);
auto
sum
=
p
.
add_instruction
(
sum_op
{},
one
,
two
);
auto
sum
=
p
.
add_instruction
(
sum_op
{},
one
,
two
);
auto
minus
=
p
.
add_instruction
(
minus_op
{},
two
,
one
);
auto
minus
=
p
.
add_instruction
(
minus_op
{},
two
,
one
);
p
.
replace_instruction
(
sum
,
minus
);
p
.
replace_instruction
(
sum
,
minus
);
...
...
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