blob: b0ec3b3bcf54b956606ad054a38c21824f48750d [file] [log] [blame]
Xusong Wang52d2df82019-07-02 13:53:25 -07001/*
2 * Copyright (C) 2019 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_FRAMEWORKS_ML_NN_RUNTIME_MODEL_ARGUMENT_INFO_H
18#define ANDROID_FRAMEWORKS_ML_NN_RUNTIME_MODEL_ARGUMENT_INFO_H
19
20#include <vector>
21
22#include "HalInterfaces.h"
23#include "NeuralNetworks.h"
24
25namespace android {
26namespace nn {
27
28// TODO move length out of DataLocation
29struct ModelArgumentInfo {
30 // Whether the argument was specified as being in a Memory, as a pointer,
31 // has no value, or has not been specified.
32 // If POINTER then:
33 // locationAndLength.length is valid.
34 // dimensions is valid.
35 // buffer is valid
36 // If MEMORY then:
37 // locationAndLength.{poolIndex, offset, length} is valid.
38 // dimensions is valid.
39 enum { POINTER, MEMORY, HAS_NO_VALUE, UNSPECIFIED } state = UNSPECIFIED;
40 hal::DataLocation locationAndLength;
41 std::vector<uint32_t> dimensions;
42 void* buffer;
43 bool isSufficient = true;
44
45 int setFromPointer(const hal::Operand& operand, const ANeuralNetworksOperandType* type,
46 void* buffer, uint32_t length);
47 int setFromMemory(const hal::Operand& operand, const ANeuralNetworksOperandType* type,
48 uint32_t poolIndex, uint32_t offset, uint32_t length);
Xusong Wang52d2df82019-07-02 13:53:25 -070049 int updateDimensionInfo(const hal::Operand& operand, const ANeuralNetworksOperandType* newType);
50};
51
52} // namespace nn
53} // namespace android
54
Slava Shklyaev4aad5a32019-10-29 13:27:13 +000055#endif // ANDROID_FRAMEWORKS_ML_NN_RUNTIME_MODEL_ARGUMENT_INFO_H