Skip to content

Commit

Permalink
restore the old behavior of the getShape() for edge (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim Andronov committed Jul 20, 2021
1 parent 7da61dd commit b1d9790
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 51 deletions.
86 changes: 37 additions & 49 deletions inference-engine/src/mkldnn_plugin/mkldnn_edge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,64 +202,52 @@ void MKLDNNEdge::changeStatus(MKLDNNEdge::Status state) {
status = state;
}

// TODO [DS]: remove while DynamicShapes migration
// TODO [DS]: How should we validate shape compatibility?
// TODO [DS]: Why do we allow uninitialized shape?
const Shape& MKLDNNEdge::getShape() {
// if (!shape.getRank()) {
// Shape inShape;
// Shape outShape;
// auto childPtr = getChild();
// auto parentPtr = getParent();
//
// int inNum = getOutputNum();
// if (inNum < 0) {
// IE_THROW() << "Error cannot find input data for " << child.lock()->getName()
// << " from " << parent.lock()->getName();
// }
// if (inNum < childPtr->inputShapes.size()) {
// outShape = childPtr->inputShapes[inNum];
// }
//
// int outNum = getInputNum();
// if (outNum < 0) {
// IE_THROW() << "Error cannot find output data for " << parent.lock()->getName()
// << " to " << child.lock()->getName();
// }
// if (outNum >= parentPtr->outputShapes.size())
// outNum = 0;
// if (outNum < parentPtr->outputShapes.size()) {
// inShape = parentPtr->outputShapes[outNum];
// }
//
// if (inShape.getRank() && outShape.getRank() && inShape.getRank() != outShape.getRank() && inShape.size() != outShape.size())
// IE_THROW() << "Nodes " << getParent()->getName() << " and " << getChild()->getName()
// << " have incompatible dimensions!";
//
// if (outShape.getRank() != 0) {
// shape = outShape;
// } else if (inShape.getRank() != 0) {
// shape = inShape;
// } else {
// shape = Shape(InferenceEngine::SizeVector({1}));
// }
//
//
// if (!(outShape.getRank() == 0 && inShape.getRank() == 0) && !shape.getRank())
// IE_THROW() << "Cannot detect right dims for nodes " << getParent()->getName()
// << " and " << getChild()->getName();
// }

// TODO [DS]: How should we validate shape compatibility?
// TODO [DS]: Why do we allow uninitialized shape?
if (!shape.getRank()) {
Shape inShape;
Shape outShape;
auto childPtr = getChild();
auto parentPtr = getParent();

int inNum = getOutputNum();
if (inNum < 0) {
IE_THROW() << "Error cannot find input data for " << getParent()->getName()
<< " from " << childPtr->getName();
IE_THROW() << "Error cannot find input data for " << child.lock()->getName()
<< " from " << parent.lock()->getName();
}
if (inNum < childPtr->inputShapes.size()) {
shape = childPtr->inputShapes[inNum];
outShape = childPtr->inputShapes[inNum];
}

int outNum = getInputNum();
if (outNum < 0) {
IE_THROW() << "Error cannot find output data for " << parent.lock()->getName()
<< " to " << child.lock()->getName();
}
if (outNum >= parentPtr->outputShapes.size())
outNum = 0;
if (outNum < parentPtr->outputShapes.size()) {
inShape = parentPtr->outputShapes[outNum];
}

if (inShape.getRank() && outShape.getRank() && inShape.getRank() != outShape.getRank() && inShape.getElementsCount() != outShape.getElementsCount())
IE_THROW() << "Nodes " << getParent()->getName() << " and " << getChild()->getName()
<< " have incompatible dimensions!";

if (outShape.getRank() != 0) {
shape = outShape;
} else if (inShape.getRank() != 0) {
shape = inShape;
} else {
shape = Shape(InferenceEngine::SizeVector({1}));
}


if (!(outShape.getRank() == 0 && inShape.getRank() == 0) && !shape.getRank())
IE_THROW() << "Cannot detect right dims for nodes " << getParent()->getName()
<< " and " << getChild()->getName();
}

return shape;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ std::vector<std::string> disabledTestPatterns() {
R"(.*SetScale.*)",
R"(.*GRUSequenceCPUTest.*)", // reorder BF16
R"(.*LSTMSequenceCPUTest.*)", // reorder BF16
R"(.*RNNSequenceCPUTest.*)", // reorder BF16
R"(.*ConvConcatSubgraphTest.*)" // inPlace
R"(.*RNNSequenceCPUTest.*)" // reorder BF16
};
#ifdef __APPLE__
// TODO: Issue 55717
Expand Down

0 comments on commit b1d9790

Please sign in to comment.