diff --git a/builtin_op_importers.cpp b/builtin_op_importers.cpp index d62d555e..b91cbb45 100644 --- a/builtin_op_importers.cpp +++ b/builtin_op_importers.cpp @@ -2445,11 +2445,11 @@ DEFINE_BUILTIN_OP_IMPORTER(Resize) auto mode = attrs.get("mode", "nearest"); auto resizeMode = mode == "nearest" ? nvinfer1::ResizeMode::kNEAREST : nvinfer1::ResizeMode::kLINEAR; + auto transformationMode = attrs.get("coordinate_transformation_mode", "half_pixel"); if (ctx->getOpsetVersion() >= 11) { - auto transformationMode = attrs.get("coordinate_transformation_mode", "half_pixel"); - ASSERT((transformationMode == "asymmetric") && "This version of TensorRT only supports asymmetric resize!", + ASSERT(((transformationMode == "asymmetric") || (transformationMode == "align_corners")) && "This version of TensorRT only supports asymmetric and align_corners resize!", ErrorCode::kUNSUPPORTED_NODE); ASSERT(mode != "cubic" && "This version of TensorRT does not support cubic interpolation!", ErrorCode::kUNSUPPORTED_NODE); @@ -2464,11 +2464,14 @@ DEFINE_BUILTIN_OP_IMPORTER(Resize) auto* resizeShape = &convertToTensor(inputs.at(3), ctx); layer->setInput(1, *resizeShape); layer->setResizeMode(resizeMode); + if (transformationMode=="align_corners") + layer->setAlignCorners(true); RETURN_FIRST_OUTPUT(layer); } } // Resizes that use scale factors have the same import logic between opsets + ASSERT(transformationMode != "align_corners" && "Align_corners should use size information not scale factors!", ErrorCode::kUNSUPPORTED_NODE); auto scales = ctx->getOpsetVersion() >= 11 ? inputs.at(2) : inputs.at(1); ASSERT(scales.is_weights() && "Resize scales must be an initializer!", ErrorCode::kUNSUPPORTED_NODE); ShapedWeights scales_weights = scales.weights();