ONE - On-device Neural Engine
Loading...
Searching...
No Matches
onert::backend::cpu Namespace Reference

Namespaces

namespace  ops
 

Data Structures

class  Backend
 
class  BackendContext
 
class  Config
 
class  ExternalContext
 
class  KernelGenerator
 
class  Validator
 

Typedefs

using StaticTensorManager = basic::StaticTensorManager
 
using Tensor = basic::Tensor
 
using ExternalTensor = basic::ExternalTensor
 
using TensorBuilder = basic::TensorBuilder
 

Functions

ops::ArithmeticType convertArithmeticType (ir::operation::BinaryArithmetic::ArithmeticType arithmetic_type_ir)
 
ops::ElementwiseActivationType convertElementwiseActivationType (ir::operation::ElementwiseActivation::Type type_ir)
 
ops::ElementwiseBinaryType convertElementwiseBinaryType (ir::operation::ElementwiseBinary::ElementwiseBinaryType type_ir)
 
ops::ElementwiseUnaryType convertElementwiseUnaryType (ir::operation::ElementwiseUnary::Type type_ir)
 
ops::PoolType convertPoolType (ir::operation::Pool2D::PoolType type_ir)
 
ops::ReduceType convertReduceType (ir::operation::Reduce::ReduceType reduce_type_ir)
 
ir::OperandIndexMap< ir::OperandIndexfindSharedMemoryOperandIndexes (const ir::IGraph &graph)
 

Typedef Documentation

◆ ExternalTensor

Definition at line 27 of file Tensor.h.

◆ StaticTensorManager

◆ Tensor

Definition at line 26 of file Tensor.h.

◆ TensorBuilder

Definition at line 25 of file TensorBuilder.h.

Function Documentation

◆ convertArithmeticType()

ops::ArithmeticType onert::backend::cpu::convertArithmeticType ( ir::operation::BinaryArithmetic::ArithmeticType  arithmetic_type_ir)

Definition at line 30 of file BinaryArithmeticLayer.cc.

31{
32 switch (arithmetic_type_ir)
33 {
34 case ir::operation::BinaryArithmetic::ArithmeticType::ADD:
35 return ops::ArithmeticType::kAdd;
36 case ir::operation::BinaryArithmetic::ArithmeticType::SUB:
37 return ops::ArithmeticType::kSub;
38 case ir::operation::BinaryArithmetic::ArithmeticType::MUL:
39 return ops::ArithmeticType::kMul;
40 case ir::operation::BinaryArithmetic::ArithmeticType::DIV:
41 return ops::ArithmeticType::kDiv;
42 default:
43 throw std::runtime_error("cpu KernelGenerator : Not supported operation yet");
44 }
45}

References onert::ir::operation::BinaryArithmetic::ADD, onert::ir::operation::BinaryArithmetic::DIV, onert::backend::cpu::ops::kAdd, onert::backend::cpu::ops::kDiv, onert::backend::cpu::ops::kMul, onert::backend::cpu::ops::kSub, onert::ir::operation::BinaryArithmetic::MUL, and onert::ir::operation::BinaryArithmetic::SUB.

◆ convertElementwiseActivationType()

ops::ElementwiseActivationType onert::backend::cpu::convertElementwiseActivationType ( ir::operation::ElementwiseActivation::Type  type_ir)

Definition at line 37 of file ElementwiseActivationLayer.cc.

38{
39 switch (type_ir)
40 {
41 case ir::operation::ElementwiseActivation::Type::ELU:
42 return ops::ElementwiseActivationType::kElu;
43 case ir::operation::ElementwiseActivation::Type::LOGISTIC:
44 return ops::ElementwiseActivationType::kLogistic;
45 case ir::operation::ElementwiseActivation::Type::RELU:
46 return ops::ElementwiseActivationType::kReLU;
47 case ir::operation::ElementwiseActivation::Type::TANH:
48 return ops::ElementwiseActivationType::kTanh;
49 case ir::operation::ElementwiseActivation::Type::LEAKY_RELU:
50 return ops::ElementwiseActivationType::kLeakyReLU;
51 case ir::operation::ElementwiseActivation::Type::GELU:
52 return ops::ElementwiseActivationType::kGELU;
53 default:
54 throw std::runtime_error("cpu KernelGenerator : Not supported operation yet");
55 }
56}

References onert::ir::operation::ElementwiseActivation::ELU, onert::ir::operation::ElementwiseActivation::GELU, onert::backend::cpu::ops::kElu, onert::backend::cpu::ops::kGELU, onert::backend::cpu::ops::kLeakyReLU, onert::backend::cpu::ops::kLogistic, onert::backend::cpu::ops::kReLU, onert::backend::cpu::ops::kTanh, onert::ir::operation::ElementwiseActivation::LEAKY_RELU, onert::ir::operation::ElementwiseActivation::LOGISTIC, onert::ir::operation::ElementwiseActivation::RELU, and onert::ir::operation::ElementwiseActivation::TANH.

◆ convertElementwiseBinaryType()

ops::ElementwiseBinaryType onert::backend::cpu::convertElementwiseBinaryType ( ir::operation::ElementwiseBinary::ElementwiseBinaryType  type_ir)

