1 /** 2 * Copyright 2024 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 17 #ifndef MINDSPORE_LITE_EXTENSION_OPTIONS_PARSER_H 18 #define MINDSPORE_LITE_EXTENSION_OPTIONS_PARSER_H 19 20 #include <vector> 21 #include "src/litert/inner_context.h" 22 #include "hiai_foundation_wrapper.h" 23 24 namespace mindspore::lite::nnrt { 25 struct ExtensionOptions { 26 std::string cache_path_ = ""; 27 uint32_t cache_version_ = 0; 28 mindspore::lite::HiAI_BandMode band_mode{HIAI_BANDMODE_UNSET}; 29 void *quant_config; 30 size_t quant_config_size = 0; 31 bool is_optional_quant_setted = false; 32 std::string model_name = ""; 33 }; 34 35 class ExtensionOptionsParser { 36 public: 37 static int Parse(const std::vector<Extension> &extensions, ExtensionOptions *param); 38 39 private: 40 static void DoParseBondMode(const std::vector<Extension> &extensions, mindspore::lite::HiAI_BandMode *band_mode); 41 static void DoParseQuantConfig(const std::vector<Extension> &extensions, void **quant_config, size_t *num, 42 bool *quant_setted); 43 static void DoParseCachePath(const std::vector<Extension> &extensions, std::string *cache_path); 44 static void DoParseCacheVersion(const std::vector<Extension> &extensions, uint32_t *cache_version); 45 static void DoParseModelName(const std::vector<Extension> &extensions, std::string *model_name); 46 }; 47 48 } // namespace mindspore::lite::nnrt 49 50 #endif // MINDSPORE_LITE_EXTENSION_OPTIONS_PARSER_H 51