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
41f9ec92
Unverified
Commit
41f9ec92
authored
Nov 21, 2017
by
Robert Kimball
Committed by
GitHub
Nov 21, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #260 from NervanaSystems/bob/bool
Bob/bool
parents
1f1e1bec
2503b3fd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
2 deletions
+29
-2
emitter.cpp
src/ngraph/runtime/cpu/emitter.cpp
+2
-2
backend_test.in.cpp
test/backend_test.in.cpp
+27
-0
No files found.
src/ngraph/runtime/cpu/emitter.cpp
View file @
41f9ec92
...
...
@@ -501,14 +501,14 @@ void Emitter::EmitParameterizedConstantBool(const ngraph::Node* n,
// Special case where constant is stored directly in the output
for
(
size_t
i
=
0
;
i
<
value
.
size
();
i
++
)
{
TU
<<
outputs
[
0
].
get_tensor
().
get_name
()
<<
"["
<<
i
<<
"] = static_cast<
bool
>("
TU
<<
outputs
[
0
].
get_tensor
().
get_name
()
<<
"["
<<
i
<<
"] = static_cast<
char
>("
<<
(
value
[
i
]
?
"true"
:
"false"
)
<<
");
\n
"
;
}
}
else
{
TU
<<
"// this should be const but eigen hates const :(
\n
"
;
TU
<<
"
bool
"
<<
outputs
[
0
].
get_tensor
().
get_name
()
<<
"[] = {
\n
"
;
TU
<<
"
char
"
<<
outputs
[
0
].
get_tensor
().
get_name
()
<<
"[] = {
\n
"
;
for
(
size_t
i
=
0
;
i
<
value
.
size
();
i
++
)
{
if
(
i
!=
0
)
...
...
test/backend_test.in.cpp
View file @
41f9ec92
...
...
@@ -2708,3 +2708,30 @@ TEST(${BACKEND_NAME}, sign)
(
*
cf
)({
a
},
{
result
});
ASSERT_EQ
((
vector
<
float
>
{
1
,
-
1
,
0
,
-
1
,
1
,
0
}),
result
->
get_vector
<
float
>
());
}
TEST
(
$
{
BACKEND_NAME
},
constant_equality_bool
)
{
auto
shape
=
Shape
{
4
};
// auto A = make_shared<op::Parameter>(element::Bool::element_type(), shape);
// auto B = make_shared<op::Parameter>(element::Bool::element_type(), shape);
// auto result_type = make_shared<TensorViewType>(element::Bool::element_type(), shape);
// auto f = make_shared<Function>(make_shared<op::Equal>(A, B), result_type, op::Parameters{A, B});
auto
a
=
runtime
::
make_tensor
<
element
::
Bool
>
(
shape
,
{
true
,
false
,
true
,
false
});
auto
A
=
make_shared
<
op
::
ParameterizedConstant
<
element
::
Bool
>>
(
shape
,
a
);
auto
b
=
runtime
::
make_tensor
<
element
::
Bool
>
(
shape
,
{
true
,
true
,
true
,
true
});
auto
B
=
make_shared
<
op
::
ParameterizedConstant
<
element
::
Bool
>>
(
shape
,
b
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Bool
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Equal
>
(
A
,
B
),
rt
,
op
::
Parameters
{});
auto
manager
=
runtime
::
Manager
::
get
(
"${BACKEND_NAME}"
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
// Create some tensors for input/output
auto
result
=
backend
->
make_primary_tensor_view
(
element
::
Bool
::
element_type
(),
shape
);
(
*
cf
)({},
{
result
});
ASSERT_EQ
((
vector
<
char
>
{
true
,
false
,
true
,
false
}),
result
->
get_vector
<
char
>
());
}
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