Skip to content

Commit

Permalink
"fix" shape inference of some dnn ops by returning -1 instead of tryi…
Browse files Browse the repository at this point in the history
…ng to calculate proper dimensions based on data that is sometimes just not there :-/

* getShape(getInput()) returns dimensions when input comes from readMatrix() but not if it's a rand() ?!
* getInputHeight(), getInputWidth() does not return proper dimensions
  • Loading branch information
corepointer committed Jul 15, 2024
1 parent 0c4eadf commit 2e51c57
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/ir/daphneir/DaphneInferShapeOpInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,11 @@ std::vector<std::pair<ssize_t, ssize_t>> daphne::BatchNorm2DTestForwardOp::infer
std::vector<std::pair<ssize_t, ssize_t>> daphne::Conv2DForwardOp::inferShape() {
auto shapeX = getShape(getInput());
auto shapeW = getShape(getFilter());

auto Hin = CompilerUtils::constantOrDefault<size_t>(getInputHeight(), 1);
auto Win = CompilerUtils::constantOrDefault<size_t>(getInputWidth(), 1);
// auto Hin = shapeX.first;
// auto Win = shapeX.second;
auto Hf = CompilerUtils::constantOrDefault<size_t>(getFilterHeight(), 1);
auto Wf = CompilerUtils::constantOrDefault<size_t>(getFilterWidth(), 1);
auto padh = CompilerUtils::constantOrDefault<size_t>(getPadHeight(), 1);
Expand All @@ -357,7 +360,8 @@ std::vector<std::pair<ssize_t, ssize_t>> daphne::Conv2DForwardOp::inferShape() {
ssize_t numCols = F == -1 ? -1 : F * Hout * Wout;

// op output is [mat, scalar, scalar] for the convolved data and its dimensions
return {{numRows, numCols}, std::make_pair(1, 1), std::make_pair(1, 1)};
// return {{numRows, numCols}, std::make_pair(1, 1), std::make_pair(1, 1)};
return {{-1, -1}, std::make_pair(1, 1), std::make_pair(1, 1)};
}

std::vector<std::pair<ssize_t, ssize_t>> daphne::AvgPoolForwardOp::inferShape() {
Expand All @@ -377,7 +381,8 @@ std::vector<std::pair<ssize_t, ssize_t>> daphne::AvgPoolForwardOp::inferShape()
auto numCols = C * Hout * Wout;

// op output is [mat, scalar, scalar] for the convolved data and its dimensions
return {{numRows, numCols}, std::make_pair(1, 1), std::make_pair(1, 1)};
// return {{numRows, numCols}, std::make_pair(1, 1), std::make_pair(1, 1)};
return {{-1, -1}, std::make_pair(1, 1), std::make_pair(1, 1)};
}

std::vector<std::pair<ssize_t, ssize_t>> daphne::MaxPoolForwardOp::inferShape() {
Expand All @@ -397,7 +402,8 @@ std::vector<std::pair<ssize_t, ssize_t>> daphne::MaxPoolForwardOp::inferShape()
auto numCols = C * Hout * Wout;

// op output is [mat, scalar, scalar] for the convolved data and its dimensions
return {{numRows, numCols}, std::make_pair(1, 1), std::make_pair(1, 1)};
// return {{numRows, numCols}, std::make_pair(1, 1), std::make_pair(1, 1)};
return {{-1, -1}, std::make_pair(1, 1), std::make_pair(1, 1)};
}

std::vector<std::pair<ssize_t, ssize_t>> daphne::CTableOp::inferShape() {
Expand Down

0 comments on commit 2e51c57

Please sign in to comment.