From: Suyeon Kim Date: Tue, 9 Jan 2024 01:26:24 +0000 (+0900) Subject: [fix/onnxruntime-filter] fixed tensor with negative value in shape X-Git-Tag: accepted/tizen/unified/20240119.154754~13 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c854cb9afeb45e0d05ec5879f502668b1e2be75d;p=platform%2Fupstream%2Fnnstreamer.git [fix/onnxruntime-filter] fixed tensor with negative value in shape Some onnx models had free dimensions for batch. ex) [None,3,720,720] It fixed that creating tensor with negative value in shape '''Ort::Value''' is treated as 1. Signed-off-by: Suyeon Kim --- diff --git a/ext/nnstreamer/tensor_filter/tensor_filter_onnxruntime.cc b/ext/nnstreamer/tensor_filter/tensor_filter_onnxruntime.cc index 6bb363f..938246e 100644 --- a/ext/nnstreamer/tensor_filter/tensor_filter_onnxruntime.cc +++ b/ext/nnstreamer/tensor_filter/tensor_filter_onnxruntime.cc @@ -70,7 +70,7 @@ class onnxruntime_subplugin final : public tensor_filter_subplugin void cleanup (); void clearNodeInfo (onnx_node_info_s &node); void convertTensorInfo (onnx_node_info_s &node, GstTensorsInfo &info); - int convertTensorDim (std::vector shapes, tensor_dim &dim); + int convertTensorDim (std::vector &shapes, tensor_dim &dim); int convertTensorType (ONNXTensorElementDataType _type, tensor_type &type); public: @@ -166,7 +166,7 @@ onnxruntime_subplugin::convertTensorInfo (onnx_node_info_s &node, GstTensorsInfo * @return 0 if OK. non-zero if error. */ int -onnxruntime_subplugin::convertTensorDim (std::vector shapes, tensor_dim &dim) +onnxruntime_subplugin::convertTensorDim (std::vector &shapes, tensor_dim &dim) { size_t i, rank; @@ -179,7 +179,8 @@ onnxruntime_subplugin::convertTensorDim (std::vector shapes, tensor_dim /* the order of dimension is reversed at CAPS negotiation */ for (i = 0; i < rank; i++) { /* free dimensions are treated as 1 if not overriden */ - dim[i] = (shapes[rank - i - 1] > 0) ? shapes[rank - i - 1] : 1; + shapes[rank - i - 1] = (shapes[rank - i - 1] > 0) ? shapes[rank - i - 1] : 1; + dim[i] = shapes[rank - i - 1]; } /* fill remaining entries with 0 */