1 /** 2 * Copyright 2023 Huawei Technologies Co., Ltd 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #ifndef MINDSPORE_LITE_SRC_EXTENDRT_DELEGATE_ASCEND_GE_GE_DYNAMIC_UTILS_H 17 #define MINDSPORE_LITE_SRC_EXTENDRT_DELEGATE_ASCEND_GE_GE_DYNAMIC_UTILS_H 18 #include <string> 19 #include <memory> 20 #include <vector> 21 #include <map> 22 #include <utility> 23 #include "include/api/context.h" 24 #include "include/model.h" 25 #include "include/transform/graph_ir/types.h" 26 #include "extendrt/session/lite_graph_executor.h" 27 #include "common/config_infos.h" 28 #include "mindspore/lite/src/common/utils.h" 29 30 namespace mindspore { 31 struct GeDynamicShapeInfo { 32 std::string name; 33 std::string shape_str; 34 std::vector<lite::ShapeDim> shape; 35 }; 36 37 class GeDynamicUtils { 38 public: 39 static bool IsDynamicInputShapes(const std::vector<ShapeVector> &input_shapes); 40 static bool IsDynamicInputShapes(const std::vector<std::pair<std::string, ShapeVector>> &input_shapes); 41 static bool GetGraphInputShapes(const std::shared_ptr<mindspore::Context> &context, const ConfigInfos &config_infos, 42 std::vector<GeDynamicShapeInfo> *input_shape, std::string *input_shape_str); 43 static void UpdateGraphInputShapes(const std::shared_ptr<mindspore::Context> &context, ConfigInfos *config_infos, 44 const std::string &input_shape); 45 static bool GetGraphOneRealShapes(const std::shared_ptr<mindspore::Context> &context, const ConfigInfos &config_infos, 46 std::vector<std::pair<std::string, ShapeVector>> *input_shape, 47 std::string *input_shape_str); 48 static bool GetDynamicBatchSize(const std::shared_ptr<mindspore::Context> &context, const ConfigInfos &config_infos, 49 std::vector<int64_t> *dynamic_batch_size); 50 static bool GetDynamicImageSize(const std::shared_ptr<mindspore::Context> &context, const ConfigInfos &config_infos, 51 std::vector<std::vector<int64_t>> *dynamic_image_size); 52 static bool GetDynamicDims(const std::shared_ptr<mindspore::Context> &context, const ConfigInfos &config_infos, 53 std::vector<std::vector<int64_t>> *dynamic_dims); 54 }; 55 } // namespace mindspore 56 #endif // MINDSPORE_LITE_SRC_EXTENDRT_DELEGATE_ASCEND_GE_GE_DYNAMIC_UTILS_H 57