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
02559274
Unverified
Commit
02559274
authored
Feb 11, 2019
by
Scott Cyphers
Committed by
GitHub
Feb 11, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into bob/backend_api3
parents
d607c6f4
13b4966b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
67 additions
and
21 deletions
+67
-21
quantization.cpp
src/ngraph/builder/quantization.cpp
+6
-0
graph_util.cpp
src/ngraph/graph_util.cpp
+16
-0
graph_util.hpp
src/ngraph/graph_util.hpp
+2
-0
quantized_conv.cpp
src/ngraph/runtime/cpu/builder/quantized_conv.cpp
+1
-1
cpu_external_function.cpp
src/ngraph/runtime/cpu/cpu_external_function.cpp
+1
-0
mkldnn_emitter.hpp
src/ngraph/runtime/cpu/mkldnn_emitter.hpp
+4
-18
mkldnn_utils.hpp
src/ngraph/runtime/cpu/mkldnn_utils.hpp
+18
-2
cpu_fusion.cpp
src/ngraph/runtime/cpu/pass/cpu_fusion.cpp
+0
-0
cpu_fusion.hpp
src/ngraph/runtime/cpu/pass/cpu_fusion.hpp
+19
-0
cpu_fusion.cpp
test/cpu_fusion.cpp
+0
-0
No files found.
src/ngraph/builder/quantization.cpp
View file @
02559274
...
...
@@ -325,6 +325,12 @@ namespace ngraph
max_freezed_output_conv_1
,
min_freezed_output_conv_2
,
max_freezed_output_conv_2
);
if
(
output_et
==
element
::
u8
)
{
// Need to multiply by two to account for u8 requantization_scale
auto
two
=
make_constant
(
element
::
f32
,
sum_scale
->
get_shape
(),
2.0
f
);
sum_scale
=
two
*
sum_scale
;
}
if
(
bias
->
get_element_type
()
!=
element
::
i32
)
{
...
...
src/ngraph/graph_util.cpp
View file @
02559274
...
...
@@ -548,3 +548,19 @@ bool ngraph::is_valid_rank(const std::shared_ptr<Node>& node, std::vector<size_t
}
return
false
;
}
bool
ngraph
::
compare_constants
(
const
std
::
shared_ptr
<
Node
>&
n1
,
const
std
::
shared_ptr
<
Node
>&
n2
)
{
if
(
!
(
n1
->
is_constant
()
&&
n2
->
is_constant
()))
{
return
false
;
}
if
(
static_pointer_cast
<
op
::
Constant
>
(
n1
)
->
get_value_strings
()
!=
static_pointer_cast
<
op
::
Constant
>
(
n2
)
->
get_value_strings
())
{
return
false
;
}
return
true
;
}
src/ngraph/graph_util.hpp
View file @
02559274
...
...
@@ -309,6 +309,8 @@ namespace ngraph
bool
is_one
(
std
::
shared_ptr
<
Node
>
reduce_constant
);
bool
compare_constants
(
const
std
::
shared_ptr
<
Node
>&
n1
,
const
std
::
shared_ptr
<
Node
>&
n2
);
// Returns true if `node` is live in the graph i.e. a result op
// transitively uses this `node`
bool
is_used
(
Node
*
node
);
...
...
src/ngraph/runtime/cpu/builder/quantized_conv.cpp
View file @
02559274
...
...
@@ -334,7 +334,7 @@ namespace ngraph
}
if
(
old_pops
.
kind
(
i
)
==
mkldnn
::
primitive
::
kind
::
sum
)
{
new_pops
.
append_sum
(
2
*
dyn_post_op_scales
[
0
]);
new_pops
.
append_sum
(
dyn_post_op_scales
[
0
]);
}
}
conv_attr
.
set_post_ops
(
new_pops
);
...
...
src/ngraph/runtime/cpu/cpu_external_function.cpp
View file @
02559274
...
...
@@ -1102,6 +1102,7 @@ void runtime::cpu::CPU_ExternalFunction::register_common_passes(ngraph::pass::Ma
REGISTER_KNOBBED_PASS
(
ReshapeElimination
,
false
,
ngraph
::
pass
);
REGISTER_KNOBBED_PASS
(
CoreFusion
,
true
,
ngraph
::
pass
);
REGISTER_KNOBBED_PASS
(
CPUFusion
,
true
,
runtime
::
cpu
::
pass
);
REGISTER_KNOBBED_PASS
(
CPUQuantFusion
,
true
,
runtime
::
cpu
::
pass
);
REGISTER_KNOBBED_PASS
(
CPUHorizontalFusion
,
true
,
runtime
::
cpu
::
pass
);
REGISTER_KNOBBED_PASS
(
CPUCollapseDims
,
true
,
runtime
::
cpu
::
pass
);
#if defined(NGRAPH_HALIDE)
...
...
src/ngraph/runtime/cpu/mkldnn_emitter.hpp
View file @
02559274
...
...
@@ -186,21 +186,14 @@ namespace ngraph
ops
.
append_sum
(
1.
f
);
}
if
(
std
::
is_same
<
OP
,
ngraph
::
op
::
QuantizedConvolutionBiasAdd
>
())
if
(
std
::
is_same
<
OP
,
ngraph
::
op
::
QuantizedConvolutionBiasAdd
>
()
||
std
::
is_same
<
OP
,
ngraph
::
op
::
QuantizedConvolutionBiasSignedAdd
>
())
{
auto
sum_scale_val
=
extract_scale_value
<
ngraph
::
op
::
QuantizedConvolutionBiasAdd
>
(
node
,
5
);
ops
.
append_sum
(
sum_scale_val
[
0
]);
}
if
(
std
::
is_same
<
OP
,
ngraph
::
op
::
QuantizedConvolutionBiasSignedAdd
>
())
{
auto
sum_scale_val
=
extract_scale_value
<
ngraph
::
op
::
QuantizedConvolutionBiasSignedAdd
>
(
node
,
5
);
ops
.
append_sum
(
2.0
*
sum_scale_val
[
0
]);
}
if
(
has_relu
<
OP
>
(
node
))
{
const
float
ops_scale
=
1.
f
;
...
...
@@ -740,21 +733,14 @@ namespace ngraph
ops
.
append_sum
(
1.
f
);
}
if
(
std
::
is_same
<
OP
,
ngraph
::
op
::
QuantizedConvolutionBiasAdd
>
())
if
(
std
::
is_same
<
OP
,
ngraph
::
op
::
QuantizedConvolutionBiasAdd
>
()
||
std
::
is_same
<
OP
,
ngraph
::
op
::
QuantizedConvolutionBiasSignedAdd
>
())
{
auto
sum_scale_val
=
extract_scale_value
<
ngraph
::
op
::
QuantizedConvolutionBiasAdd
>
(
node
,
5
);
ops
.
append_sum
(
sum_scale_val
[
0
]);
}
if
(
std
::
is_same
<
OP
,
ngraph
::
op
::
QuantizedConvolutionBiasSignedAdd
>
())
{
auto
sum_scale_val
=
extract_scale_value
<
ngraph
::
op
::
QuantizedConvolutionBiasSignedAdd
>
(
node
,
5
);
ops
.
append_sum
(
2.0
*
sum_scale_val
[
0
]);
}
if
(
has_relu
<
OP
>
(
node
))
{
const
float
ops_scale
=
1.
f
;
...
...
src/ngraph/runtime/cpu/mkldnn_utils.hpp
View file @
02559274
...
...
@@ -99,11 +99,27 @@ namespace ngraph
{
return
false
;
}
if
(
node
->
get_input_element_type
(
0
)
!=
element
::
f32
)
// Data
if
(
node
->
get_input_element_type
(
0
)
!=
element
::
f32
&&
node
->
get_input_element_type
(
0
)
!=
element
::
i8
&&
node
->
get_input_element_type
(
0
)
!=
element
::
u8
)
{
return
false
;
}
// Weights
if
(
node
->
get_input_element_type
(
1
)
!=
element
::
f32
&&
node
->
get_input_element_type
(
1
)
!=
element
::
i8
)
{
return
false
;
}
// Outputs
if
(
node
->
get_output_element_type
(
0
)
!=
element
::
f32
&&
node
->
get_output_element_type
(
0
)
!=
element
::
i8
&&
node
->
get_output_element_type
(
0
)
!=
element
::
u8
&&
node
->
get_output_element_type
(
0
)
!=
element
::
i32
)
{
return
false
;
}
return
true
;
}
}
...
...
src/ngraph/runtime/cpu/pass/cpu_fusion.cpp
View file @
02559274
This diff is collapsed.
Click to expand it.
src/ngraph/runtime/cpu/pass/cpu_fusion.hpp
View file @
02559274
...
...
@@ -28,6 +28,7 @@ namespace ngraph
namespace
pass
{
class
CPUFusion
;
class
CPUQuantFusion
;
}
}
}
...
...
@@ -101,3 +102,21 @@ private:
void
construct_update_slice
();
void
construct_fuse_lstm_recurrent_state
();
};
class
CPU_BACKEND_API
ngraph
::
runtime
::
cpu
::
pass
::
CPUQuantFusion
:
public
ngraph
::
pass
::
GraphRewrite
{
public
:
CPUQuantFusion
()
:
GraphRewrite
()
{
construct_qconv_relu
(
true
);
construct_qconv_relu
(
false
);
construct_qconvb_add
();
construct_dq_q
();
}
private
:
void
construct_qconv_relu
(
bool
with_bias
);
void
construct_dq_q
();
void
construct_qconvb_add
();
};
test/cpu_fusion.cpp
View file @
02559274
This diff is collapsed.
Click to expand it.
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