/* * Copyright (C) 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_HARDWARE_INTERFACES_NEURALNETWORKS_UTILS_ADAPTER_DEVICE_H #define ANDROID_HARDWARE_INTERFACES_NEURALNETWORKS_UTILS_ADAPTER_DEVICE_H #include "nnapi/hal/Adapter.h" #include #include #include #include #include #include #include #include #include #include #include // See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface // lifetimes across processes and for protecting asynchronous calls across HIDL. namespace android::hardware::neuralnetworks::adapter { using CacheToken = hidl_array; // Class that adapts nn::IDevice to V1_3::IDevice. class Device final : public V1_3::IDevice { public: Device(nn::SharedDevice device, Executor executor); Return getCapabilities(getCapabilities_cb cb) override; Return getCapabilities_1_1(getCapabilities_1_1_cb cb) override; Return getCapabilities_1_2(getCapabilities_1_2_cb cb) override; Return getCapabilities_1_3(getCapabilities_1_3_cb cb) override; Return getVersionString(getVersionString_cb cb) override; Return getType(getType_cb cb) override; Return getSupportedExtensions(getSupportedExtensions_cb) override; Return getSupportedOperations(const V1_0::Model& model, getSupportedOperations_cb cb) override; Return getSupportedOperations_1_1(const V1_1::Model& model, getSupportedOperations_1_1_cb cb) override; Return getSupportedOperations_1_2(const V1_2::Model& model, getSupportedOperations_1_2_cb cb) override; Return getSupportedOperations_1_3(const V1_3::Model& model, getSupportedOperations_1_3_cb cb) override; Return getNumberOfCacheFilesNeeded(getNumberOfCacheFilesNeeded_cb cb) override; Return prepareModel( const V1_0::Model& model, const sp& callback) override; Return prepareModel_1_1( const V1_1::Model& model, V1_1::ExecutionPreference preference, const sp& callback) override; Return prepareModel_1_2( const V1_2::Model& model, V1_1::ExecutionPreference preference, const hidl_vec& modelCache, const hidl_vec& dataCache, const CacheToken& token, const sp& callback) override; Return prepareModel_1_3( const V1_3::Model& model, V1_1::ExecutionPreference preference, V1_3::Priority priority, const V1_3::OptionalTimePoint& deadline, const hidl_vec& modelCache, const hidl_vec& dataCache, const CacheToken& token, const sp& callback) override; Return prepareModelFromCache( const hidl_vec& modelCache, const hidl_vec& dataCache, const CacheToken& token, const sp& callback) override; Return prepareModelFromCache_1_3( const V1_3::OptionalTimePoint& deadline, const hidl_vec& modelCache, const hidl_vec& dataCache, const CacheToken& token, const sp& callback) override; Return getStatus() override; Return allocate(const V1_3::BufferDesc& desc, const hidl_vec>& preparedModels, const hidl_vec& inputRoles, const hidl_vec& outputRoles, allocate_cb cb) override; private: const nn::SharedDevice kDevice; const Executor kExecutor; }; } // namespace android::hardware::neuralnetworks::adapter #endif // ANDROID_HARDWARE_INTERFACES_NEURALNETWORKS_UTILS_ADAPTER_DEVICE_H