Definition at line 35 of file ElementwiseBinaryLayer.cc.

36{
37 switch (type_ir)
38 {
39 case ir::operation::ElementwiseBinary::ElementwiseBinaryType::FLOOR_DIV:
40 return ops::ElementwiseBinaryType::kFloorDiv;
41 case ir::operation::ElementwiseBinary::ElementwiseBinaryType::FLOOR_MOD:
42 return ops::ElementwiseBinaryType::kFloorMod;
43 case ir::operation::ElementwiseBinary::ElementwiseBinaryType::LOGICAL_AND:
44 return ops::ElementwiseBinaryType::kLogicalAnd;
45 case ir::operation::ElementwiseBinary::ElementwiseBinaryType::LOGICAL_OR:
46 return ops::ElementwiseBinaryType::kLogicalOr;
47 case ir::operation::ElementwiseBinary::ElementwiseBinaryType::MAX:
48 return ops::ElementwiseBinaryType::kMax;
49 case ir::operation::ElementwiseBinary::ElementwiseBinaryType::MIN:
50 return ops::ElementwiseBinaryType::kMin;
51 default:
52 throw std::runtime_error("cpu KernelGenerator : Not supported operation yet");
53 }
54}

References onert::ir::operation::ElementwiseBinary::FLOOR_DIV, onert::ir::operation::ElementwiseBinary::FLOOR_MOD, onert::backend::cpu::ops::kFloorDiv, onert::backend::cpu::ops::kFloorMod, onert::backend::cpu::ops::kLogicalAnd, onert::backend::cpu::ops::kLogicalOr, onert::backend::cpu::ops::kMax, onert::backend::cpu::ops::kMin, onert::ir::operation::ElementwiseBinary::LOGICAL_AND, onert::ir::operation::ElementwiseBinary::LOGICAL_OR, onert::ir::operation::ElementwiseBinary::MAX, and onert::ir::operation::ElementwiseBinary::MIN.

◆ convertElementwiseUnaryType()

ops::ElementwiseUnaryType onert::backend::cpu::convertElementwiseUnaryType ( ir::operation::ElementwiseUnary::Type  type_ir)

Definition at line 36 of file ElementwiseUnaryLayer.cc.

37{
38 switch (type_ir)
39 {
40 case ir::operation::ElementwiseUnary::Type::ABS:
41 return ops::ElementwiseUnaryType::kAbs;
42 case ir::operation::ElementwiseUnary::Type::CAST:
43 return ops::ElementwiseUnaryType::kCast;
44 case ir::operation::ElementwiseUnary::Type::COS:
45 return ops::ElementwiseUnaryType::kCos;
46 case ir::operation::ElementwiseUnary::Type::DEQUANTIZE:
47 return ops::ElementwiseUnaryType::kDequantize;
48 case ir::operation::ElementwiseUnary::Type::ERF:
49 return ops::ElementwiseUnaryType::kErf;
50 case ir::operation::ElementwiseUnary::Type::EXP:
51 return ops::ElementwiseUnaryType::kExp;
52 case ir::operation::ElementwiseUnary::Type::FLOOR:
53 return ops::ElementwiseUnaryType::kFloor;
54 case ir::operation::ElementwiseUnary::Type::LOG:
55 return ops::ElementwiseUnaryType::kLog;
56 case ir::operation::ElementwiseUnary::Type::LOGICAL_NOT:
57 return ops::ElementwiseUnaryType::kLogicalNot;
58 case ir::operation::ElementwiseUnary::Type::NEG:
59 return ops::ElementwiseUnaryType::kNeg;
60 case ir::operation::ElementwiseUnary::Type::QUANTIZE:
61 return ops::ElementwiseUnaryType::kQuantize;
62 case ir::operation::ElementwiseUnary::Type::ROUND:
63 return ops::ElementwiseUnaryType::kRound;
64 case ir::operation::ElementwiseUnary::Type::RSQRT:
65 return ops::ElementwiseUnaryType::kRSqrt;
66 case ir::operation::ElementwiseUnary::Type::SIN:
67 return ops::ElementwiseUnaryType::kSin;
68 case ir::operation::ElementwiseUnary::Type::SQRT:
69 return ops::ElementwiseUnaryType::kSqrt;
70 case ir::operation::ElementwiseUnary::Type::SQUARE:
71 return ops::ElementwiseUnaryType::kSquare;
72 case ir::operation::ElementwiseUnary::Type::ZEROS_LIKE:
73 return ops::ElementwiseUnaryType::kZerosLike;
74 default:
75 throw std::runtime_error("cpu KernelGenerator : Not supported operation yet");
76 }
77}

