ONE - On-device Neural Engine
Loading...
Searching...
No Matches
onert::backend::acl_neon::ConstantInitializer Class Reference

#include <ConstantInitializer.h>

Collaboration diagram for onert::backend::acl_neon::ConstantInitializer:

Public Member Functions

 ConstantInitializer (const ir::Operands &operands, const std::shared_ptr< ITensorRegistry > &tensor_reg)
 
void visit (const ir::operation::SpaceToBatchND &node) final
 
- Public Member Functions inherited from onert::backend::acl_common::AclConstantInitializer
void run ()
 
 AclConstantInitializer (const ir::Operands &operands, const std::shared_ptr< ITensorRegistry > &tensor_reg)
 
void registerDefaultInitializer (const ir::OperandIndex &index, const ir::Operand &obj)
 
void registerCopyInitializer (const ir::OperandIndex &index, const ir::Operand &obj)
 
bool exist (const ir::OperandIndex &ind)
 
void visit (const ir::operation::BatchToSpaceND &) override
 
void visit (const ir::operation::Conv2D &) override
 
void visit (const ir::operation::DepthwiseConv2D &) override
 
void visit (const ir::operation::FullyConnected &) override
 
void visit (const ir::operation::LSTM &) override
 
void visit (const ir::operation::RNN &) override
 
void visit (const ir::operation::TransposeConv &) override
 
- Public Member Functions inherited from onert::ir::OperationVisitor
virtual ~OperationVisitor ()=default
 

Additional Inherited Members

- Public Types inherited from onert::backend::acl_common::AclConstantInitializer
using Initializer = std::function< void(const ir::Operand &, backend::ITensor &)>
 
- Protected Member Functions inherited from onert::backend::acl_common::AclConstantInitializer
void copyInputInitialize (const ir::Operation &node, uint32_t index)
 
- Protected Attributes inherited from onert::backend::acl_common::AclConstantInitializer
const ir::Operands_operands
 
std::shared_ptr< ITensorRegistry_tensor_reg
 
std::unordered_map< ir::OperandIndex, Initializer_init_map
 

Detailed Description

Definition at line 29 of file ConstantInitializer.h.

Constructor & Destructor Documentation

◆ ConstantInitializer()

onert::backend::acl_neon::ConstantInitializer::ConstantInitializer ( const ir::Operands operands,
const std::shared_ptr< ITensorRegistry > &  tensor_reg 
)

Definition at line 26 of file ConstantInitializer.cc.

28 : acl_common::AclConstantInitializer{operands, tensor_reg}
29{
30 // DO NOTHING
31}

Member Function Documentation

◆ visit()

void onert::backend::acl_neon::ConstantInitializer::visit ( const ir::operation::SpaceToBatchND node)
final

Definition at line 33 of file ConstantInitializer.cc.

34{
35 const auto &block_size_index = node.getInputs().at(ir::operation::SpaceToBatchND::BLOCK_SIZE);
36 const auto &block_size_obj = _operands.at(block_size_index);
37
38 if (block_size_obj.isConstant())
39 {
40 _init_map[block_size_index] = acl_common::initReverseOrder<int32_t>;
41 }
42
43 const auto &paddings_index = node.getInputs().at(ir::operation::SpaceToBatchND::PADDINGS);
44 const auto &paddings_obj = _operands.at(paddings_index);
45 if (paddings_obj.isConstant())
46 {
47 _init_map[paddings_index] = [](const ir::Operand &model_obj, backend::ITensor &obj) {
48 assert(model_obj.data());
49 const auto &shape = model_obj.shape();
50 const auto base = reinterpret_cast<const int32_t *>(model_obj.data()->base());
51 assert(model_obj.shape().rank() == 2);
52 assert(shape.dim(0) == 2);
53 assert(shape.dim(1) == 2);
54 obj.access([&](ITensor &tensor) {
55 for (auto i = 0; i < shape.dim(0); ++i)
56 {
57 for (auto j = 0; j < shape.dim(1); ++j)
58 {
59 const int32_t value = base[i * 2 + j];
60 int32_t *into = reinterpret_cast<int32_t *>(
61 // The coordinates of NETensor are different from the coordiantes of CLTensor in
62 // this operand.
63 // NEON : {j, reversed i}
64 // CL : {reversed i, j}
65 tensor.buffer() + tensor.calcOffset({j, shape.dim(0) - i - 1}));
66 *into = value;
67 }
68 }
69 });
70 };
71 }
72}
std::unordered_map< ir::OperandIndex, Initializer > _init_map
const Object & at(const Index &index) const
Get the object that is associated with the given index.

References onert::backend::acl_common::AclConstantInitializer::_init_map, onert::backend::acl_common::AclConstantInitializer::_operands, onert::util::ObjectManager< Index, Object >::at(), onert::ir::OperandIndexSequence::at(), onert::ir::operation::SpaceToBatchND::BLOCK_SIZE, onert::ir::Operand::data(), onert::ir::Operation::getInputs(), onert::ir::operation::SpaceToBatchND::PADDINGS, and onert::ir::Operand::shape().


The documentation for this class was generated from the following files: