[CPU] Fixed legacy post ops behavior (#10542)

This commit is contained in:
Gorokhov Dmitriy
2022-02-21 16:09:29 +03:00
committed by GitHub
parent 68e873c6c8
commit f53f09f020
3 changed files with 8 additions and 4 deletions

View File

@@ -2083,7 +2083,6 @@ void MKLDNNEltwiseNode::appendPostOpsImpl(mkldnn::post_ops& ops, const VectorDim
}
} else {
const size_t chIdx = postOpDims.size() > 1 ? getFusingAxis() : 0;
constexpr int bufferAlignment = 16; // always align for legacy scale/shift post ops
// since legacy depthwise post ops mechanism requires broadcasted data we need to reinitilize it in case of changed shape
if (depthwiseData.empty() || depthwiseDataSize != 2 * postOpDims[chIdx]) {
depthwiseData.clear();
@@ -2106,7 +2105,10 @@ void MKLDNNEltwiseNode::appendPostOpsImpl(mkldnn::post_ops& ops, const VectorDim
}
depthwiseDataSize = 2 * postOpDims[chIdx];
depthwiseData.resize(rnd_up(depthwiseData.size(), bufferAlignment), 0);
// always align for legacy scale/shift post ops
constexpr int bufferAlignment = 16;
int bufferPaddingSize = rnd_up(postOpDims[chIdx], bufferAlignment) - postOpDims[chIdx];
depthwiseData.resize(depthwiseDataSize + bufferPaddingSize, 0);
}
if (depthwiseData.empty())

View File

@@ -1791,7 +1791,9 @@ void MKLDNNFakeQuantizeNode::initializePostOpDataLegacy(const VectorDims &dims,
quantizationData.insert(quantizationData.end(), outputScale.begin(), outputScale.end());
quantizationData.insert(quantizationData.end(), outputShift.begin(), outputShift.end());
quantizationDataSize = quantizationData.size();
quantizationData.resize(rnd_up(quantizationData.size(), bufferAlignment), 0);
int bufferPaddingSize = rnd_up(outputShift.size(), bufferAlignment) - outputShift.size();
quantizationData.resize(quantizationDataSize + bufferPaddingSize, 0);
}
isPostOpDataInitialized = true;