ONE - On-device Neural Engine
Loading...
Searching...
No Matches
ExecutionBuilder.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
3 * Copyright (C) 2017 The Android Open Source Project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef __EXECUTION_BUILDER_H__
19#define __EXECUTION_BUILDER_H__
20
21#include "NeuralNetworks.h"
22
23#include "ModelBuilder.h"
24#include "ModelArgumentInfo.h"
25
26#include "Memory.h"
27
28#include <vector>
29
30class ModelBuilder;
31
33{
34public:
36
37public:
38 int setInput(uint32_t index, const ANeuralNetworksOperandType *type, const void *buffer,
39 size_t length);
40 int setInputFromMemory(uint32_t index, const ANeuralNetworksOperandType *type,
41 const Memory *memory, size_t offset, size_t length);
42
43public:
44 int setOutput(uint32_t index, const ANeuralNetworksOperandType *type, void *buffer,
45 size_t length);
46 int setOutputFromMemory(uint32_t index, const ANeuralNetworksOperandType *type,
47 const Memory *memory, size_t offset, size_t length);
48
49public:
50 int startCompute(void);
51
52private:
53 const ModelBuilder *mModel;
54
55private:
56 // The information we'll send to the driver about the inputs and outputs.
57 // Note that we build this in two steps:
58 // 1. As the arguments are specified, set the corresponding mInputs or mOutputs element.
59 // If set from a pointer, don't set the location in the RequestArgument but store it
60 // instead in mInputBuffers or mOutputBuffers.
61 // 2. Once we have all the inputs and outputs, if needed, allocate shared memory for
62 // the m*Buffers entries. Copy the input values into the shared memory.
63 // We do this to avoid creating a lot of shared memory objects if we have a lot of
64 // parameters specified via pointers. We also avoid copying in the case where
65 // some of the nodes will interpreted on the CPU anyway.
66 std::vector<ModelArgumentInfo> mInputs;
67 std::vector<ModelArgumentInfo> mOutputs;
68
69private:
70 MemoryTracker mMemories;
71};
72
73#endif // __EXECUTION_BUILDER_H__
int setOutputFromMemory(uint32_t index, const ANeuralNetworksOperandType *type, const Memory *memory, size_t offset, size_t length)
int setInput(uint32_t index, const ANeuralNetworksOperandType *type, const void *buffer, size_t length)
int setOutput(uint32_t index, const ANeuralNetworksOperandType *type, void *buffer, size_t length)
int setInputFromMemory(uint32_t index, const ANeuralNetworksOperandType *type, const Memory *memory, size_t offset, size_t length)
__global uchar * offset(const Image *img, int x, int y)
Definition helpers.h:540