[CPU][coverity] fix coverity issue in concat and graph_optimizer (#17191)
* fix coverity issue in concat Signed-off-by: Hu Yuan2 <yuan2.hu@intel.com> * fix coverity issue in graph_optimizer.cpp Signed-off-by: Hu Yuan2 <yuan2.hu@intel.com> * fix review issue Signed-off-by: Hu Yuan2 <yuan2.hu@intel.com> * fix the mistaken that there are two throw Signed-off-by: Hu Yuan2 <yuan2.hu@intel.com> --------- Signed-off-by: Hu Yuan2 <yuan2.hu@intel.com>
This commit is contained in:
@@ -1068,7 +1068,7 @@ void GraphOptimizer::FuseConvolutionAndDWConvolution(Graph &graph) {
|
||||
|
||||
parentConvNode->addFusedNode(childConvNode);
|
||||
|
||||
for (auto node : childConvNode->getFusedWith()) {
|
||||
for (auto& node : childConvNode->getFusedWith()) {
|
||||
parentConvNode->addFusedNode(node);
|
||||
}
|
||||
childConvNode->clearFusedWith();
|
||||
@@ -1226,7 +1226,7 @@ static bool is_data_dependency(const std::shared_ptr<Node> &parent,
|
||||
for (; !nextLayers.empty();) {
|
||||
auto layer = *nextLayers.begin();
|
||||
if (layer == child.get()) return true;
|
||||
for (auto oe : layer->getChildEdges()) {
|
||||
for (auto& oe : layer->getChildEdges()) {
|
||||
auto nn = oe.lock()->getChild();
|
||||
if (visited.find(nn.get()) == visited.end()) {
|
||||
nextLayers.push_back(nn.get());
|
||||
@@ -1837,7 +1837,7 @@ void GraphOptimizer::DropDoubleReorders(Graph &graph) {
|
||||
processed.insert(nextNode);
|
||||
|
||||
EdgePtr edge;
|
||||
for (auto cur : p->getChildEdgesAtPort(oldEdgeNum)) {
|
||||
for (auto& cur : p->getChildEdgesAtPort(oldEdgeNum)) {
|
||||
if (cur->getChild() == c)
|
||||
edge = cur;
|
||||
}
|
||||
@@ -2259,6 +2259,10 @@ void GraphOptimizer::MergeTransposeAndReorder(Graph &graph) {
|
||||
// transposeNode support blocked input & non-blocked output, in the case, the reorder
|
||||
// cannot be optimized
|
||||
auto* transposeNode = dynamic_cast<Transpose*>(parentNode.get());
|
||||
if (transposeNode == nullptr) {
|
||||
IE_THROW() << "[CPU] parent node of type:" << parentNode->getTypeStr() << " with name: "
|
||||
<< parentNode->getName() << " is not a transpose node";
|
||||
}
|
||||
auto inOrder = transposeNode->getSelectedPrimitiveDescriptor()->getConfig().inConfs[0].getMemDesc()->as<BlockedMemoryDesc>()->getOrder();
|
||||
|
||||
if (inOrder.size() > reorderOutDesc->as<BlockedMemoryDesc>()->getOrder().size()) {
|
||||
|
||||
@@ -121,7 +121,7 @@ void Concat::initSupportedPrimitiveDescriptors() {
|
||||
|
||||
// check if blocked layouts are available the channels size should be evenly divided by the block size to avoid slow oneDNN ref implementation
|
||||
if (dstShape.getRank() > channelAxis) {
|
||||
for (auto item : { std::make_pair(8lu, LayoutType::nCsp8c), std::make_pair(16lu, LayoutType::nCsp16c)}) {
|
||||
for (auto& item : { std::make_pair(8lu, LayoutType::nCsp8c), std::make_pair(16lu, LayoutType::nCsp16c)}) {
|
||||
const VectorDims &blkDims = dstShape.getDims();
|
||||
if (blkDims[channelAxis] == Shape::UNDEFINED_DIM || blkDims[channelAxis] % item.first != 0)
|
||||
continue;
|
||||
@@ -360,9 +360,9 @@ void Concat::prepareParams() {
|
||||
return;
|
||||
|
||||
const auto& dstMemPtr = getChildEdgesAtPort(0)[0]->getMemoryPtr();
|
||||
auto dstMemDesc = dstMemPtr->GetDescWithType<BlockedMemoryDesc>();
|
||||
if (!dstMemPtr || !dstMemPtr->isAllocated())
|
||||
IE_THROW() << "Destination memory didn't allocate.";
|
||||
auto dstMemDesc = dstMemPtr->GetDescWithType<BlockedMemoryDesc>();
|
||||
if (getSelectedPrimitiveDescriptor() == nullptr)
|
||||
IE_THROW() << "Preferable primitive descriptor is not set.";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user