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
90410792
Commit
90410792
authored
May 22, 2019
by
nishant.b.patel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add axes as an argument in the QC api
parent
954da585
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
16 deletions
+17
-16
quantized_conv_builder.cpp
src/ngraph/builder/quantized_conv_builder.cpp
+4
-1
quantized_convolution.cpp
src/ngraph/op/quantized_convolution.cpp
+5
-2
quantized_convolution.hpp
src/ngraph/op/quantized_convolution.hpp
+4
-1
quantized_conv.cpp
src/ngraph/runtime/cpu/builder/quantized_conv.cpp
+4
-12
No files found.
src/ngraph/builder/quantized_conv_builder.cpp
View file @
90410792
...
@@ -53,6 +53,8 @@ namespace ngraph
...
@@ -53,6 +53,8 @@ namespace ngraph
auto
filter_zero_point
=
auto
filter_zero_point
=
op
::
Constant
::
create
(
filters
->
get_element_type
(),
Shape
{},
{
0
});
op
::
Constant
::
create
(
filters
->
get_element_type
(),
Shape
{},
{
0
});
AxisSet
quantization_axes
;
return
make_shared
<
op
::
QuantizedConvolution
>
(
return
make_shared
<
op
::
QuantizedConvolution
>
(
input
,
input
,
filters
,
filters
,
...
@@ -67,7 +69,8 @@ namespace ngraph
...
@@ -67,7 +69,8 @@ namespace ngraph
filter_zero_point
,
filter_zero_point
,
output_scale
,
output_scale
,
filter_zero_point
,
// output type will be same as filter
filter_zero_point
,
// output type will be same as filter
output_type
);
output_type
,
quantization_axes
);
}
}
}
}
}
}
src/ngraph/op/quantized_convolution.cpp
View file @
90410792
...
@@ -37,7 +37,8 @@ op::QuantizedConvolution::QuantizedConvolution(const shared_ptr<Node>& input,
...
@@ -37,7 +37,8 @@ op::QuantizedConvolution::QuantizedConvolution(const shared_ptr<Node>& input,
const
std
::
shared_ptr
<
Node
>&
filter_zero_point
,
const
std
::
shared_ptr
<
Node
>&
filter_zero_point
,
const
std
::
shared_ptr
<
Node
>&
output_scale
,
const
std
::
shared_ptr
<
Node
>&
output_scale
,
const
std
::
shared_ptr
<
Node
>&
output_zero_point
,
const
std
::
shared_ptr
<
Node
>&
output_zero_point
,
const
ngraph
::
element
::
Type
&
output_type
)
const
ngraph
::
element
::
Type
&
output_type
,
const
ngraph
::
AxisSet
&
axes
)
:
Op
(
"QuantizedConvolution"
,
:
Op
(
"QuantizedConvolution"
,
check_single_output_args
({
input
,
check_single_output_args
({
input
,
filters
,
filters
,
...
@@ -53,6 +54,7 @@ op::QuantizedConvolution::QuantizedConvolution(const shared_ptr<Node>& input,
...
@@ -53,6 +54,7 @@ op::QuantizedConvolution::QuantizedConvolution(const shared_ptr<Node>& input,
,
m_padding_above
(
padding_above
)
,
m_padding_above
(
padding_above
)
,
m_data_dilation_strides
(
data_dilation_strides
)
,
m_data_dilation_strides
(
data_dilation_strides
)
,
m_output_type
(
output_type
)
,
m_output_type
(
output_type
)
,
m_axes
(
axes
)
{
{
constructor_validate_and_infer_types
();
constructor_validate_and_infer_types
();
}
}
...
@@ -162,5 +164,6 @@ shared_ptr<Node> op::QuantizedConvolution::copy_with_new_args(const NodeVector&
...
@@ -162,5 +164,6 @@ shared_ptr<Node> op::QuantizedConvolution::copy_with_new_args(const NodeVector&
new_args
.
at
(
5
),
new_args
.
at
(
5
),
new_args
.
at
(
6
),
new_args
.
at
(
6
),
new_args
.
at
(
7
),
new_args
.
at
(
7
),
m_output_type
));
m_output_type
,
m_axes
));
}
}
src/ngraph/op/quantized_convolution.hpp
View file @
90410792
...
@@ -56,7 +56,8 @@ namespace ngraph
...
@@ -56,7 +56,8 @@ namespace ngraph
const
std
::
shared_ptr
<
Node
>&
filter_zero_point
,
const
std
::
shared_ptr
<
Node
>&
filter_zero_point
,
const
std
::
shared_ptr
<
Node
>&
output_scale
,
const
std
::
shared_ptr
<
Node
>&
output_scale
,
const
std
::
shared_ptr
<
Node
>&
output_zero_point
,
const
std
::
shared_ptr
<
Node
>&
output_zero_point
,
const
ngraph
::
element
::
Type
&
output_type
);
const
ngraph
::
element
::
Type
&
output_type
,
const
ngraph
::
AxisSet
&
axes
);
const
Strides
&
get_window_movement_strides
()
const
{
return
m_window_movement_strides
;
}
const
Strides
&
get_window_movement_strides
()
const
{
return
m_window_movement_strides
;
}
const
Strides
&
get_window_dilation_strides
()
const
{
return
m_window_dilation_strides
;
}
const
Strides
&
get_window_dilation_strides
()
const
{
return
m_window_dilation_strides
;
}
const
CoordinateDiff
&
get_padding_below
()
const
{
return
m_padding_below
;
}
const
CoordinateDiff
&
get_padding_below
()
const
{
return
m_padding_below
;
}
...
@@ -65,6 +66,7 @@ namespace ngraph
...
@@ -65,6 +66,7 @@ namespace ngraph
std
::
shared_ptr
<
Node
>
get_filters
()
{
return
get_argument
(
1
);
}
std
::
shared_ptr
<
Node
>
get_filters
()
{
return
get_argument
(
1
);
}
std
::
shared_ptr
<
Node
>
get_data_batch
()
{
return
get_argument
(
0
);
}
std
::
shared_ptr
<
Node
>
get_data_batch
()
{
return
get_argument
(
0
);
}
const
ngraph
::
element
::
Type
&
get_output_type
()
const
{
return
m_output_type
;
}
const
ngraph
::
element
::
Type
&
get_output_type
()
const
{
return
m_output_type
;
}
const
ngraph
::
AxisSet
&
get_axes
()
const
{
return
m_axes
;
}
void
validate_and_infer_types
()
override
;
void
validate_and_infer_types
()
override
;
virtual
std
::
shared_ptr
<
Node
>
virtual
std
::
shared_ptr
<
Node
>
copy_with_new_args
(
const
NodeVector
&
new_args
)
const
override
;
copy_with_new_args
(
const
NodeVector
&
new_args
)
const
override
;
...
@@ -76,6 +78,7 @@ namespace ngraph
...
@@ -76,6 +78,7 @@ namespace ngraph
CoordinateDiff
m_padding_above
;
CoordinateDiff
m_padding_above
;
Strides
m_data_dilation_strides
;
Strides
m_data_dilation_strides
;
ngraph
::
element
::
Type
m_output_type
;
ngraph
::
element
::
Type
m_output_type
;
ngraph
::
AxisSet
m_axes
;
};
};
}
}
}
}
src/ngraph/runtime/cpu/builder/quantized_conv.cpp
View file @
90410792
...
@@ -88,20 +88,12 @@ namespace ngraph
...
@@ -88,20 +88,12 @@ namespace ngraph
{
{
vector
<
float
>
dyn_scales
;
vector
<
float
>
dyn_scales
;
// Calculate the requantization scale
// Calculate the requantization scale
for
(
size_t
i
=
0
;
i
<
scales_size
;
i
++
)
{
dyn_scales
.
push_back
(
dyn_scales
.
push_back
(
*
(
static_cast
<
float
*>
(
ctx
->
buffer_data
[
arg2_buffer_index
])
+
*
(
static_cast
<
float
*>
(
ctx
->
buffer_data
[
arg2_buffer_index
]))
*
i
)
*
*
(
static_cast
<
float
*>
(
ctx
->
buffer_data
[
arg4_buffer_index
]))
/
*
(
static_cast
<
float
*>
(
ctx
->
buffer_data
[
arg4_buffer_index
])
+
*
(
static_cast
<
float
*>
(
ctx
->
buffer_data
[
arg6_buffer_index
])));
i
)
/
*
(
static_cast
<
float
*>
(
ctx
->
buffer_data
[
arg6_buffer_index
])
+
i
));
}
std
::
cout
<<
"SCALE "
<<
dyn_scales
[
0
]
<<
std
::
endl
;
// use conv channelwise (dim 1, mask=2^1) if dyn_scales is a vector
// use conv channelwise (dim 1, mask=2^1) if dyn_scales is a vector
const
int
mask
=
scales_size
==
1
?
0
:
2
;
conv_attr
.
set_output_scales
(
0
,
dyn_scales
);
conv_attr
.
set_output_scales
(
mask
,
dyn_scales
);
mkldnn_emitter
->
build_convolution_forward
<
false
>
(
mkldnn_emitter
->
build_convolution_forward
<
false
>
(
ctx
->
mkldnn_primitives
,
ctx
->
mkldnn_primitives
,
conv_desc
,
conv_desc
,
...
...
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