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
91c9a1bf
Commit
91c9a1bf
authored
Mar 01, 2018
by
Louis Feng
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into louisfeng/NGMX-296-conv_bias
parents
9c395596
3da0e440
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
59 additions
and
79 deletions
+59
-79
axis_set.hpp
src/ngraph/axis_set.hpp
+0
-5
axis_vector.hpp
src/ngraph/axis_vector.hpp
+0
-5
coordinate.hpp
src/ngraph/coordinate.hpp
+0
-5
coordinate_diff.hpp
src/ngraph/coordinate_diff.hpp
+0
-5
node_vector.hpp
src/ngraph/node_vector.hpp
+0
-8
parameter_vector.hpp
src/ngraph/ops/parameter_vector.hpp
+0
-8
cpu_external_function.cpp
src/ngraph/runtime/cpu/cpu_external_function.cpp
+9
-3
cpu_external_function.hpp
src/ngraph/runtime/cpu/cpu_external_function.hpp
+1
-0
cpu_manager.cpp
src/ngraph/runtime/cpu/cpu_manager.cpp
+2
-1
mkldnn_emitter.cpp
src/ngraph/runtime/cpu/mkldnn_emitter.cpp
+12
-12
mkldnn_emitter.hpp
src/ngraph/runtime/cpu/mkldnn_emitter.hpp
+4
-9
cpu_assignment.cpp
src/ngraph/runtime/cpu/pass/cpu_assignment.cpp
+1
-1
cpu_assignment.hpp
src/ngraph/runtime/cpu/pass/cpu_assignment.hpp
+2
-2
cpu_layout.cpp
src/ngraph/runtime/cpu/pass/cpu_layout.cpp
+2
-2
cpu_layout.hpp
src/ngraph/runtime/cpu/pass/cpu_layout.hpp
+2
-2
shape.hpp
src/ngraph/shape.hpp
+0
-5
strides.hpp
src/ngraph/strides.hpp
+0
-5
backend_test.in.cpp
test/backend_test.in.cpp
+24
-1
No files found.
src/ngraph/axis_set.hpp
View file @
91c9a1bf
...
...
@@ -21,7 +21,6 @@
namespace
ngraph
{
#ifdef NO_GLOBAL_TYPE_ALIASES
/// \brief A set of axes.
class
AxisSet
:
public
std
::
set
<
size_t
>
{
...
...
@@ -54,8 +53,4 @@ namespace ngraph
return
*
this
;
}
};
#else
// Deprecated definition
using
AxisSet
=
std
::
set
<
size_t
>
;
#endif
}
src/ngraph/axis_vector.hpp
View file @
91c9a1bf
...
...
@@ -21,7 +21,6 @@
namespace
ngraph
{
#ifdef NO_GLOBAL_TYPE_ALIASES
/// \brief A vector of axes.
class
AxisVector
:
public
std
::
vector
<
size_t
>
{
...
...
@@ -64,8 +63,4 @@ namespace ngraph
return
*
this
;
}
};
#else
// Deprecated definition
using
AxisVector
=
std
::
vector
<
size_t
>
;
#endif
}
src/ngraph/coordinate.hpp
View file @
91c9a1bf
...
...
@@ -24,7 +24,6 @@
namespace
ngraph
{
#ifdef NO_GLOBAL_TYPE_ALIASES
/// \brief Coordinates for a tensor element
class
Coordinate
:
public
std
::
vector
<
size_t
>
{
...
...
@@ -73,10 +72,6 @@ namespace ngraph
return
*
this
;
}
};
#else
// Deprecated definition
using
Coordinate
=
std
::
vector
<
size_t
>
;
#endif
// Removes some values from a vector of axis values
template
<
typename
AXIS_VALUES
>
...
...
src/ngraph/coordinate_diff.hpp
View file @
91c9a1bf
...
...
@@ -21,7 +21,6 @@
namespace
ngraph
{
#ifdef NO_GLOBAL_TYPE_ALIASES
/// \brief A difference (signed) of tensor element coordinates.
class
CoordinateDiff
:
public
std
::
vector
<
std
::
ptrdiff_t
>
{
...
...
@@ -64,8 +63,4 @@ namespace ngraph
return
*
this
;
}
};
#else
// Deprecated definition
using
CoordinateDiff
=
std
::
vector
<
std
::
ptrdiff_t
>
;
#endif
}
src/ngraph/node_vector.hpp
View file @
91c9a1bf
...
...
@@ -23,8 +23,6 @@ namespace ngraph
{
class
Node
;
#ifdef NO_GLOBAL_TYPE_ALIASES
/// \brief Zero or more nodes.
class
NodeVector
:
public
std
::
vector
<
std
::
shared_ptr
<
Node
>>
{
...
...
@@ -46,10 +44,4 @@ namespace ngraph
NodeVector
()
{}
};
#else
// Deprecated definitions
using
NodeVector
=
std
::
vector
<
std
::
shared_ptr
<
Node
>>
;
using
Nodes
=
NodeVector
;
#endif
}
src/ngraph/ops/parameter_vector.hpp
View file @
91c9a1bf
...
...
@@ -24,8 +24,6 @@ namespace ngraph
{
class
Parameter
;
#ifdef NO_GLOBAL_TYPE_ALIASES
/// \brief Zero or more nodes.
class
ParameterVector
:
public
std
::
vector
<
std
::
shared_ptr
<
op
::
Parameter
>>
{
...
...
@@ -47,11 +45,5 @@ namespace ngraph
ParameterVector
()
{}
};
#else
// Deprecated definitions
using
ParameterVector
=
std
::
vector
<
std
::
shared_ptr
<
op
::
Parameter
>>
;
using
Parameters
=
ParameterVector
;
#endif
}
}
src/ngraph/runtime/cpu/cpu_external_function.cpp
View file @
91c9a1bf
...
...
@@ -256,6 +256,10 @@ runtime::cpu::CPU_ExternalFunction::CPU_ExternalFunction(
{
}
runtime
::
cpu
::
CPU_ExternalFunction
::~
CPU_ExternalFunction
()
{
}
void
runtime
::
cpu
::
CPU_ExternalFunction
::
compile
()
{
if
(
m_is_compiled
)
...
...
@@ -263,14 +267,16 @@ void runtime::cpu::CPU_ExternalFunction::compile()
return
;
}
m_mkldnn_emitter
.
reset
(
new
MKLDNNEmitter
(
shared_from_this
()));
string
function_name
=
m_function
->
get_name
();
m_mkldnn_emitter
.
reset
(
new
MKLDNNEmitter
());
ngraph
::
pass
::
Manager
pass_manager
;
pass_manager
.
register_pass
<
ngraph
::
pass
::
CoreFusion
>
();
pass_manager
.
register_pass
<
runtime
::
cpu
::
pass
::
CPUFusion
>
();
pass_manager
.
register_pass
<
runtime
::
cpu
::
pass
::
CPUAssignment
>
(
shared_from_this
()
);
pass_manager
.
register_pass
<
runtime
::
cpu
::
pass
::
CPULayout
>
(
shared_from_this
()
);
pass_manager
.
register_pass
<
runtime
::
cpu
::
pass
::
CPUAssignment
>
(
this
);
pass_manager
.
register_pass
<
runtime
::
cpu
::
pass
::
CPULayout
>
(
this
);
pass_manager
.
register_pass
<
ngraph
::
pass
::
Liveness
>
();
pass_manager
.
register_pass
<
ngraph
::
pass
::
MemoryLayout
>
(
s_memory_pool_alignment
);
...
...
src/ngraph/runtime/cpu/cpu_external_function.hpp
View file @
91c9a1bf
...
...
@@ -75,6 +75,7 @@ namespace ngraph
public
:
CPU_ExternalFunction
(
const
std
::
shared_ptr
<
ngraph
::
Function
>&
function
,
bool
release_function
=
true
);
~
CPU_ExternalFunction
();
std
::
shared_ptr
<
ngraph
::
runtime
::
CallFrame
>
make_call_frame
();
const
LayoutDescriptorPtrs
&
get_parameter_layout_descriptors
();
...
...
src/ngraph/runtime/cpu/cpu_manager.cpp
View file @
91c9a1bf
...
...
@@ -30,7 +30,8 @@ std::shared_ptr<ngraph::runtime::Backend> runtime::cpu::CPU_Manager::allocate_ba
std
::
shared_ptr
<
ngraph
::
runtime
::
ExternalFunction
>
runtime
::
cpu
::
CPU_Manager
::
compile
(
const
std
::
shared_ptr
<
ngraph
::
Function
>&
fun
)
{
return
std
::
make_shared
<
CPU_ExternalFunction
>
(
fun
);
auto
rc
=
std
::
make_shared
<
CPU_ExternalFunction
>
(
fun
);
return
rc
;
}
ngraph
::
runtime
::
Manager
::
Factory
runtime
::
cpu
::
CPU_Manager
::
factory
=
...
...
src/ngraph/runtime/cpu/mkldnn_emitter.cpp
View file @
91c9a1bf
...
...
@@ -27,18 +27,18 @@ using namespace ngraph::runtime::cpu;
const
std
::
vector
<
mkldnn
::
primitive
*>&
MKLDNNEmitter
::
get_mkldnn_primitives
()
const
{
return
mkldnn_primitives
;
return
m
_m
kldnn_primitives
;
}
size_t
MKLDNNEmitter
::
insert_primitive
(
mkldnn
::
primitive
*
primitive
)
{
mkldnn_primitives
.
emplace_back
(
primitive
);
return
(
mkldnn_primitives
.
size
()
-
1
);
m
_m
kldnn_primitives
.
emplace_back
(
primitive
);
return
(
m
_m
kldnn_primitives
.
size
()
-
1
);
}
const
std
::
vector
<
size_t
>&
MKLDNNEmitter
::
get_primitive_deps
(
size_t
index
)
const
{
return
primitive_deps
.
at
(
index
);
return
m_
primitive_deps
.
at
(
index
);
}
mkldnn
::
memory
::
desc
MKLDNNEmitter
::
build_memory_descriptor
(
const
TensorViewWrapper
&
tvw
,
...
...
@@ -98,11 +98,11 @@ size_t MKLDNNEmitter::build_convolution_forward(const mkldnn::memory::desc& inpu
mkldnn
::
memory
::
dims
(
padding_above
.
begin
(),
padding_above
.
end
()),
mkldnn
::
padding_kind
::
zero
},
mkldnn_utils
::
global_cpu_engine
},
*
mkldnn_primitives
[
input_data_index
],
*
mkldnn_primitives
[
weights_index
],
*
mkldnn_primitives
[
result_index
]));
*
m
_m
kldnn_primitives
[
input_data_index
],
*
m
_m
kldnn_primitives
[
weights_index
],
*
m
_m
kldnn_primitives
[
result_index
]));
primitive_deps
[
conv_index
]
=
{
input_data_index
,
weights_index
,
result_index
};
m_
primitive_deps
[
conv_index
]
=
{
input_data_index
,
weights_index
,
result_index
};
return
conv_index
;
}
...
...
@@ -262,16 +262,16 @@ size_t MKLDNNEmitter::build_elementwise_add(
size_t
input1_data_index
=
build_memory_primitive
(
input1_data_desc
);
size_t
result_index
=
build_memory_primitive
(
result_desc
);
inputs_primitive
.
push_back
(
*
mkldnn_primitives
[
input0_data_index
]);
inputs_primitive
.
push_back
(
*
mkldnn_primitives
[
input1_data_index
]);
inputs_primitive
.
push_back
(
*
m
_m
kldnn_primitives
[
input0_data_index
]);
inputs_primitive
.
push_back
(
*
m
_m
kldnn_primitives
[
input1_data_index
]);
// elementwise sum primtive descriptor
mkldnn
::
sum
::
primitive_desc
sum_pd
=
mkldnn
::
sum
::
primitive_desc
(
result_desc
,
scale_vector
,
inputs_pd
);
// sum primitive
size_t
add_index
=
insert_primitive
(
new
mkldnn
::
sum
(
sum_pd
,
inputs_primitive
,
*
mkldnn_primitives
[
result_index
]));
new
mkldnn
::
sum
(
sum_pd
,
inputs_primitive
,
*
m
_m
kldnn_primitives
[
result_index
]));
primitive_deps
[
add_index
]
=
{
input0_data_index
,
input1_data_index
,
result_index
};
m_
primitive_deps
[
add_index
]
=
{
input0_data_index
,
input1_data_index
,
result_index
};
return
add_index
;
}
src/ngraph/runtime/cpu/mkldnn_emitter.hpp
View file @
91c9a1bf
...
...
@@ -37,11 +37,7 @@ namespace ngraph
class
MKLDNNEmitter
{
public
:
MKLDNNEmitter
(
std
::
shared_ptr
<
CPU_ExternalFunction
>
ef
)
:
external_function
(
ef
)
{
}
MKLDNNEmitter
()
{}
const
std
::
vector
<
mkldnn
::
primitive
*>&
get_mkldnn_primitives
()
const
;
size_t
insert_primitive
(
mkldnn
::
primitive
*
primitive
);
...
...
@@ -103,10 +99,9 @@ namespace ngraph
const
std
::
vector
<
mkldnn
::
memory
::
primitive_desc
>&
input_pd
);
private
:
std
::
shared_ptr
<
CPU_ExternalFunction
>
external_function
;
std
::
vector
<
mkldnn
::
primitive
*>
mkldnn_primitives
;
std
::
vector
<
mkldnn
::
stream
>
mkldnn_streams
;
std
::
unordered_map
<
size_t
,
std
::
vector
<
size_t
>>
primitive_deps
;
std
::
vector
<
mkldnn
::
primitive
*>
m_mkldnn_primitives
;
std
::
vector
<
mkldnn
::
stream
>
m_mkldnn_streams
;
std
::
unordered_map
<
size_t
,
std
::
vector
<
size_t
>>
m_primitive_deps
;
};
}
}
...
...
src/ngraph/runtime/cpu/pass/cpu_assignment.cpp
View file @
91c9a1bf
...
...
@@ -256,7 +256,7 @@ bool runtime::cpu::pass::CPUAssignment::run_on_call_graph(
auto
handler
=
s_dispatcher
.
find
(
TI
(
n
));
if
(
handler
!=
s_dispatcher
.
end
())
{
handler
->
second
(
m_external_function
.
get
()
,
node
.
get
());
handler
->
second
(
m_external_function
,
node
.
get
());
}
}
...
...
src/ngraph/runtime/cpu/pass/cpu_assignment.hpp
View file @
91c9a1bf
...
...
@@ -39,7 +39,7 @@ namespace ngraph
class
CPUAssignment
:
public
ngraph
::
pass
::
CallGraphPass
{
public
:
CPUAssignment
(
std
::
shared_ptr
<
CPU_ExternalFunction
>
external_function
)
CPUAssignment
(
CPU_ExternalFunction
*
external_function
)
:
m_external_function
(
external_function
)
{
}
...
...
@@ -56,7 +56,7 @@ namespace ngraph
}
private
:
std
::
shared_ptr
<
CPU_ExternalFunction
>
m_external_function
;
CPU_ExternalFunction
*
m_external_function
;
};
}
}
...
...
src/ngraph/runtime/cpu/pass/cpu_layout.cpp
View file @
91c9a1bf
...
...
@@ -719,11 +719,11 @@ bool runtime::cpu::pass::CPULayout::run_on_call_graph(const std::list<std::share
auto
handler
=
s_dispatcher
.
find
(
TI
(
n
));
if
(
handler
!=
s_dispatcher
.
end
())
{
handler
->
second
(
m_external_function
.
get
()
,
node
);
handler
->
second
(
m_external_function
,
node
);
}
else
{
set_default_layouts
(
m_external_function
.
get
()
,
node
);
set_default_layouts
(
m_external_function
,
node
);
}
}
...
...
src/ngraph/runtime/cpu/pass/cpu_layout.hpp
View file @
91c9a1bf
...
...
@@ -39,7 +39,7 @@ namespace ngraph
class
CPULayout
:
public
ngraph
::
pass
::
CallGraphPass
{
public
:
CPULayout
(
std
::
shared_ptr
<
CPU_ExternalFunction
>
external_function
)
CPULayout
(
CPU_ExternalFunction
*
external_function
)
:
m_external_function
(
external_function
)
{
}
...
...
@@ -52,7 +52,7 @@ namespace ngraph
std
::
shared_ptr
<
ngraph
::
Node
>
node
);
private
:
std
::
shared_ptr
<
CPU_ExternalFunction
>
m_external_function
;
CPU_ExternalFunction
*
m_external_function
;
static
std
::
shared_ptr
<
Node
>
insert_input_conversions
(
CPU_ExternalFunction
*
external_function
,
std
::
shared_ptr
<
Node
>&
node
,
...
...
src/ngraph/shape.hpp
View file @
91c9a1bf
...
...
@@ -25,7 +25,6 @@
namespace
ngraph
{
#ifdef NO_GLOBAL_TYPE_ALIASES
/// \brief Shape for a tensor.
class
Shape
:
public
std
::
vector
<
size_t
>
{
...
...
@@ -68,10 +67,6 @@ namespace ngraph
return
*
this
;
}
};
#else
// Deprecated definition
using
Shape
=
std
::
vector
<
size_t
>
;
#endif
/// Number of elements in spanned by a shape
size_t
shape_size
(
const
Shape
&
shape
);
...
...
src/ngraph/strides.hpp
View file @
91c9a1bf
...
...
@@ -20,7 +20,6 @@
namespace
ngraph
{
#ifdef NO_GLOBAL_TYPE_ALIASES
/// \brief Strides for a tensor.
class
Strides
:
public
std
::
vector
<
size_t
>
{
...
...
@@ -63,8 +62,4 @@ namespace ngraph
return
*
this
;
}
};
#else
// Deprecated definition
using
Strides
=
std
::
vector
<
size_t
>
;
#endif
}
test/backend_test.in.cpp
View file @
91c9a1bf
...
...
@@ -43,6 +43,29 @@ static const vector<element::Type> s_known_element_types = {element::from<float>
element
::
from
<
uint32_t
>
(),
element
::
from
<
uint64_t
>
()};
TEST
(
$
{
BACKEND_NAME
},
component_cleanup
)
{
shared_ptr
<
runtime
::
Backend
>
backend
;
shared_ptr
<
runtime
::
ExternalFunction
>
external
;
shared_ptr
<
runtime
::
CallFrame
>
cf
;
{
Shape
shape
{
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
shape
);
auto
B
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
shape
);
auto
f
=
make_shared
<
Function
>
(
A
+
B
,
op
::
ParameterVector
{
A
,
B
});
auto
manager
=
runtime
::
Manager
::
get
(
"${BACKEND_NAME}"
);
external
=
manager
->
compile
(
f
);
backend
=
manager
->
allocate_backend
();
cf
=
backend
->
make_call_frame
(
external
);
}
EXPECT_EQ
(
cf
.
use_count
(),
1
);
cf
=
nullptr
;
EXPECT_EQ
(
backend
.
use_count
(),
1
);
backend
=
nullptr
;
EXPECT_EQ
(
external
.
use_count
(),
1
);
}
TEST
(
$
{
BACKEND_NAME
},
aliased_output
)
{
Shape
shape
{
2
,
2
};
...
...
@@ -138,7 +161,7 @@ TEST(${BACKEND_NAME}, abc)
auto
f
=
make_shared
<
Function
>
((
A
+
B
)
*
C
,
op
::
ParameterVector
{
A
,
B
,
C
});
auto
manager
=
runtime
::
Manager
::
get
(
"${BACKEND_NAME}"
);
auto
external
=
manager
->
compile
(
f
);
shared_ptr
<
runtime
::
ExternalFunction
>
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
...
...
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