Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
N
ngraph
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ngraph
Commits
e69e6e9a
Commit
e69e6e9a
authored
Nov 21, 2017
by
Jaikrishnan Menon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CPU: Fix float32 literal emission
parent
293042a4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
2 deletions
+27
-2
emitter.cpp
src/ngraph/runtime/cpu/emitter.cpp
+26
-2
all_close.hpp
test/util/all_close.hpp
+1
-0
No files found.
src/ngraph/runtime/cpu/emitter.cpp
View file @
e69e6e9a
...
...
@@ -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
};"
;
}
...
...
test/util/all_close.hpp
View file @
e69e6e9a
...
...
@@ -14,6 +14,7 @@
#pragma once
#include <cmath>
#include <memory>
#include <vector>
...
...
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