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_2_CONVERSIONS_H 18 #define ANDROID_HARDWARE_INTERFACES_NEURALNETWORKS_1_2_CONVERSIONS_H 19 20 #include <android/hardware/neuralnetworks/1.2/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_2::OperandType& operandType); 28 GeneralResult<OperationType> unvalidatedConvert(const hal::V1_2::OperationType& operationType); 29 GeneralResult<DeviceType> unvalidatedConvert(const hal::V1_2::DeviceType& deviceType); 30 GeneralResult<Capabilities> unvalidatedConvert(const hal::V1_2::Capabilities& capabilities); 31 GeneralResult<Capabilities::OperandPerformance> unvalidatedConvert( 32 const hal::V1_2::Capabilities::OperandPerformance& operandPerformance); 33 GeneralResult<Operation> unvalidatedConvert(const hal::V1_2::Operation& operation); 34 GeneralResult<Operand::SymmPerChannelQuantParams> unvalidatedConvert( 35 const hal::V1_2::SymmPerChannelQuantParams& symmPerChannelQuantParams); 36 GeneralResult<Operand> unvalidatedConvert(const hal::V1_2::Operand& operand); 37 GeneralResult<Operand::ExtraParams> unvalidatedConvert( 38 const hal::V1_2::Operand::ExtraParams& extraParams); 39 GeneralResult<Model> unvalidatedConvert(const hal::V1_2::Model& model); 40 GeneralResult<ExtensionNameAndPrefix> unvalidatedConvert( 41 const hal::V1_2::Model::ExtensionNameAndPrefix& extensionNameAndPrefix); 42 GeneralResult<OutputShape> unvalidatedConvert(const hal::V1_2::OutputShape& outputShape); 43 GeneralResult<MeasureTiming> unvalidatedConvert(const hal::V1_2::MeasureTiming& measureTiming); 44 GeneralResult<Timing> unvalidatedConvert(const hal::V1_2::Timing& timing); 45 GeneralResult<Extension> unvalidatedConvert(const hal::V1_2::Extension& extension); 46 GeneralResult<Extension::OperandTypeInformation> unvalidatedConvert( 47 const hal::V1_2::Extension::OperandTypeInformation& operandTypeInformation); 48 49 GeneralResult<DeviceType> convert(const hal::V1_2::DeviceType& deviceType); 50 GeneralResult<Capabilities> convert(const hal::V1_2::Capabilities& capabilities); 51 GeneralResult<Model> convert(const hal::V1_2::Model& model); 52 GeneralResult<MeasureTiming> convert(const hal::V1_2::MeasureTiming& measureTiming); 53 GeneralResult<Timing> convert(const hal::V1_2::Timing& timing); 54 GeneralResult<SharedMemory> convert(const hardware::hidl_memory& memory); 55 56 GeneralResult<std::vector<Extension>> convert( 57 const hardware::hidl_vec<hal::V1_2::Extension>& extensions); 58 GeneralResult<std::vector<SharedHandle>> convert( 59 const hardware::hidl_vec<hardware::hidl_handle>& handles); 60 GeneralResult<std::vector<OutputShape>> convert( 61 const hardware::hidl_vec<hal::V1_2::OutputShape>& outputShapes); 62 63 } // namespace android::nn 64 65 namespace android::hardware::neuralnetworks::V1_2::utils { 66 67 nn::GeneralResult<OperandType> unvalidatedConvert(const nn::OperandType& operandType); 68 nn::GeneralResult<OperationType> unvalidatedConvert(const nn::OperationType& operationType); 69 nn::GeneralResult<DeviceType> unvalidatedConvert(const nn::DeviceType& deviceType); 70 nn::GeneralResult<Capabilities> unvalidatedConvert(const nn::Capabilities& capabilities); 71 nn::GeneralResult<Capabilities::OperandPerformance> unvalidatedConvert( 72 const nn::Capabilities::OperandPerformance& operandPerformance); 73 nn::GeneralResult<Operation> unvalidatedConvert(const nn::Operation& operation); 74 nn::GeneralResult<SymmPerChannelQuantParams> unvalidatedConvert( 75 const nn::Operand::SymmPerChannelQuantParams& symmPerChannelQuantParams); 76 nn::GeneralResult<Operand> unvalidatedConvert(const nn::Operand& operand); 77 nn::GeneralResult<Operand::ExtraParams> unvalidatedConvert( 78 const nn::Operand::ExtraParams& extraParams); 79 nn::GeneralResult<Model> unvalidatedConvert(const nn::Model& model); 80 nn::GeneralResult<Model::ExtensionNameAndPrefix> unvalidatedConvert( 81 const nn::ExtensionNameAndPrefix& extensionNameAndPrefix); 82 nn::GeneralResult<OutputShape> unvalidatedConvert(const nn::OutputShape& outputShape); 83 nn::GeneralResult<MeasureTiming> unvalidatedConvert(const nn::MeasureTiming& measureTiming); 84 nn::GeneralResult<Timing> unvalidatedConvert(const nn::Timing& timing); 85 nn::GeneralResult<Extension> unvalidatedConvert(const nn::Extension& extension); 86 nn::GeneralResult<Extension::OperandTypeInformation> unvalidatedConvert( 87 const nn::Extension::OperandTypeInformation& operandTypeInformation); 88 89 nn::GeneralResult<DeviceType> convert(const nn::DeviceType& deviceType); 90 nn::GeneralResult<Capabilities> convert(const nn::Capabilities& capabilities); 91 nn::GeneralResult<Model> convert(const nn::Model& model); 92 nn::GeneralResult<MeasureTiming> convert(const nn::MeasureTiming& measureTiming); 93 nn::GeneralResult<Timing> convert(const nn::Timing& timing); 94 95 nn::GeneralResult<hidl_vec<Extension>> convert(const std::vector<nn::Extension>& extensions); 96 nn::GeneralResult<hidl_vec<hidl_handle>> convert(const std::vector<nn::SharedHandle>& handles); 97 nn::GeneralResult<hidl_vec<OutputShape>> convert(const std::vector<nn::OutputShape>& outputShapes); 98 99 nn::GeneralResult<V1_0::DeviceStatus> convert(const nn::DeviceStatus& deviceStatus); 100 nn::GeneralResult<V1_0::Request> convert(const nn::Request& request); 101 nn::GeneralResult<V1_0::ErrorStatus> convert(const nn::ErrorStatus& status); 102 nn::GeneralResult<V1_1::ExecutionPreference> convert( 103 const nn::ExecutionPreference& executionPreference); 104 105 } // namespace android::hardware::neuralnetworks::V1_2::utils 106 107 #endif // ANDROID_HARDWARE_INTERFACES_NEURALNETWORKS_1_2_CONVERSIONS_H 108