References onert::ir::operation::ElementwiseUnary::ABS, onert::ir::operation::ElementwiseUnary::CAST, onert::ir::operation::ElementwiseUnary::COS, onert::ir::operation::ElementwiseUnary::DEQUANTIZE, onert::ir::operation::ElementwiseUnary::ERF, onert::ir::operation::ElementwiseUnary::EXP, onert::ir::operation::ElementwiseUnary::FLOOR, onert::backend::cpu::ops::kAbs, onert::backend::cpu::ops::kCast, onert::backend::cpu::ops::kCos, onert::backend::cpu::ops::kDequantize, onert::backend::cpu::ops::kErf, onert::backend::cpu::ops::kExp, onert::backend::cpu::ops::kFloor, onert::backend::cpu::ops::kLog, onert::backend::cpu::ops::kLogicalNot, onert::backend::cpu::ops::kNeg, onert::backend::cpu::ops::kQuantize, onert::backend::cpu::ops::kRound, onert::backend::cpu::ops::kRSqrt, onert::backend::cpu::ops::kSin, onert::backend::cpu::ops::kSqrt, onert::backend::cpu::ops::kSquare, onert::backend::cpu::ops::kZerosLike, onert::ir::operation::ElementwiseUnary::LOG, onert::ir::operation::ElementwiseUnary::LOGICAL_NOT, onert::ir::operation::ElementwiseUnary::NEG, onert::ir::operation::ElementwiseUnary::QUANTIZE, onert::ir::operation::ElementwiseUnary::ROUND, onert::ir::operation::ElementwiseUnary::RSQRT, onert::ir::operation::ElementwiseUnary::SIN, onert::ir::operation::ElementwiseUnary::SQRT, onert::ir::operation::ElementwiseUnary::SQUARE, and onert::ir::operation::ElementwiseUnary::ZEROS_LIKE.

◆ convertPoolType()

ops::PoolType onert::backend::cpu::convertPoolType ( ir::operation::Pool2D::PoolType  type_ir)

Definition at line 32 of file Pool2DLayer.cc.

33{
34 switch (type_ir)
35 {
36 case ir::operation::Pool2D::PoolType::AVG:
37 return ops::PoolType::kAvg;
38 case ir::operation::Pool2D::PoolType::MAX:
39 return ops::PoolType::kMax;
40 default:
41 throw std::runtime_error("cpu KernelGenerator : Not supported operation yet");
42 }
43}

References onert::ir::operation::Pool2D::AVG, onert::backend::cpu::ops::kAvg, onert::backend::cpu::ops::kMax, and onert::ir::operation::Pool2D::MAX.

◆ convertReduceType()

ops::ReduceType onert::backend::cpu::convertReduceType ( ir::operation::Reduce::ReduceType  reduce_type_ir)

Definition at line 32 of file ReduceLayer.cc.

33{
34 switch (reduce_type_ir)
35 {
36 case ir::operation::Reduce::ReduceType::ALL:
37 return ops::ReduceType::kAll;
38 case ir::operation::Reduce::ReduceType::ANY:
39 return ops::ReduceType::kAny;
40 case ir::operation::Reduce::ReduceType::MAX:
41 return ops::ReduceType::kMax;
42 case ir::operation::Reduce::ReduceType::MIN:
43 return ops::ReduceType::kMin;
44 case ir::operation::Reduce::ReduceType::PROD:
45 return ops::ReduceType::kProd;
46 case ir::operation::Reduce::ReduceType::SUM:
47 return ops::ReduceType::kSum;
48 default:
49 throw std::runtime_error("cpu KernelGenerator : Not supported operation yet");
50 }
51}

References onert::ir::operation::Reduce::ALL, onert::ir::operation::Reduce::ANY, onert::backend::cpu::ops::kAll, onert::backend::cpu::ops::kAny, onert::backend::cpu::ops::kMax, onert::backend::cpu::ops::kMin, onert::backend::cpu::ops::kProd, onert::backend::cpu::ops::kSum, onert::ir::operation::Reduce::MAX, onert::ir::operation::Reduce::MIN, onert::ir::operation::Reduce::PROD, and onert::ir::operation::Reduce::SUM.

◆ findSharedMemoryOperandIndexes()

ir::OperandIndexMap< ir::OperandIndex > onert::backend::cpu::findSharedMemoryOperandIndexes ( const ir::IGraph graph)

Definition at line 73 of file SharedMemoryOperands.cc.

74{
75 ir::OperandIndexMap<ir::OperandIndex> shared_memory_operand_map;
76 graph.operations().iterate([&](const ir::OperationIndex &, const ir::IOperation &op) {
77 if (is_memory_sharing_allowed(graph, op))
78 {
79 assert(op.getInputs().size() == 1 || op.getInputs().size() == 2);
80 assert(op.getOutputs().size() == 1);
81 shared_memory_operand_map[op.getOutputs().at(0)] = op.getInputs().at(0);
82 }
83 });
84 reassign_indexes_to_single_sources(shared_memory_operand_map);
85 return shared_memory_operand_map;
86}
const OperandIndex & at(IOIndex set_index) const
std::unordered_map< OperandIndex, T > OperandIndexMap
virtual const OperandIndexSequence & getInputs() const =0
virtual const OperandIndexSequence & getOutputs() const =0

References onert::ir::OperandIndexSequence::at(), onert::ir::IOperation::getInputs(), onert::ir::IOperation::getOutputs(), and onert::ir::OperandIndexSequence::size().

Referenced by onert::backend::cpu::Backend::newContext().