• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "hdi_interfaces.h"
20 #include "interfaces/kits/c/neural_network_runtime_type.h"
21 #include "cpp_type.h"
22 #include "mindir.h"
23 #include "mindir_types.h"
24 #include "ops_builder.h"
25 
26 namespace OHOS {
27 namespace NeuralNetworkRuntime {
28 template<typename T>
ConstructVectorFromArray(const T * data,size_t size)29 std::vector<T> ConstructVectorFromArray(const T* data, size_t size)
30 {
31     std::vector<T> array;
32     if (data != nullptr) {
33         array.assign(data, data + size);
34     }
35     return array;
36 }
37 
38 uint32_t GetTypeSize(OH_NN_DataType type);
39 
40 
41 namespace HDIToNN {
42 OH_NN_DeviceType TransHDIDeviceType(const V1_0::DeviceType& iDeviceType);
43 DeviceStatus TransHDIDeviceStatus(const V1_0::DeviceStatus& iDeviceStatus);
44 } // namespace HDIToNN
45 
46 namespace NNToHDI {
47 V1_0::PerformanceMode TransPerformanceMode(const OH_NN_PerformanceMode& mode);
48 V1_0::Priority TransPriority(const OH_NN_Priority& priority);
49 V1_0::DataType TransDataType(const OH_NN_DataType& dataType);
50 V1_0::Format TransFormat(const OH_NN_Format& format);
51 V1_0::IOTensor TransIOTensor(const IOTensor& tensor);
52 } // namespace NNToHDI
53 
54 namespace NNToMS {
55 mindspore::lite::DataType TransformDataType(OH_NN_DataType type);
56 mindspore::lite::Format TransformFormat(OH_NN_Format type);
57 mindspore::lite::ActivationType TransfromFusionType(OH_NN_FuseType type);
58 mindspore::lite::QuantType TransformQuantType(OHOS::NeuralNetworkRuntime::Ops::OpsQuantType type);
59 mindspore::lite::PadMode TransformPadModeValue(int8_t padMode);
60 } // NNToMS
61 
62 namespace MSToNN {
63 OH_NN_DataType TransformDataType(mindspore::lite::DataType type);
64 std::vector<QuantParam> TransformQuantParams(std::vector<mindspore::lite::QuantParam> msQuantParams);
65 } // namespace MSToNN
66 } // namespace NeuralNetworkRuntime
67 } // namespace OHOS
68 #endif // NEURAL_NETWORK_RUNTIME_TRANSFORM_H