aboutsummaryrefslogtreecommitdiff
path: root/arm_compute/AclEntrypoints.h
blob: 0d4902a3d5002da48010c95faa531c6445a8146d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
/*
 * Copyright (c) 2021 Arm Limited.
 *
 * SPDX-License-Identifier: MIT
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to
 * deal in the Software without restriction, including without limitation the
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 * sell copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
#ifndef ARM_COMPUTE_ACL_ENTRYPOINTS_H_
#define ARM_COMPUTE_ACL_ENTRYPOINTS_H_

#include "arm_compute/AclTypes.h"

#ifdef __cplusplus
extern "C"
{
#endif /** __cplusplus */

    /** Create a context object
 *
 * Context is responsible for retaining internal information and work as an aggregate service mechanism
 *
 * @param[in, out] ctx     A valid non-zero context object if no failure occurs
 * @param[in]      target  Target to create the context for
 * @param[in]      options Context options to be used for all the kernels that are created under the context
 *
 * @return Status code
 *
 * Returns:
 *  - @ref AclSuccess if function was completed successfully
 *  - @ref AclOutOfMemory if there was a failure allocating memory resources
 *  - @ref AclUnsupportedTarget if the requested target is unsupported
 *  - @ref AclInvalidArgument if a given argument is invalid
 */
    AclStatus AclCreateContext(AclContext *ctx, AclTarget target, const AclContextOptions *options);

    /** Destroy a given context object
 *
 * @param[in] ctx A valid context object to destroy
 *
 * @return Status code
 *
 * Returns:
 *  - @ref AclSuccess if functions was completed successfully
 *  - @ref AclInvalidArgument if the provided context is invalid
 */
    AclStatus AclDestroyContext(AclContext ctx);

    /** Create an operator queue
 *
 * Queue is responsible for any scheduling related activities
 *
 * @param[in, out] queue   A valid non-zero queue object is not failures occur
 * @param[in]      ctx     Context to be used
 * @param[in]      options Queue options to be used for the operators using the queue
 *
 * @return Status code
 *
 * Returns:
 *  - @ref AclSuccess if function was completed successfully
 *  - @ref AclOutOfMemory if there was a failure allocating memory resources
 *  - @ref AclUnsupportedTarget if the requested target is unsupported
 *  - @ref AclInvalidArgument if a given argument is invalid
 */
    AclStatus AclCreateQueue(AclQueue *queue, AclContext ctx, const AclQueueOptions *options);

    /** Wait until all elements on the queue have been completed
 *
 * @param[in] queue Queue to wait on completion
 *
 * @return Status code
 *
 * Returns:
 *  - @ref AclSuccess if functions was completed successfully
 *  - @ref AclInvalidArgument if the provided queue is invalid
 *  - @ref AclRuntimeError on any other runtime related error
 */
    AclStatus AclQueueFinish(AclQueue queue);

    /** Destroy a given queue object
 *
 * @param[in] queue A valid context object to destroy
 *
 * @return Status code
 *
 * Returns:
 *  - @ref AclSuccess if functions was completed successfully
 *  - @ref AclInvalidArgument if the provided context is invalid
 */
    AclStatus AclDestroyQueue(AclQueue queue);

    /** Create a Tensor object
 *
 * Tensor is a generalized matrix construct that can represent up to ND dimensionality (where N = 6 for Compute Library)
 * The object holds a backing memory along-side to operate on
 *
 * @param[in, out] tensor   A valid non-zero tensor object if no failures occur
 * @param[in]      ctx      Context to be used
 * @param[in]      desc     Tensor representation meta-data
 * @param[in]      allocate Instructs allocation of the tensor objects
 *
 * Returns:
 *  - @ref AclSuccess if function was completed successfully
 *  - @ref AclOutOfMemory if there was a failure allocating memory resources
 *  - @ref AclUnsupportedTarget if the requested target is unsupported
 *  - @ref AclInvalidArgument if a given argument is invalid
 */
    AclStatus AclCreateTensor(AclTensor *tensor, AclContext ctx, const AclTensorDescriptor *desc, bool allocate);

    /** Map a tensor's backing memory to the host
 *
 * @param[in]      tensor Tensor to be mapped
 * @param[in, out] handle A handle to the underlying backing memory
 *
 * @return Status code
 *
 * Returns:
 *  - @ref AclSuccess if function was completed successfully
 *  - @ref AclInvalidArgument if a given argument is invalid
 */
    AclStatus AclMapTensor(AclTensor tensor, void **handle);

    /** Unmap the tensor's backing memory
 *
 * @param[in] tensor tensor to unmap memory from
 * @param[in] handle Backing memory to be unmapped
 *
 * @return Status code
 *
 * Returns:
 *  - @ref AclSuccess if function was completed successfully
 *  - @ref AclInvalidArgument if a given argument is invalid
 */
    AclStatus AclUnmapTensor(AclTensor tensor, void *handle);

    /** Import external memory to a given tensor object
 *
 * @param[in, out] tensor Tensor to import memory to
 * @param[in]      handle Backing memory to be imported
 * @param[in]      type   Type of the imported memory
 *
 * Returns:
 *  - @ref AclSuccess if function was completed successfully
 *  - @ref AclInvalidArgument if a given argument is invalid
 */
    AclStatus AclTensorImport(AclTensor tensor, void *handle, AclImportMemoryType type);

    /** Destroy a given tensor object
 *
 * @param[in,out] tensor A valid tensor object to be destroyed
 *
 * @return Status code
 *
 * Returns:
 *  - @ref AclSuccess if function was completed successfully
 *  - @ref AclInvalidArgument if the provided tensor is invalid
 */
    AclStatus AclDestroyTensor(AclTensor tensor);

    /** Creates a tensor pack
 *
 * Tensor packs are used to create a collection of tensors that can be passed around for operator execution
 *
 * @param[in,out] pack A valid non-zero tensor pack object if no failures occur
 * @param[in]     ctx  Context to be used
 *
 * @return Status code
 *
 * Returns:
 *  - @ref AclSuccess if function was completed successfully
 *  - @ref AclOutOfMemory if there was a failure allocating memory resources
 *  - @ref AclInvalidArgument if a given argument is invalid
 */
    AclStatus AclCreateTensorPack(AclTensorPack *pack, AclContext ctx);

    /** Add a tensor to a tensor pack
 *
 * @param[in,out] pack    Pack to append a tensor to
 * @param[in]     tensor  Tensor to pack
 * @param[in]     slot_id Slot of the operator that the tensors corresponds to
 *
 * @return Status code
 *
 * Returns:
 *  - @ref AclSuccess if function was completed successfully
 *  - @ref AclOutOfMemory if there was a failure allocating memory resources
 *  - @ref AclInvalidArgument if a given argument is invalid
 */
    AclStatus AclPackTensor(AclTensorPack pack, AclTensor tensor, int32_t slot_id);

    /** A list of tensors to a tensor pack
 *
 * @param[in,out] pack        Pack to append the tensors to
 * @param[in]     tensors     Tensors to append to the pack
 * @param[in]     slot_ids    Slot IDs of each tensors to the operators
 * @param[in]     num_tensors Number of tensors that are passed
 *
 * @return Status code
 *
 * Returns:
 *  - @ref AclSuccess if function was completed successfully
 *  - @ref AclOutOfMemory if there was a failure allocating memory resources
 *  - @ref AclInvalidArgument if a given argument is invalid
 */
    AclStatus AclPackTensors(AclTensorPack pack, AclTensor *tensors, int32_t *slot_ids, size_t num_tensors);

    /** Destroy a given tensor pack object
 *
 * @param[in,out] pack A valid tensor pack object to destroy
 *
 * @return Status code
 *
 * Returns:
 *  - @ref AclSuccess if functions was completed successfully
 *  - @ref AclInvalidArgument if the provided context is invalid
 */
    AclStatus AclDestroyTensorPack(AclTensorPack pack);

    /** Eager execution of a given operator on a list of inputs and outputs
 *
 * @param[in]     op      Operator to execute
 * @param[in]     queue   Queue to schedule the operator on
 * @param[in,out] tensors A list of input and outputs tensors to execute the operator on
 *
 * @return Status Code
 *
 * Returns:
 *  - @ref AclSuccess if function was completed successfully
 *  - @ref AclOutOfMemory if there was a failure allocating memory resources
 *  - @ref AclUnsupportedTarget if the requested target is unsupported
 *  - @ref AclInvalidArgument if a given argument is invalid
 *  - @ref AclRuntimeError on any other runtime related error
 */
    AclStatus AclRunOperator(AclOperator op, AclQueue queue, AclTensorPack tensors);

    /** Destroy a given operator object
 *
 * @param[in,out] op A valid operator object to destroy
 *
 * @return Status code
 *
 * Returns:
 *  - @ref AclSuccess if functions was completed successfully
 *  - @ref AclInvalidArgument if the provided context is invalid
 */
    AclStatus AclDestroyOperator(AclOperator op);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* ARM_COMPUTE_ACL_ENTRYPOINTS_H_ */