Commit 225b12bb authored by Jaikrishnan Menon's avatar Jaikrishnan Menon

Merge branch 'master' into mem_leaks

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