blob: 0d4902a3d5002da48010c95faa531c6445a8146d [file] [log] [blame]
Georgios Pinitas8a5146f2021-01-12 15:51:07 +00001/*
2 * Copyright (c) 2021 Arm Limited.
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
Georgios Pinitas06ac6e42021-07-05 08:08:52 +010024#ifndef ARM_COMPUTE_ACL_ENTRYPOINTS_H_
25#define ARM_COMPUTE_ACL_ENTRYPOINTS_H_
Georgios Pinitas8a5146f2021-01-12 15:51:07 +000026
27#include "arm_compute/AclTypes.h"
28
29#ifdef __cplusplus
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010030extern "C"
31{
Georgios Pinitas8a5146f2021-01-12 15:51:07 +000032#endif /** __cplusplus */
33
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010034 /** Create a context object
Georgios Pinitas8a5146f2021-01-12 15:51:07 +000035 *
36 * Context is responsible for retaining internal information and work as an aggregate service mechanism
37 *
38 * @param[in, out] ctx A valid non-zero context object if no failure occurs
39 * @param[in] target Target to create the context for
40 * @param[in] options Context options to be used for all the kernels that are created under the context
41 *
42 * @return Status code
43 *
44 * Returns:
45 * - @ref AclSuccess if function was completed successfully
46 * - @ref AclOutOfMemory if there was a failure allocating memory resources
47 * - @ref AclUnsupportedTarget if the requested target is unsupported
48 * - @ref AclInvalidArgument if a given argument is invalid
49 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010050 AclStatus AclCreateContext(AclContext *ctx, AclTarget target, const AclContextOptions *options);
Georgios Pinitas8a5146f2021-01-12 15:51:07 +000051
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010052 /** Destroy a given context object
Georgios Pinitas8a5146f2021-01-12 15:51:07 +000053 *
54 * @param[in] ctx A valid context object to destroy
55 *
56 * @return Status code
57 *
58 * Returns:
59 * - @ref AclSuccess if functions was completed successfully
60 * - @ref AclInvalidArgument if the provided context is invalid
61 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010062 AclStatus AclDestroyContext(AclContext ctx);
Georgios Pinitas8a5146f2021-01-12 15:51:07 +000063
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010064 /** Create an operator queue
Georgios Pinitasc3c352e2021-03-18 10:59:40 +000065 *
66 * Queue is responsible for any scheduling related activities
67 *
68 * @param[in, out] queue A valid non-zero queue object is not failures occur
69 * @param[in] ctx Context to be used
70 * @param[in] options Queue options to be used for the operators using the queue
71 *
72 * @return Status code
73 *
74 * Returns:
75 * - @ref AclSuccess if function was completed successfully
76 * - @ref AclOutOfMemory if there was a failure allocating memory resources
77 * - @ref AclUnsupportedTarget if the requested target is unsupported
78 * - @ref AclInvalidArgument if a given argument is invalid
79 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010080 AclStatus AclCreateQueue(AclQueue *queue, AclContext ctx, const AclQueueOptions *options);
Georgios Pinitasc3c352e2021-03-18 10:59:40 +000081
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010082 /** Wait until all elements on the queue have been completed
Georgios Pinitasc3c352e2021-03-18 10:59:40 +000083 *
84 * @param[in] queue Queue to wait on completion
85 *
86 * @return Status code
87 *
88 * Returns:
89 * - @ref AclSuccess if functions was completed successfully
90 * - @ref AclInvalidArgument if the provided queue is invalid
91 * - @ref AclRuntimeError on any other runtime related error
92 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010093 AclStatus AclQueueFinish(AclQueue queue);
Georgios Pinitasc3c352e2021-03-18 10:59:40 +000094
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010095 /** Destroy a given queue object
Georgios Pinitasc3c352e2021-03-18 10:59:40 +000096 *
97 * @param[in] queue A valid context object to destroy
98 *
99 * @return Status code
100 *
101 * Returns:
102 * - @ref AclSuccess if functions was completed successfully
103 * - @ref AclInvalidArgument if the provided context is invalid
104 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100105 AclStatus AclDestroyQueue(AclQueue queue);
Georgios Pinitasc3c352e2021-03-18 10:59:40 +0000106
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100107 /** Create a Tensor object
Georgios Pinitas3f26ef42021-02-23 10:01:33 +0000108 *
109 * Tensor is a generalized matrix construct that can represent up to ND dimensionality (where N = 6 for Compute Library)
110 * The object holds a backing memory along-side to operate on
111 *
112 * @param[in, out] tensor A valid non-zero tensor object if no failures occur
113 * @param[in] ctx Context to be used
114 * @param[in] desc Tensor representation meta-data
115 * @param[in] allocate Instructs allocation of the tensor objects
116 *
117 * Returns:
118 * - @ref AclSuccess if function was completed successfully
119 * - @ref AclOutOfMemory if there was a failure allocating memory resources
120 * - @ref AclUnsupportedTarget if the requested target is unsupported
121 * - @ref AclInvalidArgument if a given argument is invalid
122 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100123 AclStatus AclCreateTensor(AclTensor *tensor, AclContext ctx, const AclTensorDescriptor *desc, bool allocate);
Georgios Pinitas3f26ef42021-02-23 10:01:33 +0000124
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100125 /** Map a tensor's backing memory to the host
Georgios Pinitas3f26ef42021-02-23 10:01:33 +0000126 *
127 * @param[in] tensor Tensor to be mapped
128 * @param[in, out] handle A handle to the underlying backing memory
129 *
130 * @return Status code
131 *
132 * Returns:
133 * - @ref AclSuccess if function was completed successfully
134 * - @ref AclInvalidArgument if a given argument is invalid
135 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100136 AclStatus AclMapTensor(AclTensor tensor, void **handle);
Georgios Pinitas3f26ef42021-02-23 10:01:33 +0000137
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100138 /** Unmap the tensor's backing memory
Georgios Pinitas3f26ef42021-02-23 10:01:33 +0000139 *
140 * @param[in] tensor tensor to unmap memory from
141 * @param[in] handle Backing memory to be unmapped
142 *
143 * @return Status code
144 *
145 * Returns:
146 * - @ref AclSuccess if function was completed successfully
147 * - @ref AclInvalidArgument if a given argument is invalid
148 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100149 AclStatus AclUnmapTensor(AclTensor tensor, void *handle);
Georgios Pinitas3f26ef42021-02-23 10:01:33 +0000150
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100151 /** Import external memory to a given tensor object
Georgios Pinitas3f26ef42021-02-23 10:01:33 +0000152 *
153 * @param[in, out] tensor Tensor to import memory to
154 * @param[in] handle Backing memory to be imported
155 * @param[in] type Type of the imported memory
156 *
157 * Returns:
158 * - @ref AclSuccess if function was completed successfully
159 * - @ref AclInvalidArgument if a given argument is invalid
160 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100161 AclStatus AclTensorImport(AclTensor tensor, void *handle, AclImportMemoryType type);
Georgios Pinitas3f26ef42021-02-23 10:01:33 +0000162
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100163 /** Destroy a given tensor object
Georgios Pinitas3f26ef42021-02-23 10:01:33 +0000164 *
165 * @param[in,out] tensor A valid tensor object to be destroyed
166 *
167 * @return Status code
168 *
169 * Returns:
170 * - @ref AclSuccess if function was completed successfully
171 * - @ref AclInvalidArgument if the provided tensor is invalid
172 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100173 AclStatus AclDestroyTensor(AclTensor tensor);
Georgios Pinitas3f26ef42021-02-23 10:01:33 +0000174
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100175 /** Creates a tensor pack
Georgios Pinitas3f26ef42021-02-23 10:01:33 +0000176 *
177 * Tensor packs are used to create a collection of tensors that can be passed around for operator execution
178 *
179 * @param[in,out] pack A valid non-zero tensor pack object if no failures occur
180 * @param[in] ctx Context to be used
181 *
182 * @return Status code
183 *
184 * Returns:
185 * - @ref AclSuccess if function was completed successfully
186 * - @ref AclOutOfMemory if there was a failure allocating memory resources
187 * - @ref AclInvalidArgument if a given argument is invalid
188 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100189 AclStatus AclCreateTensorPack(AclTensorPack *pack, AclContext ctx);
Georgios Pinitas3f26ef42021-02-23 10:01:33 +0000190
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100191 /** Add a tensor to a tensor pack
Georgios Pinitas3f26ef42021-02-23 10:01:33 +0000192 *
193 * @param[in,out] pack Pack to append a tensor to
194 * @param[in] tensor Tensor to pack
195 * @param[in] slot_id Slot of the operator that the tensors corresponds to
196 *
197 * @return Status code
198 *
199 * Returns:
200 * - @ref AclSuccess if function was completed successfully
201 * - @ref AclOutOfMemory if there was a failure allocating memory resources
202 * - @ref AclInvalidArgument if a given argument is invalid
203 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100204 AclStatus AclPackTensor(AclTensorPack pack, AclTensor tensor, int32_t slot_id);
Georgios Pinitas3f26ef42021-02-23 10:01:33 +0000205
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100206 /** A list of tensors to a tensor pack
Georgios Pinitas3f26ef42021-02-23 10:01:33 +0000207 *
208 * @param[in,out] pack Pack to append the tensors to
209 * @param[in] tensors Tensors to append to the pack
210 * @param[in] slot_ids Slot IDs of each tensors to the operators
211 * @param[in] num_tensors Number of tensors that are passed
212 *
213 * @return Status code
214 *
215 * Returns:
216 * - @ref AclSuccess if function was completed successfully
217 * - @ref AclOutOfMemory if there was a failure allocating memory resources
218 * - @ref AclInvalidArgument if a given argument is invalid
219 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100220 AclStatus AclPackTensors(AclTensorPack pack, AclTensor *tensors, int32_t *slot_ids, size_t num_tensors);
Georgios Pinitas3f26ef42021-02-23 10:01:33 +0000221
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100222 /** Destroy a given tensor pack object
Georgios Pinitas3f26ef42021-02-23 10:01:33 +0000223 *
224 * @param[in,out] pack A valid tensor pack object to destroy
225 *
226 * @return Status code
227 *
228 * Returns:
229 * - @ref AclSuccess if functions was completed successfully
230 * - @ref AclInvalidArgument if the provided context is invalid
231 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100232 AclStatus AclDestroyTensorPack(AclTensorPack pack);
Georgios Pinitas3f26ef42021-02-23 10:01:33 +0000233
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100234 /** Eager execution of a given operator on a list of inputs and outputs
Georgios Pinitas06ac6e42021-07-05 08:08:52 +0100235 *
236 * @param[in] op Operator to execute
237 * @param[in] queue Queue to schedule the operator on
238 * @param[in,out] tensors A list of input and outputs tensors to execute the operator on
239 *
240 * @return Status Code
241 *
242 * Returns:
243 * - @ref AclSuccess if function was completed successfully
244 * - @ref AclOutOfMemory if there was a failure allocating memory resources
245 * - @ref AclUnsupportedTarget if the requested target is unsupported
246 * - @ref AclInvalidArgument if a given argument is invalid
247 * - @ref AclRuntimeError on any other runtime related error
248 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100249 AclStatus AclRunOperator(AclOperator op, AclQueue queue, AclTensorPack tensors);
Georgios Pinitas06ac6e42021-07-05 08:08:52 +0100250
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100251 /** Destroy a given operator object
Georgios Pinitas06ac6e42021-07-05 08:08:52 +0100252 *
253 * @param[in,out] op A valid operator object to destroy
254 *
255 * @return Status code
256 *
257 * Returns:
258 * - @ref AclSuccess if functions was completed successfully
259 * - @ref AclInvalidArgument if the provided context is invalid
260 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100261 AclStatus AclDestroyOperator(AclOperator op);
Georgios Pinitas8a5146f2021-01-12 15:51:07 +0000262#ifdef __cplusplus
263}
264#endif /* __cplusplus */
Georgios Pinitas06ac6e42021-07-05 08:08:52 +0100265#endif /* ARM_COMPUTE_ACL_ENTRYPOINTS_H_ */