xref: /aosp_15_r20/external/ComputeLibrary/src/c/AclOperator.cpp (revision c217d954acce2dbc11938adb493fc0abd69584f3)
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  */
24 #include "arm_compute/AclEntrypoints.h"
25 
26 #include "src/common/IOperator.h"
27 #include "src/common/IQueue.h"
28 #include "src/common/TensorPack.h"
29 #include "src/common/utils/Macros.h"
30 
AclRunOperator(AclOperator external_op,AclQueue external_queue,AclTensorPack external_tensors)31 extern "C" AclStatus AclRunOperator(AclOperator external_op, AclQueue external_queue, AclTensorPack external_tensors)
32 {
33     using namespace arm_compute;
34 
35     auto op    = get_internal(external_op);
36     auto queue = get_internal(external_queue);
37     auto pack  = get_internal(external_tensors);
38 
39     StatusCode status = StatusCode::Success;
40     status            = detail::validate_internal_operator(op);
41     ARM_COMPUTE_RETURN_CENUM_ON_FAILURE(status);
42     status = detail::validate_internal_queue(queue);
43     ARM_COMPUTE_RETURN_CENUM_ON_FAILURE(status);
44     status = detail::validate_internal_pack(pack);
45     ARM_COMPUTE_RETURN_CENUM_ON_FAILURE(status);
46 
47     status = op->run(*queue, pack->get_tensor_pack());
48     ARM_COMPUTE_RETURN_CENUM_ON_FAILURE(status);
49 
50     return AclSuccess;
51 }
52 
AclDestroyOperator(AclOperator external_op)53 extern "C" AclStatus AclDestroyOperator(AclOperator external_op)
54 {
55     using namespace arm_compute;
56 
57     auto op = get_internal(external_op);
58 
59     StatusCode status = detail::validate_internal_operator(op);
60     ARM_COMPUTE_RETURN_CENUM_ON_FAILURE(status);
61 
62     delete op;
63 
64     return AclSuccess;
65 }
66