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