blob: 535ccb41c7898146c55e8a2ac7b05f3745c3feca [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,
35 nn::DeviceType type, std::vector<nn::Extension> extensions,
36 nn::Capabilities capabilities,
37 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
62const 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*/,
87 const std::vector<nn::SharedHandle>& /*dataCache*/, const nn::CacheToken& /*token*/) const {
88 return NN_ERROR() << "InvalidDevice";
89}
90
91nn::GeneralResult<nn::SharedPreparedModel> InvalidDevice::prepareModelFromCache(
92 nn::OptionalTimePoint /*deadline*/, const std::vector<nn::SharedHandle>& /*modelCache*/,
93 const std::vector<nn::SharedHandle>& /*dataCache*/, const nn::CacheToken& /*token*/) const {
94 return NN_ERROR() << "InvalidDevice";
95}
96
97nn::GeneralResult<nn::SharedBuffer> InvalidDevice::allocate(
98 const nn::BufferDesc& /*desc*/,
99 const std::vector<nn::SharedPreparedModel>& /*preparedModels*/,
100 const std::vector<nn::BufferRole>& /*inputRoles*/,
101 const std::vector<nn::BufferRole>& /*outputRoles*/) const {
102 return NN_ERROR() << "InvalidDevice";
103}
104
105} // namespace android::hardware::neuralnetworks::utils