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
f6949fef
Commit
f6949fef
authored
Nov 01, 2017
by
Jaikrishnan Menon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CPU: Switch input/outputs order so outputs come first
parent
0d21bbf4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
21 deletions
+22
-21
call_frame.cpp
src/ngraph/runtime/cpu/call_frame.cpp
+7
-7
call_frame.hpp
src/ngraph/runtime/cpu/call_frame.hpp
+2
-2
external_function.cpp
src/ngraph/runtime/cpu/external_function.cpp
+13
-12
No files found.
src/ngraph/runtime/cpu/call_frame.cpp
View file @
f6949fef
...
@@ -20,30 +20,30 @@ using namespace std;
...
@@ -20,30 +20,30 @@ using namespace std;
using
namespace
ngraph
::
runtime
::
cpu
;
using
namespace
ngraph
::
runtime
::
cpu
;
CallFrame
::
CallFrame
(
EntryPoint
compiled_function
,
CallFrame
::
CallFrame
(
EntryPoint
compiled_function
,
size_t
n_inputs
,
size_t
n_outputs
,
size_t
n_outputs
,
size_t
n_inputs
,
const
TensorViewPtrs
&
temps
)
const
TensorViewPtrs
&
temps
)
:
m_n_
inputs
(
n_in
puts
)
:
m_n_
outputs
(
n_out
puts
)
,
m_n_
outputs
(
n_out
puts
)
,
m_n_
inputs
(
n_in
puts
)
,
m_tensor_views
(
n_inputs
+
n_outputs
+
temps
.
size
())
,
m_tensor_views
(
n_inputs
+
n_outputs
+
temps
.
size
())
,
m_compiled_function
(
compiled_function
)
,
m_compiled_function
(
compiled_function
)
{
{
copy
(
temps
.
begin
(),
temps
.
end
(),
m_tensor_views
.
begin
()
+
m_n_
inputs
+
m_n_out
puts
);
copy
(
temps
.
begin
(),
temps
.
end
(),
m_tensor_views
.
begin
()
+
m_n_
outputs
+
m_n_in
puts
);
}
}
void
CallFrame
::
tensor_call
(
void
CallFrame
::
tensor_call
(
const
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
runtime
::
TensorView
>>&
inputs
,
const
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
runtime
::
TensorView
>>&
inputs
,
const
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
runtime
::
TensorView
>>&
outputs
)
const
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
runtime
::
TensorView
>>&
outputs
)
{
{
copy
(
inputs
.
begin
(),
in
puts
.
end
(),
m_tensor_views
.
begin
());
copy
(
outputs
.
begin
(),
out
puts
.
end
(),
m_tensor_views
.
begin
());
copy
(
outputs
.
begin
(),
outputs
.
end
(),
m_tensor_views
.
begin
()
+
m_n_in
puts
);
copy
(
inputs
.
begin
(),
inputs
.
end
(),
m_tensor_views
.
begin
()
+
m_n_out
puts
);
// Invoke compiled computation
// Invoke compiled computation
m_compiled_function
(
this
,
m_tensor_views
);
m_compiled_function
(
this
,
m_tensor_views
);
// Don't hold onto inputs/outputs
// Don't hold onto inputs/outputs
fill_n
(
m_tensor_views
.
begin
(),
m_n_
inputs
+
m_n_out
puts
,
nullptr
);
fill_n
(
m_tensor_views
.
begin
(),
m_n_
outputs
+
m_n_in
puts
,
nullptr
);
}
}
void
CallFrame
::
operator
()(
const
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
runtime
::
Value
>>&
arguments
,
void
CallFrame
::
operator
()(
const
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
runtime
::
Value
>>&
arguments
,
...
...
src/ngraph/runtime/cpu/call_frame.hpp
View file @
f6949fef
...
@@ -39,8 +39,8 @@ namespace ngraph
...
@@ -39,8 +39,8 @@ namespace ngraph
{
{
public
:
public
:
CallFrame
(
EntryPoint
compiled_function
,
CallFrame
(
EntryPoint
compiled_function
,
size_t
n_inputs
,
size_t
n_outputs
,
size_t
n_outputs
,
size_t
n_inputs
,
const
TensorViewPtrs
&
temps
);
const
TensorViewPtrs
&
temps
);
/// @brief Invoke the function with values matching the signature of the function.
/// @brief Invoke the function with values matching the signature of the function.
...
@@ -68,8 +68,8 @@ namespace ngraph
...
@@ -68,8 +68,8 @@ namespace ngraph
}
}
protected
:
protected
:
size_t
m_n_inputs
;
size_t
m_n_outputs
;
size_t
m_n_outputs
;
size_t
m_n_inputs
;
TensorViewPtrs
m_tensor_views
;
TensorViewPtrs
m_tensor_views
;
bool
m_return
;
bool
m_return
;
EntryPoint
m_compiled_function
;
EntryPoint
m_compiled_function
;
...
...
src/ngraph/runtime/cpu/external_function.cpp
View file @
f6949fef
...
@@ -149,7 +149,17 @@ void ExternalFunction::compile(FunctionMap& function_map)
...
@@ -149,7 +149,17 @@ void ExternalFunction::compile(FunctionMap& function_map)
// Determine tensor requirements for the call frame
// Determine tensor requirements for the call frame
unordered_map
<
shared_ptr
<
ngraph
::
descriptor
::
TensorView
>
,
size_t
>
tensor_index
;
unordered_map
<
shared_ptr
<
ngraph
::
descriptor
::
TensorView
>
,
size_t
>
tensor_index
;
// First come the function inputs
// First come the function outputs
for
(
const
descriptor
::
Output
&
output
:
m_function
->
get_result
()
->
get_outputs
())
{
auto
tv
=
output
.
get_tensor_view
();
size_t
index
=
tensor_index
.
size
();
tensor_index
[
tv
]
=
index
;
}
m_n_outputs
=
tensor_index
.
size
();
// Next are the function inputs
for
(
auto
param
:
m_function
->
get_parameters
())
for
(
auto
param
:
m_function
->
get_parameters
())
{
{
for
(
const
descriptor
::
Output
&
output
:
param
->
get_outputs
())
for
(
const
descriptor
::
Output
&
output
:
param
->
get_outputs
())
...
@@ -159,16 +169,7 @@ void ExternalFunction::compile(FunctionMap& function_map)
...
@@ -159,16 +169,7 @@ void ExternalFunction::compile(FunctionMap& function_map)
tensor_index
[
tv
]
=
index
;
tensor_index
[
tv
]
=
index
;
}
}
}
}
m_n_inputs
=
tensor_index
.
size
();
m_n_inputs
=
tensor_index
.
size
()
-
m_n_outputs
;
// Next are the function outputs
for
(
const
descriptor
::
Output
&
output
:
m_function
->
get_result
()
->
get_outputs
())
{
auto
tv
=
output
.
get_tensor_view
();
size_t
index
=
tensor_index
.
size
();
tensor_index
[
tv
]
=
index
;
}
m_n_outputs
=
tensor_index
.
size
()
-
m_n_inputs
;
// All remaining tensor views
// All remaining tensor views
for
(
shared_ptr
<
Node
>
node
:
m_function
->
get_ordered_ops
())
for
(
shared_ptr
<
Node
>
node
:
m_function
->
get_ordered_ops
())
...
@@ -336,5 +337,5 @@ shared_ptr<ngraph::runtime::CallFrame> ExternalFunction::make_call_frame()
...
@@ -336,5 +337,5 @@ shared_ptr<ngraph::runtime::CallFrame> ExternalFunction::make_call_frame()
#undef M
#undef M
}
}
return
make_shared
<
ngraph
::
runtime
::
cpu
::
CallFrame
>
(
return
make_shared
<
ngraph
::
runtime
::
cpu
::
CallFrame
>
(
compiled_function
,
m_n_
inputs
,
m_n_out
puts
,
temps
);
compiled_function
,
m_n_
outputs
,
m_n_in
puts
,
temps
);
}
}
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