blob: 81bca7fad01f05756801a9162e2977456a66c8be [file] [log] [blame]
Michael Butler37600582020-11-19 20:46:58 -08001/*
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#include "InvalidDevice.h"
18
19#include "InvalidBuffer.h"
20#include "InvalidPreparedModel.h"
21
22#include <nnapi/IBuffer.h>
23#include <nnapi/IDevice.h>
24#include <nnapi/IPreparedModel.h>
25#include <nnapi/Result.h>
26#include <nnapi/Types.h>
27
28#include <memory>
29#include <string>
30#include <vector>
31
32namespace android::hardware::neuralnetworks::utils {
33
34InvalidDevice::InvalidDevice(std::string name, std::string versionString, nn::Version featureLevel,
Michael Butler9adab0c2021-01-11 19:35:53 -080035 nn::DeviceType type, bool isUpdatable,
36 std::vector<nn::Extension> extensions, nn::Capabilities capabilities,
Michael Butler37600582020-11-19 20:46:58 -080037 std::pair<uint32_t, uint32_t> numberOfCacheFilesNeeded)
38 : kName(std::move(name)),
39 kVersionString(std::move(versionString)),
40 kFeatureLevel(featureLevel),
41 kType(type),
Michael Butler9adab0c2021-01-11 19:35:53 -080042 kIsUpdatable(isUpdatable),
Michael Butler37600582020-11-19 20:46:58 -080043 kExtensions(std::move(extensions)),
44 kCapabilities(std::move(capabilities)),
45 kNumberOfCacheFilesNeeded(numberOfCacheFilesNeeded) {}
46
47const std::string& InvalidDevice::getName() const {
48 return kName;
49}
50
51const std::string& InvalidDevice::getVersionString() const {
52 return kVersionString;
53}
54
55nn::Version InvalidDevice::getFeatureLevel() const {
56 return kFeatureLevel;
57}
58
59nn::DeviceType InvalidDevice::getType() const {
60 return kType;
61}
62
Michael Butler9adab0c2021-01-11 19:35:53 -080063bool InvalidDevice::isUpdatable() const {
64 return kIsUpdatable;
65}
66
Michael Butler37600582020-11-19 20:46:58 -080067const std::vector<nn::Extension>& InvalidDevice::getSupportedExtensions() const {
68 return kExtensions;
69}
70
71const nn::Capabilities& InvalidDevice::getCapabilities() const {
72 return kCapabilities;
73}
74
75std::pair<uint32_t, uint32_t> InvalidDevice::getNumberOfCacheFilesNeeded() const {
76 return kNumberOfCacheFilesNeeded;
77}
78
79nn::GeneralResult<void> InvalidDevice::wait() const {
80 return NN_ERROR() << "InvalidDevice";
81}
82
83nn::GeneralResult<std::vector<bool>> InvalidDevice::getSupportedOperations(
84 const nn::Model& /*model*/) const {
85 return NN_ERROR() << "InvalidDevice";
86}
87
88nn::GeneralResult<nn::SharedPreparedModel> InvalidDevice::prepareModel(
89 const nn::Model& /*model*/, nn::ExecutionPreference /*preference*/,
90 nn::Priority /*priority*/, nn::OptionalTimePoint /*deadline*/,
91 const std::vector<nn::SharedHandle>& /*modelCache*/,
92 const std::vector<nn::SharedHandle>& /*dataCache*/, const nn::CacheToken& /*token*/) const {
93 return NN_ERROR() << "InvalidDevice";
94}
95
96nn::GeneralResult<nn::SharedPreparedModel> InvalidDevice::prepareModelFromCache(
97 nn::OptionalTimePoint /*deadline*/, const std::vector<nn::SharedHandle>& /*modelCache*/,
98 const std::vector<nn::SharedHandle>& /*dataCache*/, const nn::CacheToken& /*token*/) const {
99 return NN_ERROR() << "InvalidDevice";
100}
101
102nn::GeneralResult<nn::SharedBuffer> InvalidDevice::allocate(
103 const nn::BufferDesc& /*desc*/,
104 const std::vector<nn::SharedPreparedModel>& /*preparedModels*/,
105 const std::vector<nn::BufferRole>& /*inputRoles*/,
106 const std::vector<nn::BufferRole>& /*outputRoles*/) const {
107 return NN_ERROR() << "InvalidDevice";
108}
109
110} // namespace android::hardware::neuralnetworks::utils