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
22e1368a
Commit
22e1368a
authored
Oct 25, 2017
by
Jaikrishnan Menon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CPU: Apply formatting fixes from clang-format
parent
75623f48
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
74 additions
and
64 deletions
+74
-64
compiler.hpp
src/ngraph/codegen/compiler.hpp
+0
-2
call_frame.hpp
src/ngraph/runtime/cpu/call_frame.hpp
+7
-7
cpu_manager.cpp
src/ngraph/runtime/cpu/cpu_manager.cpp
+1
-1
cpu_manager.hpp
src/ngraph/runtime/cpu/cpu_manager.hpp
+2
-1
emitter.cpp
src/ngraph/runtime/cpu/emitter.cpp
+0
-0
emitter.hpp
src/ngraph/runtime/cpu/emitter.hpp
+12
-11
external_function.cpp
src/ngraph/runtime/cpu/external_function.cpp
+45
-36
external_function.hpp
src/ngraph/runtime/cpu/external_function.hpp
+7
-5
cpu.cpp
test/cpu.cpp
+0
-1
No files found.
src/ngraph/codegen/compiler.hpp
View file @
22e1368a
...
@@ -46,10 +46,8 @@ public:
...
@@ -46,10 +46,8 @@ public:
void
enable_pch
()
{
pch_enabled
=
true
;
}
void
enable_pch
()
{
pch_enabled
=
true
;
}
void
disable_pch
()
{
pch_enabled
=
false
;
}
void
disable_pch
()
{
pch_enabled
=
false
;
}
void
enable_debuginfo
()
{
debuginfo_enabled
=
true
;
}
void
enable_debuginfo
()
{
debuginfo_enabled
=
true
;
}
void
disable_debuginfo
()
{
debuginfo_enabled
=
false
;
}
void
disable_debuginfo
()
{
debuginfo_enabled
=
false
;
}
std
::
unique_ptr
<
llvm
::
Module
>
compile
(
const
std
::
string
&
source
,
const
std
::
string
&
name
=
""
);
std
::
unique_ptr
<
llvm
::
Module
>
compile
(
const
std
::
string
&
source
,
const
std
::
string
&
name
=
""
);
bool
add_module
(
std
::
unique_ptr
<
llvm
::
Module
>&
);
bool
add_module
(
std
::
unique_ptr
<
llvm
::
Module
>&
);
...
...
src/ngraph/runtime/cpu/call_frame.hpp
View file @
22e1368a
...
@@ -14,9 +14,9 @@
...
@@ -14,9 +14,9 @@
#pragma once
#pragma once
#include <functional>
#include <memory>
#include <memory>
#include <vector>
#include <vector>
#include <functional>
#include "ngraph/function.hpp"
#include "ngraph/function.hpp"
#include "ngraph/runtime/call_frame.hpp"
#include "ngraph/runtime/call_frame.hpp"
...
@@ -31,17 +31,17 @@ namespace ngraph
...
@@ -31,17 +31,17 @@ namespace ngraph
namespace
cpu
namespace
cpu
{
{
class
CallFrame
;
class
CallFrame
;
using
EntryPoint
=
std
::
function
<
void
(
ngraph
::
runtime
::
cpu
::
CallFrame
*
,
ngraph
::
runtime
::
TensorViewPtrs
&
)
>
;
using
EntryPoint
=
std
::
function
<
void
(
ngraph
::
runtime
::
cpu
::
CallFrame
*
,
ngraph
::
runtime
::
TensorViewPtrs
&
)
>
;
// Compile and execute graphs
// Compile and execute graphs
class
CallFrame
:
public
ngraph
::
runtime
::
CallFrame
class
CallFrame
:
public
ngraph
::
runtime
::
CallFrame
{
{
public
:
public
:
CallFrame
(
CallFrame
(
EntryPoint
compiled_function
,
EntryPoint
compiled_function
,
size_t
n_inputs
,
size_t
n_inputs
,
size_t
n_outputs
,
size_t
n_outputs
,
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.
///
///
...
...
src/ngraph/runtime/cpu/cpu_manager.cpp
View file @
22e1368a
...
@@ -14,9 +14,9 @@
...
@@ -14,9 +14,9 @@
#include <memory>
#include <memory>
#include "ngraph/runtime/cpu/external_function.hpp"
#include "ngraph/runtime/cpu/cpu_backend.hpp"
#include "ngraph/runtime/cpu/cpu_backend.hpp"
#include "ngraph/runtime/cpu/cpu_manager.hpp"
#include "ngraph/runtime/cpu/cpu_manager.hpp"
#include "ngraph/runtime/cpu/external_function.hpp"
using
namespace
ngraph
::
runtime
::
cpu
;
using
namespace
ngraph
::
runtime
::
cpu
;
...
...
src/ngraph/runtime/cpu/cpu_manager.hpp
View file @
22e1368a
...
@@ -16,8 +16,8 @@
...
@@ -16,8 +16,8 @@
#include <memory>
#include <memory>
#include "ngraph/runtime/manager.hpp"
#include "ngraph/codegen/compiler.hpp"
#include "ngraph/codegen/compiler.hpp"
#include "ngraph/runtime/manager.hpp"
namespace
ngraph
namespace
ngraph
{
{
...
@@ -34,6 +34,7 @@ namespace ngraph
...
@@ -34,6 +34,7 @@ namespace ngraph
{
{
protected
:
protected
:
ngraph
::
codegen
::
execution_state
exec_state
;
ngraph
::
codegen
::
execution_state
exec_state
;
public
:
public
:
virtual
std
::
shared_ptr
<
Backend
>
allocate_backend
()
override
;
virtual
std
::
shared_ptr
<
Backend
>
allocate_backend
()
override
;
...
...
src/ngraph/runtime/cpu/emitter.cpp
View file @
22e1368a
This diff is collapsed.
Click to expand it.
src/ngraph/runtime/cpu/emitter.hpp
View file @
22e1368a
...
@@ -14,19 +14,19 @@
...
@@ -14,19 +14,19 @@
#pragma once
#pragma once
#include <vector>
#include <string>
#include <string>
#include <vector>
#include "ngraph/node.hpp"
#include "ngraph/node.hpp"
#include "ngraph/runtime/tensor_view_info.hpp"
#include "ngraph/runtime/cpu/external_function.hpp"
#include "ngraph/runtime/cpu/external_function.hpp"
#include "ngraph/runtime/tensor_view_info.hpp"
#define EMITTER_DECL(E)
E(const ngraph::Node* n,
\
#define EMITTER_DECL(E)
\
ExternalFunction* ef,
\
E(const ngraph::Node* n,
\
FunctionMap& function_map,
\
ExternalFunction* ef,
\
const std::vector<TensorViewInfo>& inputs,
\
FunctionMap& function_map,
\
const std::vector<TensorViewInfo>& outputs)
const std::vector<TensorViewInfo>& inputs, \
const std::vector<TensorViewInfo>& outputs)
namespace
ngraph
namespace
ngraph
{
{
...
@@ -40,9 +40,11 @@ namespace ngraph
...
@@ -40,9 +40,11 @@ namespace ngraph
std
::
string
TU
;
std
::
string
TU
;
public
:
public
:
Emitter
()
:
TU
(
""
)
{
}
Emitter
()
:
TU
(
""
)
{
}
std
::
string
&
GetTU
()
{
return
TU
;
}
std
::
string
&
GetTU
()
{
return
TU
;
}
void
EMITTER_DECL
(
EmitNop
);
void
EMITTER_DECL
(
EmitNop
);
void
EMITTER_DECL
(
EmitAdd
);
void
EMITTER_DECL
(
EmitAdd
);
void
EMITTER_DECL
(
EmitDot
);
void
EMITTER_DECL
(
EmitDot
);
...
@@ -71,7 +73,6 @@ namespace ngraph
...
@@ -71,7 +73,6 @@ namespace ngraph
void
EMITTER_DECL
(
EmitParameterizedConstantUInt8
);
void
EMITTER_DECL
(
EmitParameterizedConstantUInt8
);
void
EMITTER_DECL
(
EmitParameterizedConstantUInt32
);
void
EMITTER_DECL
(
EmitParameterizedConstantUInt32
);
void
EMITTER_DECL
(
EmitParameterizedConstantUInt64
);
void
EMITTER_DECL
(
EmitParameterizedConstantUInt64
);
};
};
}
}
}
}
...
...
src/ngraph/runtime/cpu/external_function.cpp
View file @
22e1368a
...
@@ -12,13 +12,13 @@
...
@@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
#include <fstream>
#include <memory>
#include <memory>
#include <string>
#include <tuple>
#include <tuple>
#include <typeindex>
#include <typeindex>
#include <typeinfo>
#include <typeinfo>
#include <unordered_map>
#include <unordered_map>
#include <string>
#include <fstream>
#include "ngraph/codegen/compiler.hpp"
#include "ngraph/codegen/compiler.hpp"
#include "ngraph/descriptor/input.hpp"
#include "ngraph/descriptor/input.hpp"
...
@@ -70,36 +70,45 @@ using ngraph::descriptor::layout::DenseTensorViewLayout;
...
@@ -70,36 +70,45 @@ using ngraph::descriptor::layout::DenseTensorViewLayout;
#define TI(x) type_index(typeid(x))
#define TI(x) type_index(typeid(x))
static
const
OpMap
dispatcher
{{
TI
(
ngraph
::
op
::
Add
),
&
Emitter
::
EmitAdd
},
static
const
OpMap
dispatcher
{
{
TI
(
ngraph
::
op
::
Dot
),
&
Emitter
::
EmitDot
},
{
TI
(
ngraph
::
op
::
Add
),
&
Emitter
::
EmitAdd
},
{
TI
(
ngraph
::
op
::
Multiply
),
&
Emitter
::
EmitMultiply
},
{
TI
(
ngraph
::
op
::
Dot
),
&
Emitter
::
EmitDot
},
{
TI
(
ngraph
::
op
::
Parameter
),
&
Emitter
::
EmitNop
},
{
TI
(
ngraph
::
op
::
Multiply
),
&
Emitter
::
EmitMultiply
},
{
TI
(
ngraph
::
op
::
GetTupleElement
),
&
Emitter
::
EmitGetTupleElement
},
{
TI
(
ngraph
::
op
::
Parameter
),
&
Emitter
::
EmitNop
},
{
TI
(
ngraph
::
op
::
Tuple
),
&
Emitter
::
EmitTuple
},
{
TI
(
ngraph
::
op
::
GetTupleElement
),
&
Emitter
::
EmitGetTupleElement
},
{
TI
(
ngraph
::
op
::
Abs
),
&
Emitter
::
EmitAbs
},
{
TI
(
ngraph
::
op
::
Tuple
),
&
Emitter
::
EmitTuple
},
{
TI
(
ngraph
::
op
::
Concat
),
&
Emitter
::
EmitConcat
},
{
TI
(
ngraph
::
op
::
Abs
),
&
Emitter
::
EmitAbs
},
{
TI
(
ngraph
::
op
::
Divide
),
&
Emitter
::
EmitDivide
},
{
TI
(
ngraph
::
op
::
Concat
),
&
Emitter
::
EmitConcat
},
{
TI
(
ngraph
::
op
::
Equal
),
&
Emitter
::
EmitEqual
},
{
TI
(
ngraph
::
op
::
Divide
),
&
Emitter
::
EmitDivide
},
{
TI
(
ngraph
::
op
::
Greater
),
&
Emitter
::
EmitGreater
},
{
TI
(
ngraph
::
op
::
Equal
),
&
Emitter
::
EmitEqual
},
{
TI
(
ngraph
::
op
::
GreaterEq
),
&
Emitter
::
EmitGreaterEq
},
{
TI
(
ngraph
::
op
::
Greater
),
&
Emitter
::
EmitGreater
},
{
TI
(
ngraph
::
op
::
Less
),
&
Emitter
::
EmitLess
},
{
TI
(
ngraph
::
op
::
GreaterEq
),
&
Emitter
::
EmitGreaterEq
},
{
TI
(
ngraph
::
op
::
LessEq
),
&
Emitter
::
EmitLessEq
},
{
TI
(
ngraph
::
op
::
Less
),
&
Emitter
::
EmitLess
},
{
TI
(
ngraph
::
op
::
Log
),
&
Emitter
::
EmitLog
},
{
TI
(
ngraph
::
op
::
LessEq
),
&
Emitter
::
EmitLessEq
},
{
TI
(
ngraph
::
op
::
Maximum
),
&
Emitter
::
EmitMaximum
},
{
TI
(
ngraph
::
op
::
Log
),
&
Emitter
::
EmitLog
},
{
TI
(
ngraph
::
op
::
Negative
),
&
Emitter
::
EmitNegative
},
{
TI
(
ngraph
::
op
::
Maximum
),
&
Emitter
::
EmitMaximum
},
{
TI
(
ngraph
::
op
::
NotEqual
),
&
Emitter
::
EmitNotEqual
},
{
TI
(
ngraph
::
op
::
Negative
),
&
Emitter
::
EmitNegative
},
{
TI
(
ngraph
::
op
::
Select
),
&
Emitter
::
EmitSelect
},
{
TI
(
ngraph
::
op
::
NotEqual
),
&
Emitter
::
EmitNotEqual
},
{
TI
(
ngraph
::
op
::
Subtract
),
&
Emitter
::
EmitSubtract
},
{
TI
(
ngraph
::
op
::
Select
),
&
Emitter
::
EmitSelect
},
{
TI
(
ngraph
::
op
::
ParameterizedConstant
<
ngraph
::
element
::
Bool
>
),
&
Emitter
::
EmitParameterizedConstantBool
},
{
TI
(
ngraph
::
op
::
Subtract
),
&
Emitter
::
EmitSubtract
},
{
TI
(
ngraph
::
op
::
ParameterizedConstant
<
ngraph
::
element
::
Float32
>
),
&
Emitter
::
EmitParameterizedConstantFloat32
},
{
TI
(
ngraph
::
op
::
ParameterizedConstant
<
ngraph
::
element
::
Bool
>
),
{
TI
(
ngraph
::
op
::
ParameterizedConstant
<
ngraph
::
element
::
Int8
>
),
&
Emitter
::
EmitParameterizedConstantInt8
},
&
Emitter
::
EmitParameterizedConstantBool
},
{
TI
(
ngraph
::
op
::
ParameterizedConstant
<
ngraph
::
element
::
Int32
>
),
&
Emitter
::
EmitParameterizedConstantInt32
},
{
TI
(
ngraph
::
op
::
ParameterizedConstant
<
ngraph
::
element
::
Float32
>
),
{
TI
(
ngraph
::
op
::
ParameterizedConstant
<
ngraph
::
element
::
Int64
>
),
&
Emitter
::
EmitParameterizedConstantInt64
},
&
Emitter
::
EmitParameterizedConstantFloat32
},
{
TI
(
ngraph
::
op
::
ParameterizedConstant
<
ngraph
::
element
::
UInt8
>
),
&
Emitter
::
EmitParameterizedConstantUInt8
},
{
TI
(
ngraph
::
op
::
ParameterizedConstant
<
ngraph
::
element
::
Int8
>
),
{
TI
(
ngraph
::
op
::
ParameterizedConstant
<
ngraph
::
element
::
UInt32
>
),
&
Emitter
::
EmitParameterizedConstantUInt32
},
&
Emitter
::
EmitParameterizedConstantInt8
},
{
TI
(
ngraph
::
op
::
ParameterizedConstant
<
ngraph
::
element
::
UInt64
>
),
&
Emitter
::
EmitParameterizedConstantUInt64
},
{
TI
(
ngraph
::
op
::
ParameterizedConstant
<
ngraph
::
element
::
Int32
>
),
&
Emitter
::
EmitParameterizedConstantInt32
},
};
{
TI
(
ngraph
::
op
::
ParameterizedConstant
<
ngraph
::
element
::
Int64
>
),
&
Emitter
::
EmitParameterizedConstantInt64
},
{
TI
(
ngraph
::
op
::
ParameterizedConstant
<
ngraph
::
element
::
UInt8
>
),
&
Emitter
::
EmitParameterizedConstantUInt8
},
{
TI
(
ngraph
::
op
::
ParameterizedConstant
<
ngraph
::
element
::
UInt32
>
),
&
Emitter
::
EmitParameterizedConstantUInt32
},
{
TI
(
ngraph
::
op
::
ParameterizedConstant
<
ngraph
::
element
::
UInt64
>
),
&
Emitter
::
EmitParameterizedConstantUInt64
},
};
#undef TI
#undef TI
...
@@ -183,15 +192,15 @@ void ExternalFunction::compile(FunctionMap& function_map)
...
@@ -183,15 +192,15 @@ void ExternalFunction::compile(FunctionMap& function_map)
Emitter
emitter
;
Emitter
emitter
;
auto
&
TU
=
emitter
.
GetTU
();
auto
&
TU
=
emitter
.
GetTU
();
TU
+=
R"(
TU
+=
R"(
#include <vector>
#include <memory>
#include <memory>
#include <vector>
#include <Eigen/Dense>
#include <Eigen/Dense>
#include "ngraph/descriptor/layout/dense_tensor_view_layout.hpp"
#include "ngraph/descriptor/layout/dense_tensor_view_layout.hpp"
#include "ngraph/runtime/tensor_view_info.hpp"
#include "ngraph/runtime/cpu/call_frame.hpp"
#include "ngraph/runtime/cpu/call_frame.hpp"
#include "ngraph/runtime/cpu/eigen_utils.hpp"
#include "ngraph/runtime/cpu/eigen_utils.hpp"
#include "ngraph/runtime/tensor_view_info.hpp"
void *__dso_handle = 0;
void *__dso_handle = 0;
...
@@ -247,8 +256,8 @@ extern "C" void __entrypoint(ngraph::runtime::cpu::CallFrame* call_frame,
...
@@ -247,8 +256,8 @@ extern "C" void __entrypoint(ngraph::runtime::cpu::CallFrame* call_frame,
assert
(
llvm_module
);
assert
(
llvm_module
);
estate
.
add_module
(
llvm_module
);
estate
.
add_module
(
llvm_module
);
estate
.
finalize
();
estate
.
finalize
();
compiled_function
=
estate
.
find_function
<
void
(
ngraph
::
runtime
::
cpu
::
CallFrame
*
,
compiled_function
=
estate
.
find_function
<
void
(
ngraph
::
runtime
::
TensorViewPtrs
&
)
>
(
"__entrypoint"
);
ngraph
::
runtime
::
cpu
::
CallFrame
*
,
ngraph
::
runtime
::
TensorViewPtrs
&
)
>
(
"__entrypoint"
);
assert
(
compiled_function
);
assert
(
compiled_function
);
m_is_compiled
=
true
;
m_is_compiled
=
true
;
...
...
src/ngraph/runtime/cpu/external_function.hpp
View file @
22e1368a
...
@@ -14,14 +14,14 @@
...
@@ -14,14 +14,14 @@
#pragma once
#pragma once
#include <functional>
#include <memory>
#include <memory>
#include <typeindex>
#include <typeindex>
#include <typeinfo>
#include <typeinfo>
#include <unordered_map>
#include <unordered_map>
#include <functional>
#include "ngraph/function.hpp"
#include "ngraph/codegen/compiler.hpp"
#include "ngraph/codegen/compiler.hpp"
#include "ngraph/function.hpp"
#include "ngraph/runtime/external_function.hpp"
#include "ngraph/runtime/external_function.hpp"
#include "ngraph/runtime/tensor_view_info.hpp"
#include "ngraph/runtime/tensor_view_info.hpp"
...
@@ -35,8 +35,8 @@ namespace ngraph
...
@@ -35,8 +35,8 @@ namespace ngraph
class
Emitter
;
class
Emitter
;
class
CallFrame
;
class
CallFrame
;
using
FunctionMap
=
std
::
unordered_map
<
std
::
shared_ptr
<
Function
>
,
using
FunctionMap
=
std
::
shared_ptr
<
ExternalFunction
>>
;
std
::
unordered_map
<
std
::
shared_ptr
<
Function
>
,
std
::
shared_ptr
<
ExternalFunction
>>
;
using
OpFunction
=
std
::
function
<
void
(
Emitter
*
,
using
OpFunction
=
std
::
function
<
void
(
Emitter
*
,
const
ngraph
::
Node
*
,
const
ngraph
::
Node
*
,
...
@@ -47,7 +47,8 @@ namespace ngraph
...
@@ -47,7 +47,8 @@ namespace ngraph
using
OpMap
=
std
::
unordered_map
<
std
::
type_index
,
OpFunction
>
;
using
OpMap
=
std
::
unordered_map
<
std
::
type_index
,
OpFunction
>
;
using
EntryPoint
=
std
::
function
<
void
(
ngraph
::
runtime
::
cpu
::
CallFrame
*
,
ngraph
::
runtime
::
TensorViewPtrs
&
)
>
;
using
EntryPoint
=
std
::
function
<
void
(
ngraph
::
runtime
::
cpu
::
CallFrame
*
,
ngraph
::
runtime
::
TensorViewPtrs
&
)
>
;
class
ExternalFunction
:
public
ngraph
::
runtime
::
ExternalFunction
class
ExternalFunction
:
public
ngraph
::
runtime
::
ExternalFunction
{
{
...
@@ -55,6 +56,7 @@ namespace ngraph
...
@@ -55,6 +56,7 @@ namespace ngraph
ExternalFunction
(
const
std
::
shared_ptr
<
ngraph
::
Function
>&
function
,
ExternalFunction
(
const
std
::
shared_ptr
<
ngraph
::
Function
>&
function
,
bool
release_function
=
true
);
bool
release_function
=
true
);
std
::
shared_ptr
<
ngraph
::
runtime
::
CallFrame
>
make_call_frame
();
std
::
shared_ptr
<
ngraph
::
runtime
::
CallFrame
>
make_call_frame
();
protected
:
protected
:
void
compile
(
FunctionMap
&
function_map
);
void
compile
(
FunctionMap
&
function_map
);
...
...
test/cpu.cpp
View file @
22e1368a
...
@@ -803,7 +803,6 @@ TEST(cpu, greater)
...
@@ -803,7 +803,6 @@ TEST(cpu, greater)
ASSERT_EQ
((
vector
<
char
>
{
0
,
1
,
0
,
1
,
0
,
1
,
1
,
0
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
char
>
{
0
,
1
,
0
,
1
,
0
,
1
,
1
,
0
}),
result
->
get_vector
());
}
}
TEST
(
cpu
,
greatereq
)
TEST
(
cpu
,
greatereq
)
{
{
auto
shape
=
Shape
{
2
,
2
,
2
};
auto
shape
=
Shape
{
2
,
2
,
2
};
...
...
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