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
21d4e6e3
Commit
21d4e6e3
authored
Nov 29, 2017
by
Adam Procter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
De-Eigenize select
parent
6d336670
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
12 deletions
+50
-12
select.hpp
src/ngraph/runtime/kernel/select.hpp
+33
-0
external_function.cpp
src/ngraph/runtime/ngvm/external_function.cpp
+2
-2
select.hpp
src/ngraph/runtime/ngvm/instruction/select.hpp
+15
-10
No files found.
src/ngraph/runtime/kernel/select.hpp
0 → 100644
View file @
21d4e6e3
// ----------------------------------------------------------------------------
// Copyright 2017 Nervana Systems Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#pragma once
namespace
ngraph
{
namespace
runtime
{
namespace
kernel
{
template
<
typename
T
>
void
select
(
char
*
arg0
,
T
*
arg1
,
T
*
arg2
,
T
*
out
,
size_t
count
)
// FIXME: temporararily char not bool
{
for
(
size_t
i
=
0
;
i
<
count
;
i
++
)
{
out
[
i
]
=
arg0
[
i
]
?
arg1
[
i
]
:
arg2
[
i
];
}
}
}
}
}
src/ngraph/runtime/ngvm/external_function.cpp
View file @
21d4e6e3
...
...
@@ -115,7 +115,7 @@
#include "ngraph/runtime/ngvm/eigen/replace_vector_slice.hpp"
#include "ngraph/runtime/ngvm/eigen/return.hpp"
#include "ngraph/runtime/ngvm/eigen/scalar_tensor_product.hpp"
#include "ngraph/runtime/ngvm/
eige
n/select.hpp"
#include "ngraph/runtime/ngvm/
instructio
n/select.hpp"
#include "ngraph/runtime/ngvm/instruction/sign.hpp"
#include "ngraph/runtime/ngvm/instruction/sin.hpp"
#include "ngraph/runtime/ngvm/instruction/sinh.hpp"
...
...
@@ -399,7 +399,7 @@ ExternalFunction::OpMap& ExternalFunction::get_op_map()
REGISTER_POLYMORPHIC_BINOP
(
op
::
Less
,
instruction
::
LessInstruction
);
REGISTER_POLYMORPHIC_BINOP
(
op
::
LessEq
,
instruction
::
LessEqInstruction
);
REGISTER_POLYMORPHIC_TERNOP
(
op
::
Select
,
eige
n
::
SelectInstruction
);
REGISTER_POLYMORPHIC_TERNOP
(
op
::
Select
,
instructio
n
::
SelectInstruction
);
REGISTER_CONSTANT_INSTRUCTIONS
(
element
::
Bool
);
REGISTER_CONSTANT_INSTRUCTIONS
(
element
::
Float32
);
...
...
src/ngraph/runtime/ngvm/
eige
n/select.hpp
→
src/ngraph/runtime/ngvm/
instructio
n/select.hpp
View file @
21d4e6e3
...
...
@@ -14,8 +14,9 @@
#pragma once
#include "ngraph/runtime/kernel/select.hpp"
#include "ngraph/runtime/ngvm/call_frame.hpp"
#include "ngraph/runtime/ngvm/
eigen/
utils.hpp"
#include "ngraph/runtime/ngvm/utils.hpp"
#include "ngraph/runtime/ngvm/instruction.hpp"
#include "ngraph/runtime/tensor_view.hpp"
...
...
@@ -25,16 +26,16 @@ namespace ngraph
{
namespace
ngvm
{
namespace
eige
n
namespace
instructio
n
{
template
<
typename
ET
>
class
SelectInstruction
:
public
Instruction
{
public
:
SelectInstruction
(
TensorViewInfo
arg0
,
TensorViewInfo
arg1
,
TensorViewInfo
arg2
,
TensorViewInfo
out
)
SelectInstruction
(
const
TensorViewInfo
&
arg0
,
const
TensorViewInfo
&
arg1
,
const
TensorViewInfo
&
arg2
,
const
TensorViewInfo
&
out
)
:
m_arg0
(
arg0
)
,
m_arg1
(
arg1
)
,
m_arg2
(
arg2
)
...
...
@@ -44,10 +45,14 @@ namespace ngraph
virtual
void
execute
(
CallFrame
&
call_frame
)
const
override
{
EigenArray1d
<
ET
>
(
call_frame
,
m_out
)
=
EigenArray1d
<
element
::
Bool
>
(
call_frame
,
m_arg0
)
.
select
(
EigenArray1d
<
ET
>
(
call_frame
,
m_arg1
),
EigenArray1d
<
ET
>
(
call_frame
,
m_arg2
));
char
*
arg0
=
get_tensor_data_ptr
<
element
::
Bool
>
(
call_frame
,
m_arg0
);
// FIXME: temporarily char not bool
typename
ET
::
type
*
arg1
=
get_tensor_data_ptr
<
ET
>
(
call_frame
,
m_arg1
);
typename
ET
::
type
*
arg2
=
get_tensor_data_ptr
<
ET
>
(
call_frame
,
m_arg2
);
typename
ET
::
type
*
out
=
get_tensor_data_ptr
<
ET
>
(
call_frame
,
m_out
);
size_t
count
=
get_tensor_element_count
(
call_frame
,
m_arg0
);
kernel
::
select
<
typename
ET
::
type
>
(
arg0
,
arg1
,
arg2
,
out
,
count
);
}
protected
:
...
...
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