diff --git a/mindspore-lite/test/config_level0/models_cloud_ascend_a2.cfg b/mindspore-lite/test/config_level0/models_cloud_ascend_a2.cfg index 4cd5b8ecbfe70419f64004a40af7fdcc6c4e3884..7e958c20ebd9853feaceb3e6a1246bd1ea552d25 100644 --- a/mindspore-lite/test/config_level0/models_cloud_ascend_a2.cfg +++ b/mindspore-lite/test/config_level0/models_cloud_ascend_a2.cfg @@ -15,4 +15,5 @@ long_sequence_eta.pb;2:id,wt;1,576:1,576;static;; 1 vod_sr_M5_H10_20231107_manualv4_int8_dynamic.onnx;1:input1;1,3,1080,1920;static;; 2 user_latent_vector.pb;3:embedding-feature,dense,emb;1,10688:1,1:1,128;static;; 1 single_matmul_model.onnx;1:input;1,4;static;; 1 -fas.mindir;3:query,key,value;1,12,287,128:1,12,287,128:1,12,287,128;static;; 1 \ No newline at end of file +fas.mindir;3:query,key,value;1,12,287,128:1,12,287,128:1,12,287,128;static;; 1 +MultiScaleDeformableAttnFunction.onnx;5:value,value_spatial_shapes,value_level_start_index,sampling_locations,attention_weights;1,153450,8,32:5,2:5:1,153450,8,5,4,2:1,153450,8,5,4;static;; 1 diff --git a/mindspore-lite/tools/converter/parser/onnx/onnx_multi_scale_deformable_attn_function.cc b/mindspore-lite/tools/converter/parser/onnx/onnx_multi_scale_deformable_attn_function.cc new file mode 100644 index 0000000000000000000000000000000000000000..c80abbbbdabcbdc4d7cf7a8b82f74a55556af926 --- /dev/null +++ b/mindspore-lite/tools/converter/parser/onnx/onnx_multi_scale_deformable_attn_function.cc @@ -0,0 +1,43 @@ +/** + * Copyright 2025 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "tools/converter/parser/onnx/onnx_multi_scale_deformable_attn_function.h" +#include +#include +#include +#include "infer/custom.h" +#include "nnacl_c/op_base.h" + +namespace mindspore { +namespace lite { +PrimitiveCPtr OnnxMultiScaleDeformableAttnFunctionParser::Parse(const onnx::GraphProto &onnx_graph, + const onnx::NodeProto &onnx_node) { + auto prim = std::make_unique(); + MS_CHECK_TRUE_RET(prim != nullptr, nullptr); + std::vector input_name = {"value", "value_spatial_shapes", "value_level_start_index", + "sampling_locations", "attention_weights"}; + std::vector output_name = {"output"}; + prim->AddAttr("input_names", api::MakeValue(input_name)); + prim->AddAttr("output_names", api::MakeValue(output_name)); + prim->set_type("MultiScaleDeformableAttnFunction"); + prim->AddAttr("reg_op_name", api::MakeValue("MultiScaleDeformableAttnFunction")); + return prim->GetPrim(); +} + +OnnxNodeRegistrar g_onnxMultiScaleDeformableAttnFunctionParser("MultiScaleDeformableAttnFunction", + new OnnxMultiScaleDeformableAttnFunctionParser()); +} // namespace lite +} // namespace mindspore diff --git a/mindspore-lite/tools/converter/parser/onnx/onnx_multi_scale_deformable_attn_function.h b/mindspore-lite/tools/converter/parser/onnx/onnx_multi_scale_deformable_attn_function.h new file mode 100644 index 0000000000000000000000000000000000000000..daaae85a0f6f4363a321cab3154115f5baea1a8f --- /dev/null +++ b/mindspore-lite/tools/converter/parser/onnx/onnx_multi_scale_deformable_attn_function.h @@ -0,0 +1,34 @@ +/** + * Copyright 2025 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef MINDSPORE_LITE_TOOLS_CONVERTER_PARSER_ONNX_ONNX_MULTI_SCALE_DEFORMABLE_ATTN_FUNCTION_PARSER_H_ +#define MINDSPORE_LITE_TOOLS_CONVERTER_PARSER_ONNX_ONNX_MULTI_SCALE_DEFORMABLE_ATTN_FUNCTION_PARSER_H_ + +#include "tools/converter/parser/onnx/onnx_node_parser.h" +#include "tools/converter/parser/onnx/onnx_node_parser_registry.h" + +namespace mindspore { +namespace lite { +class OnnxMultiScaleDeformableAttnFunctionParser : public OnnxNodeParser { + public: + OnnxMultiScaleDeformableAttnFunctionParser() : OnnxNodeParser("MultiScaleDeformableAttnFunction") {} + ~OnnxMultiScaleDeformableAttnFunctionParser() override = default; + + PrimitiveCPtr Parse(const onnx::GraphProto &onnx_graph, const onnx::NodeProto &onnx_node) override; +}; +} // namespace lite +} // namespace mindspore +#endif // MINDSPORE_LITE_TOOLS_CONVERTER_PARSER_ONNX_ONNX_MULTI_SCALE_DEFORMABLE_ATTN_FUNCTION_PARSER_H_