Georgios Pinitas | 8a5146f | 2021-01-12 15:51:07 +0000 | [diff] [blame] | 1 | /* |
| 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 Pinitas | 06ac6e4 | 2021-07-05 08:08:52 +0100 | [diff] [blame] | 24 | #ifndef ARM_COMPUTE_ACL_ENTRYPOINTS_H_ |
| 25 | #define ARM_COMPUTE_ACL_ENTRYPOINTS_H_ |
Georgios Pinitas | 8a5146f | 2021-01-12 15:51:07 +0000 | [diff] [blame] | 26 | |
| 27 | #include "arm_compute/AclTypes.h" |
| 28 | |
| 29 | #ifdef __cplusplus |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 30 | extern "C" |
| 31 | { |
Georgios Pinitas | 8a5146f | 2021-01-12 15:51:07 +0000 | [diff] [blame] | 32 | #endif /** __cplusplus */ |
| 33 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 34 | /** Create a context object |
Georgios Pinitas | 8a5146f | 2021-01-12 15:51:07 +0000 | [diff] [blame] | 35 | * |
| 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 Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 50 | AclStatus AclCreateContext(AclContext *ctx, AclTarget target, const AclContextOptions *options); |
Georgios Pinitas | 8a5146f | 2021-01-12 15:51:07 +0000 | [diff] [blame] | 51 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 52 | /** Destroy a given context object |
Georgios Pinitas | 8a5146f | 2021-01-12 15:51:07 +0000 | [diff] [blame] | 53 | * |
| 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 Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 62 | AclStatus AclDestroyContext(AclContext ctx); |
Georgios Pinitas | 8a5146f | 2021-01-12 15:51:07 +0000 | [diff] [blame] | 63 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 64 | /** Create an operator queue |
Georgios Pinitas | c3c352e | 2021-03-18 10:59:40 +0000 | [diff] [blame] | 65 | * |
| 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 Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 80 | AclStatus AclCreateQueue(AclQueue *queue, AclContext ctx, const AclQueueOptions *options); |
Georgios Pinitas | c3c352e | 2021-03-18 10:59:40 +0000 | [diff] [blame] | 81 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 82 | /** Wait until all elements on the queue have been completed |
Georgios Pinitas | c3c352e | 2021-03-18 10:59:40 +0000 | [diff] [blame] | 83 | * |
| 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 Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 93 | AclStatus AclQueueFinish(AclQueue queue); |
Georgios Pinitas | c3c352e | 2021-03-18 10:59:40 +0000 | [diff] [blame] | 94 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 95 | /** Destroy a given queue object |
Georgios Pinitas | c3c352e | 2021-03-18 10:59:40 +0000 | [diff] [blame] | 96 | * |
| 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 Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 105 | AclStatus AclDestroyQueue(AclQueue queue); |
Georgios Pinitas | c3c352e | 2021-03-18 10:59:40 +0000 | [diff] [blame] | 106 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 107 | /** Create a Tensor object |
Georgios Pinitas | 3f26ef4 | 2021-02-23 10:01:33 +0000 | [diff] [blame] | 108 | * |
| 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 Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 123 | AclStatus AclCreateTensor(AclTensor *tensor, AclContext ctx, const AclTensorDescriptor *desc, bool allocate); |
Georgios Pinitas | 3f26ef4 | 2021-02-23 10:01:33 +0000 | [diff] [blame] | 124 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 125 | /** Map a tensor's backing memory to the host |
Georgios Pinitas | 3f26ef4 | 2021-02-23 10:01:33 +0000 | [diff] [blame] | 126 | * |
| 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 Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 136 | AclStatus AclMapTensor(AclTensor tensor, void **handle); |
Georgios Pinitas | 3f26ef4 | 2021-02-23 10:01:33 +0000 | [diff] [blame] | 137 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 138 | /** Unmap the tensor's backing memory |
Georgios Pinitas | 3f26ef4 | 2021-02-23 10:01:33 +0000 | [diff] [blame] | 139 | * |
| 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 Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 149 | AclStatus AclUnmapTensor(AclTensor tensor, void *handle); |
Georgios Pinitas | 3f26ef4 | 2021-02-23 10:01:33 +0000 | [diff] [blame] | 150 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 151 | /** Import external memory to a given tensor object |
Georgios Pinitas | 3f26ef4 | 2021-02-23 10:01:33 +0000 | [diff] [blame] | 152 | * |
| 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 Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 161 | AclStatus AclTensorImport(AclTensor tensor, void *handle, AclImportMemoryType type); |
Georgios Pinitas | 3f26ef4 | 2021-02-23 10:01:33 +0000 | [diff] [blame] | 162 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 163 | /** Destroy a given tensor object |
Georgios Pinitas | 3f26ef4 | 2021-02-23 10:01:33 +0000 | [diff] [blame] | 164 | * |
| 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 Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 173 | AclStatus AclDestroyTensor(AclTensor tensor); |
Georgios Pinitas | 3f26ef4 | 2021-02-23 10:01:33 +0000 | [diff] [blame] | 174 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 175 | /** Creates a tensor pack |
Georgios Pinitas | 3f26ef4 | 2021-02-23 10:01:33 +0000 | [diff] [blame] | 176 | * |
| 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 Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 189 | AclStatus AclCreateTensorPack(AclTensorPack *pack, AclContext ctx); |
Georgios Pinitas | 3f26ef4 | 2021-02-23 10:01:33 +0000 | [diff] [blame] | 190 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 191 | /** Add a tensor to a tensor pack |
Georgios Pinitas | 3f26ef4 | 2021-02-23 10:01:33 +0000 | [diff] [blame] | 192 | * |
| 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 Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 204 | AclStatus AclPackTensor(AclTensorPack pack, AclTensor tensor, int32_t slot_id); |
Georgios Pinitas | 3f26ef4 | 2021-02-23 10:01:33 +0000 | [diff] [blame] | 205 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 206 | /** A list of tensors to a tensor pack |
Georgios Pinitas | 3f26ef4 | 2021-02-23 10:01:33 +0000 | [diff] [blame] | 207 | * |
| 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 Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 220 | AclStatus AclPackTensors(AclTensorPack pack, AclTensor *tensors, int32_t *slot_ids, size_t num_tensors); |
Georgios Pinitas | 3f26ef4 | 2021-02-23 10:01:33 +0000 | [diff] [blame] | 221 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 222 | /** Destroy a given tensor pack object |
Georgios Pinitas | 3f26ef4 | 2021-02-23 10:01:33 +0000 | [diff] [blame] | 223 | * |
| 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 Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 232 | AclStatus AclDestroyTensorPack(AclTensorPack pack); |
Georgios Pinitas | 3f26ef4 | 2021-02-23 10:01:33 +0000 | [diff] [blame] | 233 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 234 | /** Eager execution of a given operator on a list of inputs and outputs |
Georgios Pinitas | 06ac6e4 | 2021-07-05 08:08:52 +0100 | [diff] [blame] | 235 | * |
| 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 Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 249 | AclStatus AclRunOperator(AclOperator op, AclQueue queue, AclTensorPack tensors); |
Georgios Pinitas | 06ac6e4 | 2021-07-05 08:08:52 +0100 | [diff] [blame] | 250 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 251 | /** Destroy a given operator object |
Georgios Pinitas | 06ac6e4 | 2021-07-05 08:08:52 +0100 | [diff] [blame] | 252 | * |
| 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 Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 261 | AclStatus AclDestroyOperator(AclOperator op); |
Georgios Pinitas | 8a5146f | 2021-01-12 15:51:07 +0000 | [diff] [blame] | 262 | #ifdef __cplusplus |
| 263 | } |
| 264 | #endif /* __cplusplus */ |
Georgios Pinitas | 06ac6e4 | 2021-07-05 08:08:52 +0100 | [diff] [blame] | 265 | #endif /* ARM_COMPUTE_ACL_ENTRYPOINTS_H_ */ |