ONE - On-device Neural Engine
Loading...
Searching...
No Matches
ElementwiseBinary.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2025 Samsung Electronics Co., Ltd. All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "../KernelGenerator.h"
18#include "../Validator.h"
19
20#include <AclKernelGen.h>
21
23{
24
25void Validator::visit(const ir::operation::ElementwiseBinary &) { _supported = true; }
26
27void KernelGenerator::visit(const ir::operation::ElementwiseBinary &node)
28{
29 const auto output_index{node.getOutputs().at(0)};
30 const auto lhs_index{node.getInputs().at(ir::operation::ElementwiseBinary::Input::LHS)};
31 const auto rhs_index{node.getInputs().at(ir::operation::ElementwiseBinary::Input::RHS)};
32
33 auto output_tensor = _tensor_reg->getAclTensor(output_index);
34 auto lhs_tensor = _tensor_reg->getAclTensor(lhs_index);
35 auto rhs_tensor = _tensor_reg->getAclTensor(rhs_index);
36
37 std::unique_ptr<arm_compute::IFunction> fn;
38 switch (node.param().op_type)
39 {
41 {
42 fn = acl_common::generateLayer<arm_compute::CLLogicalAnd>(
43 lhs_tensor->handle(), rhs_tensor->handle(), output_tensor->handle());
44 break;
45 }
47 {
48 fn = acl_common::generateLayer<arm_compute::CLLogicalOr>(
49 lhs_tensor->handle(), rhs_tensor->handle(), output_tensor->handle());
50 break;
51 }
53 {
54 fn = acl_common::generateLayer<arm_compute::CLElementwiseMax>(
55 lhs_tensor->handle(), rhs_tensor->handle(), output_tensor->handle());
56 break;
57 }
59 {
60 fn = acl_common::generateLayer<arm_compute::CLElementwiseMin>(
61 lhs_tensor->handle(), rhs_tensor->handle(), output_tensor->handle());
62 break;
63 }
64 default:
65 {
66 std::string err_msg("acl_cl KernelGenerator : " + node.name() +
67 "is not elementwise-binary operations");
68 assert(false && err_msg.c_str());
69 break;
70 }
71 }
72
74}
75
76} // namespace onert::backend::acl_cl
std::unique_ptr< exec::IFunction > _return_fn
std::unique_ptr< AclFunction > asAclFunction(std::unique_ptr<::arm_compute::IFunction > &&layer)
Definition Convert.cc:246