blob: cd974341c24b71298fcb72b60fb52864e7b9a2f7 [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 */
24#ifndef ARM_COMPUTE_ACLENTRYPOINTS_H_
25#define ARM_COMPUTE_ACLENTRYPOINTS_H_
26
27#include "arm_compute/AclTypes.h"
28
29#ifdef __cplusplus
30extern "C" {
31#endif /** __cplusplus */
32
33/** Create a context object
34 *
35 * Context is responsible for retaining internal information and work as an aggregate service mechanism
36 *
37 * @param[in, out] ctx A valid non-zero context object if no failure occurs
38 * @param[in] target Target to create the context for
39 * @param[in] options Context options to be used for all the kernels that are created under the context
40 *
41 * @return Status code
42 *
43 * Returns:
44 * - @ref AclSuccess if function was completed successfully
45 * - @ref AclOutOfMemory if there was a failure allocating memory resources
46 * - @ref AclUnsupportedTarget if the requested target is unsupported
47 * - @ref AclInvalidArgument if a given argument is invalid
48 */
49AclStatus AclCreateContext(AclContext *ctx,
50 AclTarget target,
51 const AclContextOptions *options);
52
53/** Destroy a given context object
54 *
55 * @param[in] ctx A valid context object to destroy
56 *
57 * @return Status code
58 *
59 * Returns:
60 * - @ref AclSuccess if functions was completed successfully
61 * - @ref AclInvalidArgument if the provided context is invalid
62 */
63AclStatus AclDestroyContext(AclContext ctx);
64
Georgios Pinitas3f26ef42021-02-23 10:01:33 +000065/** Create a Tensor object
66 *
67 * Tensor is a generalized matrix construct that can represent up to ND dimensionality (where N = 6 for Compute Library)
68 * The object holds a backing memory along-side to operate on
69 *
70 * @param[in, out] tensor A valid non-zero tensor object if no failures occur
71 * @param[in] ctx Context to be used
72 * @param[in] desc Tensor representation meta-data
73 * @param[in] allocate Instructs allocation of the tensor objects
74 *
75 * Returns:
76 * - @ref AclSuccess if function was completed successfully
77 * - @ref AclOutOfMemory if there was a failure allocating memory resources
78 * - @ref AclUnsupportedTarget if the requested target is unsupported
79 * - @ref AclInvalidArgument if a given argument is invalid
80 */
81AclStatus AclCreateTensor(AclTensor *tensor, AclContext ctx, const AclTensorDescriptor *desc, bool allocate);
82
83/** Map a tensor's backing memory to the host
84 *
85 * @param[in] tensor Tensor to be mapped
86 * @param[in, out] handle A handle to the underlying backing memory
87 *
88 * @return Status code
89 *
90 * Returns:
91 * - @ref AclSuccess if function was completed successfully
92 * - @ref AclInvalidArgument if a given argument is invalid
93 */
94AclStatus AclMapTensor(AclTensor tensor, void **handle);
95
96/** Unmap the tensor's backing memory
97 *
98 * @param[in] tensor tensor to unmap memory from
99 * @param[in] handle Backing memory to be unmapped
100 *
101 * @return Status code
102 *
103 * Returns:
104 * - @ref AclSuccess if function was completed successfully
105 * - @ref AclInvalidArgument if a given argument is invalid
106 */
107AclStatus AclUnmapTensor(AclTensor tensor, void *handle);
108
109/** Import external memory to a given tensor object
110 *
111 * @param[in, out] tensor Tensor to import memory to
112 * @param[in] handle Backing memory to be imported
113 * @param[in] type Type of the imported memory
114 *
115 * Returns:
116 * - @ref AclSuccess if function was completed successfully
117 * - @ref AclInvalidArgument if a given argument is invalid
118 */
119AclStatus AclTensorImport(AclTensor tensor, void *handle, AclImportMemoryType type);
120
121/** Destroy a given tensor object
122 *
123 * @param[in,out] tensor A valid tensor object to be destroyed
124 *
125 * @return Status code
126 *
127 * Returns:
128 * - @ref AclSuccess if function was completed successfully
129 * - @ref AclInvalidArgument if the provided tensor is invalid
130 */
131AclStatus AclDestroyTensor(AclTensor tensor);
132
133/** Creates a tensor pack
134 *
135 * Tensor packs are used to create a collection of tensors that can be passed around for operator execution
136 *
137 * @param[in,out] pack A valid non-zero tensor pack object if no failures occur
138 * @param[in] ctx Context to be used
139 *
140 * @return Status code
141 *
142 * Returns:
143 * - @ref AclSuccess if function was completed successfully
144 * - @ref AclOutOfMemory if there was a failure allocating memory resources
145 * - @ref AclInvalidArgument if a given argument is invalid
146 */
147AclStatus AclCreateTensorPack(AclTensorPack *pack, AclContext ctx);
148
149/** Add a tensor to a tensor pack
150 *
151 * @param[in,out] pack Pack to append a tensor to
152 * @param[in] tensor Tensor to pack
153 * @param[in] slot_id Slot of the operator that the tensors corresponds to
154 *
155 * @return Status code
156 *
157 * Returns:
158 * - @ref AclSuccess if function was completed successfully
159 * - @ref AclOutOfMemory if there was a failure allocating memory resources
160 * - @ref AclInvalidArgument if a given argument is invalid
161 */
162AclStatus AclPackTensor(AclTensorPack pack, AclTensor tensor, int32_t slot_id);
163
164/** A list of tensors to a tensor pack
165 *
166 * @param[in,out] pack Pack to append the tensors to
167 * @param[in] tensors Tensors to append to the pack
168 * @param[in] slot_ids Slot IDs of each tensors to the operators
169 * @param[in] num_tensors Number of tensors that are passed
170 *
171 * @return Status code
172 *
173 * Returns:
174 * - @ref AclSuccess if function was completed successfully
175 * - @ref AclOutOfMemory if there was a failure allocating memory resources
176 * - @ref AclInvalidArgument if a given argument is invalid
177 */
178AclStatus AclPackTensors(AclTensorPack pack, AclTensor *tensors, int32_t *slot_ids, size_t num_tensors);
179
180/** Destroy a given tensor pack object
181 *
182 * @param[in,out] pack A valid tensor pack object to destroy
183 *
184 * @return Status code
185 *
186 * Returns:
187 * - @ref AclSuccess if functions was completed successfully
188 * - @ref AclInvalidArgument if the provided context is invalid
189 */
190AclStatus AclDestroyTensorPack(AclTensorPack pack);
191
Georgios Pinitas8a5146f2021-01-12 15:51:07 +0000192#ifdef __cplusplus
193}
194#endif /* __cplusplus */
195#endif /* ARM_COMPUTE_ACLENTRYPOINTS_H_ */