1 /* 2 * Copyright (C) 2020 The Android Open Source Project 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 ANDROID_HARDWARE_INTERFACES_NEURALNETWORKS_1_0_CONVERSIONS_H 18 #define ANDROID_HARDWARE_INTERFACES_NEURALNETWORKS_1_0_CONVERSIONS_H 19 20 #include <android/hardware/neuralnetworks/1.0/types.h> 21 #include <nnapi/Result.h> 22 #include <nnapi/Types.h> 23 #include <nnapi/hal/CommonUtils.h> 24 25 namespace android::nn { 26 27 GeneralResult<OperandType> unvalidatedConvert(const hal::V1_0::OperandType& operandType); 28 GeneralResult<OperationType> unvalidatedConvert(const hal::V1_0::OperationType& operationType); 29 GeneralResult<Operand::LifeTime> unvalidatedConvert(const hal::V1_0::OperandLifeTime& lifetime); 30 GeneralResult<DeviceStatus> unvalidatedConvert(const hal::V1_0::DeviceStatus& deviceStatus); 31 GeneralResult<Capabilities::PerformanceInfo> unvalidatedConvert( 32 const hal::V1_0::PerformanceInfo& performanceInfo); 33 GeneralResult<Capabilities> unvalidatedConvert(const hal::V1_0::Capabilities& capabilities); 34 GeneralResult<DataLocation> unvalidatedConvert(const hal::V1_0::DataLocation& location); 35 GeneralResult<Operand> unvalidatedConvert(const hal::V1_0::Operand& operand); 36 GeneralResult<Operation> unvalidatedConvert(const hal::V1_0::Operation& operation); 37 GeneralResult<Model::OperandValues> unvalidatedConvert( 38 const hardware::hidl_vec<uint8_t>& operandValues); 39 GeneralResult<SharedMemory> unvalidatedConvert(const hardware::hidl_memory& memory); 40 GeneralResult<Model> unvalidatedConvert(const hal::V1_0::Model& model); 41 GeneralResult<Request::Argument> unvalidatedConvert( 42 const hal::V1_0::RequestArgument& requestArgument); 43 GeneralResult<Request> unvalidatedConvert(const hal::V1_0::Request& request); 44 GeneralResult<ErrorStatus> unvalidatedConvert(const hal::V1_0::ErrorStatus& status); 45 46 GeneralResult<DeviceStatus> convert(const hal::V1_0::DeviceStatus& deviceStatus); 47 GeneralResult<Capabilities> convert(const hal::V1_0::Capabilities& capabilities); 48 GeneralResult<Model> convert(const hal::V1_0::Model& model); 49 GeneralResult<Request> convert(const hal::V1_0::Request& request); 50 GeneralResult<ErrorStatus> convert(const hal::V1_0::ErrorStatus& status); 51 52 } // namespace android::nn 53 54 namespace android::hardware::neuralnetworks::V1_0::utils { 55 56 nn::GeneralResult<OperandType> unvalidatedConvert(const nn::OperandType& operandType); 57 nn::GeneralResult<OperationType> unvalidatedConvert(const nn::OperationType& operationType); 58 nn::GeneralResult<OperandLifeTime> unvalidatedConvert(const nn::Operand::LifeTime& lifetime); 59 nn::GeneralResult<DeviceStatus> unvalidatedConvert(const nn::DeviceStatus& deviceStatus); 60 nn::GeneralResult<PerformanceInfo> unvalidatedConvert( 61 const nn::Capabilities::PerformanceInfo& performanceInfo); 62 nn::GeneralResult<Capabilities> unvalidatedConvert(const nn::Capabilities& capabilities); 63 nn::GeneralResult<DataLocation> unvalidatedConvert(const nn::DataLocation& location); 64 nn::GeneralResult<Operand> unvalidatedConvert(const nn::Operand& operand); 65 nn::GeneralResult<Operation> unvalidatedConvert(const nn::Operation& operation); 66 nn::GeneralResult<hidl_vec<uint8_t>> unvalidatedConvert( 67 const nn::Model::OperandValues& operandValues); 68 nn::GeneralResult<hidl_memory> unvalidatedConvert(const nn::SharedMemory& memory); 69 nn::GeneralResult<Model> unvalidatedConvert(const nn::Model& model); 70 nn::GeneralResult<RequestArgument> unvalidatedConvert(const nn::Request::Argument& requestArgument); 71 nn::GeneralResult<hidl_memory> unvalidatedConvert(const nn::Request::MemoryPool& memoryPool); 72 nn::GeneralResult<Request> unvalidatedConvert(const nn::Request& request); 73 nn::GeneralResult<ErrorStatus> unvalidatedConvert(const nn::ErrorStatus& status); 74 75 nn::GeneralResult<DeviceStatus> convert(const nn::DeviceStatus& deviceStatus); 76 nn::GeneralResult<Capabilities> convert(const nn::Capabilities& capabilities); 77 nn::GeneralResult<Model> convert(const nn::Model& model); 78 nn::GeneralResult<Request> convert(const nn::Request& request); 79 nn::GeneralResult<ErrorStatus> convert(const nn::ErrorStatus& status); 80 81 } // namespace android::hardware::neuralnetworks::V1_0::utils 82 83 #endif // ANDROID_HARDWARE_INTERFACES_NEURALNETWORKS_1_0_CONVERSIONS_H 84