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
bd24f471
Commit
bd24f471
authored
Jun 01, 2022
by
charlie
Browse files
Use custom distance function
parent
6e94e607
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
1 deletion
+16
-1
src/instruction.cpp
src/instruction.cpp
+16
-1
No files found.
src/instruction.cpp
View file @
bd24f471
...
...
@@ -74,14 +74,29 @@ bool operator==(const instruction& i, instruction_ref ref)
return
std
::
addressof
(
i
)
==
std
::
addressof
(
*
ref
);
}
static
void
debug_name
(
std
::
ostream
&
os
,
const
instruction
&
ins
);
bool
instruction
::
valid
(
instruction_ref
start
,
bool
check_order
)
const
{
// Need this lambda because std::distance has undefined behavior when comparing iterators of
// from different ranges
auto
ins_dist
=
[](
instruction_ref
s
,
instruction_ref
e
)
{
int
dist
=
0
;
while
((
*
s
)
!=
(
*
e
))
{
++
s
;
++
dist
;
}
return
dist
;
};
return
valid
()
&&
std
::
all_of
(
arguments
.
begin
(),
arguments
.
end
(),
[
&
](
instruction_ref
i
)
{
auto
self
=
std
::
find
(
i
->
outputs
().
begin
(),
i
->
outputs
().
end
(),
*
this
);
bool
ret
=
self
!=
i
->
outputs
().
end
();
if
(
check_order
)
{
ret
=
ret
and
(
std
::
distance
(
start
,
i
)
<
std
::
distance
(
start
,
*
self
));
// arguments for this instruction before this instruction
ret
=
ret
and
(
ins_dist
(
start
,
i
)
<
ins_dist
(
start
,
*
self
));
}
return
ret
;
});
...
...
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