Skip to content

Commit

Permalink
[CPU] Deconvolution int8 support (#5565)
Browse files Browse the repository at this point in the history
  • Loading branch information
antonvor authored May 21, 2021
1 parent 5a42015 commit 5e4c3c4
Show file tree
Hide file tree
Showing 8 changed files with 217 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
4 changes: 4 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,10 @@ 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>();

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 @@ -334,7 +334,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
243 changes: 191 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
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ std::vector<std::string> disabledTestPatterns() {
R"(.*ClampLayerTest.*netPrc=U64.*)",
// TODO: 42538. Unexpected application crush
R"(.*CoreThreadingTestsWithIterations\.smoke_LoadNetwork.t.*)",
R"(.*CoreThreadingTestsWithIterations\.smoke_LoadNetworkAccuracy.*AUTO.*)",

// incorrect reference implementation
R"(.*NormalizeL2LayerTest.*axes=\(\).*)",
Expand Down

0 comments on commit 5e4c3c4

Please sign in to comment.