Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ResolveDilatedConv bug fix #28410

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ namespace toco {
//
// SpaceToBatchND -> Expand -> Conv2D -> Squeeze -> BatchToSpaceND -> BiasAdd
//
// Pad -> SpaceToBatchND -> Expand -> Conv2D -> Squeeze -> BatchToSpaceND ->
// BiasAdd
//
// SpaceToBatchND -> Expand -> Conv2D -> Squeeze -> Pad -> BatchToSpaceND ->
// BiasAdd
//
Expand Down Expand Up @@ -119,6 +122,19 @@ bool ResolveDilatedConv(Model* model, Operator* conv_base_op, Operator* stb_op,
CHECK_EQ(bias_add_op->inputs.size(), 2);
CHECK_EQ(bias_add_op->outputs.size(), 1);

// If still Pad Op is not present, there might be possiblity it is added
// before STB Op like below Pad -> SpaceToBatchND -> Expand -> Conv2D ->
// Squeeze -> BatchToSpaceND -> BiasAdd So eliminate this Pad Op as well
if (!has_pad_op) {
auto* pre_stb_pad_op = GetOpWithOutput(*model, stb_op->inputs[0]);
// If it is a Pad Op then just rewire the Input of Pad Op with Input of STB
if (pre_stb_pad_op->type == OperatorType::kPad) {
stb_op->inputs[0] = pre_stb_pad_op->inputs[0];
has_pad_op = true;
pad_op = pre_stb_pad_op;
}
}

// 2. RE-WIRE OPERATORS
// ***************************************************************************
// Re-use the existing Conv2D op.
Expand Down