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_3_CONVERSIONS_H 18 #define ANDROID_HARDWARE_INTERFACES_NEURALNETWORKS_1_3_CONVERSIONS_H 19 20 #include <android/hardware/neuralnetworks/1.3/IPreparedModel.h> 21 #include <android/hardware/neuralnetworks/1.3/types.h> 22 #include <nnapi/Result.h> 23 #include <nnapi/Types.h> 24 #include <nnapi/hal/CommonUtils.h> 25 26 namespace android::nn { 27 28 GeneralResult<OperandType> unvalidatedConvert(const hal::V1_3::OperandType& operandType); 29 GeneralResult<OperationType> unvalidatedConvert(const hal::V1_3::OperationType& operationType); 30 GeneralResult<Priority> unvalidatedConvert(const hal::V1_3::Priority& priority); 31 GeneralResult<Capabilities> unvalidatedConvert(const hal::V1_3::Capabilities& capabilities); 32 GeneralResult<Capabilities::OperandPerformance> unvalidatedConvert( 33 const hal::V1_3::Capabilities::OperandPerformance& operandPerformance); 34 GeneralResult<Operation> unvalidatedConvert(const hal::V1_3::Operation& operation); 35 GeneralResult<Operand::LifeTime> unvalidatedConvert( 36 const hal::V1_3::OperandLifeTime& operandLifeTime); 37 GeneralResult<Operand> unvalidatedConvert(const hal::V1_3::Operand& operand); 38 GeneralResult<Model> unvalidatedConvert(const hal::V1_3::Model& model); 39 GeneralResult<Model::Subgraph> unvalidatedConvert(const hal::V1_3::Subgraph& subgraph); 40 GeneralResult<BufferDesc> unvalidatedConvert(const hal::V1_3::BufferDesc& bufferDesc); 41 GeneralResult<BufferRole> unvalidatedConvert(const hal::V1_3::BufferRole& bufferRole); 42 GeneralResult<Request> unvalidatedConvert(const hal::V1_3::Request& request); 43 GeneralResult<Request::MemoryPool> unvalidatedConvert( 44 const hal::V1_3::Request::MemoryPool& memoryPool); 45 GeneralResult<OptionalTimePoint> unvalidatedConvert( 46 const hal::V1_3::OptionalTimePoint& optionalTimePoint); 47 GeneralResult<OptionalDuration> unvalidatedConvert( 48 const hal::V1_3::OptionalTimeoutDuration& optionalTimeoutDuration); 49 GeneralResult<ErrorStatus> unvalidatedConvert(const hal::V1_3::ErrorStatus& errorStatus); 50 51 GeneralResult<Priority> convert(const hal::V1_3::Priority& priority); 52 GeneralResult<Capabilities> convert(const hal::V1_3::Capabilities& capabilities); 53 GeneralResult<Model> convert(const hal::V1_3::Model& model); 54 GeneralResult<BufferDesc> convert(const hal::V1_3::BufferDesc& bufferDesc); 55 GeneralResult<Request> convert(const hal::V1_3::Request& request); 56 GeneralResult<OptionalTimePoint> convert(const hal::V1_3::OptionalTimePoint& optionalTimePoint); 57 GeneralResult<OptionalDuration> convert( 58 const hal::V1_3::OptionalTimeoutDuration& optionalTimeoutDuration); 59 GeneralResult<ErrorStatus> convert(const hal::V1_3::ErrorStatus& errorStatus); 60 61 GeneralResult<SharedHandle> convert(const hardware::hidl_handle& handle); 62 GeneralResult<std::vector<BufferRole>> convert( 63 const hardware::hidl_vec<hal::V1_3::BufferRole>& bufferRoles); 64 65 } // namespace android::nn 66 67 namespace android::hardware::neuralnetworks::V1_3::utils { 68 69 nn::GeneralResult<OperandType> unvalidatedConvert(const nn::OperandType& operandType); 70 nn::GeneralResult<OperationType> unvalidatedConvert(const nn::OperationType& operationType); 71 nn::GeneralResult<Priority> unvalidatedConvert(const nn::Priority& priority); 72 nn::GeneralResult<Capabilities> unvalidatedConvert(const nn::Capabilities& capabilities); 73 nn::GeneralResult<Capabilities::OperandPerformance> unvalidatedConvert( 74 const nn::Capabilities::OperandPerformance& operandPerformance); 75 nn::GeneralResult<Operation> unvalidatedConvert(const nn::Operation& operation); 76 nn::GeneralResult<OperandLifeTime> unvalidatedConvert(const nn::Operand::LifeTime& operandLifeTime); 77 nn::GeneralResult<Operand> unvalidatedConvert(const nn::Operand& operand); 78 nn::GeneralResult<Model> unvalidatedConvert(const nn::Model& model); 79 nn::GeneralResult<Subgraph> unvalidatedConvert(const nn::Model::Subgraph& subgraph); 80 nn::GeneralResult<BufferDesc> unvalidatedConvert(const nn::BufferDesc& bufferDesc); 81 nn::GeneralResult<BufferRole> unvalidatedConvert(const nn::BufferRole& bufferRole); 82 nn::GeneralResult<Request> unvalidatedConvert(const nn::Request& request); 83 nn::GeneralResult<Request::MemoryPool> unvalidatedConvert( 84 const nn::Request::MemoryPool& memoryPool); 85 nn::GeneralResult<OptionalTimePoint> unvalidatedConvert( 86 const nn::OptionalTimePoint& optionalTimePoint); 87 nn::GeneralResult<OptionalTimeoutDuration> unvalidatedConvert( 88 const nn::OptionalDuration& optionalTimeoutDuration); 89 nn::GeneralResult<ErrorStatus> unvalidatedConvert(const nn::ErrorStatus& errorStatus); 90 91 nn::GeneralResult<Priority> convert(const nn::Priority& priority); 92 nn::GeneralResult<Capabilities> convert(const nn::Capabilities& capabilities); 93 nn::GeneralResult<Model> convert(const nn::Model& model); 94 nn::GeneralResult<BufferDesc> convert(const nn::BufferDesc& bufferDesc); 95 nn::GeneralResult<Request> convert(const nn::Request& request); 96 nn::GeneralResult<OptionalTimePoint> convert(const nn::OptionalTimePoint& optionalTimePoint); 97 nn::GeneralResult<OptionalTimeoutDuration> convert( 98 const nn::OptionalDuration& optionalTimeoutDuration); 99 nn::GeneralResult<ErrorStatus> convert(const nn::ErrorStatus& errorStatus); 100 101 nn::GeneralResult<hidl_handle> convert(const nn::SharedHandle& handle); 102 nn::GeneralResult<hidl_memory> convert(const nn::SharedMemory& memory); 103 nn::GeneralResult<hidl_vec<BufferRole>> convert(const std::vector<nn::BufferRole>& bufferRoles); 104 105 nn::GeneralResult<V1_0::DeviceStatus> convert(const nn::DeviceStatus& deviceStatus); 106 nn::GeneralResult<V1_1::ExecutionPreference> convert( 107 const nn::ExecutionPreference& executionPreference); 108 nn::GeneralResult<hidl_vec<V1_2::Extension>> convert(const std::vector<nn::Extension>& extensions); 109 nn::GeneralResult<hidl_vec<hidl_handle>> convert(const std::vector<nn::SharedHandle>& handles); 110 nn::GeneralResult<hidl_vec<V1_2::OutputShape>> convert( 111 const std::vector<nn::OutputShape>& outputShapes); 112 nn::GeneralResult<V1_2::DeviceType> convert(const nn::DeviceType& deviceType); 113 nn::GeneralResult<V1_2::MeasureTiming> convert(const nn::MeasureTiming& measureTiming); 114 nn::GeneralResult<V1_2::Timing> convert(const nn::Timing& timing); 115 116 nn::GeneralResult<hidl_vec<hidl_handle>> convertSyncFences( 117 const std::vector<nn::SyncFence>& fences); 118 119 } // namespace android::hardware::neuralnetworks::V1_3::utils 120 121 #endif // ANDROID_HARDWARE_INTERFACES_NEURALNETWORKS_1_3_CONVERSIONS_H 122