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
3b184cb8
Commit
3b184cb8
authored
Sep 16, 2018
by
Paul
Browse files
Add reduction to verify
parent
f33c7a48
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
1 deletion
+31
-1
src/include/migraph/generate.hpp
src/include/migraph/generate.hpp
+1
-1
src/onnx/verify_onnx.cpp
src/onnx/verify_onnx.cpp
+30
-0
No files found.
src/include/migraph/generate.hpp
View file @
3b184cb8
...
@@ -12,7 +12,7 @@ constexpr T normalize(unsigned long z)
...
@@ -12,7 +12,7 @@ constexpr T normalize(unsigned long z)
{
{
if
(
z
==
0
)
if
(
z
==
0
)
return
0
;
return
0
;
const
auto
max
=
2
048
;
const
auto
max
=
3
2
;
const
double
range
=
max
/
2
;
// NOLINT
const
double
range
=
max
/
2
;
// NOLINT
double
result
=
(
z
%
max
)
/
range
;
double
result
=
(
z
%
max
)
/
range
;
result
-=
1
;
result
-=
1
;
...
...
src/onnx/verify_onnx.cpp
View file @
3b184cb8
...
@@ -93,6 +93,32 @@ void verify_instructions(const migraph::program& prog, double tolerance = 80)
...
@@ -93,6 +93,32 @@ void verify_instructions(const migraph::program& prog, double tolerance = 80)
}
}
}
}
template
<
class
F
>
void
verify_reduced
(
F
f
,
int
n
,
double
tolerance
=
80
)
{
auto
create_program
=
[
&
]
{
migraph
::
program
p
=
f
();
auto
last
=
std
::
prev
(
p
.
end
(),
n
+
1
);
p
.
remove_instructions
(
last
,
p
.
end
());
return
p
;
};
std
::
cout
<<
"Verify: "
<<
std
::
endl
;
std
::
cout
<<
create_program
()
<<
std
::
endl
;
verify_program
(
std
::
to_string
(
n
),
create_program
,
tolerance
);
}
template
<
class
F
>
void
verify_reduced_program
(
F
f
,
double
tolerance
=
80
)
{
migraph
::
program
p
=
f
();
auto
n
=
std
::
distance
(
p
.
begin
(),
p
.
end
());
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
verify_reduced
(
f
,
i
,
tolerance
);
}
}
int
main
(
int
argc
,
char
const
*
argv
[])
int
main
(
int
argc
,
char
const
*
argv
[])
{
{
std
::
vector
<
std
::
string
>
args
(
argv
+
1
,
argv
+
argc
);
std
::
vector
<
std
::
string
>
args
(
argv
+
1
,
argv
+
argc
);
...
@@ -106,6 +132,10 @@ int main(int argc, char const* argv[])
...
@@ -106,6 +132,10 @@ int main(int argc, char const* argv[])
{
{
verify_instructions
(
p
);
verify_instructions
(
p
);
}
}
else
if
(
std
::
any_of
(
args
.
begin
(),
args
.
end
(),
[](
const
auto
&
s
)
{
return
s
==
"-r"
;
}))
{
verify_reduced_program
([
&
]
{
return
migraph
::
parse_onnx
(
file
);
});
}
else
else
{
{
verify_program
(
file
,
[
&
]
{
return
migraph
::
parse_onnx
(
file
);
});
verify_program
(
file
,
[
&
]
{
return
migraph
::
parse_onnx
(
file
);
});
...
...
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