From 0ef2d96d2d022a83bacf6f91f4a7de6748846665 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=8B=87=E8=B4=A4?= Date: Thu, 5 Jan 2023 10:26:12 +0800 Subject: [PATCH] [MSLITE] Fix bug for strideslice stride and tensorflow parser for resize --- .../src/extendrt/delegate/tensorrt/op/convolution_tensorrt.cc | 4 ---- .../lite/src/extendrt/delegate/tensorrt/op/pool_tensorrt.cc | 4 ---- .../src/extendrt/delegate/tensorrt/op/strideslice_tensorrt.cc | 1 + mindspore/lite/tools/converter/parser/tf/tf_resize_parser.cc | 1 + mindspore/lite/tools/optimizer/fusion/resize_fusion.cc | 4 ---- 5 files changed, 2 insertions(+), 12 deletions(-) diff --git a/mindspore/lite/src/extendrt/delegate/tensorrt/op/convolution_tensorrt.cc b/mindspore/lite/src/extendrt/delegate/tensorrt/op/convolution_tensorrt.cc index 78a619dad68..f47bc1ec7a3 100644 --- a/mindspore/lite/src/extendrt/delegate/tensorrt/op/convolution_tensorrt.cc +++ b/mindspore/lite/src/extendrt/delegate/tensorrt/op/convolution_tensorrt.cc @@ -23,10 +23,6 @@ constexpr int BIAS_INDEX = 2; int ConvolutionTensorRT::IsSupport(const schema::Primitive *primitive, const std::vector &in_tensors, const std::vector &out_tensors) { - if (!IsShapeKnown()) { - MS_LOG(ERROR) << "Unsupported input tensor unknown shape: " << op_name_; - return RET_ERROR; - } if (in_tensors.size() != INPUT_SIZE2 && in_tensors.size() != INPUT_SIZE3) { MS_LOG(ERROR) << "Unsupported input tensor size, size is " << in_tensors.size(); return RET_ERROR; diff --git a/mindspore/lite/src/extendrt/delegate/tensorrt/op/pool_tensorrt.cc b/mindspore/lite/src/extendrt/delegate/tensorrt/op/pool_tensorrt.cc index 8568f6e0db6..768cfe8941b 100644 --- a/mindspore/lite/src/extendrt/delegate/tensorrt/op/pool_tensorrt.cc +++ b/mindspore/lite/src/extendrt/delegate/tensorrt/op/pool_tensorrt.cc @@ -22,10 +22,6 @@ namespace mindspore::lite { int PoolTensorRT::IsSupport(const mindspore::schema::Primitive *primitive, const std::vector &in_tensors, const std::vector &out_tensors) { - if (!IsShapeKnown()) { - MS_LOG(ERROR) << "Unsupported input tensor unknown shape: " << op_name_; - return RET_ERROR; - } if (in_tensors.size() != 1) { MS_LOG(ERROR) << "Unsupported input tensor size, size is " << in_tensors.size(); return RET_ERROR; diff --git a/mindspore/lite/src/extendrt/delegate/tensorrt/op/strideslice_tensorrt.cc b/mindspore/lite/src/extendrt/delegate/tensorrt/op/strideslice_tensorrt.cc index b7874db3737..c766f4a3dc0 100644 --- a/mindspore/lite/src/extendrt/delegate/tensorrt/op/strideslice_tensorrt.cc +++ b/mindspore/lite/src/extendrt/delegate/tensorrt/op/strideslice_tensorrt.cc @@ -249,6 +249,7 @@ int StrideSliceTensorRT::ComputeDimsSingle(TensorRTContext *ctx, ITensorHelper * } else { size_dims_.d[i] = input_dims.d[i]; } + size_dims_.d[i] = std::abs(size_dims_.d[i] / stride_dims_.d[i]) + ((size_dims_.d[i] % stride_dims_.d[i]) != 0); } } return RET_OK; diff --git a/mindspore/lite/tools/converter/parser/tf/tf_resize_parser.cc b/mindspore/lite/tools/converter/parser/tf/tf_resize_parser.cc index 7a5262e9540..aaa11cc5783 100644 --- a/mindspore/lite/tools/converter/parser/tf/tf_resize_parser.cc +++ b/mindspore/lite/tools/converter/parser/tf/tf_resize_parser.cc @@ -44,6 +44,7 @@ PrimitiveCPtr TFResizeParser::Parse(const tensorflow::NodeDef &tf_op, } else if (TensorFlowUtils::FindAttrValue(tf_op, "half_pixel_centers", &attr_value) && attr_value.b()) { prim->set_coordinate_transform_mode(mindspore::CoordinateTransformMode::HALF_PIXEL); prim->set_cubic_coeff(-0.5f); + prim->set_nearest_mode(mindspore::NearestMode::ROUND_HALF_UP); prim_c->AddAttr("half_pixel_centers", MakeValue(true)); } else { prim->set_coordinate_transform_mode(mindspore::CoordinateTransformMode::ASYMMETRIC); diff --git a/mindspore/lite/tools/optimizer/fusion/resize_fusion.cc b/mindspore/lite/tools/optimizer/fusion/resize_fusion.cc index 6d4ddd0d563..924391f418b 100644 --- a/mindspore/lite/tools/optimizer/fusion/resize_fusion.cc +++ b/mindspore/lite/tools/optimizer/fusion/resize_fusion.cc @@ -93,7 +93,6 @@ const BaseRef ResizeFusion1::DefinePattern() const { } const BaseRef ResizeFusion2::DefinePattern() const { - MS_LOG(WARNING) << "DefinePattern begin"; input_ = std::make_shared(); MS_CHECK_TRUE_RET(input_ != nullptr, false); @@ -145,7 +144,6 @@ const BaseRef ResizeFusion2::DefinePattern() const { auto is_resize = std::make_shared(IsSpecifiedNode<&prim::kPrimResize>); MS_CHECK_TRUE_RET(is_resize != nullptr, {}); VectorRef resize_ref = VectorRef({is_resize, input_, gather_ref}); - MS_LOG(WARNING) << "DefinePattern end"; return resize_ref; } @@ -211,7 +209,6 @@ int ResizeFusion1::DoFuison(const FuncGraphPtr &func_graph, const AnfNodePtr &no } int ResizeFusion2::DoFuison(const FuncGraphPtr &func_graph, const AnfNodePtr &node) const { - MS_LOG(WARNING) << "DoFuison begin"; MS_ASSERT(node != nullptr); auto resize_cnode = node->cast(); MS_ASSERT(resize_cnode != nullptr); @@ -233,7 +230,6 @@ int ResizeFusion2::DoFuison(const FuncGraphPtr &func_graph, const AnfNodePtr &no MS_ASSERT(manager != nullptr); manager->SetEdge(resize_cnode, kInputIndexTwo, resize_input); - MS_LOG(WARNING) << "DoFuison end"; return lite::RET_OK; }