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
f6e536cd
Commit
f6e536cd
authored
Sep 28, 2017
by
Scott Cyphers
Committed by
Adam Procter
Sep 28, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up some names. (#149)
parent
3ad5140c
Hide whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
149 additions
and
126 deletions
+149
-126
tensor_view.hpp
src/ngraph/descriptor/tensor_view.hpp
+2
-0
call_frame.cpp
src/ngraph/runtime/call_frame.cpp
+14
-12
call_frame.hpp
src/ngraph/runtime/call_frame.hpp
+6
-8
abs.hpp
src/ngraph/runtime/eigen/abs.hpp
+3
-3
add.hpp
src/ngraph/runtime/eigen/add.hpp
+4
-4
concat_matrix.hpp
src/ngraph/runtime/eigen/concat_matrix.hpp
+2
-2
concat_vector.hpp
src/ngraph/runtime/eigen/concat_vector.hpp
+2
-2
constant.hpp
src/ngraph/runtime/eigen/constant.hpp
+1
-1
copy.hpp
src/ngraph/runtime/eigen/copy.hpp
+2
-2
divide.hpp
src/ngraph/runtime/eigen/divide.hpp
+4
-4
dot.hpp
src/ngraph/runtime/eigen/dot.hpp
+3
-3
equal.hpp
src/ngraph/runtime/eigen/equal.hpp
+5
-5
less_than.hpp
src/ngraph/runtime/eigen/less_than.hpp
+5
-5
log.hpp
src/ngraph/runtime/eigen/log.hpp
+3
-3
matrix_mult.hpp
src/ngraph/runtime/eigen/matrix_mult.hpp
+3
-3
matrix_vector_product.hpp
src/ngraph/runtime/eigen/matrix_vector_product.hpp
+3
-3
maximum.hpp
src/ngraph/runtime/eigen/maximum.hpp
+4
-4
multiply.hpp
src/ngraph/runtime/eigen/multiply.hpp
+4
-4
negate.hpp
src/ngraph/runtime/eigen/negate.hpp
+3
-3
not_equal.hpp
src/ngraph/runtime/eigen/not_equal.hpp
+5
-5
scalar_tensor_product.hpp
src/ngraph/runtime/eigen/scalar_tensor_product.hpp
+3
-3
select.hpp
src/ngraph/runtime/eigen/select.hpp
+5
-5
subtract.hpp
src/ngraph/runtime/eigen/subtract.hpp
+4
-4
utils.hpp
src/ngraph/runtime/eigen/utils.hpp
+8
-8
external_function.cpp
src/ngraph/runtime/external_function.cpp
+12
-20
external_function.hpp
src/ngraph/runtime/external_function.hpp
+10
-9
tensor_view.hpp
src/ngraph/runtime/tensor_view.hpp
+3
-1
tensor_view_index.hpp
src/ngraph/runtime/tensor_view_index.hpp
+26
-0
No files found.
src/ngraph/descriptor/tensor_view.hpp
View file @
f6e536cd
...
...
@@ -85,5 +85,7 @@ namespace ngraph
std
::
shared_ptr
<
layout
::
TensorViewLayout
>
m_tensor_view_layout
;
std
::
string
m_name
;
};
using
TensorViewPtrs
=
std
::
vector
<
std
::
shared_ptr
<
TensorView
>>
;
}
}
src/ngraph/runtime/call_frame.cpp
View file @
f6e536cd
...
...
@@ -20,27 +20,27 @@ using namespace std;
using
namespace
ngraph
;
using
namespace
ngraph
::
runtime
;
CallFrame
::
CallFrame
(
size_t
n_inputs
,
size_t
n_outputs
,
const
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
runtime
::
TensorView
>>&
temps
,
size_t
initial_pc
,
const
shared_ptr
<
vector
<
shared_ptr
<
Instruction
>>>&
instructions
)
CallFrame
::
CallFrame
(
size_t
n_inputs
,
size_t
n_outputs
,
const
TensorViewPtrs
&
temps
,
size_t
initial_pc
,
const
shared_ptr
<
vector
<
shared_ptr
<
Instruction
>>>&
instructions
)
:
m_n_inputs
(
n_inputs
)
,
m_n_outputs
(
n_outputs
)
,
m_tensors
(
n_inputs
+
n_outputs
+
temps
.
size
())
,
m_tensor
_view
s
(
n_inputs
+
n_outputs
+
temps
.
size
())
,
m_initial_pc
(
initial_pc
)
,
m_instructions
(
instructions
)
{
copy
(
temps
.
begin
(),
temps
.
end
(),
m_tensors
.
begin
()
+
m_n_inputs
+
m_n_outputs
);
copy
(
temps
.
begin
(),
temps
.
end
(),
m_tensor
_view
s
.
begin
()
+
m_n_inputs
+
m_n_outputs
);
}
void
CallFrame
::
tensor_call
(
const
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
runtime
::
TensorView
>>&
inputs
,
const
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
runtime
::
TensorView
>>&
outputs
)
{
copy
(
inputs
.
begin
(),
inputs
.
end
(),
m_tensors
.
begin
());
copy
(
outputs
.
begin
(),
outputs
.
end
(),
m_tensors
.
begin
()
+
m_n_inputs
);
copy
(
inputs
.
begin
(),
inputs
.
end
(),
m_tensor
_view
s
.
begin
());
copy
(
outputs
.
begin
(),
outputs
.
end
(),
m_tensor
_view
s
.
begin
()
+
m_n_inputs
);
m_next_pc
=
m_initial_pc
;
m_return
=
false
;
while
(
!
m_return
)
...
...
@@ -50,7 +50,7 @@ void CallFrame::tensor_call(
m_instructions
->
at
(
m_pc
)
->
execute
(
*
this
);
}
// Don't hold onto inputs/outputs
fill_n
(
m_tensors
.
begin
(),
m_n_inputs
+
m_n_outputs
,
nullptr
);
fill_n
(
m_tensor
_view
s
.
begin
(),
m_n_inputs
+
m_n_outputs
,
nullptr
);
}
void
CallFrame
::
operator
()(
const
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
runtime
::
Value
>>&
arguments
,
...
...
@@ -58,12 +58,14 @@ void CallFrame::operator()(const std::vector<std::shared_ptr<ngraph::runtime::Va
{
// TODO: Check types of args and result
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
runtime
::
TensorView
>>
inputs
;
for
(
auto
argument
:
arguments
){
for
(
auto
argument
:
arguments
)
{
argument
->
collect_tensor_views
(
inputs
,
argument
);
}
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
runtime
::
TensorView
>>
outputs
;
for
(
auto
result
:
results
){
for
(
auto
result
:
results
)
{
result
->
collect_tensor_views
(
outputs
,
result
);
}
...
...
src/ngraph/runtime/call_frame.hpp
View file @
f6e536cd
...
...
@@ -34,7 +34,7 @@ namespace ngraph
CallFrame
(
size_t
n_inputs
,
size_t
n_outputs
,
const
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
runtime
::
TensorView
>>&
temps
,
const
TensorViewPtrs
&
temps
,
size_t
initial_pc
,
const
std
::
shared_ptr
<
std
::
vector
<
std
::
shared_ptr
<
Instruction
>>>&
instructions
);
...
...
@@ -45,24 +45,22 @@ namespace ngraph
const
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
runtime
::
Value
>>&
outpus
);
/// @brief Invoke the function with tuples pre-expanded to their underlying tensor views.
void
tensor_call
(
const
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
runtime
::
TensorView
>>&
inputs
,
const
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
runtime
::
TensorView
>>&
outpus
);
void
tensor_call
(
const
TensorViewPtrs
&
inputs
,
const
TensorViewPtrs
&
outpus
);
void
set_return
()
{
m_return
=
true
;
}
std
::
shared_ptr
<
TensorView
>
get_tensor
(
size_t
i
)
{
return
m_tensor
s
[
i
];
}
std
::
shared_ptr
<
TensorView
>
get_tensor
_view
(
size_t
i
)
{
return
m_tensor_view
s
[
i
];
}
template
<
typename
ET
>
ParameterizedTensorView
<
ET
>*
get_parameterized_tensor
(
size_t
i
)
ParameterizedTensorView
<
ET
>*
get_parameterized_tensor
_view
(
size_t
i
)
{
return
m_tensor
s
[
i
]
->
get_parameterized_tensor
<
ET
>
();
return
m_tensor
_views
[
i
]
->
get_parameterized_tensor_view
<
ET
>
();
}
protected
:
size_t
m_n_inputs
;
size_t
m_n_outputs
;
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
runtime
::
TensorView
>>
m_tensor
s
;
TensorViewPtrs
m_tensor_view
s
;
size_t
m_initial_pc
;
std
::
shared_ptr
<
std
::
vector
<
std
::
shared_ptr
<
Instruction
>>>
m_instructions
;
size_t
m_pc
;
...
...
src/ngraph/runtime/eigen/abs.hpp
View file @
f6e536cd
...
...
@@ -28,7 +28,7 @@ namespace ngraph
template
<
typename
T
>
void
abs
(
T
arg
,
T
out
)
{
set_map
(
&*
out
,
Eigen
::
abs
(
get_map
(
&*
arg
)));
set_map
_array
(
&*
out
,
Eigen
::
abs
(
get_map_array
(
&*
arg
)));
}
template
<
typename
ET
>
...
...
@@ -44,8 +44,8 @@ namespace ngraph
virtual
void
execute
(
CallFrame
&
call_frame
)
const
override
{
runtime
::
eigen
::
abs
(
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_arg
),
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_out
));
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_arg
),
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_out
));
}
protected
:
...
...
src/ngraph/runtime/eigen/add.hpp
View file @
f6e536cd
...
...
@@ -28,7 +28,7 @@ namespace ngraph
template
<
typename
T
>
void
add
(
T
arg0
,
T
arg1
,
T
out
)
{
set_map
(
&*
out
,
get_map
(
&*
arg0
)
+
get_map
(
&*
arg1
));
set_map
_array
(
&*
out
,
get_map_array
(
&*
arg0
)
+
get_map_array
(
&*
arg1
));
}
template
<
typename
ET
>
...
...
@@ -45,9 +45,9 @@ namespace ngraph
virtual
void
execute
(
CallFrame
&
call_frame
)
const
override
{
runtime
::
eigen
::
add
(
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_arg0
),
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_arg1
),
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_out
));
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_arg0
),
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_arg1
),
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_out
));
}
protected
:
...
...
src/ngraph/runtime/eigen/concat_matrix.hpp
View file @
f6e536cd
...
...
@@ -76,11 +76,11 @@ namespace ngraph
std
::
vector
<
ParameterizedTensorView
<
ET
>*>
ptvs
;
for
(
size_t
arg
:
m_args
)
{
ptvs
.
push_back
(
call_frame
.
get_parameterized_tensor
<
ET
>
(
arg
));
ptvs
.
push_back
(
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
arg
));
}
runtime
::
eigen
::
concat_matrix
(
ptvs
,
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_out
),
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_out
),
m_axis
);
}
...
...
src/ngraph/runtime/eigen/concat_vector.hpp
View file @
f6e536cd
...
...
@@ -64,11 +64,11 @@ namespace ngraph
std
::
vector
<
ParameterizedTensorView
<
ET
>*>
ptvs
;
for
(
size_t
arg
:
m_args
)
{
ptvs
.
push_back
(
call_frame
.
get_parameterized_tensor
<
ET
>
(
arg
));
ptvs
.
push_back
(
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
arg
));
}
runtime
::
eigen
::
concat_vector
(
ptvs
,
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_out
));
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_out
));
}
protected
:
...
...
src/ngraph/runtime/eigen/constant.hpp
View file @
f6e536cd
...
...
@@ -45,7 +45,7 @@ namespace ngraph
{
runtime
::
eigen
::
assign_constant
(
m_value
,
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_out
));
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_out
));
}
protected
:
...
...
src/ngraph/runtime/eigen/copy.hpp
View file @
f6e536cd
...
...
@@ -42,8 +42,8 @@ namespace ngraph
virtual
void
execute
(
CallFrame
&
call_frame
)
const
override
{
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_out
)
->
get_vector
()
=
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_in
)
->
get_vector
();
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_out
)
->
get_vector
()
=
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_in
)
->
get_vector
();
}
protected
:
...
...
src/ngraph/runtime/eigen/divide.hpp
View file @
f6e536cd
...
...
@@ -28,7 +28,7 @@ namespace ngraph
template
<
typename
T
>
void
divide
(
T
arg0
,
T
arg1
,
T
out
)
{
set_map
(
&*
out
,
get_map
(
&*
arg0
)
/
get_map
(
&*
arg1
));
set_map
_array
(
&*
out
,
get_map_array
(
&*
arg0
)
/
get_map_array
(
&*
arg1
));
}
template
<
typename
ET
>
...
...
@@ -45,9 +45,9 @@ namespace ngraph
virtual
void
execute
(
CallFrame
&
call_frame
)
const
override
{
runtime
::
eigen
::
divide
(
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_arg0
),
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_arg1
),
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_out
));
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_arg0
),
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_arg1
),
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_out
));
}
protected
:
...
...
src/ngraph/runtime/eigen/dot.hpp
View file @
f6e536cd
...
...
@@ -45,9 +45,9 @@ namespace ngraph
virtual
void
execute
(
CallFrame
&
call_frame
)
const
override
{
runtime
::
eigen
::
dot
(
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_arg0
),
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_arg1
),
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_out
));
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_arg0
),
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_arg1
),
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_out
));
}
protected
:
...
...
src/ngraph/runtime/eigen/equal.hpp
View file @
f6e536cd
...
...
@@ -28,9 +28,9 @@ namespace ngraph
template
<
typename
TI
,
typename
TO
>
void
equal
(
TI
arg0
,
TI
arg1
,
TO
out
)
{
auto
result_as_float
=
get_map
(
&*
arg0
)
==
get_map
(
&*
arg1
);
auto
result_as_float
=
get_map
_array
(
&*
arg0
)
==
get_map_array
(
&*
arg1
);
auto
result_as_char
=
result_as_float
.
template
cast
<
char
>
();
set_map
(
&*
out
,
result_as_char
);
set_map
_array
(
&*
out
,
result_as_char
);
}
template
<
typename
ET
>
...
...
@@ -47,9 +47,9 @@ namespace ngraph
virtual
void
execute
(
CallFrame
&
call_frame
)
const
override
{
runtime
::
eigen
::
equal
(
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_arg0
),
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_arg1
),
call_frame
.
get_parameterized_tensor
<
element
::
Bool
>
(
m_out
));
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_arg0
),
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_arg1
),
call_frame
.
get_parameterized_tensor
_view
<
element
::
Bool
>
(
m_out
));
}
protected
:
...
...
src/ngraph/runtime/eigen/less_than.hpp
View file @
f6e536cd
...
...
@@ -28,9 +28,9 @@ namespace ngraph
template
<
typename
TI
,
typename
TO
>
void
less_than
(
TI
arg0
,
TI
arg1
,
TO
out
)
{
auto
result_as_float
=
get_map
(
&*
arg0
)
<
get_map
(
&*
arg1
);
auto
result_as_float
=
get_map
_array
(
&*
arg0
)
<
get_map_array
(
&*
arg1
);
auto
result_as_char
=
result_as_float
.
template
cast
<
char
>
();
set_map
(
&*
out
,
result_as_char
);
set_map
_array
(
&*
out
,
result_as_char
);
}
template
<
typename
ET
>
...
...
@@ -47,9 +47,9 @@ namespace ngraph
virtual
void
execute
(
CallFrame
&
call_frame
)
const
override
{
runtime
::
eigen
::
less_than
(
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_arg0
),
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_arg1
),
call_frame
.
get_parameterized_tensor
<
element
::
Bool
>
(
m_out
));
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_arg0
),
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_arg1
),
call_frame
.
get_parameterized_tensor
_view
<
element
::
Bool
>
(
m_out
));
}
protected
:
...
...
src/ngraph/runtime/eigen/log.hpp
View file @
f6e536cd
...
...
@@ -28,7 +28,7 @@ namespace ngraph
template
<
typename
T
>
void
log
(
T
arg
,
T
out
)
{
set_map
(
&*
out
,
Eigen
::
log
(
get_map
(
&*
arg
)));
set_map
_array
(
&*
out
,
Eigen
::
log
(
get_map_array
(
&*
arg
)));
}
template
<
typename
ET
>
...
...
@@ -44,8 +44,8 @@ namespace ngraph
virtual
void
execute
(
CallFrame
&
call_frame
)
const
override
{
runtime
::
eigen
::
log
(
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_arg
),
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_out
));
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_arg
),
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_out
));
}
protected
:
...
...
src/ngraph/runtime/eigen/matrix_mult.hpp
View file @
f6e536cd
...
...
@@ -45,9 +45,9 @@ namespace ngraph
virtual
void
execute
(
CallFrame
&
call_frame
)
const
override
{
runtime
::
eigen
::
matrix_mult
(
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_arg0
),
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_arg1
),
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_out
));
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_arg0
),
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_arg1
),
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_out
));
}
protected
:
...
...
src/ngraph/runtime/eigen/matrix_vector_product.hpp
View file @
f6e536cd
...
...
@@ -45,9 +45,9 @@ namespace ngraph
virtual
void
execute
(
CallFrame
&
call_frame
)
const
override
{
runtime
::
eigen
::
matrix_vector_product
(
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_arg0
),
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_arg1
),
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_out
));
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_arg0
),
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_arg1
),
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_out
));
}
protected
:
...
...
src/ngraph/runtime/eigen/maximum.hpp
View file @
f6e536cd
...
...
@@ -28,7 +28,7 @@ namespace ngraph
template
<
typename
T
>
void
maximum
(
T
arg0
,
T
arg1
,
T
out
)
{
set_map
(
out
,
get_map
(
&*
arg0
).
max
(
get_map
(
&*
arg1
)));
set_map
_array
(
out
,
get_map_array
(
&*
arg0
).
max
(
get_map_array
(
&*
arg1
)));
}
template
<
typename
ET
>
...
...
@@ -45,9 +45,9 @@ namespace ngraph
virtual
void
execute
(
CallFrame
&
call_frame
)
const
override
{
runtime
::
eigen
::
maximum
(
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_arg0
),
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_arg1
),
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_out
));
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_arg0
),
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_arg1
),
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_out
));
}
protected
:
...
...
src/ngraph/runtime/eigen/multiply.hpp
View file @
f6e536cd
...
...
@@ -27,7 +27,7 @@ namespace ngraph
template
<
typename
T
>
void
multiply
(
T
arg0
,
T
arg1
,
T
out
)
{
set_map
(
&*
out
,
get_map
(
&*
arg0
)
*
get_map
(
&*
arg1
));
set_map
_array
(
&*
out
,
get_map_array
(
&*
arg0
)
*
get_map_array
(
&*
arg1
));
}
template
<
typename
ET
>
...
...
@@ -44,9 +44,9 @@ namespace ngraph
virtual
void
execute
(
CallFrame
&
call_frame
)
const
override
{
runtime
::
eigen
::
multiply
(
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_arg0
),
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_arg1
),
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_out
));
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_arg0
),
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_arg1
),
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_out
));
}
protected
:
...
...
src/ngraph/runtime/eigen/negate.hpp
View file @
f6e536cd
...
...
@@ -28,7 +28,7 @@ namespace ngraph
template
<
typename
T
>
void
negate
(
T
arg
,
T
out
)
{
set_map
(
&*
out
,
-
(
get_map
(
&*
arg
)));
set_map
_array
(
&*
out
,
-
(
get_map_array
(
&*
arg
)));
}
template
<
typename
ET
>
...
...
@@ -44,8 +44,8 @@ namespace ngraph
virtual
void
execute
(
CallFrame
&
call_frame
)
const
override
{
runtime
::
eigen
::
negate
(
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_arg
),
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_out
));
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_arg
),
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_out
));
}
protected
:
...
...
src/ngraph/runtime/eigen/not_equal.hpp
View file @
f6e536cd
...
...
@@ -28,9 +28,9 @@ namespace ngraph
template
<
typename
TI
,
typename
TO
>
void
not_equal
(
TI
arg0
,
TI
arg1
,
TO
out
)
{
auto
result_as_float
=
get_map
(
&*
arg0
)
!=
get_map
(
&*
arg1
);
auto
result_as_float
=
get_map
_array
(
&*
arg0
)
!=
get_map_array
(
&*
arg1
);
auto
result_as_char
=
result_as_float
.
template
cast
<
char
>
();
set_map
(
&*
out
,
result_as_char
);
set_map
_array
(
&*
out
,
result_as_char
);
}
template
<
typename
ET
>
...
...
@@ -47,9 +47,9 @@ namespace ngraph
virtual
void
execute
(
CallFrame
&
call_frame
)
const
override
{
runtime
::
eigen
::
not_equal
(
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_arg0
),
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_arg1
),
call_frame
.
get_parameterized_tensor
<
element
::
Bool
>
(
m_out
));
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_arg0
),
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_arg1
),
call_frame
.
get_parameterized_tensor
_view
<
element
::
Bool
>
(
m_out
));
}
protected
:
...
...
src/ngraph/runtime/eigen/scalar_tensor_product.hpp
View file @
f6e536cd
...
...
@@ -45,9 +45,9 @@ namespace ngraph
virtual
void
execute
(
CallFrame
&
call_frame
)
const
override
{
runtime
::
eigen
::
scalar_tensor_product
(
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_arg0
),
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_arg1
),
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_out
));
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_arg0
),
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_arg1
),
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_out
));
}
protected
:
...
...
src/ngraph/runtime/eigen/select.hpp
View file @
f6e536cd
...
...
@@ -28,7 +28,7 @@ namespace ngraph
template
<
typename
TA
,
typename
TB
>
void
select
(
TA
arg0
,
TB
arg1
,
TB
arg2
,
TB
out
)
{
set_map
(
&*
out
,
get_map
(
&*
arg0
).
select
(
get_map
(
&*
arg1
),
get_map
(
&*
arg2
)));
set_map
_array
(
&*
out
,
get_map_array
(
&*
arg0
).
select
(
get_map_array
(
&*
arg1
),
get_map_array
(
&*
arg2
)));
}
template
<
typename
ET
>
...
...
@@ -46,10 +46,10 @@ namespace ngraph
virtual
void
execute
(
CallFrame
&
call_frame
)
const
override
{
runtime
::
eigen
::
select
(
call_frame
.
get_parameterized_tensor
<
element
::
Bool
>
(
m_arg0
),
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_arg1
),
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_arg2
),
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_out
));
call_frame
.
get_parameterized_tensor
_view
<
element
::
Bool
>
(
m_arg0
),
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_arg1
),
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_arg2
),
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_out
));
}
protected
:
...
...
src/ngraph/runtime/eigen/subtract.hpp
View file @
f6e536cd
...
...
@@ -28,7 +28,7 @@ namespace ngraph
template
<
typename
T
>
void
subtract
(
T
arg0
,
T
arg1
,
T
out
)
{
set_map
(
&*
out
,
get_map
(
&*
arg0
)
-
get_map
(
&*
arg1
));
set_map
_array
(
&*
out
,
get_map_array
(
&*
arg0
)
-
get_map_array
(
&*
arg1
));
}
template
<
typename
ET
>
...
...
@@ -45,9 +45,9 @@ namespace ngraph
virtual
void
execute
(
CallFrame
&
call_frame
)
const
override
{
runtime
::
eigen
::
subtract
(
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_arg0
),
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_arg1
),
call_frame
.
get_parameterized_tensor
<
ET
>
(
m_out
));
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_arg0
),
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_arg1
),
call_frame
.
get_parameterized_tensor
_view
<
ET
>
(
m_out
));
}
protected
:
...
...
src/ngraph/runtime/eigen/utils.hpp
View file @
f6e536cd
...
...
@@ -25,7 +25,7 @@ namespace ngraph
namespace
eigen
{
template
<
typename
T
,
typename
U
>
void
set_map
(
std
::
shared_ptr
<
T
>&
t
,
const
U
&
u
)
void
set_map
_array
(
std
::
shared_ptr
<
T
>&
t
,
const
U
&
u
)
{
auto
&
v
=
t
->
get_vector
();
Eigen
::
Map
<
Eigen
::
Array
<
typename
T
::
value_type
,
Eigen
::
Dynamic
,
1
>>
(
...
...
@@ -33,7 +33,7 @@ namespace ngraph
}
template
<
typename
T
,
typename
U
>
void
set_map
(
T
*
t
,
const
U
&
u
)
void
set_map
_array
(
T
*
t
,
const
U
&
u
)
{
auto
&
v
=
t
->
get_vector
();
Eigen
::
Map
<
Eigen
::
Array
<
typename
T
::
value_type
,
Eigen
::
Dynamic
,
1
>>
(
...
...
@@ -57,7 +57,7 @@ namespace ngraph
}
template
<
typename
T
,
typename
U
>
void
set_map_2d
(
std
::
shared_ptr
<
T
>&
t
,
const
U
&
u
)
void
set_map_
array_
2d
(
std
::
shared_ptr
<
T
>&
t
,
const
U
&
u
)
{
auto
&
v
=
t
->
get_vector
();
auto
&
s
=
t
->
get_shape
();
...
...
@@ -69,7 +69,7 @@ namespace ngraph
}
template
<
typename
T
,
typename
U
>
void
set_map_2d
(
T
*
t
,
const
U
&
u
)
void
set_map_
array_
2d
(
T
*
t
,
const
U
&
u
)
{
auto
&
v
=
t
->
get_vector
();
auto
&
s
=
t
->
get_shape
();
...
...
@@ -106,7 +106,7 @@ namespace ngraph
template
<
typename
T
>
Eigen
::
Map
<
Eigen
::
Array
<
typename
T
::
value_type
,
Eigen
::
Dynamic
,
1
>>
get_map
(
std
::
shared_ptr
<
T
>&
arg
)
get_map
_array
(
std
::
shared_ptr
<
T
>&
arg
)
{
auto
&
v
=
arg
->
get_vector
();
return
Eigen
::
Map
<
Eigen
::
Array
<
typename
T
::
value_type
,
Eigen
::
Dynamic
,
1
>>
(
...
...
@@ -114,7 +114,7 @@ namespace ngraph
}
template
<
typename
T
>
Eigen
::
Map
<
Eigen
::
Array
<
typename
T
::
value_type
,
Eigen
::
Dynamic
,
1
>>
get_map
(
T
*
arg
)
Eigen
::
Map
<
Eigen
::
Array
<
typename
T
::
value_type
,
Eigen
::
Dynamic
,
1
>>
get_map
_array
(
T
*
arg
)
{
auto
&
v
=
arg
->
get_vector
();
return
Eigen
::
Map
<
Eigen
::
Array
<
typename
T
::
value_type
,
Eigen
::
Dynamic
,
1
>>
(
...
...
@@ -140,7 +140,7 @@ namespace ngraph
template
<
typename
T
>
Eigen
::
Map
<
Eigen
::
Array
<
typename
T
::
value_type
,
Eigen
::
Dynamic
,
Eigen
::
Dynamic
,
Eigen
::
RowMajor
>>
get_map_2d
(
std
::
shared_ptr
<
T
>&
arg
)
get_map_
array_
2d
(
std
::
shared_ptr
<
T
>&
arg
)
{
auto
&
v
=
arg
->
get_vector
();
auto
&
s
=
arg
->
get_shape
();
...
...
@@ -152,7 +152,7 @@ namespace ngraph
}
template
<
typename
T
>
Eigen
::
Map
<
Eigen
::
Array
<
typename
T
::
value_type
,
Eigen
::
Dynamic
,
Eigen
::
Dynamic
,
Eigen
::
RowMajor
>>
get_map_2d
(
T
*
arg
)
Eigen
::
Map
<
Eigen
::
Array
<
typename
T
::
value_type
,
Eigen
::
Dynamic
,
Eigen
::
Dynamic
,
Eigen
::
RowMajor
>>
get_map_
array_
2d
(
T
*
arg
)
{
auto
&
v
=
arg
->
get_vector
();
auto
&
s
=
arg
->
get_shape
();
...
...
src/ngraph/runtime/external_function.cpp
View file @
f6e536cd
...
...
@@ -45,10 +45,10 @@
#include "ngraph/pass/topological_sort.hpp"
#include "ngraph/runtime/eigen/abs.hpp"
#include "ngraph/runtime/eigen/add.hpp"
#include "ngraph/runtime/eigen/copy.hpp"
#include "ngraph/runtime/eigen/concat_matrix.hpp"
#include "ngraph/runtime/eigen/concat_vector.hpp"
#include "ngraph/runtime/eigen/constant.hpp"
#include "ngraph/runtime/eigen/copy.hpp"
#include "ngraph/runtime/eigen/divide.hpp"
#include "ngraph/runtime/eigen/dot.hpp"
#include "ngraph/runtime/eigen/equal.hpp"
...
...
@@ -67,7 +67,7 @@
#include "ngraph/runtime/external_function.hpp"
#include "ngraph/runtime/utils.hpp"
using
namespace
std
;
using
namespace
std
;
using
namespace
ngraph
::
runtime
;
ExternalFunction
::
ExternalFunction
(
const
std
::
shared_ptr
<
ngraph
::
Function
>&
function
,
...
...
@@ -95,20 +95,10 @@ ExternalFunction::ExternalFunction(const std::shared_ptr<ngraph::Function>& func
REGISTER_INSTRUCTION(op_class, instr_class, in[0], in[1], in[2], out[0])
// Define code generators for handled ops.
std
::
unordered_map
<
std
::
type_index
,
std
::
function
<
void
(
const
ngraph
::
Node
*
,
ExternalFunction
*
,
const
std
::
vector
<
size_t
>&
inputs
,
const
std
::
vector
<
size_t
>&
outputs
)
>>&
ExternalFunction
::
get_op_map
()
ExternalFunction
::
OpMap
&
ExternalFunction
::
get_op_map
()
{
static
bool
initialized
=
false
;
static
std
::
unordered_map
<
std
::
type_index
,
std
::
function
<
void
(
const
Node
*
,
ExternalFunction
*
,
const
std
::
vector
<
size_t
>&
inputs
,
const
std
::
vector
<
size_t
>&
outputs
)
>>
op_map
;
static
OpMap
op_map
;
if
(
!
initialized
)
{
REGISTER_UNOP
(
op
::
Abs
,
runtime
::
eigen
::
AbsInstruction
<
element
::
Float32
>
);
...
...
@@ -142,7 +132,7 @@ std::unordered_map<std::type_index,
const
std
::
vector
<
size_t
>&
in
,
const
std
::
vector
<
size_t
>&
out
)
{
auto
result_tensor_type
=
dynamic_pointer_cast
<
const
TensorViewType
>
(
n
->
get_value_type
());
dynamic_pointer_cast
<
const
TensorViewType
>
(
n
->
get_value_type
());
assert
(
nullptr
!=
result_tensor_type
);
auto
result_shape
=
result_tensor_type
->
get_shape
();
...
...
@@ -150,14 +140,16 @@ std::unordered_map<std::type_index,
if
(
result_shape
.
size
()
==
1
)
{
ef
->
get_instructions
()
->
push_back
(
make_shared
<
runtime
::
eigen
::
ConcatVectorInstruction
<
element
::
Float32
>>
(
in
,
out
[
0
]));
make_shared
<
runtime
::
eigen
::
ConcatVectorInstruction
<
element
::
Float32
>>
(
in
,
out
[
0
]));
}
else
if
(
result_shape
.
size
()
==
2
)
else
if
(
result_shape
.
size
()
==
2
)
{
ef
->
get_instructions
()
->
push_back
(
make_shared
<
runtime
::
eigen
::
ConcatMatrixInstruction
<
element
::
Float32
>>
(
in
,
(
dynamic_cast
<
const
op
::
Concat
*>
(
n
))
->
get_concatenation_axis
(),
out
[
0
]));
in
,
(
dynamic_cast
<
const
op
::
Concat
*>
(
n
))
->
get_concatenation_axis
(),
out
[
0
]));
}
else
{
...
...
@@ -330,7 +322,7 @@ void ExternalFunction::compile()
for
(
const
descriptor
::
Input
&
input
:
node
->
get_inputs
())
{
const
descriptor
::
Output
&
output
=
input
.
get_output
();
auto
tv
=
output
.
get_tensor_view
();
auto
tv
=
output
.
get_tensor_view
();
in
.
push_back
(
tensor_index
.
at
(
tv
));
}
std
::
vector
<
size_t
>
out
;
...
...
src/ngraph/runtime/external_function.hpp
View file @
f6e536cd
...
...
@@ -27,6 +27,12 @@ namespace ngraph
{
class
ExternalFunction
{
using
OpFunction
=
std
::
function
<
void
(
const
ngraph
::
Node
*
,
ExternalFunction
*
,
const
std
::
vector
<
size_t
>&
inputs
,
const
std
::
vector
<
size_t
>&
outputs
)
>
;
using
OpMap
=
std
::
unordered_map
<
std
::
type_index
,
OpFunction
>
;
public
:
ExternalFunction
(
const
std
::
shared_ptr
<
ngraph
::
Function
>&
function
,
bool
release_function
=
true
);
...
...
@@ -49,15 +55,10 @@ namespace ngraph
size_t
m_n_inputs
;
size_t
m_n_outputs
;
std
::
shared_ptr
<
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
runtime
::
Instruction
>>>
m_instructions
;
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
descriptor
::
TensorView
>>
m_temp_views
;
static
std
::
unordered_map
<
std
::
type_index
,
std
::
function
<
void
(
const
ngraph
::
Node
*
,
ExternalFunction
*
,
const
std
::
vector
<
size_t
>&
inputs
,
const
std
::
vector
<
size_t
>&
outputs
)
>>&
get_op_map
();
m_instructions
;
ngraph
::
descriptor
::
TensorViewPtrs
m_temp_views
;
static
OpMap
&
get_op_map
();
};
}
}
src/ngraph/runtime/tensor_view.hpp
View file @
f6e536cd
...
...
@@ -43,7 +43,7 @@ namespace ngraph
virtual
~
TensorView
()
{}
template
<
typename
ET
>
ParameterizedTensorView
<
ET
>*
get_parameterized_tensor
()
ParameterizedTensorView
<
ET
>*
get_parameterized_tensor
_view
()
{
return
dynamic_cast
<
ParameterizedTensorView
<
ET
>*>
(
this
);
}
...
...
@@ -69,5 +69,7 @@ namespace ngraph
protected
:
std
::
shared_ptr
<
ngraph
::
descriptor
::
TensorView
>
m_descriptor
;
};
using
TensorViewPtrs
=
std
::
vector
<
std
::
shared_ptr
<
TensorView
>>
;
}
}
src/ngraph/runtime/tensor_view_index.hpp
0 → 100644
View file @
f6e536cd
// ----------------------------------------------------------------------------
// 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
#include "ngraph/descriptor/tensor_view.hpp"
namespace
ngraph
{
namespace
runtime
{
using
TensorViewIndex
=
unordered_map
<
shared_ptr
<
ngraph
::
descriptor
::
TensorView
>
,
size_t
>
;
}
}
\ No newline at end of file
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