Unverified Commit be13ab7c authored by Robert Kimball's avatar Robert Kimball Committed by GitHub

Merge branch 'master' into bob/pch

parents c9ea4ca1 8ff5c586
......@@ -13,6 +13,7 @@
// ----------------------------------------------------------------------------
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <typeindex>
......@@ -521,6 +522,29 @@ void Emitter::EmitParameterizedConstantBool(const ngraph::Node* n,
TU << "\n";
}
static string format_float_as_string(float value)
{
if (isnan(value))
{
return "NAN";
}
else if (isinf(value))
{
if (value > 0)
{
return "INFINITY";
}
else
{
return "-INFINITY";
}
}
else
{
return to_string(value);
}
}
void Emitter::EmitParameterizedConstantFloat32(const ngraph::Node* n,
ExternalFunction* ef,
const std::vector<TensorViewInfo>& inputs,
......@@ -538,7 +562,7 @@ void Emitter::EmitParameterizedConstantFloat32(const ngraph::Node* n,
for (size_t i = 0; i < value.size(); i++)
{
TU << outputs[0].get_tensor().get_name() << "[" << i << "] = static_cast<" << type
<< ">(" << value[i] << ");\n";
<< ">(" << format_float_as_string(value[i]) << ");\n";
}
}
else
......@@ -551,7 +575,7 @@ void Emitter::EmitParameterizedConstantFloat32(const ngraph::Node* n,
{
TU << ",\n";
}
TU << " " << value[i];
TU << " " << format_float_as_string(value[i]);
}
TU << "\n};";
}
......
......@@ -14,6 +14,7 @@
#pragma once
#include <cmath>
#include <memory>
#include <vector>
......
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