ONE - On-device Neural Engine
Loading...
Searching...
No Matches
RNN.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::RNN &) { _supported = true; }
26
27void KernelGenerator::visit(const ir::operation::RNN &node)
28{
29 const auto output_index{node.getOutputs().at(ir::operation::RNN::Output::OUTPUT)};
30 const auto hidden_state_out_index{
32
33 const auto input_index{node.getInputs().at(ir::operation::RNN::Input::INPUT)};
34 const auto weights_index{node.getInputs().at(ir::operation::RNN::Input::WEIGHTS)};
35 const auto recurrent_weights_index{
37 const auto bias_index{node.getInputs().at(ir::operation::RNN::Input::BIAS)};
38 const auto hidden_state_in_index{node.getInputs().at(ir::operation::RNN::Input::HIDDEN_STATE_IN)};
39
40 const auto activation = node.param().activation;
41
42 auto output_tensor = _tensor_reg->getAclTensor(output_index);
43 auto hidden_state_out_tensor = _tensor_reg->getAclTensor(hidden_state_out_index);
44
45 auto input_tensor = _tensor_reg->getAclTensor(input_index);
46 auto weights_tensor = _tensor_reg->getAclTensor(weights_index);
47 auto recurrent_weights_tensor = _tensor_reg->getAclTensor(recurrent_weights_index);
48 auto bias_tensor = _tensor_reg->getAclTensor(bias_index);
49 auto hidden_state_in_tensor = _tensor_reg->getAclTensor(hidden_state_in_index);
51
52 auto copy_layer = acl_common::generateLayer<arm_compute::CLCopy>(
53 hidden_state_in_tensor->handle(), hidden_state_out_tensor->handle());
54 _return_fn = acl_common::asAclFunction(std::move(copy_layer));
55
56 auto fn = acl_common::generateLayer<arm_compute::CLRNNLayer>(
57 _tensor_builder->acl_tensor_manager()->internal_buffer_manager(), input_tensor->handle(),
58 weights_tensor->handle(), recurrent_weights_tensor->handle(), bias_tensor->handle(),
59 hidden_state_out_tensor->handle(), output_tensor->handle(), act_info);
61}
62
63} // namespace onert::backend::acl_cl
std::unique_ptr< exec::IFunction > _return_fn
::arm_compute::ActivationLayerInfo asActivationLayerInfo(const ir::Activation act_code)
Definition Convert.cc:131
std::unique_ptr< AclFunction > asAclFunction(std::unique_ptr<::arm_compute::IFunction > &&layer)
Definition Convert.cc:246
CLTensor bias_tensor