Skip to content

Commit

Permalink
[CPU] int8 deconvolution support
Browse files Browse the repository at this point in the history
  • Loading branch information
antonvor committed May 17, 2021
1 parent ba14905 commit a77552c
Show file tree
Hide file tree
Showing 7 changed files with 225 additions and 54 deletions.
12 changes: 12 additions & 0 deletions inference-engine/src/mkldnn_plugin/mkldnn_descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ MKLDNNDescriptor::operator std::shared_ptr<mkldnn::convolution_forward::desc>()
return typeDesc->getPtr();
}

MKLDNNDescriptor::MKLDNNDescriptor(std::shared_ptr<mkldnn::deconvolution_forward::desc> desc) {
this->desc.reset(new DescFwdImpl<mkldnn::deconvolution_forward::desc>(desc));
}

MKLDNNDescriptor::operator std::shared_ptr<mkldnn::deconvolution_forward::desc>() {
auto typeDesc = std::dynamic_pointer_cast<DescFwdImpl<mkldnn::deconvolution_forward::desc>>(desc);
if (typeDesc == nullptr) {
IE_THROW() << "Cannot cast descriptor!";
}
return typeDesc->getPtr();
}

MKLDNNDescriptor::MKLDNNDescriptor(std::shared_ptr<mkldnn::convolution_backward_data::desc> desc,
std::shared_ptr<mkldnn::convolution_forward::primitive_desc> prim) {
this->desc.reset(
Expand Down
7 changes: 7 additions & 0 deletions inference-engine/src/mkldnn_plugin/mkldnn_descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ class MKLDNNDescriptor {

MKLDNNDescriptor(std::shared_ptr<mkldnn::convolution_backward_data::desc> desc,
std::shared_ptr<mkldnn::convolution_forward::primitive_desc> prim);

explicit MKLDNNDescriptor(std::shared_ptr<mkldnn::deconvolution_forward::desc> desc);
operator std::shared_ptr<mkldnn::deconvolution_forward::desc>();

MKLDNNDescriptor(std::shared_ptr<mkldnn::deconvolution_forward::desc> desc,
std::shared_ptr<mkldnn::deconvolution_forward::primitive_desc> prim);

operator std::shared_ptr<mkldnn::convolution_backward_data::desc>();
operator std::shared_ptr<mkldnn::convolution_forward::primitive_desc>();

Expand Down
1 change: 1 addition & 0 deletions inference-engine/src/mkldnn_plugin/mkldnn_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ void MKLDNNGraph::InitGraph() {
SortTopologically();

InitDescriptors();
RemoveDroppedEdges();

InitOptimalPrimitiveDescriptors();

Expand Down
3 changes: 2 additions & 1 deletion inference-engine/src/mkldnn_plugin/mkldnn_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,8 @@ static void Transformation(CNNNetwork& clonedNetwork, const Config& conf) {
LayerTransformation::Params(params).setPrecisionsOnActivations({ ngraph::element::u8 }).setSupportAsymmetricQuantization(true))
.addStandaloneCleanup<MultiplyToGroupConvolutionTransformation, ngraph::opset1::Multiply>(
LayerTransformation::Params(params).setPrecisionsOnActivations({ ngraph::element::u8 }))
.remove<ConvolutionBackpropDataTransformation, ngraph::opset1::ConvolutionBackpropData>());
.add<ConvolutionBackpropDataTransformation, ngraph::opset1::ConvolutionBackpropData>(
LayerTransformation::Params(params).setSupportAsymmetricQuantization(false)));

transformer.transform(nGraphFunc);
}
Expand Down
249 changes: 197 additions & 52 deletions inference-engine/src/mkldnn_plugin/nodes/mkldnn_deconv_node.cpp

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions inference-engine/src/mkldnn_plugin/nodes/mkldnn_deconv_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ class MKLDNNDeconvolutionNode : public MKLDNNNode {
private:
bool withGroups = false;
bool isDW = false;
bool isInt8 = false;
size_t groupNum = 1;
size_t outDepth;
size_t IC;
size_t OC;
std::vector<ptrdiff_t> kernel;
std::vector<ptrdiff_t> stride;
std::vector<ptrdiff_t> dilation;
std::vector<ptrdiff_t> paddingL;
Expand All @@ -57,6 +59,9 @@ class MKLDNNDeconvolutionNode : public MKLDNNNode {
void setPostOps(mkldnn::primitive_attr &attr);

std::string errorPrefix;

bool canBeExecutedInInt8();
InferenceEngine::Blob::Ptr createWeiBlobAsIO(InferenceEngine::SizeVector dims);
};

} // namespace MKLDNNPlugin
Expand Down

0 comments on commit a77552c

Please sign in to comment.