1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef NEURAL_NETWORK_RUNTIME_TRANSFORM_H 17 #define NEURAL_NETWORK_RUNTIME_TRANSFORM_H 18 19 #include "interfaces/kits/c/neural_network_runtime/neural_network_runtime_type.h" 20 #include "cpp_type.h" 21 #include "mindir.h" 22 #include "mindir_types.h" 23 #include "ops_builder.h" 24 25 namespace OHOS { 26 namespace NeuralNetworkRuntime { 27 template<typename T> ConstructVectorFromArray(const T * data,size_t size)28std::vector<T> ConstructVectorFromArray(const T* data, size_t size) 29 { 30 std::vector<T> array; 31 if (data != nullptr) { 32 array.assign(data, data + size); 33 } 34 return array; 35 } 36 37 uint32_t GetTypeSize(OH_NN_DataType type); 38 39 40 namespace NNToMS { 41 mindspore::lite::DataType TransformDataType(OH_NN_DataType type); 42 mindspore::lite::Format TransformFormat(OH_NN_Format type); 43 mindspore::lite::ActivationType TransfromFusionType(OH_NN_FuseType type); 44 mindspore::lite::QuantType TransformQuantType(OHOS::NeuralNetworkRuntime::Ops::OpsQuantType type); 45 mindspore::lite::PadMode TransformPadModeValue(int8_t padMode); 46 } // NNToMS 47 48 namespace MSToNN { 49 OH_NN_DataType TransformDataType(mindspore::lite::DataType type); 50 std::vector<QuantParam> TransformQuantParams(std::vector<mindspore::lite::QuantParam> msQuantParams); 51 OH_NN_Format TransformFormat(mindspore::lite::Format msFormat); 52 } // namespace MSToNN 53 } // namespace NeuralNetworkRuntime 54 } // namespace OHOS 55 #endif // NEURAL_NETWORK_RUNTIME_TRANSFORM_H