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
954da585
Commit
954da585
authored
May 22, 2019
by
nishant.b.patel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add QuantizedConvolution::validate_and_infer_types()
parent
bdf082d9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
54 deletions
+71
-54
quantized_conv_builder.cpp
src/ngraph/builder/quantized_conv_builder.cpp
+18
-15
quantized_convolution.cpp
src/ngraph/op/quantized_convolution.cpp
+51
-37
quantized_convolution.hpp
src/ngraph/op/quantized_convolution.hpp
+2
-2
No files found.
src/ngraph/builder/quantized_conv_builder.cpp
View file @
954da585
...
...
@@ -49,22 +49,25 @@ namespace ngraph
// TODO: Check for this later
// For Builders the zero point is assumed to be zero (for now)
auto
zero_point
=
op
::
Constant
::
create
(
output_type
,
Shape
{},
{
0
});
auto
input_zero_point
=
op
::
Constant
::
create
(
input
->
get_element_type
(),
Shape
{},
{
0
});
auto
filter_zero_point
=
op
::
Constant
::
create
(
filters
->
get_element_type
(),
Shape
{},
{
0
});
return
make_shared
<
op
::
QuantizedConvolution
>
(
input
,
filters
,
window_movement_strides
,
window_dilation_strides
,
padding_below
,
padding_above
,
data_dilation_strides
,
input_scale
,
zero_point
,
filter_scale
,
zero_point
,
output_scale
,
zero_point
,
output_type
);
return
make_shared
<
op
::
QuantizedConvolution
>
(
input
,
filters
,
window_movement_strides
,
window_dilation_strides
,
padding_below
,
padding_above
,
data_dilation_strides
,
input_scale
,
input_zero_point
,
filter_scale
,
filter_zero_point
,
output_scale
,
filter_zero_point
,
// output type will be same as filter
output_type
);
}
}
}
src/ngraph/op/quantized_convolution.cpp
View file @
954da585
...
...
@@ -24,7 +24,7 @@
using
namespace
std
;
using
namespace
ngraph
;
op
::
QuantizedConvolution
::
QuantizedConvolution
(
const
shared_ptr
<
Node
>&
data_batch
,
op
::
QuantizedConvolution
::
QuantizedConvolution
(
const
shared_ptr
<
Node
>&
input
,
const
shared_ptr
<
Node
>&
filters
,
const
Strides
&
window_movement_strides
,
const
Strides
&
window_dilation_strides
,
...
...
@@ -39,7 +39,7 @@ op::QuantizedConvolution::QuantizedConvolution(const shared_ptr<Node>& data_batc
const
std
::
shared_ptr
<
Node
>&
output_zero_point
,
const
ngraph
::
element
::
Type
&
output_type
)
:
Op
(
"QuantizedConvolution"
,
check_single_output_args
({
data_batch
,
check_single_output_args
({
input
,
filters
,
input_scale
,
input_zero_point
,
...
...
@@ -55,66 +55,82 @@ op::QuantizedConvolution::QuantizedConvolution(const shared_ptr<Node>& data_batc
,
m_output_type
(
output_type
)
{
constructor_validate_and_infer_types
();
auto
&
data_batch_shape
=
data_batch
->
get_shape
();
auto
&
filters_shape
=
filters
->
get_shape
();
set_output_type
(
0
,
output_type
,
util
::
infer_convolution_output_shape
(
this
,
data_batch_shape
,
filters_shape
,
window_movement_strides
,
window_dilation_strides
,
padding_below
,
padding_above
,
data_dilation_strides
,
0
,
/* batch_axis_data, */
1
,
/* input_channel_axis_data, */
1
,
/* input_channel_axis_filters, */
0
,
/* output_channel_axis_filters, */
0
,
/* batch_axis_result, */
1
/* output_channel_axis_result, */
));
}
#if 0
void
op
::
QuantizedConvolution
::
validate_and_infer_types
()
{
const Shape& data_batch_shape = get_input_shape(0);
element::Type data_batch_et = get_input_element_type(0);
const Shape& filters_shape = get_input_shape(1);
element::Type filters_et = get_input_element_type(1);
enum
{
INPUT_SCALE
=
2
,
INPUT_ZERO_POINT
,
FILTER_SCALE
,
FILTER_ZERO_POINT
,
OUTPUT_SCALE
,
OUTPUT_ZERO_POINT
};
NODE_VALIDATION_CHECK
(
this
,
get_input_element_type
(
INPUT_SCALE
).
is_real
()
||
get_input_element_type
(
FILTER_SCALE
).
is_real
()
||
get_input_element_type
(
OUTPUT_SCALE
).
is_real
(),
"Scale must be a floating point number"
);
NODE_VALIDATION_CHECK
(
this
,
get_input_element_type
(
0
)
==
get_input_element_type
(
INPUT_ZERO_POINT
),
"Input Zero point element type ("
,
get_input_element_type
(
INPUT_ZERO_POINT
),
") must match Input element type ("
,
get_input_element_type
(
0
),
")"
);
NODE_VALIDATION_CHECK
(
this
,
get_input_element_type
(
1
)
==
get_input_element_type
(
FILTER_ZERO_POINT
),
"Filter Zero point element type ("
,
get_input_element_type
(
FILTER_ZERO_POINT
),
") must match Input element type ("
,
get_input_element_type
(
1
),
")"
);
NODE_VALIDATION_CHECK
(
this
,
get_input_element_type
(
1
)
==
get_input_element_type
(
OUTPUT_ZERO_POINT
),
"Output Zero point element type ("
,
get_input_element_type
(
OUTPUT_ZERO_POINT
),
") must match Input element type ("
,
get_input_element_type
(
1
),
")"
);
auto
input_shape
=
get_input_shape
(
0
);
auto
filters_shape
=
get_input_shape
(
1
);
if
(
m_data_dilation_strides
.
size
()
==
0
)
{
m_data_dilation_strides = conv_default_strides(this,
data_batch
_shape, filters_shape);
m_data_dilation_strides
=
conv_default_strides
(
this
,
input
_shape
,
filters_shape
);
}
if
(
m_window_movement_strides
.
size
()
==
0
)
{
m_window_movement_strides = conv_default_strides(this,
data_batch
_shape, filters_shape);
m_window_movement_strides
=
conv_default_strides
(
this
,
input
_shape
,
filters_shape
);
}
if
(
m_window_dilation_strides
.
size
()
==
0
)
{
m_window_dilation_strides = conv_default_strides(this,
data_batch
_shape, filters_shape);
m_window_dilation_strides
=
conv_default_strides
(
this
,
input
_shape
,
filters_shape
);
}
if
(
m_padding_below
.
size
()
==
0
)
{
m_padding_below = conv_default_padding(this,
data_batch
_shape, filters_shape);
m_padding_below
=
conv_default_padding
(
this
,
input
_shape
,
filters_shape
);
}
if
(
m_padding_above
.
size
()
==
0
)
{
m_padding_above = conv_default_padding(this,
data_batch
_shape, filters_shape);
m_padding_above
=
conv_default_padding
(
this
,
input
_shape
,
filters_shape
);
}
set_output_type(0,
set_output_type
(
0
,
m_output_type
,
util
::
infer_convolution_output_shape
(
this
,
data_batch
_shape,
input
_shape
,
filters_shape
,
m_window_movement_strides
,
m_window_dilation_strides
,
...
...
@@ -128,9 +144,7 @@ void op::QuantizedConvolution::validate_and_infer_types()
0
,
/* batch_axis_result, */
1
/* output_channel_axis_result, */
));
}
#endif
shared_ptr
<
Node
>
op
::
QuantizedConvolution
::
copy_with_new_args
(
const
NodeVector
&
new_args
)
const
{
...
...
src/ngraph/op/quantized_convolution.hpp
View file @
954da585
...
...
@@ -43,7 +43,7 @@ namespace ngraph
/// \param output_zero_point Zero point used for mapping
/// \param output_type Output element type
///
QuantizedConvolution
(
const
std
::
shared_ptr
<
Node
>&
data_batch
,
QuantizedConvolution
(
const
std
::
shared_ptr
<
Node
>&
input
,
const
std
::
shared_ptr
<
Node
>&
filters
,
const
Strides
&
window_movement_strides
,
const
Strides
&
window_dilation_strides
,
...
...
@@ -65,7 +65,7 @@ namespace ngraph
std
::
shared_ptr
<
Node
>
get_filters
()
{
return
get_argument
(
1
);
}
std
::
shared_ptr
<
Node
>
get_data_batch
()
{
return
get_argument
(
0
);
}
const
ngraph
::
element
::
Type
&
get_output_type
()
const
{
return
m_output_type
;
}
//
void validate_and_infer_types() override;
void
validate_and_infer_types
()
override
;
virtual
std
::
shared_ptr
<
Node
>
copy_with_new_args
(
const
NodeVector
&
new_args
)
const
override
;
...
...
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