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
203a4c4c
Commit
203a4c4c
authored
Jul 10, 2018
by
Paul
Browse files
Add more validation
parent
84714596
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
4 deletions
+14
-4
src/include/migraph/instruction.hpp
src/include/migraph/instruction.hpp
+13
-3
src/program.cpp
src/program.cpp
+1
-1
No files found.
src/include/migraph/instruction.hpp
View file @
203a4c4c
...
...
@@ -62,16 +62,26 @@ struct instruction
return
std
::
addressof
(
i
)
==
std
::
addressof
(
*
ref
);
}
bool
valid
()
const
bool
valid
(
instruction_ref
start
)
const
{
return
std
::
all_of
(
output
.
begin
(),
std
::
vector
<
shape
>
shapes
(
arguments
.
size
());
std
::
transform
(
arguments
.
begin
(),
arguments
.
end
(),
shapes
.
begin
(),
[](
instruction_ref
ins
)
{
return
ins
->
result
;
});
shape
computed
;
try
{
computed
=
op
.
compute_shape
(
shapes
);
}
catch
(
migraph
::
exception
&
)
{
return
false
;
}
return
result
==
computed
&&
std
::
all_of
(
output
.
begin
(),
output
.
end
(),
[
&
](
instruction_ref
i
)
{
return
std
::
find
(
i
->
arguments
.
begin
(),
i
->
arguments
.
end
(),
*
this
)
!=
i
->
arguments
.
end
();
})
&&
std
::
all_of
(
arguments
.
begin
(),
arguments
.
end
(),
[
&
](
instruction_ref
i
)
{
return
std
::
find
(
i
->
output
.
begin
(),
i
->
output
.
end
(),
*
this
)
!=
i
->
output
.
end
();
auto
self
=
std
::
find
(
i
->
output
.
begin
(),
i
->
output
.
end
(),
*
this
);
return
self
!=
i
->
output
.
end
()
&&
std
::
distance
(
start
,
i
)
<
std
::
distance
(
start
,
*
self
);
});
}
...
...
src/program.cpp
View file @
203a4c4c
...
...
@@ -129,7 +129,7 @@ instruction_ref program::validate() const
{
return
std
::
find_if
(
impl
->
instructions
.
begin
(),
impl
->
instructions
.
end
(),
[](
const
instruction
&
i
)
{
return
i
.
valid
();
});
[
&
](
const
instruction
&
i
)
{
return
i
.
valid
(
impl
->
instructions
.
begin
()
);
});
}
void
program
::
compile
(
const
target
&
t
)
...
...
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