"...resnet50_tensorflow.git" did not exist on "e0d33132313c612eeae15add067a288eb3182d56"
Commit 3b184cb8 authored by Paul's avatar Paul
Browse files

Add reduction to verify

parent f33c7a48
...@@ -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 = 2048; const auto max = 32;
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;
......
...@@ -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); });
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment