blob: c8cc287573e3b94fb7c20e4e2114f3ef0d3f47ea [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 Butler3e9720b2021-04-14 23:26:47 -070035 nn::DeviceType type, std::vector<nn::Extension> extensions,
36 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),
42 kExtensions(std::move(extensions)),
43 kCapabilities(std::move(capabilities)),
44 kNumberOfCacheFilesNeeded(numberOfCacheFilesNeeded) {}
45
46const std::string& InvalidDevice::getName() const {
47 return kName;
48}
49
50const std::string& InvalidDevice::getVersionString() const {
51 return kVersionString;
52}
53
54nn::Version InvalidDevice::getFeatureLevel() const {
55 return kFeatureLevel;
56}
57
58nn::DeviceType InvalidDevice::getType() const {
59 return kType;
60}
61
Michael Butler37600582020-11-19 20:46:58 -080062const std::vector<nn::Extension>& InvalidDevice::getSupportedExtensions() const {
63 return kExtensions;
64}
65
66const nn::Capabilities& InvalidDevice::getCapabilities() const {
67 return kCapabilities;
68}
69
70std::pair<uint32_t, uint32_t> InvalidDevice::getNumberOfCacheFilesNeeded() const {
71 return kNumberOfCacheFilesNeeded;
72}
73
74nn::GeneralResult<void> InvalidDevice::wait() const {
75 return NN_ERROR() << "InvalidDevice";
76}
77
78nn::GeneralResult<std::vector<bool>> InvalidDevice::getSupportedOperations(
79 const nn::Model& /*model*/) const {
80 return NN_ERROR() << "InvalidDevice";
81}
82
83nn::GeneralResult<nn::SharedPreparedModel> InvalidDevice::prepareModel(
84 const nn::Model& /*model*/, nn::ExecutionPreference /*preference*/,
85 nn::Priority /*priority*/, nn::OptionalTimePoint /*deadline*/,
86 const std::vector<nn::SharedHandle>& /*modelCache*/,
Miao Wang0e671f32021-10-26 20:03:05 +000087 const std::vector<nn::SharedHandle>& /*dataCache*/, const nn::CacheToken& /*token*/,
88 const std::vector<nn::TokenValuePair>& /*hints*/,
89 const std::vector<nn::ExtensionNameAndPrefix>& /*extensionNameToPrefix*/) const {
Michael Butler37600582020-11-19 20:46:58 -080090 return NN_ERROR() << "InvalidDevice";
91}
92
93nn::GeneralResult<nn::SharedPreparedModel> InvalidDevice::prepareModelFromCache(
94 nn::OptionalTimePoint /*deadline*/, const std::vector<nn::SharedHandle>& /*modelCache*/,
95 const std::vector<nn::SharedHandle>& /*dataCache*/, const nn::CacheToken& /*token*/) const {
96 return NN_ERROR() << "InvalidDevice";
97}
98
99nn::GeneralResult<nn::SharedBuffer> InvalidDevice::allocate(
100 const nn::BufferDesc& /*desc*/,
101 const std::vector<nn::SharedPreparedModel>& /*preparedModels*/,
102 const std::vector<nn::BufferRole>& /*inputRoles*/,
103 const std::vector<nn::BufferRole>& /*outputRoles*/) const {
104 return NN_ERROR() << "InvalidDevice";
105}
106
107} // namespace android::hardware::neuralnetworks::utils