ONE - On-device Neural Engine
Loading...
Searching...
No Matches
luci_interpreter Namespace Reference

Namespaces

namespace  kernels
 
namespace  lstm
 
namespace  test_kernel
 

Data Structures

struct  AddParams
 
struct  AffineQuantization
 
struct  ArgMaxParams
 
struct  BatchMatMulParams
 
class  BuddyMemoryManager
 
class  CircleReader
 Loads Circle file and provides helpers to access attributes. More...
 
class  CircleReferencingConstNodeBuilder
 Builder creates CircleCustom node with pointer to constants data from Tensor with buffer. More...
 
struct  ConcatenationParams
 
struct  Conv2DParams
 
struct  CumSumParams
 
struct  DataTypeImpl
 C++ scalar type corresponding to each DataType. More...
 
struct  DataTypeImpl< DataType::BOOL >
 
struct  DataTypeImpl< DataType::FLOAT16 >
 
struct  DataTypeImpl< DataType::FLOAT32 >
 
struct  DataTypeImpl< DataType::FLOAT64 >
 
struct  DataTypeImpl< DataType::S16 >
 
struct  DataTypeImpl< DataType::S32 >
 
struct  DataTypeImpl< DataType::S64 >
 
struct  DataTypeImpl< DataType::S8 >
 
struct  DataTypeImpl< DataType::U16 >
 
struct  DataTypeImpl< DataType::U32 >
 
struct  DataTypeImpl< DataType::U64 >
 
struct  DataTypeImpl< DataType::U8 >
 
struct  DepthToSpaceParams
 
struct  DepthwiseConv2DParams
 
struct  DivParams
 
class  EventNotifier
 
class  ExecutionObserver
 
struct  FullyConnectedParams
 
struct  GatherParams
 
struct  GeluParams
 
class  GraphLoader
 
struct  GRUParams
 
class  IMemoryManager
 
struct  InstanceNormParams
 
class  Interpreter
 
class  Kernel
 
class  KernelBuilder
 
class  KernelBuilderHelper
 
class  KernelBuilderRegistry
 Registry of kernel builders. More...
 
class  KernelConfigureRegistry
 
class  KernelExecuteRegistry
 
class  KernelWithParams
 
struct  L2NormParams
 
struct  LeakyReluParams
 
struct  LocalResponseNormalizationParams
 
struct  MirrorPadParams
 
class  ModuleLoader
 
struct  MulParams
 
struct  OneHotParams
 
struct  PackParams
 
struct  Pool2DParams
 
struct  ReducerParams
 
struct  ResizeBilinearParams
 
struct  ResizeNearestNeighborParams
 
struct  RmsNormParams
 
struct  RoPEParams
 
class  RuntimeGraph
 
class  RuntimeModule
 
class  RuntimeShape
 
struct  RuntimeToIR
 
class  Shape
 
struct  ShapeParams
 
class  SimpleMemoryManager
 
struct  SoftmaxParams
 
struct  SpaceToDepthParams
 
struct  SqueezeParams
 
class  StaticMemoryManager
 
struct  StridedSliceParams
 
struct  SubParams
 
struct  SVDFParams
 
class  Tensor
 
class  TestMemoryManager
 
struct  TransposeConvParams
 
struct  UnidirectionalSequenceLSTMParams
 
struct  UnpackParams
 
class  VectorWrapper
 Wrapper to use flatbuffers::Vector pointer as std::vector entity. More...
 

Typedefs

using DataType = loco::DataType
 
template<DataType DT>
using DataTypeImpl = loco::DataTypeImpl< DT >
 
using Activation = luci::FusedActFunc
 
using Padding = luci::Padding
 
using MirrorPadMode = luci::MirrorPadMode
 
using RoPEMode = luci::RoPEMode
 
using BaseRuntimeGraph = RuntimeGraph
 
using MemoryManager = SimpleMemoryManager
 

Enumerations

enum class  BuilderId { Size }
 
enum class  DataType {
  Unknown , U8 , U16 , U32 ,
  U64 , S8 , S16 , S32 ,
  S64 , FLOAT16 , FLOAT32 , FLOAT64 ,
  BOOL
}
 "scalar" value type More...
 
enum class  FusedActFunc {
  UNDEFINED , NONE , RELU , RELU_N1_TO_1 ,
  RELU6 , TANH , SIGN_BIT
}
 
enum class  Padding { UNDEFINED , SAME , VALID }
 
enum class  MirrorPadMode { UNDEFINED , REFLECT , SYMMETRIC }
 
enum class  BuilderID { Size }
 

Functions

size_t getDataTypeSize (DataType data_type)
 
std::unique_ptr< luci::GraphBuilderSourcesource_without_constant_copying ()
 Creates and returns GraphBuilderSource, which allows to not copy constant buffers from model's file.
 
template<typename CircleNodeOut >
std::vector< const loco::Node * > collectOutputNodes (const loco::Node *node)
 
std::unique_ptr< Kernelbuild_kernel_CircleAbs (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleAdd (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleArgMax (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleAveragePool2D (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleBatchMatMul (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleBatchToSpaceND (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleBroadcastTo (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleCast (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleConcatenation (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleConv2D (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleCos (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleCumSum (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleDepthToSpace (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleDepthwiseConv2D (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleDequantize (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleDiv (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleElu (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleEqual (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleExp (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleExpandDims (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleFill (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleFloor (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleFloorDiv (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleFloorMod (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleFullyConnected (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleGather (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleGelu (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleGreater (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleGreaterEqual (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleGRU (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleHardSwish (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleIf (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleInstanceNorm (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleL2Normalize (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleL2Pool2D (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleLeakyRelu (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleLess (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleLessEqual (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleLocalResponseNormalization (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleLog (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleLogicalAnd (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleLogicalNot (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleLogicalOr (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleLogistic (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleLogSoftmax (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleMaximum (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleMaxPool2D (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleMean (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleMinimum (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleMirrorPad (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleMul (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleNeg (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleNotEqual (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleOneHot (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CirclePack (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CirclePad (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CirclePadV2 (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CirclePow (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CirclePRelu (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleQuantize (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleReduceMax (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleReduceProd (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleRelu (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleRelu0To1 (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleRelu6 (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleReshape (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleResizeBilinear (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleResizeNearestNeighbor (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleReverseV2 (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleRmsNorm (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleRoPE (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleRsqrt (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleSelect (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleSelectV2 (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleShape (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleSin (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleSlice (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleSoftmax (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleSpaceToBatchND (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleSpaceToDepth (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleSplit (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleSplitV (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleSqrt (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleSquare (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleSquaredDifference (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleSqueeze (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleStridedSlice (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleSub (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleSum (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleSVDF (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleTanh (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleTile (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleTranspose (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleTransposeConv (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleUnidirectionalSequenceLSTM (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleUnpack (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
std::unique_ptr< Kernelbuild_kernel_CircleWhile (const luci::CircleNode *circle_node, KernelBuilderHelper &helper)
 
uint32_t size (DataType data_type)
 Returns the size of the data type.
 
DataType luci_datatype (circle::TensorType type)
 
FusedActFunc luci_actfunc (circle::ActivationFunctionType type)
 
Padding luci_padding (circle::Padding padding)
 
MirrorPadMode luci_mirrorpad_mode (circle::MirrorPadMode mode)
 
template<typename T >
VectorWrapper< T > wrap (const flatbuffers::Vector< T > *vec)
 
 REGISTER_WRAPPER (flatbuffers::Offset< circle::SubGraph >)
 
 REGISTER_WRAPPER (flatbuffers::Offset< circle::Buffer >)
 
 REGISTER_WRAPPER (flatbuffers::Offset< circle::Tensor >)
 
 REGISTER_WRAPPER (flatbuffers::Offset< circle::Operator >)
 
 REGISTER_WRAPPER (flatbuffers::Offset< circle::OperatorCode >)
 
 REGISTER_WRAPPER (flatbuffers::Offset< circle::Metadata >)
 
 REGISTER_WRAPPER (int32_t)
 
 REGISTER_WRAPPER (uint8_t)
 
void configure_kernel_CircleAbs (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleAbs (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleAdd (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleAdd (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleAddN (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleAddN (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleArgMax (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleArgMax (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleArgMin (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleArgMin (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleAveragePool2D (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleAveragePool2D (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleBatchToSpaceND (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleBatchToSpaceND (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleBroadcastTo (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleBroadcastTo (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleCast (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleCast (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleCeil (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleCeil (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleConcatenation (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleConcatenation (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleConv2D (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleConv2D (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
int32_t computeConvPadding (const circle::Tensor *input, const circle::Tensor *filter, circle::Padding padding_type, int32_t stride, int32_t dilation, int axis)
 
luci_interpreter_pal::ConvParams createConv2DParams (const circle::Tensor *input, const circle::Tensor *filter, const circle::Tensor *output, const circle::Conv2DOptions *options)
 
void configure_kernel_CircleCos (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleCos (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleDepthToSpace (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleDepthToSpace (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleDepthwiseConv2D (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleDepthwiseConv2D (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleDequantize (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleDequantize (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleDiv (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleDiv (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleElu (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleElu (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleEqual (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleEqual (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleExp (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleExp (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleExpandDims (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleExpandDims (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleFill (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleFill (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleFloor (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleFloor (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleFloorDiv (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleFloorDiv (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleFloorMod (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleFloorMod (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleFullyConnected (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleFullyConnected (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleGather (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleGather (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleGatherND (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleGatherND (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleGreater (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleGreater (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleGreaterEqual (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleGreaterEqual (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleIf (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleIf (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
constexpr BuilderID get_builder_id (circle::BuiltinOperator opcode)
 
void configure_kernel_CircleL2Normalize (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleL2Normalize (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleL2Pool2D (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleL2Pool2D (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleLeakyRelu (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleLeakyRelu (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleLess (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleLess (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleLessEqual (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleLessEqual (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleLog (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleLog (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleLogicalAnd (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleLogicalAnd (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleLogicalNot (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleLogicalNot (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleLogicalOr (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleLogicalOr (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleLogistic (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleLogistic (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleLogSoftmax (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleLogSoftmax (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleMaximum (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleMaximum (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleMaxPool2D (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleMaxPool2D (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleMean (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleMean (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleMinimum (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleMinimum (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleMirrorPad (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleMirrorPad (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleMul (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleMul (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleNeg (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleNeg (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleNotEqual (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleNotEqual (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CirclePack (const circle::Operator *, BaseRuntimeGraph *)
 
void execute_kernel_CirclePack (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CirclePad (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CirclePad (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CirclePadCommon (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CirclePadCommon (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CirclePadV2 (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CirclePadV2 (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CirclePool2DCommon (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
luci_interpreter_pal::PoolParams createPoolParams (const circle::Operator *cur_op, const kernels::SISOKernel &siso_kernel)
 
void configure_kernel_CirclePRelu (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CirclePRelu (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleQuantize (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleQuantize (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleReduceCommon (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleReduceCommon (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleReduceMax (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleReduceMax (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleRelu (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleRelu (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleRelu6 (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleRelu6 (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleReshape (const circle::Operator *, BaseRuntimeGraph *)
 
void execute_kernel_CircleReshape (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleResizeBilinear (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleResizeBilinear (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleResizeNearestNeighbor (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleResizeNearestNeighbor (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleRound (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleRound (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleRsqrt (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleRsqrt (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleSelectV2 (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleSelectV2 (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleShape (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleShape (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleSin (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleSin (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleSlice (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleSlice (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleSoftmax (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleSoftmax (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleSpaceToBatchND (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleSpaceToBatchND (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleSpaceToDepth (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleSpaceToDepth (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleSplit (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleSplit (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
template<typename T >
void splitImpl (const circle::Operator *cur_op, const circle::Tensor *input, int axis_value, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleSplitV (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleSplitV (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleSqrt (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleSqrt (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleSquare (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleSquare (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleSquaredDifference (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleSquaredDifference (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleSqueeze (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleSqueeze (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleStridedSlice (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleStridedSlice (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleSub (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleSub (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleSum (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleSum (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleSVDF (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleSVDF (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void evalInteger (const circle::Tensor *input, const circle::Tensor *output, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleTanh (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleTanh (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleTranspose (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleTranspose (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleTransposeConv (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleTransposeConv (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleUnidirectionalSequenceLSTM (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleUnidirectionalSequenceLSTM (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleUnpack (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleUnpack (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleWhile (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleWhile (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void configure_kernel_CircleZerosLike (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 
void execute_kernel_CircleZerosLike (const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
 

Variables

constexpr KernelConfigureRegistry kernel_configure
 
constexpr KernelExecuteRegistry kernel_executor
 

Typedef Documentation

◆ Activation

Definition at line 33 of file KernelParams.h.

◆ BaseRuntimeGraph

Definition at line 39 of file RuntimeModule.h.

◆ DataType

Definition at line 29 of file DataType.h.

◆ DataTypeImpl

Definition at line 31 of file DataType.h.

◆ MemoryManager

Definition at line 40 of file RuntimeModule.h.

◆ MirrorPadMode

Definition at line 35 of file KernelParams.h.

◆ Padding

Definition at line 34 of file KernelParams.h.

◆ RoPEMode

Definition at line 36 of file KernelParams.h.

Enumeration Type Documentation

◆ BuilderId

enum class luci_interpreter::BuilderId
strong
Enumerator
Size 

Definition at line 59 of file KernelBuilder.cpp.

60{
61#include <luci/IR/CircleNodes.lst>
62 Size // casts to count of values in BuilderId enum
63};

◆ BuilderID

enum class luci_interpreter::BuilderID
strong
Enumerator
Size 

Definition at line 31 of file KernelBuilder.h.

32{
33#if USE_GENERATED_LIST
34#include "GeneratedKernelsToBuild.lst"
35#else
36#include "KernelsToBuild.lst"
37#endif
38 Size // casts to count of values in BuilderId enum
39};

◆ DataType

enum class luci_interpreter::DataType
strong

"scalar" value type

Enumerator
Unknown 
U8 
U16 
U32 
U64 
S8 
S16 
S32 
S64 
FLOAT16 
FLOAT32 
FLOAT64 
BOOL 

Definition at line 31 of file DataType.h.

32{
33 Unknown, // Unknown type (serves as a default value)
34
35 U8, // 8-bit unsigned integer
36 U16, // 16-bit unsigned integer
37 U32, // 32-bit unsigned integer
38 U64, // 64-bit unsigned integer
39
40 S8, // 8-bit signed integer
41 S16, // 16-bit signed integer
42 S32, // 32-bit signed integer
43 S64, // 64-bit signed integer
44
45 FLOAT16, // IEEE 16-bit floating-point
46 FLOAT32, // IEEE 32-bit floating-point
47 FLOAT64, // IEEE 64-bit floating-point
48
49 // WARNING the size of Bool may vary for NN frameworks
50 // TODO we need to find a way to resolve this issue
51 BOOL, // Boolean
52};

◆ FusedActFunc

enum class luci_interpreter::FusedActFunc
strong
Enumerator
UNDEFINED 
NONE 
RELU 
RELU_N1_TO_1 
RELU6 
TANH 
SIGN_BIT 

Definition at line 27 of file ParamsType.h.

28{
29 UNDEFINED, // This is not defined by TFLite or Circle. This was added to
30 // prevent programming error.
31 NONE,
32 RELU,
33 RELU_N1_TO_1,
34 RELU6,
35 TANH,
36 SIGN_BIT
37};

◆ MirrorPadMode

Enumerator
UNDEFINED 
REFLECT 
SYMMETRIC 

Definition at line 47 of file ParamsType.h.

48{
49 UNDEFINED, // This is not defined by Circle. This was added to prevent programming error.
50
51 REFLECT,
53};

◆ Padding

enum class luci_interpreter::Padding
strong
Enumerator
UNDEFINED 
SAME 
VALID 

Definition at line 39 of file ParamsType.h.

40{
41 UNDEFINED, // This is not defined by TFLite. This was added to prevent programming error.
42
43 SAME,
44 VALID,
45};

Function Documentation

◆ build_kernel_CircleAbs()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleAbs ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Abs.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleAbs *>(circle_node);
28 assert(node->arity() == 1);
29
30 const Tensor *input = helper.getInputTensor(node->x());
31 Tensor *output = helper.getOutputTensor(node);
32
33 return std::make_unique<kernels::Abs>(input, output);
34}
Tensor * getOutputTensor(const loco::Node *node) const
const Tensor * getInputTensor(const loco::Node *node) const

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleAdd()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleAdd ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Add.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleAdd *>(circle_node);
28 assert(node->arity() == 2);
29
30 const Tensor *input1 = helper.getInputTensor(node->x());
31 const Tensor *input2 = helper.getInputTensor(node->y());
32 Tensor *output = helper.getOutputTensor(node);
33
34 AddParams params{};
35 params.activation = node->fusedActivationFunction();
36
37 return std::make_unique<kernels::Add>(input1, input2, output, params);
38}

References luci_interpreter::AddParams::activation, luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleArgMax()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleArgMax ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file ArgMax.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleArgMax *>(circle_node);
28 assert(node->arity() == 2);
29 const Tensor *input = helper.getInputTensor(node->input());
30 const Tensor *axis = helper.getInputTensor(node->dimension());
31 Tensor *output = helper.getOutputTensor(node);
32
33 ArgMaxParams params{};
34 params.output_type = node->output_type();
35
36 return std::make_unique<kernels::ArgMax>(input, axis, output, params);
37}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), luci_interpreter::KernelBuilderHelper::getOutputTensor(), and luci_interpreter::ArgMaxParams::output_type.

◆ build_kernel_CircleAveragePool2D()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleAveragePool2D ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 25 of file AveragePool2D.cpp.

27{
28 const auto *node = loco::must_cast<const luci::CircleAveragePool2D *>(circle_node);
29 assert(node->arity() == 1);
30
31 const Tensor *input = helper.getInputTensor(node->value());
32 Tensor *output = helper.getOutputTensor(node);
33
34 Pool2DParams params{};
35 params.padding = node->padding();
36 params.filter_height = node->filter()->h();
37 params.filter_width = node->filter()->w();
38 params.stride_height = node->stride()->h();
39 params.stride_width = node->stride()->w();
40 params.activation = node->fusedActivationFunction();
41
42 // It is unknown what data will be stored in scratchpad tensor,
43 // using UINT8 as a most general option
44 auto scratchpad = std::make_unique<Tensor>(DataType::U8, Shape({}), AffineQuantization{}, "");
45 scratchpad->set_observable(false);
46 scratchpad->set_data_buffer(nullptr);
47 // If node has execution plan then read memory offsets for scratchpad temporary tensor
48 // from the beginning of shared memory buffer.
49 // Used in Static Memory Manager.
50 // TODO move tensors offset initialization to one place
52 {
53 const auto execution_plan = luci::get_execution_plan(node);
54 // Check whether the offset for the current CircleConv2D temporary was found.
55 if (execution_plan.offsets().size() > 1)
56 // If this is true, then we keep this offset in scratchpad.
57 scratchpad->set_offset(execution_plan.offsets().at(1));
58 }
59 Tensor *tmp = helper.getRuntimeGraph(node->graph())->addTensor(std::move(scratchpad));
60
61 return std::make_unique<kernels::AveragePool2D>(input, output, tmp, params);
62}
RuntimeGraph * getRuntimeGraph(const loco::Graph *graph) const
Tensor * addTensor(std::unique_ptr< Tensor > &&tensor)
bool has_execution_plan(const luci::CircleNode *circle_node)
luci::CircleNodeExecutionPlan get_execution_plan(const luci::CircleNode *circle_node)
Definition Shape.h:28

References luci_interpreter::RuntimeGraph::addTensor(), luci::get_execution_plan(), luci_interpreter::KernelBuilderHelper::getInputTensor(), luci_interpreter::KernelBuilderHelper::getOutputTensor(), luci_interpreter::KernelBuilderHelper::getRuntimeGraph(), luci::has_execution_plan(), and luci_interpreter::Pool2DParams::padding.

◆ build_kernel_CircleBatchMatMul()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleBatchMatMul ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 25 of file BatchMatMul.cpp.

27{
28 const auto *node = loco::must_cast<const luci::CircleBatchMatMul *>(circle_node);
29 assert(node->arity() == 2);
30
31 const Tensor *lhs = helper.getInputTensor(node->x());
32 const Tensor *rhs = helper.getInputTensor(node->y());
33 Tensor *output = helper.getOutputTensor(node);
34
35 auto lhs_scratchpad =
36 std::make_unique<Tensor>(lhs->element_type(), Shape({}), AffineQuantization{}, "");
37 lhs_scratchpad->set_observable(false);
38 lhs_scratchpad->set_data_buffer(nullptr);
39 auto rhs_scratchpad =
40 std::make_unique<Tensor>(rhs->element_type(), Shape({}), AffineQuantization{}, "");
41 rhs_scratchpad->set_observable(false);
42 rhs_scratchpad->set_data_buffer(nullptr);
43 // If node has execution plan then read memory offsets for scratchpad temporary tensor
44 // from the beginning of shared memory buffer.
45 // Used in Static Memory Manager.
46 // TODO move tensors offset initialization to one place
48 {
49 const auto execution_plan = luci::get_execution_plan(node);
50 // Check whether the offset for the current BatchMatMul temporary was found.
51 if (execution_plan.offsets().size() > 1)
52 {
53 assert(execution_plan.offsets().size() == 3);
54
55 // If this is true, then we keep this offset in scratchpad.
56 lhs_scratchpad->set_offset(execution_plan.offsets().at(1));
57 rhs_scratchpad->set_offset(execution_plan.offsets().at(2));
58 }
59 }
60 Tensor *lhs_tmp = helper.getRuntimeGraph(node->graph())->addTensor(std::move(lhs_scratchpad));
61 Tensor *rhs_tmp = helper.getRuntimeGraph(node->graph())->addTensor(std::move(rhs_scratchpad));
62
63 BatchMatMulParams params;
64 params.adj_x = node->adj_x();
65 params.adj_y = node->adj_y();
66
67 return std::make_unique<kernels::BatchMatMul>(lhs, rhs, output, lhs_tmp, rhs_tmp, params);
68}
void set_observable(bool value)
Definition Tensor.h:164
DataType element_type() const
Definition Tensor.h:105

References luci_interpreter::RuntimeGraph::addTensor(), luci_interpreter::BatchMatMulParams::adj_x, luci_interpreter::BatchMatMulParams::adj_y, luci_interpreter::Tensor::element_type(), luci::get_execution_plan(), luci_interpreter::KernelBuilderHelper::getInputTensor(), luci_interpreter::KernelBuilderHelper::getOutputTensor(), luci_interpreter::KernelBuilderHelper::getRuntimeGraph(), luci::has_execution_plan(), and luci_interpreter::Tensor::set_observable().

◆ build_kernel_CircleBatchToSpaceND()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleBatchToSpaceND ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file BatchToSpaceND.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleBatchToSpaceND *>(circle_node);
28 assert(node->arity() == 3);
29
30 const Tensor *input = helper.getInputTensor(node->input());
31 const Tensor *block_shape = helper.getInputTensor(node->block_shape());
32 const Tensor *crops = helper.getInputTensor(node->crops());
33 Tensor *output = helper.getOutputTensor(node);
34
35 return std::make_unique<kernels::BatchToSpaceND>(input, block_shape, crops, output);
36}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleBroadcastTo()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleBroadcastTo ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file BroadcastTo.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleBroadcastTo *>(circle_node);
28 assert(node->arity() == 2);
29
30 const Tensor *input = helper.getInputTensor(node->input());
31 const Tensor *shape = helper.getInputTensor(node->shape());
32 Tensor *output = helper.getOutputTensor(node);
33
34 return std::make_unique<kernels::BroadcastTo>(input, shape, output);
35}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleCast()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleCast ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Cast.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleCast *>(circle_node);
28
29 assert(node->arity() == 1);
30
31 const Tensor *input = helper.getInputTensor(node->x());
32 Tensor *output = helper.getOutputTensor(node);
33
34 return std::make_unique<kernels::Cast>(input, output);
35}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleConcatenation()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleConcatenation ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Concatenation.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleConcatenation *>(circle_node);
28 std::vector<const Tensor *> inputs(node->numValues());
29 for (uint32_t i = 0; i < node->numValues(); ++i)
30 {
31 inputs[i] = helper.getInputTensor(node->values(i));
32 }
33 Tensor *output = helper.getOutputTensor(node);
34
35 ConcatenationParams params{};
36 params.axis = node->axis();
37 params.activation = node->fusedActivationFunction();
38
39 return std::make_unique<kernels::Concatenation>(std::move(inputs), output, params);
40}

References luci_interpreter::ConcatenationParams::axis, luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleConv2D()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleConv2D ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 25 of file Conv2D.cpp.

27{
28 const auto *node = loco::must_cast<const luci::CircleConv2D *>(circle_node);
29 assert(node->arity() == 3);
30
31 const Tensor *input = helper.getInputTensor(node->input());
32 const Tensor *filter = helper.getInputTensor(node->filter());
33 const Tensor *bias = helper.getOptionalInputTensor(node->bias());
34 Tensor *output = helper.getOutputTensor(node);
35
36 // It is unknown what data will be stored in scratchpad tensor,
37 // using UINT8 as a most general option
38 auto scratchpad = std::make_unique<Tensor>(DataType::U8, Shape({}), AffineQuantization{}, "");
39 scratchpad->set_observable(false);
40 scratchpad->set_data_buffer(nullptr);
41 // If node has execution plan then read memory offsets for scratchpad temporary tensor
42 // from the beginning of shared memory buffer.
43 // Used in Static Memory Manager.
44 // TODO move tensors offset initialization to one place
46 {
47 const auto execution_plan = luci::get_execution_plan(node);
48 // Check whether the offset for the current CircleConv2D temporary was found.
49 if (execution_plan.offsets().size() > 1)
50 // If this is true, then we keep this offset in scratchpad.
51 scratchpad->set_offset(execution_plan.offsets().at(1));
52 }
53 Tensor *tmp = helper.getRuntimeGraph(node->graph())->addTensor(std::move(scratchpad));
54
55 Conv2DParams params{};
56 params.padding = node->padding();
57 params.stride_height = node->stride()->h();
58 params.stride_width = node->stride()->w();
59 params.dilation_height_factor = node->dilation()->h();
60 params.dilation_width_factor = node->dilation()->w();
61 params.activation = node->fusedActivationFunction();
62
63 return std::make_unique<kernels::Conv2D>(input, filter, bias, output, tmp, params);
64}
const Tensor * getOptionalInputTensor(const loco::Node *node) const

References luci_interpreter::RuntimeGraph::addTensor(), luci::get_execution_plan(), luci_interpreter::KernelBuilderHelper::getInputTensor(), luci_interpreter::KernelBuilderHelper::getOptionalInputTensor(), luci_interpreter::KernelBuilderHelper::getOutputTensor(), luci_interpreter::KernelBuilderHelper::getRuntimeGraph(), luci::has_execution_plan(), luci_interpreter::Conv2DParams::padding, and luci_interpreter::Tensor::set_observable().

◆ build_kernel_CircleCos()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleCos ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Cos.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleCos *>(circle_node);
28 assert(node->arity() == 1);
29
30 const Tensor *input = helper.getInputTensor(node->x());
31 Tensor *output = helper.getOutputTensor(node);
32
33 return std::make_unique<kernels::Cos>(input, output);
34}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleCumSum()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleCumSum ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file CumSum.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleCumSum *>(circle_node);
28 const Tensor *input = helper.getInputTensor(node->input());
29 const Tensor *axis = helper.getInputTensor(node->axis());
30 Tensor *output = helper.getOutputTensor(node);
31
32 CumSumParams params{};
33 params.exclusive = node->exclusive();
34 params.reverse = node->reverse();
35
36 return std::make_unique<kernels::CumSum>(input, axis, output, params);
37}

References luci_interpreter::CumSumParams::exclusive, luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleDepthToSpace()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleDepthToSpace ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file DepthToSpace.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleDepthToSpace *>(circle_node);
28 assert(node->arity() == 1);
29
30 const Tensor *input = helper.getInputTensor(node->input());
31 Tensor *output = helper.getOutputTensor(node);
32
33 DepthToSpaceParams params{};
34 params.block_size = node->block_size();
35
36 return std::make_unique<kernels::DepthToSpace>(input, output, params);
37}

References luci_interpreter::DepthToSpaceParams::block_size, luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleDepthwiseConv2D()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleDepthwiseConv2D ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 25 of file DepthwiseConv2D.cpp.

27{
28 const auto *node = loco::must_cast<const luci::CircleDepthwiseConv2D *>(circle_node);
29 assert(node->arity() == 3);
30
31 const Tensor *input = helper.getInputTensor(node->input());
32 const Tensor *filter = helper.getInputTensor(node->filter());
33 const Tensor *bias = helper.getInputTensor(node->bias());
34 Tensor *output = helper.getOutputTensor(node);
35
36 DepthwiseConv2DParams params{};
37 params.padding = node->padding();
38 params.depth_multiplier = node->depthMultiplier();
39 params.stride_height = node->stride()->h();
40 params.stride_width = node->stride()->w();
41 params.dilation_height_factor = node->dilation()->h();
42 params.dilation_width_factor = node->dilation()->w();
43 params.activation = node->fusedActivationFunction();
44
45 // It is unknown what data will be stored in scratchpad tensor,
46 // using UINT8 as a most general option
47 auto scratchpad = std::make_unique<Tensor>(DataType::U8, Shape({}), AffineQuantization{}, "");
48 scratchpad->set_observable(false);
49 scratchpad->set_data_buffer(nullptr);
50 // If node has execution plan then read memory offsets for scratchpad temporary tensor
51 // from the beginning of shared memory buffer.
52 // Used in Static Memory Manager.
53 // TODO move tensors offset initialization to one place
55 {
56 const auto execution_plan = luci::get_execution_plan(node);
57 // Check whether the offset for the current CircleConv2D temporary was found.
58 if (execution_plan.offsets().size() > 1)
59 // If this is true, then we keep this offset in scratchpad.
60 scratchpad->set_offset(execution_plan.offsets().at(1));
61 }
62 Tensor *tmp = helper.getRuntimeGraph(node->graph())->addTensor(std::move(scratchpad));
63
64 return std::make_unique<kernels::DepthwiseConv2D>(input, filter, bias, output, tmp, params);
65}

References luci_interpreter::RuntimeGraph::addTensor(), luci::get_execution_plan(), luci_interpreter::KernelBuilderHelper::getInputTensor(), luci_interpreter::KernelBuilderHelper::getOutputTensor(), luci_interpreter::KernelBuilderHelper::getRuntimeGraph(), luci::has_execution_plan(), and luci_interpreter::DepthwiseConv2DParams::padding.

◆ build_kernel_CircleDequantize()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleDequantize ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Dequantize.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleDequantize *>(circle_node);
28
29 const Tensor *input = helper.getInputTensor(node->input());
30 Tensor *output = helper.getOutputTensor(node);
31
32 return std::make_unique<kernels::Dequantize>(input, output);
33}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleDiv()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleDiv ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Div.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleDiv *>(circle_node);
28 assert(node->arity() == 2);
29 const Tensor *input1 = helper.getInputTensor(node->x());
30 const Tensor *input2 = helper.getInputTensor(node->y());
31 Tensor *output = helper.getOutputTensor(node);
32
33 DivParams params{};
34 params.activation = node->fusedActivationFunction();
35
36 return std::make_unique<kernels::Div>(input1, input2, output, params);
37}

References luci_interpreter::DivParams::activation, luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleElu()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleElu ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Elu.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleElu *>(circle_node);
28 assert(node->arity() == 1);
29
30 const Tensor *input = helper.getInputTensor(node->features());
31 Tensor *output = helper.getOutputTensor(node);
32
33 return std::make_unique<kernels::Elu>(input, output);
34}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleEqual()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleEqual ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Equal.cpp.

27{
28 const auto *node = loco::must_cast<const luci::CircleEqual *>(circle_node);
29 assert(node->arity() == 2);
30
31 const Tensor *x = helper.getInputTensor(node->x());
32 const Tensor *y = helper.getInputTensor(node->y());
33 Tensor *output = helper.getOutputTensor(node);
34
35 return std::make_unique<kernels::Equal>(x, y, output);
36}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleExp()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleExp ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Exp.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleExp *>(circle_node);
28 assert(node->arity() == 1);
29
30 const Tensor *input = helper.getInputTensor(node->x());
31 Tensor *output = helper.getOutputTensor(node);
32
33 return std::make_unique<kernels::Exp>(input, output);
34}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleExpandDims()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleExpandDims ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file ExpandDims.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleExpandDims *>(circle_node);
28 assert(node->arity() == 2);
29
30 const Tensor *input = helper.getInputTensor(node->input());
31 const Tensor *axis = helper.getInputTensor(node->axis());
32 Tensor *output = helper.getOutputTensor(node);
33
34 return std::make_unique<kernels::ExpandDims>(input, axis, output);
35}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleFill()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleFill ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Fill.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleFill *>(circle_node);
28 assert(node->arity() == 2);
29
30 const auto dims = helper.getInputTensor(node->dims());
31 const auto value = helper.getInputTensor(node->value());
32 auto output = helper.getOutputTensor(node);
33
34 return std::make_unique<kernels::Fill>(dims, value, output);
35}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleFloor()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleFloor ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Floor.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleFloor *>(circle_node);
28 assert(node->arity() == 1);
29
30 const Tensor *input = helper.getInputTensor(node->x());
31 Tensor *output = helper.getOutputTensor(node);
32
33 return std::make_unique<kernels::Floor>(input, output);
34}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleFloorDiv()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleFloorDiv ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file FloorDiv.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleFloorDiv *>(circle_node);
28 assert(node->arity() == 2);
29
30 const Tensor *x = helper.getInputTensor(node->x());
31 const Tensor *y = helper.getInputTensor(node->y());
32 Tensor *output = helper.getOutputTensor(node);
33
34 return std::make_unique<kernels::FloorDiv>(x, y, output);
35}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleFloorMod()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleFloorMod ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file FloorMod.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleFloorMod *>(circle_node);
28 assert(node->arity() == 2);
29
30 const Tensor *x = helper.getInputTensor(node->x());
31 const Tensor *y = helper.getInputTensor(node->y());
32 Tensor *output = helper.getOutputTensor(node);
33
34 return std::make_unique<kernels::FloorMod>(x, y, output);
35}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleFullyConnected()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleFullyConnected ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file FullyConnected.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleFullyConnected *>(circle_node);
28 assert(node->arity() == 3);
29
30 const Tensor *input = helper.getInputTensor(node->input());
31 const Tensor *weights = helper.getInputTensor(node->weights());
32 const Tensor *bias = helper.getOptionalInputTensor(node->bias());
33 Tensor *output = helper.getOutputTensor(node);
34
35 FullyConnectedParams params{};
36 params.activation = node->fusedActivationFunction();
37 params.keep_num_dims = node->keep_num_dims();
38 if (weights->element_type() == loco::DataType::S4 ||
39 weights->element_type() == loco::DataType::U4)
40 {
41 auto scratchpad =
42 std::make_unique<Tensor>(input->element_type(), weights->shape(), AffineQuantization{}, "");
43 scratchpad->set_observable(false);
44 scratchpad->set_data_buffer(nullptr);
45 Tensor *scratchpad_tmp =
46 helper.getRuntimeGraph(node->graph())->addTensor(std::move(scratchpad));
47 helper.getRuntimeGraph(node->graph())->configureAllocations(scratchpad_tmp);
48 return std::make_unique<kernels::FullyConnected>(input, weights, bias, output, scratchpad_tmp,
49 params);
50 }
51 return std::make_unique<kernels::FullyConnected>(input, weights, bias, output, params);
52}
void configureAllocations(Tensor *tensor)
const Shape & shape() const
Definition Tensor.h:107

References luci_interpreter::FullyConnectedParams::activation, luci_interpreter::RuntimeGraph::addTensor(), luci_interpreter::RuntimeGraph::configureAllocations(), luci_interpreter::Tensor::element_type(), luci_interpreter::KernelBuilderHelper::getInputTensor(), luci_interpreter::KernelBuilderHelper::getOptionalInputTensor(), luci_interpreter::KernelBuilderHelper::getOutputTensor(), luci_interpreter::KernelBuilderHelper::getRuntimeGraph(), and luci_interpreter::Tensor::shape().

◆ build_kernel_CircleGather()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleGather ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Gather.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleGather *>(circle_node);
28 assert(node->arity() == 2);
29
30 const Tensor *params = helper.getInputTensor(node->params());
31 const Tensor *indices = helper.getInputTensor(node->indices());
32 Tensor *output = helper.getOutputTensor(node);
33
34 GatherParams gparams{};
35 gparams.axis = node->axis();
36 // TODO support batch_dims
37 gparams.batch_dims = 0;
38
39 return std::make_unique<kernels::Gather>(params, indices, output, gparams);
40}

References luci_interpreter::GatherParams::axis, luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleGelu()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleGelu ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Gelu.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleGelu *>(circle_node);
28 assert(node->arity() == 1);
29 const Tensor *input = helper.getInputTensor(node->features());
30 Tensor *output = helper.getOutputTensor(node);
31
32 GeluParams params{};
33 params.approximate = node->approximate();
34
35 return std::make_unique<kernels::Gelu>(input, output, params);
36}

References luci_interpreter::GeluParams::approximate, luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleGreater()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleGreater ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Greater.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleGreater *>(circle_node);
28 assert(node->arity() == 2);
29
30 const Tensor *x = helper.getInputTensor(node->x());
31 const Tensor *y = helper.getInputTensor(node->y());
32 Tensor *output = helper.getOutputTensor(node);
33
34 return std::make_unique<kernels::Greater>(x, y, output);
35}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleGreaterEqual()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleGreaterEqual ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file GreaterEqual.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleGreaterEqual *>(circle_node);
28 assert(node->arity() == 2);
29
30 const Tensor *x = helper.getInputTensor(node->x());
31 const Tensor *y = helper.getInputTensor(node->y());
32 Tensor *output = helper.getOutputTensor(node);
33
34 return std::make_unique<kernels::GreaterEqual>(x, y, output);
35}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleGRU()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleGRU ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file GRU.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleGRU *>(circle_node);
28 assert(node->arity() == 6);
29
30 const Tensor *input = helper.getInputTensor(node->input());
31 const Tensor *hidden_hidden = helper.getInputTensor(node->hidden_hidden());
32 const Tensor *hidden_hidden_bias = helper.getInputTensor(node->hidden_hidden_bias());
33 const Tensor *hidden_input = helper.getInputTensor(node->hidden_input());
34 const Tensor *hidden_input_bias = helper.getInputTensor(node->hidden_input_bias());
35 const Tensor *state = helper.getInputTensor(node->state());
36
37 Tensor *output = helper.getOutputTensor(node);
38
39 GRUParams params{};
40 params.fused_act_function = node->fusedActivationFunction();
41 params.return_sequences = node->returnSequences();
42 params.time_major = node->timeMajor();
43
44 return std::make_unique<kernels::GRU>(input, hidden_hidden, hidden_hidden_bias, hidden_input,
45 hidden_input_bias, state, output, params);
46}

References luci_interpreter::GRUParams::fused_act_function, luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleHardSwish()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleHardSwish ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file HardSwish.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleHardSwish *>(circle_node);
28 assert(node->arity() == 1);
29
30 const Tensor *input = helper.getInputTensor(node->features());
31 Tensor *output = helper.getOutputTensor(node);
32
33 return std::make_unique<kernels::HardSwish>(input, output);
34}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleIf()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleIf ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file If.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleIf *>(circle_node);
28 auto output_nodes = collectOutputNodes<luci::CircleIfOut>(node);
29 assert(node->arity() == 1 + node->input_count());
30 assert(output_nodes.size() == static_cast<size_t>(node->output_count()));
31
32 const Tensor *cond = helper.getInputTensor(node->cond());
33 std::vector<const Tensor *> inputs(node->input_count());
34 for (uint32_t i = 0; i < node->input_count(); ++i)
35 {
36 inputs[i] = helper.getInputTensor(node->input(i));
37 }
38 std::vector<Tensor *> outputs = helper.getOutputTensors(output_nodes);
39
40 RuntimeGraph *then_graph = helper.getRuntimeGraph(node->then_graph());
41 RuntimeGraph *else_graph = helper.getRuntimeGraph(node->else_graph());
42
43 return std::make_unique<kernels::If>(cond, std::move(inputs), std::move(outputs), then_graph,
44 else_graph);
45}
std::vector< Tensor * > getOutputTensors(const std::vector< const loco::Node * > &nodes) const

References luci_interpreter::KernelBuilderHelper::getInputTensor(), luci_interpreter::KernelBuilderHelper::getOutputTensors(), and luci_interpreter::KernelBuilderHelper::getRuntimeGraph().

◆ build_kernel_CircleInstanceNorm()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleInstanceNorm ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file InstanceNorm.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleInstanceNorm *>(circle_node);
28 assert(node->arity() == 3);
29
30 const Tensor *input = helper.getInputTensor(node->input());
31 const Tensor *gamma = helper.getInputTensor(node->gamma());
32 const Tensor *beta = helper.getInputTensor(node->beta());
33
34 Tensor *output = helper.getOutputTensor(node);
35
36 InstanceNormParams params{};
37 params.epsilon = node->epsilon();
38 params.activation = node->fusedActivationFunction();
39
40 return std::make_unique<kernels::InstanceNorm>(input, gamma, beta, output, params);
41}

References luci_interpreter::InstanceNormParams::epsilon, luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleL2Normalize()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleL2Normalize ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file L2Normalize.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleL2Normalize *>(circle_node);
28 assert(node->arity() == 1);
29
30 const Tensor *input = helper.getInputTensor(node->x());
31 Tensor *output = helper.getOutputTensor(node);
32
33 L2NormParams params{};
34 params.activation = node->fusedActivationFunction();
35
36 return std::make_unique<kernels::L2Normalize>(input, output, params);
37}

References luci_interpreter::L2NormParams::activation, luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleL2Pool2D()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleL2Pool2D ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file L2Pool2D.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleL2Pool2D *>(circle_node);
28 assert(node->arity() == 1);
29
30 const Tensor *input = helper.getInputTensor(node->value());
31 Tensor *output = helper.getOutputTensor(node);
32
33 Pool2DParams params{};
34 params.padding = node->padding();
35 params.filter_height = node->filter()->h();
36 params.filter_width = node->filter()->w();
37 params.stride_height = node->stride()->h();
38 params.stride_width = node->stride()->w();
39 params.activation = node->fusedActivationFunction();
40
41 return std::make_unique<kernels::L2Pool2D>(input, output, params);
42}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), luci_interpreter::KernelBuilderHelper::getOutputTensor(), and luci_interpreter::Pool2DParams::padding.

◆ build_kernel_CircleLeakyRelu()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleLeakyRelu ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file LeakyRelu.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleLeakyRelu *>(circle_node);
28 assert(node->arity() == 1);
29 const Tensor *input = helper.getInputTensor(node->features());
30 Tensor *output = helper.getOutputTensor(node);
31
32 LeakyReluParams params{};
33 params.alpha = node->alpha();
34
35 return std::make_unique<kernels::LeakyRelu>(input, output, params);
36}

References luci_interpreter::LeakyReluParams::alpha, luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleLess()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleLess ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Less.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleLess *>(circle_node);
28 assert(node->arity() == 2);
29
30 const Tensor *x = helper.getInputTensor(node->x());
31 const Tensor *y = helper.getInputTensor(node->y());
32 Tensor *output = helper.getOutputTensor(node);
33
34 return std::make_unique<kernels::Less>(x, y, output);
35}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleLessEqual()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleLessEqual ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file LessEqual.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleLessEqual *>(circle_node);
28 assert(node->arity() == 2);
29
30 const Tensor *x = helper.getInputTensor(node->x());
31 const Tensor *y = helper.getInputTensor(node->y());
32 Tensor *output = helper.getOutputTensor(node);
33
34 return std::make_unique<kernels::LessEqual>(x, y, output);
35}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleLocalResponseNormalization()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleLocalResponseNormalization ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 25 of file LocalResponseNormalization.cpp.

27{
28 const auto *node = loco::must_cast<const luci::CircleLocalResponseNormalization *>(circle_node);
29 assert(node->arity() == 1);
30 const Tensor *input = helper.getInputTensor(node->input());
31 Tensor *output = helper.getOutputTensor(node);
32
34 params.radius = node->radius();
35 params.bias = node->bias();
36 params.alpha = node->alpha();
37 params.beta = node->beta();
38
39 return std::make_unique<kernels::LocalResponseNormalization>(input, output, params);
40}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), luci_interpreter::KernelBuilderHelper::getOutputTensor(), and luci_interpreter::LocalResponseNormalizationParams::radius.

◆ build_kernel_CircleLog()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleLog ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Log.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleLog *>(circle_node);
28 assert(node->arity() == 1);
29
30 const Tensor *input = helper.getInputTensor(node->x());
31 Tensor *output = helper.getOutputTensor(node);
32
33 return std::make_unique<kernels::Log>(input, output);
34}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleLogicalAnd()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleLogicalAnd ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file LogicalAnd.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleLogicalAnd *>(circle_node);
28 assert(node->arity() == 2);
29
30 const Tensor *input1 = helper.getInputTensor(node->x());
31 const Tensor *input2 = helper.getInputTensor(node->y());
32 Tensor *output = helper.getOutputTensor(node);
33
34 return std::make_unique<kernels::LogicalAnd>(input1, input2, output);
35}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleLogicalNot()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleLogicalNot ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file LogicalNot.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleLogicalNot *>(circle_node);
28 assert(node->arity() == 1);
29
30 const Tensor *input = helper.getInputTensor(node->x());
31 Tensor *output = helper.getOutputTensor(node);
32
33 return std::make_unique<kernels::LogicalNot>(input, output);
34}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleLogicalOr()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleLogicalOr ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file LogicalOr.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleLogicalOr *>(circle_node);
28 assert(node->arity() == 2);
29
30 const Tensor *input1 = helper.getInputTensor(node->x());
31 const Tensor *input2 = helper.getInputTensor(node->y());
32 Tensor *output = helper.getOutputTensor(node);
33
34 return std::make_unique<kernels::LogicalOr>(input1, input2, output);
35}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleLogistic()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleLogistic ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Logistic.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleLogistic *>(circle_node);
28 assert(node->arity() == 1);
29
30 const Tensor *input = helper.getInputTensor(node->x());
31 Tensor *output = helper.getOutputTensor(node);
32
33 return std::make_unique<kernels::Logistic>(input, output);
34}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleLogSoftmax()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleLogSoftmax ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file LogSoftmax.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleLogSoftmax *>(circle_node);
28 assert(node->arity() == 1);
29
30 const Tensor *input = helper.getInputTensor(node->logits());
31 Tensor *output = helper.getOutputTensor(node);
32
33 return std::make_unique<kernels::LogSoftmax>(input, output);
34}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleMaximum()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleMaximum ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Maximum.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleMaximum *>(circle_node);
28 assert(node->arity() == 2);
29
30 const Tensor *input1 = helper.getInputTensor(node->x());
31 const Tensor *input2 = helper.getInputTensor(node->y());
32 Tensor *output = helper.getOutputTensor(node);
33
34 return std::make_unique<kernels::Maximum>(input1, input2, output);
35}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleMaxPool2D()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleMaxPool2D ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file MaxPool2D.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleMaxPool2D *>(circle_node);
28 assert(node->arity() == 1);
29
30 const Tensor *input = helper.getInputTensor(node->value());
31 Tensor *output = helper.getOutputTensor(node);
32
33 Pool2DParams params{};
34 params.padding = node->padding();
35 params.filter_height = node->filter()->h();
36 params.filter_width = node->filter()->w();
37 params.stride_height = node->stride()->h();
38 params.stride_width = node->stride()->w();
39 params.activation = node->fusedActivationFunction();
40
41 return std::make_unique<kernels::MaxPool2D>(input, output, params);
42}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), luci_interpreter::KernelBuilderHelper::getOutputTensor(), and luci_interpreter::Pool2DParams::padding.

◆ build_kernel_CircleMean()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleMean ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Mean.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleMean *>(circle_node);
28 assert(node->arity() == 2);
29
30 const Tensor *input = helper.getInputTensor(node->input());
31 const Tensor *axes = helper.getInputTensor(node->reduction_indices());
32 Tensor *output = helper.getOutputTensor(node);
33
34 auto temp_index_unique =
35 std::make_unique<Tensor>(DataType::S32, Shape({}), AffineQuantization{}, "");
36 temp_index_unique->set_observable(false);
37 temp_index_unique->set_data_buffer(nullptr);
38 Tensor *temp_index =
39 helper.getRuntimeGraph(node->graph())->addTensor(std::move(temp_index_unique));
40
41 auto resolved_axes_unique =
42 std::make_unique<Tensor>(DataType::S32, Shape({}), AffineQuantization{}, "");
43 resolved_axes_unique->set_observable(false);
44 resolved_axes_unique->set_data_buffer(nullptr);
45 Tensor *resolved_axes =
46 helper.getRuntimeGraph(node->graph())->addTensor(std::move(resolved_axes_unique));
47
48 auto temp_sum_unique =
49 std::make_unique<Tensor>(input->element_type(), Shape({}), AffineQuantization{}, "");
50 temp_sum_unique->set_observable(false);
51 temp_sum_unique->set_data_buffer(nullptr);
52 Tensor *temp_sum = helper.getRuntimeGraph(node->graph())->addTensor(std::move(temp_sum_unique));
53
54 ReducerParams params{};
55 params.keep_dims = node->keep_dims();
56
57 return std::make_unique<kernels::Mean>(input, axes, output, temp_index, resolved_axes, temp_sum,
58 params);
59}

References luci_interpreter::RuntimeGraph::addTensor(), luci_interpreter::KernelBuilderHelper::getInputTensor(), luci_interpreter::KernelBuilderHelper::getOutputTensor(), luci_interpreter::KernelBuilderHelper::getRuntimeGraph(), luci_interpreter::ReducerParams::keep_dims, and luci_interpreter::Tensor::set_observable().

◆ build_kernel_CircleMinimum()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleMinimum ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Minimum.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleMinimum *>(circle_node);
28 assert(node->arity() == 2);
29
30 const Tensor *input1 = helper.getInputTensor(node->x());
31 const Tensor *input2 = helper.getInputTensor(node->y());
32 Tensor *output = helper.getOutputTensor(node);
33
34 return std::make_unique<kernels::Minimum>(input1, input2, output);
35}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleMirrorPad()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleMirrorPad ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file MirrorPad.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleMirrorPad *>(circle_node);
28 assert(node->arity() == 2);
29
30 const Tensor *input = helper.getInputTensor(node->input());
31 const Tensor *paddings = helper.getInputTensor(node->paddings());
32 Tensor *output = helper.getOutputTensor(node);
33
34 MirrorPadParams params{};
35 params.mode = node->mode();
36
37 return std::make_unique<kernels::MirrorPad>(input, paddings, output, params);
38}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), luci_interpreter::KernelBuilderHelper::getOutputTensor(), and luci_interpreter::MirrorPadParams::mode.

◆ build_kernel_CircleMul()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleMul ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Mul.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleMul *>(circle_node);
28 assert(node->arity() == 2);
29
30 const Tensor *input1 = helper.getInputTensor(node->x());
31 const Tensor *input2 = helper.getInputTensor(node->y());
32 Tensor *output = helper.getOutputTensor(node);
33
34 MulParams params{};
35 params.activation = node->fusedActivationFunction();
36
37 return std::make_unique<kernels::Mul>(input1, input2, output, params);
38}

References luci_interpreter::MulParams::activation, luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleNeg()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleNeg ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Neg.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleNeg *>(circle_node);
28 assert(node->arity() == 1);
29
30 const Tensor *input = helper.getInputTensor(node->x());
31 Tensor *output = helper.getOutputTensor(node);
32
33 return std::make_unique<kernels::Neg>(input, output);
34}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleNotEqual()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleNotEqual ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file NotEqual.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleNotEqual *>(circle_node);
28 assert(node->arity() == 2);
29
30 const Tensor *x = helper.getInputTensor(node->x());
31 const Tensor *y = helper.getInputTensor(node->y());
32 Tensor *output = helper.getOutputTensor(node);
33
34 return std::make_unique<kernels::NotEqual>(x, y, output);
35}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleOneHot()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleOneHot ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file OneHot.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleOneHot *>(circle_node);
28 assert(node->arity() == 4);
29
30 const Tensor *indices = helper.getInputTensor(node->indices());
31 const Tensor *depth = helper.getInputTensor(node->depth());
32 const Tensor *on_value = helper.getInputTensor(node->on_value());
33 const Tensor *off_value = helper.getInputTensor(node->off_value());
34 Tensor *output = helper.getOutputTensor(node);
35
36 OneHotParams params{};
37 params.axis = node->axis();
38
39 return std::make_unique<kernels::OneHot>(indices, depth, on_value, off_value, output, params);
40}

References luci_interpreter::OneHotParams::axis, luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CirclePack()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CirclePack ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Pack.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CirclePack *>(circle_node);
28 assert(node->arity() == node->values_count());
29
30 std::vector<const Tensor *> inputs(node->values_count());
31 for (uint32_t i = 0; i < node->values_count(); ++i)
32 {
33 inputs[i] = helper.getInputTensor(node->values(i));
34 }
35 Tensor *output = helper.getOutputTensor(node);
36
37 PackParams params{};
38 params.axis = node->axis();
39 params.values_count = node->values_count();
40
41 return std::make_unique<kernels::Pack>(std::move(inputs), output, params);
42}

References luci_interpreter::PackParams::axis, luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CirclePad()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CirclePad ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Pad.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CirclePad *>(circle_node);
28 assert(node->arity() == 2);
29
30 const Tensor *input = helper.getInputTensor(node->input());
31 const Tensor *paddings = helper.getInputTensor(node->paddings());
32 Tensor *output = helper.getOutputTensor(node);
33
34 return std::make_unique<kernels::Pad>(input, paddings, output);
35}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CirclePadV2()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CirclePadV2 ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file PadV2.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CirclePadV2 *>(circle_node);
28 assert(node->arity() == 3);
29
30 const Tensor *input = helper.getInputTensor(node->input());
31 const Tensor *paddings = helper.getInputTensor(node->paddings());
32 const Tensor *constant_values = helper.getInputTensor(node->constant_values());
33 Tensor *output = helper.getOutputTensor(node);
34
35 return std::make_unique<kernels::PadV2>(input, paddings, constant_values, output);
36}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CirclePow()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CirclePow ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Pow.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CirclePow *>(circle_node);
28 assert(node->arity() == 2);
29
30 const Tensor *input1 = helper.getInputTensor(node->x());
31 const Tensor *input2 = helper.getInputTensor(node->y());
32
33 Tensor *output = helper.getOutputTensor(node);
34
35 return std::make_unique<kernels::Pow>(input1, input2, output);
36}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CirclePRelu()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CirclePRelu ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file PRelu.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CirclePRelu *>(circle_node);
28 assert(node->arity() == 2);
29
30 const Tensor *input = helper.getInputTensor(node->input());
31 const Tensor *alpha = helper.getInputTensor(node->alpha());
32 Tensor *output = helper.getOutputTensor(node);
33
34 return std::make_unique<kernels::PRelu>(input, alpha, output);
35}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleQuantize()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleQuantize ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Quantize.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleQuantize *>(circle_node);
28 assert(node->arity() == 1);
29
30 const Tensor *input = helper.getInputTensor(node->input());
31 Tensor *output = helper.getOutputTensor(node);
32
33 return std::make_unique<kernels::Quantize>(input, output);
34}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleReduceMax()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleReduceMax ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file ReduceMax.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleReduceMax *>(circle_node);
28 assert(node->arity() == 2);
29
30 const Tensor *input = helper.getInputTensor(node->input());
31 const Tensor *axes = helper.getInputTensor(node->reduction_indices());
32 Tensor *output = helper.getOutputTensor(node);
33
34 auto temp_index_unique =
35 std::make_unique<Tensor>(DataType::S32, Shape({}), AffineQuantization{}, "");
36 temp_index_unique->set_observable(false);
37 temp_index_unique->set_data_buffer(nullptr);
38 Tensor *temp_index =
39 helper.getRuntimeGraph(node->graph())->addTensor(std::move(temp_index_unique));
40
41 auto resolved_axes_unique =
42 std::make_unique<Tensor>(DataType::S32, Shape({}), AffineQuantization{}, "");
43 resolved_axes_unique->set_observable(false);
44 resolved_axes_unique->set_data_buffer(nullptr);
45 Tensor *resolved_axes =
46 helper.getRuntimeGraph(node->graph())->addTensor(std::move(resolved_axes_unique));
47
48 ReducerParams params{};
49 params.keep_dims = node->keep_dims();
50
51 return std::make_unique<kernels::ReduceMax>(input, axes, output, temp_index, resolved_axes,
52 params);
53}

References luci_interpreter::RuntimeGraph::addTensor(), luci_interpreter::KernelBuilderHelper::getInputTensor(), luci_interpreter::KernelBuilderHelper::getOutputTensor(), luci_interpreter::KernelBuilderHelper::getRuntimeGraph(), luci_interpreter::ReducerParams::keep_dims, and luci_interpreter::Tensor::set_observable().

◆ build_kernel_CircleReduceProd()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleReduceProd ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file ReduceProd.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleReduceProd *>(circle_node);
28 assert(node->arity() == 2);
29
30 const Tensor *input = helper.getInputTensor(node->input());
31 const Tensor *axes = helper.getInputTensor(node->reduction_indices());
32 Tensor *output = helper.getOutputTensor(node);
33
34 auto temp_index_unique =
35 std::make_unique<Tensor>(DataType::S32, Shape({}), AffineQuantization{}, "");
36 temp_index_unique->set_observable(false);
37 temp_index_unique->set_data_buffer(nullptr);
38 Tensor *temp_index =
39 helper.getRuntimeGraph(node->graph())->addTensor(std::move(temp_index_unique));
40
41 auto resolved_axes_unique =
42 std::make_unique<Tensor>(DataType::S32, Shape({}), AffineQuantization{}, "");
43 resolved_axes_unique->set_observable(false);
44 resolved_axes_unique->set_data_buffer(nullptr);
45 Tensor *resolved_axes =
46 helper.getRuntimeGraph(node->graph())->addTensor(std::move(resolved_axes_unique));
47
48 ReducerParams params{};
49 params.keep_dims = node->keep_dims();
50
51 return std::make_unique<kernels::ReduceProd>(input, axes, output, temp_index, resolved_axes,
52 params);
53}

References luci_interpreter::RuntimeGraph::addTensor(), luci_interpreter::KernelBuilderHelper::getInputTensor(), luci_interpreter::KernelBuilderHelper::getOutputTensor(), luci_interpreter::KernelBuilderHelper::getRuntimeGraph(), luci_interpreter::ReducerParams::keep_dims, and luci_interpreter::Tensor::set_observable().

◆ build_kernel_CircleRelu()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleRelu ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Relu.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleRelu *>(circle_node);
28 assert(node->arity() == 1);
29
30 const Tensor *input = helper.getInputTensor(node->features());
31 Tensor *output = helper.getOutputTensor(node);
32
33 return std::make_unique<kernels::Relu>(input, output);
34}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleRelu0To1()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleRelu0To1 ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Relu0To1.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleRelu0To1 *>(circle_node);
28 assert(node->arity() == 1);
29
30 const Tensor *input = helper.getInputTensor(node->features());
31 Tensor *output = helper.getOutputTensor(node);
32
33 return std::make_unique<kernels::Relu0To1>(input, output);
34}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleRelu6()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleRelu6 ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Relu6.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleRelu6 *>(circle_node);
28 assert(node->arity() == 1);
29
30 const Tensor *input = helper.getInputTensor(node->features());
31 Tensor *output = helper.getOutputTensor(node);
32
33 return std::make_unique<kernels::Relu6>(input, output);
34}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleReshape()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleReshape ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Reshape.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleReshape *>(circle_node);
28 assert(node->arity() == 2);
29
30 const Tensor *input = helper.getInputTensor(node->tensor());
31 const Tensor *shape = helper.getInputTensor(node->shape());
32 Tensor *output = helper.getOutputTensor(node);
33
34 // NOTE 'newShape' attribute is ignored.
35 return std::make_unique<kernels::Reshape>(input, shape, output);
36}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleResizeBilinear()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleResizeBilinear ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file ResizeBilinear.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleResizeBilinear *>(circle_node);
28 assert(node->arity() == 2);
29
30 const Tensor *input = helper.getInputTensor(node->input());
31 const Tensor *size = helper.getInputTensor(node->size());
32 Tensor *output = helper.getOutputTensor(node);
33
34 ResizeBilinearParams params{};
35 params.align_corners = node->align_corners();
36 params.half_pixel_centers = node->half_pixel_centers();
37
38 return std::make_unique<kernels::ResizeBilinear>(input, size, output, params);
39}
int32_t size[5]
Definition Slice.cpp:35

References luci_interpreter::ResizeBilinearParams::align_corners, luci_interpreter::KernelBuilderHelper::getInputTensor(), luci_interpreter::KernelBuilderHelper::getOutputTensor(), and size.

◆ build_kernel_CircleResizeNearestNeighbor()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleResizeNearestNeighbor ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 25 of file ResizeNearestNeighbor.cpp.

27{
28 const auto *node = loco::must_cast<const luci::CircleResizeNearestNeighbor *>(circle_node);
29 assert(node->arity() == 2);
30
31 const Tensor *input = helper.getInputTensor(node->input());
32 const Tensor *size = helper.getInputTensor(node->size());
33 Tensor *output = helper.getOutputTensor(node);
34
36 params.align_corners = node->align_corners();
37 // TODO update half_pixel_centers after CircleResizeNearestNeighbor updated
38 // Current CircleResizeNearestNeighbor don't have half_pixel_centers.
39 // default value on current is false.
40 // it need to be updated when CircleResizeNearestNeighbor updated.
41 params.half_pixel_centers = false;
42
43 return std::make_unique<kernels::ResizeNearestNeighbor>(input, size, output, params);
44}

References luci_interpreter::ResizeNearestNeighborParams::align_corners, luci_interpreter::KernelBuilderHelper::getInputTensor(), luci_interpreter::KernelBuilderHelper::getOutputTensor(), and size.

◆ build_kernel_CircleReverseV2()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleReverseV2 ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file ReverseV2.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleReverseV2 *>(circle_node);
28 assert(node->arity() == 2);
29
30 const Tensor *input = helper.getInputTensor(node->tensor());
31 const Tensor *axes = helper.getInputTensor(node->axis());
32 Tensor *output = helper.getOutputTensor(node);
33
34 return std::make_unique<kernels::ReverseV2>(input, axes, output);
35}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleRmsNorm()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleRmsNorm ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file RmsNorm.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleRmsNorm *>(circle_node);
28 assert(node->arity() == 2);
29
30 const Tensor *input = helper.getInputTensor(node->input());
31 const Tensor *gamma = helper.getInputTensor(node->gamma());
32
33 Tensor *output = helper.getOutputTensor(node);
34
35 RmsNormParams params{};
36 params.epsilon = node->epsilon();
37
38 return std::make_unique<kernels::RmsNorm>(input, gamma, output, params);
39}

References luci_interpreter::RmsNormParams::epsilon, luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleRoPE()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleRoPE ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file RoPE.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleRoPE *>(circle_node);
28 assert(node->arity() == 3);
29
30 const Tensor *input = helper.getInputTensor(node->input());
31 const Tensor *sin_table = helper.getInputTensor(node->sin_table());
32 const Tensor *cos_table = helper.getInputTensor(node->cos_table());
33
34 Tensor *output = helper.getOutputTensor(node);
35
36 RoPEParams params{};
37 params.mode = node->mode();
38
39 return std::make_unique<kernels::RoPE>(input, sin_table, cos_table, output, params);
40}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), luci_interpreter::KernelBuilderHelper::getOutputTensor(), and luci_interpreter::RoPEParams::mode.

◆ build_kernel_CircleRsqrt()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleRsqrt ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Rsqrt.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleRsqrt *>(circle_node);
28 assert(node->arity() == 1);
29
30 const Tensor *input = helper.getInputTensor(node->x());
31 Tensor *output = helper.getOutputTensor(node);
32
33 return std::make_unique<kernels::Rsqrt>(input, output);
34}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleSelect()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleSelect ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Select.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleSelect *>(circle_node);
28 assert(node->arity() == 3);
29
30 const Tensor *c = helper.getInputTensor(node->condition());
31 const Tensor *t = helper.getInputTensor(node->t());
32 const Tensor *e = helper.getInputTensor(node->e());
33 Tensor *output = helper.getOutputTensor(node);
34
35 return std::make_unique<kernels::Select>(c, t, e, output);
36}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleSelectV2()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleSelectV2 ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file SelectV2.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleSelectV2 *>(circle_node);
28 assert(node->arity() == 3);
29
30 const Tensor *c = helper.getInputTensor(node->condition());
31 const Tensor *t = helper.getInputTensor(node->t());
32 const Tensor *e = helper.getInputTensor(node->e());
33 Tensor *output = helper.getOutputTensor(node);
34
35 return std::make_unique<kernels::SelectV2>(c, t, e, output);
36}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleShape()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleShape ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Shape.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleShape *>(circle_node);
28 assert(node->arity() == 1);
29
30 const auto input = helper.getInputTensor(node->input());
31 auto output = helper.getOutputTensor(node);
32
33 ShapeParams shape_params{};
34 shape_params.out_type = node->out_type();
35
36 return std::make_unique<kernels::ShapeKernel>(input, output, shape_params);
37}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), luci_interpreter::KernelBuilderHelper::getOutputTensor(), and luci_interpreter::ShapeParams::out_type.

◆ build_kernel_CircleSin()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleSin ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Sin.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleSin *>(circle_node);
28 assert(node->arity() == 1);
29
30 const Tensor *input = helper.getInputTensor(node->x());
31 Tensor *output = helper.getOutputTensor(node);
32
33 return std::make_unique<kernels::Sin>(input, output);
34}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleSlice()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleSlice ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Slice.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleSlice *>(circle_node);
28 assert(node->arity() == 3);
29
30 const Tensor *input = helper.getInputTensor(node->input());
31 const Tensor *begin = helper.getInputTensor(node->begin());
32 const Tensor *size = helper.getInputTensor(node->size());
33
34 Tensor *output = helper.getOutputTensor(node);
35
36 return std::make_unique<kernels::Slice>(input, begin, size, output);
37}
int32_t begin[5]
Definition Slice.cpp:33

References begin, luci_interpreter::KernelBuilderHelper::getInputTensor(), luci_interpreter::KernelBuilderHelper::getOutputTensor(), and size.

◆ build_kernel_CircleSoftmax()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleSoftmax ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Softmax.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleSoftmax *>(circle_node);
28 assert(node->arity() == 1);
29
30 const Tensor *input = helper.getInputTensor(node->logits());
31 Tensor *output = helper.getOutputTensor(node);
32
33 SoftmaxParams params{};
34 params.beta = node->beta();
35
36 return std::make_unique<kernels::Softmax>(input, output, params);
37}

References luci_interpreter::SoftmaxParams::beta, luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleSpaceToBatchND()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleSpaceToBatchND ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file SpaceToBatchND.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleSpaceToBatchND *>(circle_node);
28 assert(node->arity() == 3);
29
30 const Tensor *input = helper.getInputTensor(node->input());
31 const Tensor *block_shape = helper.getInputTensor(node->block_shape());
32 const Tensor *paddings = helper.getInputTensor(node->paddings());
33
34 Tensor *output = helper.getOutputTensor(node);
35
36 return std::make_unique<kernels::SpaceToBatchND>(input, block_shape, paddings, output);
37}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleSpaceToDepth()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleSpaceToDepth ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file SpaceToDepth.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleSpaceToDepth *>(circle_node);
28 assert(node->arity() == 1);
29 const Tensor *input = helper.getInputTensor(node->input());
30
31 Tensor *output = helper.getOutputTensor(node);
32
33 SpaceToDepthParams params{};
34 params.block_size = node->block_size();
35
36 return std::make_unique<kernels::SpaceToDepth>(input, output, params);
37}

References luci_interpreter::SpaceToDepthParams::block_size, luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleSplit()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleSplit ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Split.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleSplit *>(circle_node);
28 auto output_nodes = collectOutputNodes<luci::CircleSplitOut>(node);
29 assert(node->arity() == 2);
30 assert(output_nodes.size() == static_cast<size_t>(node->num_split()));
31
32 const Tensor *axis = helper.getInputTensor(node->split_dim());
33 const Tensor *input = helper.getInputTensor(node->input());
34 std::vector<Tensor *> outputs = helper.getOutputTensors(output_nodes);
35
36 // NOTE 'num_splits' attribute is ignored.
37 return std::make_unique<kernels::Split>(axis, input, std::move(outputs));
38}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensors().

◆ build_kernel_CircleSplitV()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleSplitV ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file SplitV.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleSplitV *>(circle_node);
28 auto output_nodes = collectOutputNodes<luci::CircleSplitVOut>(node);
29 assert(node->arity() == 3);
30 assert(output_nodes.size() == static_cast<size_t>(node->num_split()));
31
32 const Tensor *input = helper.getInputTensor(node->input());
33 const Tensor *sizes_data = helper.getInputTensor(node->size_splits());
34 const Tensor *axis = helper.getInputTensor(node->split_dim());
35 std::vector<Tensor *> outputs = helper.getOutputTensors(output_nodes);
36
37 // NOTE 'num_splits' attribute is ignored.
38 return std::make_unique<kernels::SplitV>(input, sizes_data, axis, std::move(outputs));
39}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensors().

◆ build_kernel_CircleSqrt()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleSqrt ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Sqrt.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleSqrt *>(circle_node);
28 assert(node->arity() == 1);
29
30 const Tensor *input = helper.getInputTensor(node->x());
31 Tensor *output = helper.getOutputTensor(node);
32
33 return std::make_unique<kernels::Sqrt>(input, output);
34}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleSquare()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleSquare ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Square.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleSquare *>(circle_node);
28 assert(node->arity() == 1);
29
30 const Tensor *input = helper.getInputTensor(node->x());
31 Tensor *output = helper.getOutputTensor(node);
32
33 return std::make_unique<kernels::Square>(input, output);
34}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleSquaredDifference()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleSquaredDifference ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file SquaredDifference.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleSquaredDifference *>(circle_node);
28 assert(node->arity() == 2);
29
30 const Tensor *input1 = helper.getInputTensor(node->x());
31 const Tensor *input2 = helper.getInputTensor(node->y());
32 Tensor *output = helper.getOutputTensor(node);
33
34 return std::make_unique<kernels::SquaredDifference>(input1, input2, output);
35}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleSqueeze()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleSqueeze ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Squeeze.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleSqueeze *>(circle_node);
28 assert(node->arity() == 1);
29
30 const Tensor *input = helper.getInputTensor(node->input());
31 Tensor *output = helper.getOutputTensor(node);
32
33 SqueezeParams params{};
34 params.squeeze_dims = node->squeeze_dims();
35
36 return std::make_unique<kernels::Squeeze>(input, output, params);
37}
std::vector< int32_t > squeeze_dims

References luci_interpreter::KernelBuilderHelper::getInputTensor(), luci_interpreter::KernelBuilderHelper::getOutputTensor(), and luci_interpreter::SqueezeParams::squeeze_dims.

◆ build_kernel_CircleStridedSlice()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleStridedSlice ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file StridedSlice.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleStridedSlice *>(circle_node);
28 assert(node->arity() == 4);
29
30 const Tensor *input = helper.getInputTensor(node->input());
31 const Tensor *begin = helper.getInputTensor(node->begin());
32 const Tensor *end = helper.getInputTensor(node->end());
33 const Tensor *strides = helper.getInputTensor(node->strides());
34
35 Tensor *output = helper.getOutputTensor(node);
36
37 StridedSliceParams params{};
38 params.begin_mask = node->begin_mask();
39 params.ellipsis_mask = node->ellipsis_mask();
40 params.end_mask = node->end_mask();
41 params.new_axis_mask = node->new_axis_mask();
42 params.shrink_axis_mask = node->shrink_axis_mask();
43
44 return std::make_unique<kernels::StridedSlice>(input, begin, end, strides, output, params);
45}

References begin, luci_interpreter::StridedSliceParams::begin_mask, luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleSub()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleSub ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Sub.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleSub *>(circle_node);
28 assert(node->arity() == 2);
29
30 const Tensor *input1 = helper.getInputTensor(node->x());
31 const Tensor *input2 = helper.getInputTensor(node->y());
32 Tensor *output = helper.getOutputTensor(node);
33
34 SubParams params{};
35 params.activation = node->fusedActivationFunction();
36
37 return std::make_unique<kernels::Sub>(input1, input2, output, params);
38}

References luci_interpreter::SubParams::activation, luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleSum()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleSum ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Sum.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleSum *>(circle_node);
28 assert(node->arity() == 2);
29
30 const Tensor *input = helper.getInputTensor(node->input());
31 const Tensor *axes = helper.getInputTensor(node->reduction_indices());
32 Tensor *output = helper.getOutputTensor(node);
33
34 auto temp_index_unique =
35 std::make_unique<Tensor>(DataType::S32, Shape({}), AffineQuantization{}, "");
36 temp_index_unique->set_observable(false);
37 temp_index_unique->set_data_buffer(nullptr);
38 Tensor *temp_index =
39 helper.getRuntimeGraph(node->graph())->addTensor(std::move(temp_index_unique));
40
41 auto resolved_axes_unique =
42 std::make_unique<Tensor>(DataType::S32, Shape({}), AffineQuantization{}, "");
43 resolved_axes_unique->set_observable(false);
44 resolved_axes_unique->set_data_buffer(nullptr);
45 Tensor *resolved_axes =
46 helper.getRuntimeGraph(node->graph())->addTensor(std::move(resolved_axes_unique));
47
48 ReducerParams params{};
49 params.keep_dims = node->keep_dims();
50
51 return std::make_unique<kernels::Sum>(input, axes, output, temp_index, resolved_axes, params);
52}

References luci_interpreter::RuntimeGraph::addTensor(), luci_interpreter::KernelBuilderHelper::getInputTensor(), luci_interpreter::KernelBuilderHelper::getOutputTensor(), luci_interpreter::KernelBuilderHelper::getRuntimeGraph(), luci_interpreter::ReducerParams::keep_dims, and luci_interpreter::Tensor::set_observable().

◆ build_kernel_CircleSVDF()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleSVDF ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file SVDF.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleSVDF *>(circle_node);
28 assert(node->arity() == 5);
29
30 const Tensor *input = helper.getInputTensor(node->input());
31 const Tensor *feature = helper.getInputTensor(node->weight_feature());
32 const Tensor *time = helper.getInputTensor(node->weight_time());
33 const Tensor *bias = helper.getOptionalInputTensor(node->bias());
34 const Tensor *input_activation_state = helper.getInputTensor(node->input_activation_state());
35 Tensor *output = helper.getOutputTensor(node);
36
37 auto scratchpad_tensor = std::make_unique<Tensor>(input_activation_state->element_type(),
38 Shape({}), AffineQuantization{}, "");
39 scratchpad_tensor->set_observable(false);
40 scratchpad_tensor->set_data_buffer(nullptr);
41 Tensor *tmp = helper.getRuntimeGraph(node->graph())->addTensor(std::move(scratchpad_tensor));
42
43 DataType data_type = input->element_type() == DataType::S8 ? DataType::S32 : DataType::FLOAT32;
44
45 scratchpad_tensor = std::make_unique<Tensor>(data_type, Shape({}), AffineQuantization{}, "");
46 scratchpad_tensor->set_observable(false);
47 scratchpad_tensor->set_data_buffer(nullptr);
48 Tensor *tmp_1 = helper.getRuntimeGraph(node->graph())->addTensor(std::move(scratchpad_tensor));
49
50 if (data_type == DataType::FLOAT32 &&
51 (feature->element_type() == DataType::S8 || feature->element_type() == DataType::U8))
52 {
53 data_type = feature->element_type();
54 }
55
56 scratchpad_tensor = std::make_unique<Tensor>(data_type, Shape({}), AffineQuantization{}, "");
57 scratchpad_tensor->set_observable(false);
58 scratchpad_tensor->set_data_buffer(nullptr);
59 Tensor *tmp_2 = helper.getRuntimeGraph(node->graph())->addTensor(std::move(scratchpad_tensor));
60
61 data_type = DataType::FLOAT32;
62
63 scratchpad_tensor = std::make_unique<Tensor>(data_type, Shape({}), AffineQuantization{}, "");
64 scratchpad_tensor->set_observable(false);
65 scratchpad_tensor->set_data_buffer(nullptr);
66 Tensor *tmp_3 = helper.getRuntimeGraph(node->graph())->addTensor(std::move(scratchpad_tensor));
67
68 scratchpad_tensor = std::make_unique<Tensor>(data_type, Shape({}), AffineQuantization{}, "");
69 scratchpad_tensor->set_observable(false);
70 scratchpad_tensor->set_data_buffer(nullptr);
71 Tensor *tmp_4 = helper.getRuntimeGraph(node->graph())->addTensor(std::move(scratchpad_tensor));
72
73 scratchpad_tensor = std::make_unique<Tensor>(data_type, Shape({}), AffineQuantization{}, "");
74 scratchpad_tensor->set_observable(false);
75 scratchpad_tensor->set_data_buffer(nullptr);
76 Tensor *tmp_5 = helper.getRuntimeGraph(node->graph())->addTensor(std::move(scratchpad_tensor));
77
78 scratchpad_tensor = std::make_unique<Tensor>(data_type, Shape({}), AffineQuantization{}, "");
79 scratchpad_tensor->set_observable(false);
80 scratchpad_tensor->set_data_buffer(nullptr);
81 Tensor *tmp_6 = helper.getRuntimeGraph(node->graph())->addTensor(std::move(scratchpad_tensor));
82
83 SVDFParams params{};
84 params.activation = node->fusedActivationFunction();
85 params.svdf_rank = node->svdf_rank();
86 params.asymmetric_quantize_inputs = node->asymmetric_quantize_inputs();
87
88 return std::make_unique<kernels::SVDF>(input, feature, time, bias, input_activation_state, output,
89 tmp, tmp_1, tmp_2, tmp_3, tmp_4, tmp_5, tmp_6, params);
90}
DataType
"scalar" value type
Definition DataType.h:27

References luci_interpreter::SVDFParams::activation, luci_interpreter::RuntimeGraph::addTensor(), luci_interpreter::Tensor::element_type(), luci_interpreter::KernelBuilderHelper::getInputTensor(), luci_interpreter::KernelBuilderHelper::getOptionalInputTensor(), luci_interpreter::KernelBuilderHelper::getOutputTensor(), luci_interpreter::KernelBuilderHelper::getRuntimeGraph(), and luci_interpreter::Tensor::set_observable().

◆ build_kernel_CircleTanh()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleTanh ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Tanh.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleTanh *>(circle_node);
28 assert(node->arity() == 1);
29
30 const Tensor *input = helper.getInputTensor(node->x());
31 Tensor *output = helper.getOutputTensor(node);
32
33 return std::make_unique<kernels::Tanh>(input, output);
34}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleTile()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleTile ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Tile.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleTile *>(circle_node);
28 assert(node->arity() == 2);
29
30 const Tensor *input = helper.getInputTensor(node->input());
31 const Tensor *multiples = helper.getInputTensor(node->multiples());
32 Tensor *output = helper.getOutputTensor(node);
33
34 return std::make_unique<kernels::Tile>(input, multiples, output);
35}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleTranspose()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleTranspose ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Transpose.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleTranspose *>(circle_node);
28 assert(node->arity() == 2);
29
30 const Tensor *input = helper.getInputTensor(node->a());
31 const Tensor *perm = helper.getInputTensor(node->perm());
32 Tensor *output = helper.getOutputTensor(node);
33
34 return std::make_unique<kernels::Transpose>(input, perm, output);
35}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensor().

◆ build_kernel_CircleTransposeConv()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleTransposeConv ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file TransposeConv.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleTransposeConv *>(circle_node);
28 assert(node->arity() == 4);
29
30 const Tensor *input_sizes = helper.getInputTensor(node->inputSizes());
31 const Tensor *filter = helper.getInputTensor(node->filter());
32 const Tensor *out_backprop = helper.getInputTensor(node->outBackprop());
33 const Tensor *bias = helper.getOptionalInputTensor(node->bias());
34
35 Tensor *output = helper.getOutputTensor(node);
36
37 DataType scratch_data_type =
38 helper.getInputTensor(node)->element_type() == DataType::S16 ? DataType::S64 : DataType::S32;
39
40 auto scratch_tensor =
41 std::make_unique<Tensor>(scratch_data_type, Shape({}), AffineQuantization{}, "");
42 scratch_tensor->set_observable(false);
43 scratch_tensor->set_data_buffer(nullptr);
44 Tensor *tmp = helper.getRuntimeGraph(node->graph())->addTensor(std::move(scratch_tensor));
45
46 TransposeConvParams params{};
47 params.padding = node->padding();
48 params.stride_height = node->stride()->h();
49 params.stride_width = node->stride()->w();
50 params.activation = node->fusedActivationFunction();
51
52 // TODO support activation
53 if (params.activation != luci::FusedActFunc::NONE)
54 {
55 throw std::runtime_error("Unsupported activation of TransposeConv");
56 }
57
58 return std::make_unique<kernels::TransposeConv>(input_sizes, filter, out_backprop, bias, output,
59 tmp, params);
60}
DataType
"scalar" value type
Definition DataType.h:32

References luci_interpreter::RuntimeGraph::addTensor(), luci_interpreter::Tensor::element_type(), luci_interpreter::KernelBuilderHelper::getInputTensor(), luci_interpreter::KernelBuilderHelper::getOptionalInputTensor(), luci_interpreter::KernelBuilderHelper::getOutputTensor(), luci_interpreter::KernelBuilderHelper::getRuntimeGraph(), luci::NONE, and luci_interpreter::TransposeConvParams::padding.

◆ build_kernel_CircleUnidirectionalSequenceLSTM()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleUnidirectionalSequenceLSTM ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 26 of file UnidirectionalSequenceLSTM.cpp.

28{
29 const auto *node = loco::must_cast<const luci::CircleUnidirectionalSequenceLSTM *>(circle_node);
30 assert(node->arity() == 24);
31
32 const Tensor *input = helper.getInputTensor(node->input());
33 const Tensor *input_to_input_weights =
34 helper.getOptionalInputTensor(node->input_to_input_weights());
35 const Tensor *input_to_cell_weights = helper.getInputTensor(node->input_to_cell_weights());
36 const Tensor *input_to_forget_weights = helper.getInputTensor(node->input_to_forget_weights());
37 const Tensor *input_to_output_weights = helper.getInputTensor(node->input_to_output_weights());
38 const Tensor *recurrent_to_input_weights =
39 helper.getOptionalInputTensor(node->recurrent_to_input_weights());
40 const Tensor *recurrent_to_cell_weights =
41 helper.getInputTensor(node->recurrent_to_cell_weights());
42 const Tensor *recurrent_to_forget_weights =
43 helper.getInputTensor(node->recurrent_to_forget_weights());
44 const Tensor *recurrent_to_output_weights =
45 helper.getInputTensor(node->recurrent_to_output_weights());
46 const Tensor *cell_to_input_weights =
47 helper.getOptionalInputTensor(node->cell_to_input_weights());
48 const Tensor *cell_to_forget_weights =
49 helper.getOptionalInputTensor(node->cell_to_forget_weights());
50 const Tensor *cell_to_output_weights =
51 helper.getOptionalInputTensor(node->cell_to_output_weights());
52 const Tensor *input_gate_bias = helper.getOptionalInputTensor(node->input_gate_bias());
53 const Tensor *forget_gate_bias = helper.getInputTensor(node->forget_gate_bias());
54 const Tensor *cell_gate_bias = helper.getInputTensor(node->cell_gate_bias());
55 const Tensor *output_gate_bias = helper.getInputTensor(node->output_gate_bias());
56 const Tensor *projection_weights = helper.getOptionalInputTensor(node->projection_weights());
57 const Tensor *projection_bias = helper.getOptionalInputTensor(node->projection_bias());
58 const Tensor *output_state = helper.getInputTensor(node->output_state());
59 const Tensor *cell_state = helper.getInputTensor(node->cell_state());
60 const Tensor *input_layer_norm_coefficients =
61 helper.getOptionalInputTensor(node->input_layer_norm_coefficients());
62 const Tensor *forget_layer_norm_coefficients =
63 helper.getOptionalInputTensor(node->forget_layer_norm_coefficients());
64 const Tensor *cell_layer_norm_coefficients =
65 helper.getOptionalInputTensor(node->cell_layer_norm_coefficients());
66 const Tensor *output_layer_norm_coefficients =
67 helper.getOptionalInputTensor(node->output_layer_norm_coefficients());
68 Tensor *output = helper.getOutputTensor(node);
69
70 // scratch pad tensor
71 // NOTE provide more scratch pads if support hybrid or integer
72 auto sp_output_state =
73 std::make_unique<Tensor>(output_state->element_type(), Shape({}), AffineQuantization{}, "");
74 sp_output_state->set_observable(false);
75 sp_output_state->set_data_buffer(nullptr);
76 Tensor *tmp_1 = helper.getRuntimeGraph(node->graph())->addTensor(std::move(sp_output_state));
77
78 auto sp_cell_state =
79 std::make_unique<Tensor>(cell_state->element_type(), Shape({}), AffineQuantization{}, "");
80 sp_cell_state->set_observable(false);
81 sp_cell_state->set_data_buffer(nullptr);
82 Tensor *tmp_2 = helper.getRuntimeGraph(node->graph())->addTensor(std::move(sp_cell_state));
83
84 auto sp_3 = std::make_unique<Tensor>(input->element_type(), Shape({}), AffineQuantization{}, "");
85 sp_3->set_observable(false);
86 sp_3->set_data_buffer(nullptr);
87 Tensor *tmp_3 = helper.getRuntimeGraph(node->graph())->addTensor(std::move(sp_3));
88
89 UnidirectionalSequenceLSTMParams params{};
90 params.activation = node->fusedActivationFunction();
91 params.cell_clip = node->cell_clip();
92 params.proj_clip = node->proj_clip();
93 params.time_major = node->time_major();
94 params.asymmetric_quantize_inputs = node->asymmetric_quantize_inputs();
95
96 return std::make_unique<kernels::UnidirectionalSequenceLSTM>(
97 input, input_to_input_weights, input_to_forget_weights, input_to_cell_weights,
98 input_to_output_weights, recurrent_to_input_weights, recurrent_to_forget_weights,
99 recurrent_to_cell_weights, recurrent_to_output_weights, cell_to_input_weights,
100 cell_to_forget_weights, cell_to_output_weights, input_gate_bias, forget_gate_bias,
101 cell_gate_bias, output_gate_bias, projection_weights, projection_bias, output_state, cell_state,
102 input_layer_norm_coefficients, forget_layer_norm_coefficients, cell_layer_norm_coefficients,
103 output_layer_norm_coefficients, output, tmp_1, tmp_2, tmp_3, params);
104}

References luci_interpreter::UnidirectionalSequenceLSTMParams::activation, luci_interpreter::RuntimeGraph::addTensor(), luci_interpreter::Tensor::element_type(), luci_interpreter::KernelBuilderHelper::getInputTensor(), luci_interpreter::KernelBuilderHelper::getOptionalInputTensor(), luci_interpreter::KernelBuilderHelper::getOutputTensor(), luci_interpreter::KernelBuilderHelper::getRuntimeGraph(), and luci_interpreter::Tensor::set_observable().

◆ build_kernel_CircleUnpack()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleUnpack ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file Unpack.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleUnpack *>(circle_node);
28 auto output_nodes = collectOutputNodes<luci::CircleUnpackOut>(node);
29 assert(node->arity() == 1);
30 assert(output_nodes.size() == static_cast<size_t>(node->num()));
31
32 const Tensor *input = helper.getInputTensor(node->value());
33 std::vector<Tensor *> outputs = helper.getOutputTensors(output_nodes);
34
35 UnpackParams params{};
36 params.axis = node->axis();
37
38 // NOTE 'num' attribute is ignored.
39 return std::make_unique<kernels::Unpack>(input, std::move(outputs), params);
40}

References luci_interpreter::UnpackParams::axis, luci_interpreter::KernelBuilderHelper::getInputTensor(), and luci_interpreter::KernelBuilderHelper::getOutputTensors().

◆ build_kernel_CircleWhile()

std::unique_ptr< Kernel > luci_interpreter::build_kernel_CircleWhile ( const luci::CircleNode circle_node,
KernelBuilderHelper helper 
)

Definition at line 24 of file While.cpp.

26{
27 const auto *node = loco::must_cast<const luci::CircleWhile *>(circle_node);
28
29 auto output_nodes = collectOutputNodes<luci::CircleWhileOut>(node);
30 assert(node->arity() == node->input_count());
31 assert(output_nodes.size() == static_cast<size_t>(node->output_count()));
32
33 std::vector<const Tensor *> inputs(node->input_count());
34 for (uint32_t i = 0; i < node->input_count(); ++i)
35 {
36 inputs[i] = helper.getInputTensor(node->input(i));
37 }
38 std::vector<Tensor *> outputs = helper.getOutputTensors(output_nodes);
39
40 RuntimeGraph *cond_graph = helper.getRuntimeGraph(node->cond_graph());
41 RuntimeGraph *body_graph = helper.getRuntimeGraph(node->body_graph());
42
43 return std::make_unique<kernels::While>(std::move(inputs), std::move(outputs), cond_graph,
44 body_graph);
45}

References luci_interpreter::KernelBuilderHelper::getInputTensor(), luci_interpreter::KernelBuilderHelper::getOutputTensors(), and luci_interpreter::KernelBuilderHelper::getRuntimeGraph().

◆ collectOutputNodes()

template<typename CircleNodeOut >
std::vector< const loco::Node * > luci_interpreter::collectOutputNodes ( const loco::Node node)

Definition at line 68 of file KernelBuilderHelper.h.

69{
70 std::vector<const CircleNodeOut *> output_nodes;
71 for (const loco::Node *loco_node : loco::succs(node))
72 {
73 output_nodes.push_back(loco::must_cast<const CircleNodeOut *>(loco_node));
74 }
75 std::sort(output_nodes.begin(), output_nodes.end(),
76 [](const CircleNodeOut *node1, const CircleNodeOut *node2) {
77 return node1->index() < node2->index();
78 });
79 return {output_nodes.cbegin(), output_nodes.cend()};
80}
Logical unit of computation.
Definition Node.h:54

References loco::succs().

◆ computeConvPadding()

int32_t luci_interpreter::computeConvPadding ( const circle::Tensor *  input,
const circle::Tensor *  filter,
circle::Padding  padding_type,
int32_t  stride,
int32_t  dilation,
int  axis 
)

Definition at line 41 of file ConvolutionCommon.cpp.

43{
44 const int32_t input_dim = Tensor::dim(input, axis);
45 const int32_t filter_dim = Tensor::dim(filter, axis);
46 const int32_t output_dim =
47 kernels::computeOutputSize(luci_padding(padding_type), input_dim, filter_dim, stride, dilation);
48
49 const auto padding = kernels::computePadding(stride, dilation, input_dim, filter_dim, output_dim);
50
51 return padding;
52}
Padding luci_padding(const circle::Padding padding)
const loco::Dimension & dim(uint32_t axis) const
Definition Tensor.h:44

References luci_interpreter::kernels::computeOutputSize(), luci_interpreter::kernels::computePadding(), circle_eval_diff::TensorShape::dim(), and luci::luci_padding().

Referenced by createConv2DParams().

◆ configure_kernel_CircleAbs()

void luci_interpreter::configure_kernel_CircleAbs ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 25 of file Abs.cpp.

26{
27 kernels::SISOKernel kernel(cur_op, runtime_graph);
28
29 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input()) ==
30 Tensor::element_type(kernel.output()));
31 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input()) == Tensor::num_dims(kernel.output()));
32 LUCI_INTERPRETER_CHECK(Tensor::num_elements(kernel.input()) ==
33 Tensor::num_elements(kernel.output()));
34}
#define LUCI_INTERPRETER_CHECK(cond)
Definition Utils.h:36

References luci_interpreter::kernels::SISOKernel::input(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::SISOKernel::output().

◆ configure_kernel_CircleAdd()

void luci_interpreter::configure_kernel_CircleAdd ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 96 of file Add.cpp.

97{
98 kernels::TISOKernel kernel(cur_op, runtime_graph);
99
100 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
101 Tensor::element_type(kernel.input2()));
102 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
103 Tensor::element_type(kernel.input2()));
104
105#ifndef DIS_QUANT
106 if (Tensor::element_type(kernel.input1()) == DataType::S16)
107 {
108 LUCI_INTERPRETER_CHECK(Tensor::zero_points(kernel.input1()).size() == 1 &&
109 Tensor::zero_points(kernel.input2()).size() == 1);
110 LUCI_INTERPRETER_CHECK(Tensor::zero_point(kernel.input1()) == 0 &&
111 Tensor::zero_point(kernel.input2()) == 0 &&
112 Tensor::zero_point(kernel.output()) == 0);
113 }
114#endif // DIS_QUANT
115}

References luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::TISOKernel::output().

◆ configure_kernel_CircleAddN()

void luci_interpreter::configure_kernel_CircleAddN ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 64 of file AddN.cpp.

65{
66 const int num_inputs = cur_op->inputs()->size();
67
68 LUCI_INTERPRETER_CHECK(num_inputs >= 2);
69 LUCI_INTERPRETER_CHECK(cur_op->outputs()->size() == 1);
70
71 const auto input1_index = cur_op->inputs()->operator[](0);
72 assert(input1_index != -1);
73
74 const auto input1_tensor = runtime_graph->getCircleTensorByIndex(input1_index);
75 assert(input1_tensor != nullptr);
76
77 for (int i = 1; i < num_inputs; ++i)
78 {
79 const auto input_index = cur_op->inputs()->operator[](i);
80 assert(input_index != -1);
81
82 const auto input_tensor = runtime_graph->getCircleTensorByIndex(input_index);
83 assert(input_tensor != nullptr);
84
85 LUCI_INTERPRETER_CHECK(Tensor::element_type(input1_tensor) ==
86 Tensor::element_type(input_tensor));
87 LUCI_INTERPRETER_CHECK(Tensor::num_dims(input1_tensor) == Tensor::num_dims(input_tensor));
88 LUCI_INTERPRETER_CHECK(Tensor::num_elements(input1_tensor) ==
89 Tensor::num_elements(input_tensor));
90 }
91}
const circle::Tensor * getCircleTensorByIndex(int32_t index)

References luci_interpreter::RuntimeGraph::getCircleTensorByIndex(), and LUCI_INTERPRETER_CHECK.

◆ configure_kernel_CircleArgMax()

void luci_interpreter::configure_kernel_CircleArgMax ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 27 of file ArgMax.cpp.

28{
29 kernels::TISOKernel kernel(cur_op, runtime_graph);
30 // dim tensor must be a scalar or has one element
31 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input2()) == 0 or
32 Tensor::num_elements(kernel.input2()) == 1);
33 // value and output type must match
34 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.output()) == DataType::S32);
35
36 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input2()) == DataType::S32);
37}

References luci_interpreter::kernels::TISOKernel::input2(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::TISOKernel::output().

◆ configure_kernel_CircleArgMin()

void luci_interpreter::configure_kernel_CircleArgMin ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 28 of file ArgMin.cpp.

29{
30 kernels::TISOKernel kernel(cur_op, runtime_graph);
31 // dim tensor must be a scalar or has one element
32 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input2()) == 0 or
33 Tensor::num_elements(kernel.input2()) == 1);
34 // value and output type must match
35 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.output()) == DataType::S32);
36
37 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input2()) == DataType::S32);
38}

References luci_interpreter::kernels::TISOKernel::input2(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::TISOKernel::output().

◆ configure_kernel_CircleAveragePool2D()

void luci_interpreter::configure_kernel_CircleAveragePool2D ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 25 of file AveragePool2D.cpp.

27{
28 configure_kernel_CirclePool2DCommon(cur_op, runtime_graph);
29}
void configure_kernel_CirclePool2DCommon(const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)

References configure_kernel_CirclePool2DCommon().

◆ configure_kernel_CircleBatchToSpaceND()

void luci_interpreter::configure_kernel_CircleBatchToSpaceND ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 27 of file BatchToSpaceND.cpp.

29{
30 kernels::MISOKernel kernel(cur_op, runtime_graph);
31
32 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
33 Tensor::element_type(kernel.output()));
34 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input2()) == DataType::S32);
35 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input3()) == DataType::S32);
36 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.output()) >= 3);
37 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input1()) >= 3);
38 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.output()) <= 4);
39 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input1()) <= 4);
40}

References luci_interpreter::kernels::MISOKernel::input1(), luci_interpreter::kernels::MISOKernel::input2(), luci_interpreter::kernels::MISOKernel::input3(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::MISOKernel::output().

◆ configure_kernel_CircleBroadcastTo()

void luci_interpreter::configure_kernel_CircleBroadcastTo ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 30 of file BroadcastTo.cpp.

32{
33 kernels::TISOKernel kernel(cur_op, runtime_graph);
34
35 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
36 Tensor::element_type(kernel.output()));
37 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input2()) == DataType::S32 or
38 Tensor::element_type(kernel.input2()) == DataType::S64);
39
40 // Ensure output dims is not less than input dims.
41 int input_num_dims = Tensor::num_dims(kernel.input1());
42 int output_num_dims = Tensor::num_dims(kernel.output());
43 int shape_num_dims = Tensor::dim(kernel.input2(), 0);
44
45 LUCI_INTERPRETER_CHECK(output_num_dims == shape_num_dims);
46 LUCI_INTERPRETER_CHECK(input_num_dims <= output_num_dims);
47 LUCI_INTERPRETER_CHECK(output_num_dims <= kMaxDims);
48}

References circle_eval_diff::TensorShape::dim(), luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::TISOKernel::output().

◆ configure_kernel_CircleCast()

void luci_interpreter::configure_kernel_CircleCast ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 34 of file Cast.cpp.

35{
36 kernels::SISOKernel kernel(cur_op, runtime_graph);
37
38 LUCI_INTERPRETER_CHECK(Tensor::num_elements(kernel.input()) ==
39 Tensor::num_elements(kernel.output()));
40 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input()) == Tensor::num_dims(kernel.output()));
41}

References luci_interpreter::kernels::SISOKernel::input(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::SISOKernel::output().

◆ configure_kernel_CircleCeil()

void luci_interpreter::configure_kernel_CircleCeil ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 26 of file Ceil.cpp.

27{
28 kernels::SISOKernel kernel(cur_op, runtime_graph);
29
30 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input()) ==
31 Tensor::element_type(kernel.output()));
32 LUCI_INTERPRETER_CHECK(Tensor::num_elements(kernel.input()) ==
33 Tensor::num_elements(kernel.output()));
34 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input()) == Tensor::num_dims(kernel.output()));
35}

References luci_interpreter::kernels::SISOKernel::input(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::SISOKernel::output().

◆ configure_kernel_CircleConcatenation()

void luci_interpreter::configure_kernel_CircleConcatenation ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 83 of file Concatenation.cpp.

85{
86 const int num_inputs = cur_op->inputs()->size();
87 LUCI_INTERPRETER_CHECK(num_inputs > 0);
88
89 auto input_index = cur_op->inputs()->operator[](0);
90 auto output_index = cur_op->outputs()->operator[](0);
91
92 assert(input_index != -1);
93 assert(output_index != -1);
94
95 const auto *t0 = runtime_graph->getCircleTensorByIndex(input_index);
96 const auto *output = runtime_graph->getCircleTensorByIndex(output_index);
97
98 const auto *params = cur_op->builtin_options_as_ConcatenationOptions();
99
100 // TODO: Support concat with fused activation function
101 LUCI_INTERPRETER_CHECK(luci_actfunc(params->fused_activation_function()) == FusedActFunc::NONE);
102
103 int axis = params->axis();
104 if (axis < 0)
105 axis += Tensor::num_dims(t0);
106 LUCI_INTERPRETER_CHECK(axis >= 0 && axis < Tensor::num_dims(t0));
107
108 for (int i = 1; i < num_inputs; ++i)
109 {
110 input_index = cur_op->inputs()->operator[](i);
111 const auto *tensor = runtime_graph->getCircleTensorByIndex(input_index);
112 LUCI_INTERPRETER_CHECK(Tensor::element_type(tensor) == Tensor::element_type(t0));
113 LUCI_INTERPRETER_CHECK(Tensor::num_dims(tensor) == Tensor::num_dims(t0));
114 }
115
116#ifndef DIS_QUANT
117 // If input tensors are INT8 type then quantization parameters of all input tensors and the output
118 // should be the same
119 for (int i = 1; i < num_inputs; ++i)
120 {
121 input_index = cur_op->inputs()->operator[](i);
122 const auto *tensor = runtime_graph->getCircleTensorByIndex(input_index);
123 if (Tensor::element_type(tensor) == DataType::S8)
124 {
125 LUCI_INTERPRETER_CHECK(Tensor::quantized_dimension(tensor) ==
126 Tensor::quantized_dimension(output));
127
128 LUCI_INTERPRETER_CHECK(Tensor::zero_points(tensor).size() == Tensor::scales(tensor).size());
129 LUCI_INTERPRETER_CHECK(Tensor::zero_points(tensor) == Tensor::zero_points(output));
130 LUCI_INTERPRETER_CHECK(Tensor::scales(tensor) == Tensor::scales(output));
131 }
132 }
133#endif // DIS_QUANT
134}
FusedActFunc luci_actfunc(const circle::ActivationFunctionType type)

References luci_interpreter::RuntimeGraph::getCircleTensorByIndex(), luci::luci_actfunc(), LUCI_INTERPRETER_CHECK, NONE, and size.

◆ configure_kernel_CircleConv2D()

void luci_interpreter::configure_kernel_CircleConv2D ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 213 of file Conv2D.cpp.

214{
215 kernels::DownsamplingConv2DKernel kernel(cur_op, runtime_graph);
216
217 const auto input = kernel.input();
218 const auto filter = kernel.filter();
219 const auto bias = kernel.bias();
220 const auto output = kernel.output();
221
222 auto filter_data = runtime_graph->getConstDataByTensor(filter);
223
224 assert(filter_data != nullptr);
225
226 const auto *options = cur_op->builtin_options_as_Conv2DOptions();
227
228 if (Tensor::element_type(input) == DataType::FLOAT32 &&
229 Tensor::element_type(filter) == DataType::FLOAT32)
230 {
231 LUCI_INTERPRETER_CHECK(bias == nullptr || Tensor::element_type(bias) == DataType::FLOAT32);
232 }
233#ifndef DIS_QUANT
234 else if (Tensor::element_type(input) == DataType::U8 &&
235 Tensor::element_type(filter) == DataType::U8)
236 {
237 LUCI_INTERPRETER_CHECK(bias == nullptr || Tensor::element_type(bias) == DataType::S32);
238 }
239 else if (Tensor::element_type(input) == DataType::S8 &&
240 Tensor::element_type(filter) == DataType::S8)
241 {
242 LUCI_INTERPRETER_CHECK(bias == nullptr || Tensor::element_type(bias) == DataType::S32);
243 LUCI_INTERPRETER_CHECK(Tensor::num_dims(filter) == 4);
244 LUCI_INTERPRETER_CHECK(Tensor::scales(filter).size() ==
245 static_cast<size_t>(Tensor::dim(filter, 0)));
246 for (auto zerop : Tensor::zero_points(filter))
247 {
248 LUCI_INTERPRETER_CHECK(zerop == 0);
249 }
250 }
251 else if (Tensor::element_type(input) == DataType::S16 &&
252 Tensor::element_type(filter) == DataType::S16)
253 {
254 LUCI_INTERPRETER_CHECK(bias == nullptr || Tensor::element_type(bias) == DataType::S64);
255 }
256#endif // DIS_QUANT
257 else
258 {
259 assert(false && "Unsupported type.");
260 }
261 LUCI_INTERPRETER_CHECK(Tensor::element_type(output) == Tensor::element_type(input));
262 LUCI_INTERPRETER_CHECK(Tensor::num_dims(input) == 4 && Tensor::num_dims(filter) == 4);
263
264 const int32_t output_depth = Tensor::dim(filter, 0);
265 LUCI_INTERPRETER_CHECK(Tensor::dim(filter, 3) == Tensor::dim(input, 3));
266
267 LUCI_INTERPRETER_CHECK(bias == nullptr ||
268 (Tensor::num_dims(bias) == 1 && Tensor::dim(bias, 0) == output_depth));
269
270 switch (options->fused_activation_function())
271 {
272 case circle::ActivationFunctionType_NONE:
273 case circle::ActivationFunctionType_RELU:
274 case circle::ActivationFunctionType_RELU6:
275 case circle::ActivationFunctionType_RELU_N1_TO_1:
276 break;
277 default:
278 assert(false && "Unsupported fused activation");
279 }
280}
uint8_t * getConstDataByTensor(const circle::Tensor *raw_tensor)

References luci_interpreter::kernels::DownsamplingConv2DKernel::bias(), circle_eval_diff::TensorShape::dim(), luci_interpreter::kernels::DownsamplingConv2DKernel::filter(), luci_interpreter::RuntimeGraph::getConstDataByTensor(), luci_interpreter::kernels::DownsamplingConv2DKernel::input(), LUCI_INTERPRETER_CHECK, luci_interpreter::kernels::DownsamplingConv2DKernel::output(), and size.

◆ configure_kernel_CircleCos()

void luci_interpreter::configure_kernel_CircleCos ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 26 of file Cos.cpp.

27{
28 kernels::SISOKernel kernel(cur_op, runtime_graph);
29
30 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input()) ==
31 Tensor::element_type(kernel.output()));
32 LUCI_INTERPRETER_CHECK(Tensor::num_elements(kernel.input()) ==
33 Tensor::num_elements(kernel.output()));
34 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input()) == Tensor::num_dims(kernel.output()));
35}

References luci_interpreter::kernels::SISOKernel::input(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::SISOKernel::output().

◆ configure_kernel_CircleDepthToSpace()

void luci_interpreter::configure_kernel_CircleDepthToSpace ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 26 of file DepthToSpace.cpp.

28{
29 kernels::SISOKernel kernel(cur_op, runtime_graph);
30
31 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input()) ==
32 Tensor::element_type(kernel.output()));
33
34 const auto *options = cur_op->builtin_options_as_DepthToSpaceOptions();
35
36 const int32_t block_size = options->block_size();
37 LUCI_INTERPRETER_CHECK(block_size > 0);
38
39 constexpr int kHeightRank = 1;
40 constexpr int kWidthRank = 2;
41 constexpr int kDepthRank = 3;
42
43 const int input_height = Tensor::dim(kernel.input(), kHeightRank);
44 const int input_width = Tensor::dim(kernel.input(), kWidthRank);
45 const int input_channels = Tensor::dim(kernel.input(), kDepthRank);
46 int output_height = input_height * block_size;
47 int output_width = input_width * block_size;
48 int output_channels = input_channels / block_size / block_size;
49
50 LUCI_INTERPRETER_CHECK(input_height == output_height / block_size);
51 LUCI_INTERPRETER_CHECK(input_width == output_width / block_size);
52 LUCI_INTERPRETER_CHECK(input_channels == output_channels * block_size * block_size);
53}

References circle_eval_diff::TensorShape::dim(), luci_interpreter::kernels::SISOKernel::input(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::SISOKernel::output().

◆ configure_kernel_CircleDepthwiseConv2D()

void luci_interpreter::configure_kernel_CircleDepthwiseConv2D ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 78 of file DepthwiseConv2D.cpp.

80{
81 kernels::DownsamplingConv2DKernel kernel(cur_op, runtime_graph);
82
83 const auto input = kernel.input();
84 const auto filter = kernel.filter();
85 const auto bias = kernel.bias();
86 const auto output = kernel.output();
87
88 auto filter_data = runtime_graph->getConstDataByTensor(filter);
89
90 assert(filter_data != nullptr);
91
92 const auto *options = cur_op->builtin_options_as_DepthwiseConv2DOptions();
93
94 if (Tensor::element_type(input) == DataType::FLOAT32 &&
95 Tensor::element_type(filter) == DataType::FLOAT32)
96 {
97 LUCI_INTERPRETER_CHECK(bias == nullptr || Tensor::element_type(bias) == DataType::FLOAT32);
98 }
99 else
100 {
101 assert(false && "Unsupported type.");
102 }
103 LUCI_INTERPRETER_CHECK(Tensor::element_type(output) == Tensor::element_type(input));
104 LUCI_INTERPRETER_CHECK(Tensor::num_dims(input) == 4 && Tensor::num_dims(filter) == 4);
105
106 const int32_t output_depth = Tensor::dim(output, 3);
107 LUCI_INTERPRETER_CHECK(bias == nullptr ||
108 (Tensor::num_dims(bias) == 1 && Tensor::dim(bias, 0) == output_depth));
109
110 switch (options->fused_activation_function())
111 {
112 case circle::ActivationFunctionType_NONE:
113 case circle::ActivationFunctionType_RELU:
114 case circle::ActivationFunctionType_RELU6:
115 case circle::ActivationFunctionType_RELU_N1_TO_1:
116 break;
117 default:
118 assert(false && "Unsupported fused activation");
119 }
120}

References luci_interpreter::kernels::DownsamplingConv2DKernel::bias(), circle_eval_diff::TensorShape::dim(), luci_interpreter::kernels::DownsamplingConv2DKernel::filter(), luci_interpreter::RuntimeGraph::getConstDataByTensor(), luci_interpreter::kernels::DownsamplingConv2DKernel::input(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::DownsamplingConv2DKernel::output().

◆ configure_kernel_CircleDequantize()

void luci_interpreter::configure_kernel_CircleDequantize ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 26 of file Dequantize.cpp.

28{
29#ifndef DIS_QUANT
30 kernels::SISOKernel kernel(cur_op, runtime_graph);
31
32 LUCI_INTERPRETER_CHECK(Tensor::num_elements(kernel.input()) ==
33 Tensor::num_elements(kernel.output()));
34 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input()) == Tensor::num_dims(kernel.output()));
35 LUCI_INTERPRETER_CHECK(!Tensor::scales(kernel.input()).empty());
36 LUCI_INTERPRETER_CHECK(!Tensor::zero_points(kernel.input()).empty());
37#else
38 assert(false && "Remove DIS_QUANT flag");
39#endif // DIS_QUANT
40}

References luci_interpreter::kernels::SISOKernel::input(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::SISOKernel::output().

◆ configure_kernel_CircleDiv()

void luci_interpreter::configure_kernel_CircleDiv ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 28 of file Div.cpp.

29{
30 kernels::TISOKernel kernel(cur_op, runtime_graph);
31
32 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
33 Tensor::element_type(kernel.input2()));
34 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
35 Tensor::element_type(kernel.input2()));
36}

References luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), and LUCI_INTERPRETER_CHECK.

◆ configure_kernel_CircleElu()

void luci_interpreter::configure_kernel_CircleElu ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 26 of file Elu.cpp.

27{
28 kernels::SISOKernel kernel(cur_op, runtime_graph);
29
30 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input()) ==
31 Tensor::element_type(kernel.output()));
32 LUCI_INTERPRETER_CHECK(Tensor::num_elements(kernel.input()) ==
33 Tensor::num_elements(kernel.output()));
34 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input()) == Tensor::num_dims(kernel.output()));
35}

References luci_interpreter::kernels::SISOKernel::input(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::SISOKernel::output().

◆ configure_kernel_CircleEqual()

void luci_interpreter::configure_kernel_CircleEqual ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 24 of file Equal.cpp.

25{
26 kernels::TISOKernel kernel(cur_op, runtime_graph);
27
28 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
29 Tensor::element_type(kernel.input2()));
30 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.output()) == DataType::BOOL);
31}

References luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::TISOKernel::output().

◆ configure_kernel_CircleExp()

void luci_interpreter::configure_kernel_CircleExp ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 27 of file Exp.cpp.

28{
29 kernels::SISOKernel kernel(cur_op, runtime_graph);
30
31 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input()) ==
32 Tensor::element_type(kernel.output()));
33 LUCI_INTERPRETER_CHECK(Tensor::num_elements(kernel.input()) ==
34 Tensor::num_elements(kernel.output()));
35 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input()) == Tensor::num_dims(kernel.output()));
36}

References luci_interpreter::kernels::SISOKernel::input(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::SISOKernel::output().

◆ configure_kernel_CircleExpandDims()

void luci_interpreter::configure_kernel_CircleExpandDims ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 23 of file ExpandDims.cpp.

25{
26 const auto input_index = cur_op->inputs()->operator[](0);
27 const auto axis_index = cur_op->inputs()->operator[](1);
28 const auto output_index = cur_op->outputs()->operator[](0);
29
30 assert(input_index != -1);
31 assert(axis_index != -1);
32 assert(output_index != -1);
33
34 const auto input = runtime_graph->getCircleTensorByIndex(input_index);
35 const auto axis = runtime_graph->getCircleTensorByIndex(axis_index);
36 auto output = runtime_graph->getCircleTensorByIndex(output_index);
37
38 assert(input != nullptr);
39 assert(axis != nullptr);
40 assert(output != nullptr);
41
42 auto axis_data = runtime_graph->getConstDataByTensor(axis);
43 assert(axis_data != nullptr);
44
45 int32_t axis_value;
46
47 switch (Tensor::element_type(axis))
48 {
49 case DataType::S32:
50 axis_value = *reinterpret_cast<int32_t *>(axis_data);
51 break;
52 case DataType::S64:
53 axis_value = static_cast<int32_t>(*reinterpret_cast<int64_t *>(axis_data));
54 break;
55 default:
56 assert(false && "Unsupported type.");
57 }
58
59 if (axis_value < 0)
60 {
61 axis_value += Tensor::num_dims(input) + 1;
62 }
63
64 LUCI_INTERPRETER_CHECK(axis_value <= Tensor::num_dims(input) and axis_value >= 0);
65}

References luci_interpreter::RuntimeGraph::getCircleTensorByIndex(), luci_interpreter::RuntimeGraph::getConstDataByTensor(), and LUCI_INTERPRETER_CHECK.

◆ configure_kernel_CircleFill()

void luci_interpreter::configure_kernel_CircleFill ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 37 of file Fill.cpp.

38{
39 kernels::TISOKernel kernel(cur_op, runtime_graph);
40 // value tensor must be a scalar or has one element
41 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input2()) == 0 or
42 Tensor::num_elements(kernel.input2()) == 1);
43 // value and output type must match
44 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input2()) ==
45 Tensor::element_type(kernel.output()));
46}

References luci_interpreter::kernels::TISOKernel::input2(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::TISOKernel::output().

◆ configure_kernel_CircleFloor()

void luci_interpreter::configure_kernel_CircleFloor ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 25 of file Floor.cpp.

26{
27 const auto input_index = cur_op->inputs()->operator[](0);
28 const auto output_index = cur_op->outputs()->operator[](0);
29
30 assert(input_index != -1);
31 assert(output_index != -1);
32
33 const auto input = runtime_graph->getCircleTensorByIndex(input_index);
34 const auto output = runtime_graph->getCircleTensorByIndex(output_index);
35
36 LUCI_INTERPRETER_CHECK(Tensor::element_type(input) == Tensor::element_type(output));
37 // check that input and output dimensions are equal
38 int N = kernels::getTensorShape(input).dimensionsCount();
39 LUCI_INTERPRETER_CHECK(N == kernels::getTensorShape(output).dimensionsCount());
40
41 // check that sizes of all dimensions are equal
42 for (int i = 0; i < N; ++i)
43 {
44 LUCI_INTERPRETER_CHECK(kernels::getTensorShape(input).dims(i) ==
45 kernels::getTensorShape(output).dims(i));
46 }
47}

References luci_interpreter::RuntimeGraph::getCircleTensorByIndex(), luci_interpreter::kernels::getTensorShape(), and LUCI_INTERPRETER_CHECK.

◆ configure_kernel_CircleFloorDiv()

void luci_interpreter::configure_kernel_CircleFloorDiv ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 27 of file FloorDiv.cpp.

29{
30 kernels::TISOKernel kernel(cur_op, runtime_graph);
31
32 CheckBinaryOpDataTypesEqual(kernel);
33}

◆ configure_kernel_CircleFloorMod()

void luci_interpreter::configure_kernel_CircleFloorMod ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 27 of file FloorMod.cpp.

29{
30 kernels::TISOKernel kernel(cur_op, runtime_graph);
31
32 CheckBinaryOpDataTypesEqual(kernel);
33}

◆ configure_kernel_CircleFullyConnected()

void luci_interpreter::configure_kernel_CircleFullyConnected ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 204 of file FullyConnected.cpp.

206{
207 const auto input_index = cur_op->inputs()->operator[](0);
208 const auto weight_index = cur_op->inputs()->operator[](1);
209 const auto bias_index = cur_op->inputs()->operator[](2);
210 const auto output_index = cur_op->outputs()->operator[](0);
211
212 assert(input_index != -1);
213 assert(weight_index != -1);
214 assert(output_index != -1);
215
216 const auto input = runtime_graph->getCircleTensorByIndex(input_index);
217 const auto weights = runtime_graph->getCircleTensorByIndex(weight_index);
218 const auto bias = runtime_graph->getCircleTensorByIndex(bias_index);
219 const auto output = runtime_graph->getCircleTensorByIndex(output_index);
220
221 assert(input != nullptr);
222 assert(weights != nullptr);
223 assert(output != nullptr);
224
225#ifndef DIS_FLOAT
226 if (Tensor::element_type(weights) == DataType::S8 and
227 Tensor::element_type(input) == DataType::FLOAT32)
228 {
229 // hybrid mode
230 LUCI_INTERPRETER_CHECK(Tensor::element_type(output) == DataType::FLOAT32);
231 LUCI_INTERPRETER_CHECK(!bias || Tensor::element_type(bias) == DataType::FLOAT32)
232 }
233 else if (Tensor::element_type(weights) == DataType::FLOAT32)
234 {
235 LUCI_INTERPRETER_CHECK(Tensor::element_type(input) == DataType::FLOAT32);
236 LUCI_INTERPRETER_CHECK(Tensor::element_type(output) == DataType::FLOAT32);
237 LUCI_INTERPRETER_CHECK(!bias || Tensor::element_type(bias) == DataType::FLOAT32)
238 }
239#endif // DIS_FLOAT
240#ifndef DIS_QUANT
241 else if (Tensor::element_type(weights) == DataType::U8)
242 {
243 LUCI_INTERPRETER_CHECK(Tensor::element_type(input) == DataType::U8);
244 LUCI_INTERPRETER_CHECK(Tensor::element_type(output) == DataType::U8);
245 LUCI_INTERPRETER_CHECK(!bias || Tensor::element_type(bias) == DataType::S32)
246 }
247 else if (Tensor::element_type(weights) == DataType::S8)
248 {
249 LUCI_INTERPRETER_CHECK(Tensor::element_type(input) == DataType::S8 ||
250 Tensor::element_type(input) == DataType::FLOAT32);
251 LUCI_INTERPRETER_CHECK(Tensor::element_type(output) == DataType::S8 ||
252 Tensor::element_type(output) == DataType::FLOAT32);
253 LUCI_INTERPRETER_CHECK(!bias || Tensor::element_type(bias) == DataType::S32 ||
254 Tensor::element_type(bias) == DataType::S64 ||
255 Tensor::element_type(bias) == DataType::FLOAT32)
256 if (Tensor::element_type(input) == DataType::FLOAT32)
257 {
258 // Check it is channel wise quantization
259 LUCI_INTERPRETER_CHECK(weights->quantization() != nullptr);
260 LUCI_INTERPRETER_CHECK(weights->quantization()->scale() != nullptr);
261 }
262 }
263#endif // DIS_QUANT
264 else
265 {
266 assert(false && "Unsupported type.");
267 }
268
269 LUCI_INTERPRETER_CHECK(Tensor::num_dims(weights) == 2);
270 LUCI_INTERPRETER_CHECK(bias == nullptr || Tensor::num_elements(bias) == Tensor::dim(weights, 0));
271
272#ifdef DIS_DYN_SHAPES
273 int32_t input_num_elements = Tensor::num_elements(input);
274 LUCI_INTERPRETER_CHECK(input_num_elements % Tensor::dim(weights, 1) == 0);
275#endif // DIS_DYN_SHAPES
276
277 if (bias)
278 LUCI_INTERPRETER_CHECK(Tensor::num_elements(bias) == Tensor::dim(weights, 0));
279}

References circle_eval_diff::TensorShape::dim(), luci_interpreter::RuntimeGraph::getCircleTensorByIndex(), and LUCI_INTERPRETER_CHECK.

◆ configure_kernel_CircleGather()

void luci_interpreter::configure_kernel_CircleGather ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 100 of file Gather.cpp.

101{
102 kernels::TISOKernel kernel(cur_op, runtime_graph);
103
104 const auto *options = cur_op->builtin_options_as_GatherOptions();
105
106 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input2()) == DataType::S32);
107 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) == DataType::FLOAT32 or
108 Tensor::element_type(kernel.input1()) == DataType::S8 or
109 Tensor::element_type(kernel.input1()) == DataType::S32);
110
111 int32_t axis = options->axis();
112 int32_t num_dims = Tensor::num_dims(kernel.input1());
113 if (axis < 0)
114 {
115 axis += num_dims;
116 }
117
118 LUCI_INTERPRETER_CHECK(axis >= 0 and axis < num_dims);
119
120 int32_t batch_dims = options->batch_dims();
121 int32_t coords_num_dims = Tensor::num_dims(kernel.input2());
122 // batch_dims should be in range: [-rank(coords), rank(coords)].
123 // Negative batch_dims is added with rank of coords.
124 if (batch_dims < 0)
125 {
126 batch_dims += coords_num_dims;
127 }
128 LUCI_INTERPRETER_CHECK(batch_dims <= axis);
129 LUCI_INTERPRETER_CHECK(batch_dims >= 0 and batch_dims < num_dims);
130 LUCI_INTERPRETER_CHECK(batch_dims <= coords_num_dims);
131 for (int i = 0; i < batch_dims; ++i)
132 {
133 LUCI_INTERPRETER_CHECK(Tensor::dim(kernel.input1(), i) == Tensor::dim(kernel.input2(), i));
134 }
135}

References circle_eval_diff::TensorShape::dim(), luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), and LUCI_INTERPRETER_CHECK.

◆ configure_kernel_CircleGatherND()

void luci_interpreter::configure_kernel_CircleGatherND ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 28 of file GatherND.cpp.

30{
31 kernels::TISOKernel kernel(cur_op, runtime_graph);
32
33 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input2()) == DataType::S32);
34 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
35 Tensor::element_type(kernel.output()));
36
37 const int params_rank = Tensor::num_dims(kernel.input1());
38 const int indices_rank = Tensor::num_dims(kernel.input2());
39 const int indices_nd = Tensor::dim(kernel.input2(), indices_rank - 1);
40
41 LUCI_INTERPRETER_CHECK(params_rank >= 1);
42 LUCI_INTERPRETER_CHECK(indices_rank >= 1);
43 LUCI_INTERPRETER_CHECK(indices_nd <= params_rank);
45}
constexpr int MAX_INDICES_ND
Definition PALGatherND.h:27

References circle_eval_diff::TensorShape::dim(), luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), LUCI_INTERPRETER_CHECK, luci_interpreter_pal::MAX_INDICES_ND, and luci_interpreter::kernels::TISOKernel::output().

◆ configure_kernel_CircleGreater()

void luci_interpreter::configure_kernel_CircleGreater ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 24 of file Greater.cpp.

25{
26 kernels::TISOKernel kernel(cur_op, runtime_graph);
27
28 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
29 Tensor::element_type(kernel.input2()));
30 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.output()) == DataType::BOOL);
31}

References luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::TISOKernel::output().

◆ configure_kernel_CircleGreaterEqual()

void luci_interpreter::configure_kernel_CircleGreaterEqual ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 24 of file GreaterEqual.cpp.

26{
27 kernels::TISOKernel kernel(cur_op, runtime_graph);
28
29 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
30 Tensor::element_type(kernel.input2()));
31 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.output()) == DataType::BOOL);
32}

References luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::TISOKernel::output().

◆ configure_kernel_CircleIf()

void luci_interpreter::configure_kernel_CircleIf ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 24 of file If.cpp.

25{
26 auto *main_runtime_graph = runtime_graph;
27
28 auto *runtime_module = runtime_graph->getRuntimeModule();
29
30 const auto *options = cur_op->builtin_options_as_IfOptions();
31
32 const auto cond_index = cur_op->inputs()->operator[](0);
33 const auto output_index = cur_op->outputs()->operator[](0);
34
35 const auto then_subgraph_index = options->then_subgraph_index();
36 const auto else_subgraph_index = options->else_subgraph_index();
37
38 assert(cond_index != -1);
39 assert(output_index != -1);
40
41 assert(then_subgraph_index != -1);
42 assert(else_subgraph_index != -1);
43
44 const auto cond = runtime_graph->getCircleTensorByIndex(cond_index);
45 LUCI_INTERPRETER_CHECK(Tensor::element_type(cond) == DataType::BOOL);
46 LUCI_INTERPRETER_CHECK(Tensor::num_elements(cond) == 1);
47
48 const auto output = runtime_graph->getCircleTensorByIndex(output_index);
49 auto *then_subgraph = runtime_module->getRuntimeGraphAt(then_subgraph_index);
50 auto *else_subgraph = runtime_module->getRuntimeGraphAt(else_subgraph_index);
51 for (RuntimeGraph *graph : {then_subgraph, else_subgraph})
52 {
53 graph->selectOwnSubgraph();
54 const auto graph_input_size = graph->getNumOfInputTensors();
55 const auto graph_output_size = graph->getNumOfOutputTensors();
56 LUCI_INTERPRETER_CHECK(graph_input_size == cur_op->inputs()->size() - 1);
57 LUCI_INTERPRETER_CHECK(graph_output_size == cur_op->outputs()->size());
58 graph->invalidate();
59 graph->configure(false);
60 }
61 main_runtime_graph->selectOwnSubgraph();
62}
RuntimeModule * getRuntimeModule()

References luci_interpreter::RuntimeGraph::getCircleTensorByIndex(), luci_interpreter::RuntimeGraph::getRuntimeModule(), and LUCI_INTERPRETER_CHECK.

◆ configure_kernel_CircleL2Normalize()

void luci_interpreter::configure_kernel_CircleL2Normalize ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 26 of file L2Normalize.cpp.

28{
29 kernels::SISOKernel kernel(cur_op, runtime_graph);
30
31 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input()) ==
32 Tensor::element_type(kernel.output()));
33 LUCI_INTERPRETER_CHECK(Tensor::num_elements(kernel.input()) ==
34 Tensor::num_elements(kernel.output()));
35 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input()) == Tensor::num_dims(kernel.output()));
36}

References luci_interpreter::kernels::SISOKernel::input(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::SISOKernel::output().

◆ configure_kernel_CircleL2Pool2D()

void luci_interpreter::configure_kernel_CircleL2Pool2D ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 24 of file L2Pool2D.cpp.

26{
27 configure_kernel_CirclePool2DCommon(cur_op, runtime_graph);
28}

References configure_kernel_CirclePool2DCommon().

◆ configure_kernel_CircleLeakyRelu()

void luci_interpreter::configure_kernel_CircleLeakyRelu ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 26 of file LeakyRelu.cpp.

28{
29 kernels::SISOKernel kernel(cur_op, runtime_graph);
30
31 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input()) ==
32 Tensor::element_type(kernel.output()));
33 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input()) == Tensor::num_dims(kernel.output()));
34 LUCI_INTERPRETER_CHECK(Tensor::num_elements(kernel.input()) ==
35 Tensor::num_elements(kernel.output()));
36}

References luci_interpreter::kernels::SISOKernel::input(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::SISOKernel::output().

◆ configure_kernel_CircleLess()

void luci_interpreter::configure_kernel_CircleLess ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 80 of file Less.cpp.

81{
82 kernels::TISOKernel kernel(cur_op, runtime_graph);
83
84 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
85 Tensor::element_type(kernel.input2()));
86 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.output()) == DataType::BOOL);
87}

References luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::TISOKernel::output().

◆ configure_kernel_CircleLessEqual()

void luci_interpreter::configure_kernel_CircleLessEqual ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 24 of file LessEqual.cpp.

26{
27 kernels::TISOKernel kernel(cur_op, runtime_graph);
28
29 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
30 Tensor::element_type(kernel.input2()));
31 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.output()) == DataType::BOOL);
32}

References luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::TISOKernel::output().

◆ configure_kernel_CircleLog()

void luci_interpreter::configure_kernel_CircleLog ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 26 of file Log.cpp.

27{
28 kernels::SISOKernel kernel(cur_op, runtime_graph);
29
30 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input()) ==
31 Tensor::element_type(kernel.output()));
32 LUCI_INTERPRETER_CHECK(Tensor::num_elements(kernel.input()) ==
33 Tensor::num_elements(kernel.output()));
34 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input()) == Tensor::num_dims(kernel.output()));
35}

References luci_interpreter::kernels::SISOKernel::input(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::SISOKernel::output().

◆ configure_kernel_CircleLogicalAnd()

void luci_interpreter::configure_kernel_CircleLogicalAnd ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 30 of file LogicalAnd.cpp.

32{
33 kernels::TISOKernel kernel(cur_op, runtime_graph);
34
35 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
36 Tensor::element_type(kernel.input2()));
37 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) == DataType::BOOL);
38 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.output()) == DataType::BOOL);
39
40 // TODO support broadcast
41 LUCI_INTERPRETER_CHECK(Tensor::num_elements(kernel.input1()) ==
42 Tensor::num_elements(kernel.input2()));
43 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input1()) == Tensor::num_dims(kernel.input2()));
44}

References luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::TISOKernel::output().

◆ configure_kernel_CircleLogicalNot()

void luci_interpreter::configure_kernel_CircleLogicalNot ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 24 of file LogicalNot.cpp.

26{
27 kernels::SISOKernel kernel(cur_op, runtime_graph);
28
29 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input()) == DataType::BOOL);
30 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.output()) == DataType::BOOL);
31
32 // check that input and output dimensions are equal
33 int N = Tensor::num_dims(kernel.input());
34 LUCI_INTERPRETER_CHECK(N == Tensor::num_dims(kernel.output()));
35
36 // check that sizes of all dimensions are equal
37 for (int i = 0; i < N; ++i)
38 {
39 LUCI_INTERPRETER_CHECK(kernels::getTensorShape(kernel.input()).dims(i) ==
40 kernels::getTensorShape(kernel.output()).dims(i));
41 }
42}

References luci_interpreter::kernels::getTensorShape(), luci_interpreter::kernels::SISOKernel::input(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::SISOKernel::output().

◆ configure_kernel_CircleLogicalOr()

void luci_interpreter::configure_kernel_CircleLogicalOr ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 31 of file LogicalOr.cpp.

33{
34 kernels::TISOKernel kernel(cur_op, runtime_graph);
35
36 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
37 Tensor::element_type(kernel.input2()));
38 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) == DataType::BOOL);
39 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.output()) == DataType::BOOL);
40
41 // TODO support broadcast
42 LUCI_INTERPRETER_CHECK(Tensor::num_elements(kernel.input1()) ==
43 Tensor::num_elements(kernel.input2()));
44 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input1()) == Tensor::num_dims(kernel.input2()));
45}

References luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::TISOKernel::output().

◆ configure_kernel_CircleLogistic()

void luci_interpreter::configure_kernel_CircleLogistic ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 25 of file Logistic.cpp.

27{
28 kernels::SISOKernel kernel(cur_op, runtime_graph);
29
30 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input()) ==
31 Tensor::element_type(kernel.output()))
32
33#ifndef DIS_QUANT
34 if (Tensor::element_type(kernel.input()) == DataType::U8)
35 {
36 LUCI_INTERPRETER_CHECK(Tensor::scale(kernel.output()) == 1. / 256);
37 }
38#endif // DIS_QUANT
39}

References luci_interpreter::kernels::SISOKernel::input(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::SISOKernel::output().

◆ configure_kernel_CircleLogSoftmax()

void luci_interpreter::configure_kernel_CircleLogSoftmax ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 26 of file LogSoftmax.cpp.

28{
29 kernels::SISOKernel kernel(cur_op, runtime_graph);
30
31 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input()) ==
32 Tensor::element_type(kernel.output()));
33 LUCI_INTERPRETER_CHECK(Tensor::num_elements(kernel.input()) ==
34 Tensor::num_elements(kernel.output()));
35 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input()) == Tensor::num_dims(kernel.output()));
36}

References luci_interpreter::kernels::SISOKernel::input(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::SISOKernel::output().

◆ configure_kernel_CircleMaximum()

void luci_interpreter::configure_kernel_CircleMaximum ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 27 of file Maximum.cpp.

28{
29 kernels::TISOKernel kernel(cur_op, runtime_graph);
30
31 kernels::CheckBinaryOpDataTypesEqual(kernel);
32}

References luci_interpreter::kernels::CheckBinaryOpDataTypesEqual().

◆ configure_kernel_CircleMaxPool2D()

void luci_interpreter::configure_kernel_CircleMaxPool2D ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 23 of file MaxPool2D.cpp.

25{
26 configure_kernel_CirclePool2DCommon(cur_op, runtime_graph);
27}

References configure_kernel_CirclePool2DCommon().

◆ configure_kernel_CircleMean()

void luci_interpreter::configure_kernel_CircleMean ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 48 of file Mean.cpp.

49{
50 kernels::TISOKernel kernel(cur_op, runtime_graph);
51
52 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
53 Tensor::element_type(kernel.output()));
54 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input2()) == DataType::S32);
55
56 const int32_t axis_value =
57 kernels::getTensorData<int>(runtime_graph->getConstDataByTensor(kernel.input2()))[0];
58 LUCI_INTERPRETER_CHECK(axis_value >= 0);
59}

References luci_interpreter::RuntimeGraph::getConstDataByTensor(), luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::TISOKernel::output().

◆ configure_kernel_CircleMinimum()

void luci_interpreter::configure_kernel_CircleMinimum ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 27 of file Minimum.cpp.

28{
29 kernels::TISOKernel kernel(cur_op, runtime_graph);
30
31 kernels::CheckBinaryOpDataTypesEqual(kernel);
32}

References luci_interpreter::kernels::CheckBinaryOpDataTypesEqual().

◆ configure_kernel_CircleMirrorPad()

void luci_interpreter::configure_kernel_CircleMirrorPad ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 31 of file MirrorPad.cpp.

33{
34 kernels::TISOKernel kernel(cur_op, runtime_graph);
35
36 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
37 Tensor::element_type(kernel.output()));
38 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input2()) == 2);
39 LUCI_INTERPRETER_CHECK(Tensor::dim(kernel.input2(), 0) == Tensor::num_dims(kernel.input1()));
40}

References circle_eval_diff::TensorShape::dim(), luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::TISOKernel::output().

◆ configure_kernel_CircleMul()

void luci_interpreter::configure_kernel_CircleMul ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 85 of file Mul.cpp.

86{
87 kernels::TISOKernel kernel(cur_op, runtime_graph);
88
89 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
90 Tensor::element_type(kernel.input2()));
91 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
92 Tensor::element_type(kernel.input2()));
93#ifndef DIS_QUANT
94 if (Tensor::element_type(kernel.input1()) == DataType::S16)
95 {
96 LUCI_INTERPRETER_CHECK(Tensor::zero_points(kernel.input1()).size() == 1 &&
97 Tensor::zero_points(kernel.input2()).size() == 1);
98 LUCI_INTERPRETER_CHECK(Tensor::zero_point(kernel.input1()) == 0 &&
99 Tensor::zero_point(kernel.input2()) == 0 &&
100 Tensor::zero_point(kernel.output()) == 0);
101 }
102#endif // DIS_QUANT
103}

References luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::TISOKernel::output().

◆ configure_kernel_CircleNeg()

void luci_interpreter::configure_kernel_CircleNeg ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 27 of file Neg.cpp.

28{
29 const auto input_index = cur_op->inputs()->operator[](0);
30 const auto output_index = cur_op->outputs()->operator[](0);
31
32 assert(input_index != -1);
33 assert(output_index != -1);
34
35 const auto input = runtime_graph->getCircleTensorByIndex(input_index);
36 const auto output = runtime_graph->getCircleTensorByIndex(output_index);
37
38 LUCI_INTERPRETER_CHECK(Tensor::element_type(input) == Tensor::element_type(output));
39
40 assert(Tensor::num_dims(input) == 4);
41
42 // TODO: enable it only if kernel with dynamic shapes
43 // output-> resize(input->shape());
44}

References luci_interpreter::RuntimeGraph::getCircleTensorByIndex(), and LUCI_INTERPRETER_CHECK.

◆ configure_kernel_CircleNotEqual()

void luci_interpreter::configure_kernel_CircleNotEqual ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 24 of file NotEqual.cpp.

26{
27 kernels::TISOKernel kernel(cur_op, runtime_graph);
28
29 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
30 Tensor::element_type(kernel.input2()));
31 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.output()) == DataType::BOOL);
32}

References luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::TISOKernel::output().

◆ configure_kernel_CirclePack()

void luci_interpreter::configure_kernel_CirclePack ( const circle::Operator *  ,
BaseRuntimeGraph  
)

Definition at line 85 of file Pack.cpp.

86{
87 // Do nothing
88}

◆ configure_kernel_CirclePad()

void luci_interpreter::configure_kernel_CirclePad ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 22 of file Pad.cpp.

23{
24 configure_kernel_CirclePadCommon(cur_op, runtime_graph);
25}
void configure_kernel_CirclePadCommon(const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
Definition PadCommon.cpp:94

References configure_kernel_CirclePadCommon().

◆ configure_kernel_CirclePadCommon()

void luci_interpreter::configure_kernel_CirclePadCommon ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 94 of file PadCommon.cpp.

96{
97 PadKernel kernel(cur_op, runtime_graph);
98
99 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input2()) == DataType::S32);
100 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
101 Tensor::element_type(kernel.output()));
102 if (kernel.input3() != nullptr)
103 PadKernel kernel(cur_op, runtime_graph);
104
105 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input2()) == DataType::S32);
106 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
107 Tensor::element_type(kernel.output()));
108 if (kernel.input3() != nullptr)
109 {
110 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input3()) ==
111 Tensor::element_type(kernel.input1()));
112 // Value is scalar
113 LUCI_INTERPRETER_CHECK(Tensor::num_elements(kernel.input3()) == 1);
114 }
115
116 // Check shapes
117 const int32_t *paddings_data =
118 kernels::getTensorData<int32_t>(runtime_graph->getConstDataByTensor(kernel.input2()));
119 for (int i = 0; i < Tensor::num_dims(kernel.output()); i++)
120 {
121 int output_dim = Tensor::dim(kernel.output(), i);
122 int expected_dim =
123 Tensor::dim(kernel.input1(), i) + paddings_data[i * 2] + paddings_data[i * 2 + 1];
124 LUCI_INTERPRETER_CHECK(output_dim == expected_dim);
125 }
126}

References circle_eval_diff::TensorShape::dim(), luci_interpreter::RuntimeGraph::getConstDataByTensor(), and LUCI_INTERPRETER_CHECK.

Referenced by configure_kernel_CirclePad(), and configure_kernel_CirclePadV2().

◆ configure_kernel_CirclePadV2()

void luci_interpreter::configure_kernel_CirclePadV2 ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 22 of file PadV2.cpp.

23{
24 configure_kernel_CirclePadCommon(cur_op, runtime_graph);
25}

References configure_kernel_CirclePadCommon().

◆ configure_kernel_CirclePool2DCommon()

void luci_interpreter::configure_kernel_CirclePool2DCommon ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)
inline

Definition at line 27 of file Pool2DCommon.h.

29{
30 const kernels::SISOKernel siso_kernel(cur_op, runtime_graph);
31
32 LUCI_INTERPRETER_CHECK(Tensor::element_type(siso_kernel.input()) ==
33 Tensor::element_type(siso_kernel.output()));
34 LUCI_INTERPRETER_CHECK(Tensor::num_dims(siso_kernel.input()) == 4);
35 LUCI_INTERPRETER_CHECK(Tensor::num_dims(siso_kernel.input()) ==
36 Tensor::num_dims(siso_kernel.output()));
37
38#ifndef DIS_QUANT
39 if (Tensor::element_type(siso_kernel.input()) == DataType::U8)
40 {
42 std::abs(Tensor::scale(siso_kernel.output()) - Tensor::scale(siso_kernel.input())) <= 1.0e-6);
43 LUCI_INTERPRETER_CHECK(Tensor::zero_point(siso_kernel.output()) ==
44 Tensor::zero_point(siso_kernel.input()));
45 }
46 else if (Tensor::element_type(siso_kernel.input()) == DataType::S16)
47 {
49 std::abs(Tensor::scale(siso_kernel.output()) - Tensor::scale(siso_kernel.input())) <= 1.0e-6);
50 LUCI_INTERPRETER_CHECK(Tensor::zero_point(siso_kernel.input()) == 0 &&
51 Tensor::zero_point(siso_kernel.output()) == 0);
52 }
53#endif // DIS_QUANT
54}

References luci_interpreter::kernels::SISOKernel::input(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::SISOKernel::output().

Referenced by configure_kernel_CircleAveragePool2D(), configure_kernel_CircleL2Pool2D(), and configure_kernel_CircleMaxPool2D().

◆ configure_kernel_CirclePRelu()

void luci_interpreter::configure_kernel_CirclePRelu ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 26 of file PRelu.cpp.

27{
28 kernels::TISOKernel kernel(cur_op, runtime_graph);
29
30 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
31 Tensor::element_type(kernel.output()));
32 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
33 Tensor::element_type(kernel.input2()));
34
35 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input1()) == Tensor::num_dims(kernel.output()));
36 LUCI_INTERPRETER_CHECK(Tensor::num_elements(kernel.input1()) ==
37 Tensor::num_elements(kernel.output()));
38}

References luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::TISOKernel::output().

◆ configure_kernel_CircleQuantize()

void luci_interpreter::configure_kernel_CircleQuantize ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 26 of file Quantize.cpp.

28{
29#ifndef DIS_QUANT
30 kernels::SISOKernel kernel(cur_op, runtime_graph);
31
32 LUCI_INTERPRETER_CHECK(Tensor::num_elements(kernel.input()) ==
33 Tensor::num_elements(kernel.output()));
34 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input()) == Tensor::num_dims(kernel.output()));
35 LUCI_INTERPRETER_CHECK(!Tensor::scales(kernel.output()).empty());
36 LUCI_INTERPRETER_CHECK(!Tensor::zero_points(kernel.output()).empty());
37#else
38 assert(false && "Remove DIS_QUANT flag");
39#endif // DIS_QUANT
40}

References luci_interpreter::kernels::SISOKernel::input(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::SISOKernel::output().

◆ configure_kernel_CircleReduceCommon()

void luci_interpreter::configure_kernel_CircleReduceCommon ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 51 of file ReduceCommon.cpp.

53{
54 kernels::TISOKernel kernel(cur_op, runtime_graph);
55
56 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) == DataType::S32 or
57 Tensor::element_type(kernel.input1()) == DataType::FLOAT32 or
58 Tensor::element_type(kernel.input1()) == DataType::S64);
59 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input2()) == DataType::S32);
60}

References luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), and LUCI_INTERPRETER_CHECK.

◆ configure_kernel_CircleReduceMax()

void luci_interpreter::configure_kernel_CircleReduceMax ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 51 of file ReduceMax.cpp.

53{
54 kernels::TISOKernel kernel(cur_op, runtime_graph);
55
56 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
57 Tensor::element_type(kernel.output()));
58 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input1()) == Tensor::num_dims(kernel.output()));
59 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input2()) == DataType::S32);
60
61 const int32_t axis_value =
62 kernels::getTensorData<int>(runtime_graph->getConstDataByTensor(kernel.input2()))[0];
63 LUCI_INTERPRETER_CHECK(axis_value >= 0);
64}

References luci_interpreter::RuntimeGraph::getConstDataByTensor(), luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::TISOKernel::output().

◆ configure_kernel_CircleRelu()

void luci_interpreter::configure_kernel_CircleRelu ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 26 of file Relu.cpp.

27{
28 kernels::SISOKernel kernel(cur_op, runtime_graph);
29
30 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input()) ==
31 Tensor::element_type(kernel.output()));
32 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input()) == Tensor::num_dims(kernel.output()));
33 LUCI_INTERPRETER_CHECK(Tensor::num_elements(kernel.input()) ==
34 Tensor::num_elements(kernel.output()));
35}

References luci_interpreter::kernels::SISOKernel::input(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::SISOKernel::output().

◆ configure_kernel_CircleRelu6()

void luci_interpreter::configure_kernel_CircleRelu6 ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 26 of file Relu6.cpp.

27{
28 kernels::SISOKernel kernel(cur_op, runtime_graph);
29
30 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input()) ==
31 Tensor::element_type(kernel.output()));
32 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input()) == Tensor::num_dims(kernel.output()));
33 LUCI_INTERPRETER_CHECK(Tensor::num_elements(kernel.input()) ==
34 Tensor::num_elements(kernel.output()));
35}

References luci_interpreter::kernels::SISOKernel::input(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::SISOKernel::output().

◆ configure_kernel_CircleReshape()

void luci_interpreter::configure_kernel_CircleReshape ( const circle::Operator *  ,
BaseRuntimeGraph  
)

Definition at line 27 of file Reshape.cpp.

28{
29 // Do nothing
30}

◆ configure_kernel_CircleResizeBilinear()

void luci_interpreter::configure_kernel_CircleResizeBilinear ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 44 of file ResizeBilinear.cpp.

46{
47 // Check of the size of input. Should be 2
48 assert(cur_op->inputs()->size() == 2);
49 const auto input_index = cur_op->inputs()->operator[](0);
50 const auto size_index = cur_op->inputs()->operator[](1);
51 const auto output_index = cur_op->outputs()->operator[](0);
52
53 assert(input_index != -1);
54 assert(size_index != -1);
55 assert(output_index != -1);
56 // Get tensors
57 const auto input = runtime_graph->getCircleTensorByIndex(input_index);
58 const auto size = runtime_graph->getCircleTensorByIndex(size_index);
59 const auto output = runtime_graph->getCircleTensorByIndex(output_index);
60 // Check of the Input shape
61 assert(kernels::getTensorShape(input).dimensionsCount() == 4);
62 // Check of the Const input size shape
63 assert(kernels::getTensorShape(size).dimensionsCount() == 1);
64 assert(Tensor::element_type(size) == DataType::S32);
65 assert(kernels::getTensorShape(size).dims(0) == 2);
66
67 const auto *params = cur_op->builtin_options_as_ResizeBilinearOptions();
68 if (params->half_pixel_centers() && params->align_corners())
69 assert(false && "If half_pixel_centers is True, align_corners must be False.");
70}

References luci_interpreter::RuntimeGraph::getCircleTensorByIndex(), luci_interpreter::kernels::getTensorShape(), and size.

◆ configure_kernel_CircleResizeNearestNeighbor()

void luci_interpreter::configure_kernel_CircleResizeNearestNeighbor ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 27 of file ResizeNearestNeighbor.cpp.

29{
30 // Check of the size of input. Should be 2
31 LUCI_INTERPRETER_CHECK(cur_op->inputs()->size() == 2);
32 const kernels::TISOKernel tiso_kernel(cur_op, runtime_graph);
33
34 LUCI_INTERPRETER_CHECK(Tensor::element_type(tiso_kernel.input1()) ==
35 Tensor::element_type(tiso_kernel.output()));
36 LUCI_INTERPRETER_CHECK(Tensor::num_dims(tiso_kernel.input1()) == 4);
37 LUCI_INTERPRETER_CHECK(Tensor::num_dims(tiso_kernel.input2()) == 1);
38 LUCI_INTERPRETER_CHECK(Tensor::element_type(tiso_kernel.input2()) == DataType::S32);
39 LUCI_INTERPRETER_CHECK(Tensor::dim(tiso_kernel.input2(), 0) == 2);
40
41 const auto *params = cur_op->builtin_options_as_ResizeNearestNeighborOptions();
42 if (params->half_pixel_centers() && params->align_corners())
43 assert(false && "If half_pixel_centers is True, align_corners must be False.");
44}

References circle_eval_diff::TensorShape::dim(), luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::TISOKernel::output().

◆ configure_kernel_CircleRound()

void luci_interpreter::configure_kernel_CircleRound ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 26 of file Round.cpp.

27{
28 kernels::SISOKernel kernel(cur_op, runtime_graph);
29
30 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input()) ==
31 Tensor::element_type(kernel.output()));
32 LUCI_INTERPRETER_CHECK(Tensor::num_elements(kernel.input()) ==
33 Tensor::num_elements(kernel.output()));
34 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input()) == Tensor::num_dims(kernel.output()));
35}

References luci_interpreter::kernels::SISOKernel::input(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::SISOKernel::output().

◆ configure_kernel_CircleRsqrt()

void luci_interpreter::configure_kernel_CircleRsqrt ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 26 of file Rsqrt.cpp.

27{
28 kernels::SISOKernel kernel(cur_op, runtime_graph);
29
30 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input()) ==
31 Tensor::element_type(kernel.output()));
32 LUCI_INTERPRETER_CHECK(Tensor::num_elements(kernel.input()) ==
33 Tensor::num_elements(kernel.output()));
34 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input()) == Tensor::num_dims(kernel.output()));
35}

References luci_interpreter::kernels::SISOKernel::input(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::SISOKernel::output().

◆ configure_kernel_CircleSelectV2()

void luci_interpreter::configure_kernel_CircleSelectV2 ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 62 of file SelectV2.cpp.

64{
65 const auto input_cond_index = cur_op->inputs()->operator[](kInputTensorCondition);
66 const auto input_x_index = cur_op->inputs()->operator[](kInputTensorX);
67 const auto input_y_index = cur_op->inputs()->operator[](kInputTensorY);
68 const auto output_index = cur_op->outputs()->operator[](kOutputTensor);
69
70 assert(input_cond_index != -1);
71 assert(input_x_index != -1);
72 assert(input_y_index != -1);
73 assert(output_index != -1);
74
75 const auto input_cond = runtime_graph->getCircleTensorByIndex(input_cond_index);
76 const auto input_x = runtime_graph->getCircleTensorByIndex(input_x_index);
77 const auto input_y = runtime_graph->getCircleTensorByIndex(input_y_index);
78 const auto output = runtime_graph->getCircleTensorByIndex(output_index);
79
80 assert(input_cond != nullptr);
81 assert(input_x != nullptr);
82 assert(input_y != nullptr);
83
84 // Input condition should be bool
85 LUCI_INTERPRETER_CHECK(Tensor::element_type(input_cond) == DataType::BOOL);
86
87 // X, Y and Output should be the same type
88 LUCI_INTERPRETER_CHECK(Tensor::element_type(input_x) == Tensor::element_type(input_y));
89 LUCI_INTERPRETER_CHECK(Tensor::element_type(input_x) == Tensor::element_type(output));
90
91 bool possible_mixed_scaler =
92 Tensor::num_elements(input_cond) == 1 && Tensor::num_elements(input_x) == 1 &&
93 Tensor::num_elements(input_y) == 1 && Tensor::num_elements(output) == 1;
94
95 bool same_shape = Tensor::num_elements(input_cond) == Tensor::num_elements(input_x) &&
96 Tensor::num_elements(input_x) == Tensor::num_elements(input_y);
97
98 // Broadcast not supported now
99 if (not same_shape and not possible_mixed_scaler)
100 {
102 }
103}

References luci_interpreter::RuntimeGraph::getCircleTensorByIndex(), and LUCI_INTERPRETER_CHECK.

◆ configure_kernel_CircleShape()

void luci_interpreter::configure_kernel_CircleShape ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 23 of file Shape.cpp.

24{
25 kernels::SISOKernel kernel(cur_op, runtime_graph);
26 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.output()) == DataType::S32);
27}

References LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::SISOKernel::output().

◆ configure_kernel_CircleSin()

void luci_interpreter::configure_kernel_CircleSin ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 26 of file Sin.cpp.

27{
28 kernels::SISOKernel kernel(cur_op, runtime_graph);
29
30 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input()) ==
31 Tensor::element_type(kernel.output()));
32 LUCI_INTERPRETER_CHECK(Tensor::num_elements(kernel.input()) ==
33 Tensor::num_elements(kernel.output()));
34 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input()) == Tensor::num_dims(kernel.output()));
35}

References luci_interpreter::kernels::SISOKernel::input(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::SISOKernel::output().

◆ configure_kernel_CircleSlice()

void luci_interpreter::configure_kernel_CircleSlice ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 94 of file Slice.cpp.

95{
96 kernels::MISOKernel kernel(cur_op, runtime_graph);
97
98 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
99 Tensor::element_type(kernel.output()));
100 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input2()) == DataType::S32 ||
101 Tensor::element_type(kernel.input2()) == DataType::S64);
102 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input3()) == DataType::S32 ||
103 Tensor::element_type(kernel.input3()) == DataType::S64);
104 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input2()) == 1);
105 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input3()) == 1);
106 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input1()) <= max_dim);
107}

References luci_interpreter::kernels::MISOKernel::input1(), luci_interpreter::kernels::MISOKernel::input2(), luci_interpreter::kernels::MISOKernel::input3(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::MISOKernel::output().

◆ configure_kernel_CircleSoftmax()

void luci_interpreter::configure_kernel_CircleSoftmax ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 123 of file Softmax.cpp.

124{
125 kernels::SISOKernel kernel(cur_op, runtime_graph);
126
127 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input()) ==
128 Tensor::element_type(kernel.output()));
129 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input()) >= 1);
130
131#ifndef DIS_QUANT
132 if (Tensor::element_type(kernel.input()) == DataType::U8 ||
133 Tensor::element_type(kernel.input()) == DataType::S8)
134 {
135 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input()) == DataType::S8 ||
136 Tensor::zero_point(kernel.output()) == 0);
137 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input()) == DataType::U8 ||
138 Tensor::zero_point(kernel.output()) ==
139 std::numeric_limits<int8_t>::min());
140 }
141#endif
142}

References luci_interpreter::kernels::SISOKernel::input(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::SISOKernel::output().

◆ configure_kernel_CircleSpaceToBatchND()

void luci_interpreter::configure_kernel_CircleSpaceToBatchND ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 27 of file SpaceToBatchND.cpp.

29{
30 kernels::MISOKernel kernel(cur_op, runtime_graph);
31
32 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
33 Tensor::element_type(kernel.output()));
34 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input2()) == DataType::S32);
35 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input3()) == DataType::S32);
36 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.output()) >= 3);
37 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input1()) >= 3);
38 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.output()) <= 4);
39 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input1()) <= 4);
40}

References luci_interpreter::kernels::MISOKernel::input1(), luci_interpreter::kernels::MISOKernel::input2(), luci_interpreter::kernels::MISOKernel::input3(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::MISOKernel::output().

◆ configure_kernel_CircleSpaceToDepth()

void luci_interpreter::configure_kernel_CircleSpaceToDepth ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 26 of file SpaceToDepth.cpp.

28{
29 kernels::SISOKernel kernel(cur_op, runtime_graph);
30
31 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input()) ==
32 Tensor::element_type(kernel.output()));
33
34 const auto *options = cur_op->builtin_options_as_SpaceToDepthOptions();
35
36 const int32_t block_size = options->block_size();
37 LUCI_INTERPRETER_CHECK(block_size > 0);
38
39 constexpr int kHeightRank = 1;
40 constexpr int kWidthRank = 2;
41 constexpr int kDepthRank = 3;
42
43 const int input_height = Tensor::dim(kernel.input(), kHeightRank);
44 const int input_width = Tensor::dim(kernel.input(), kWidthRank);
45 int output_height = input_height / block_size;
46 int output_width = input_width / block_size;
47
48 LUCI_INTERPRETER_CHECK(input_height == output_height * block_size);
49 LUCI_INTERPRETER_CHECK(input_width == output_width * block_size);
50}

References circle_eval_diff::TensorShape::dim(), luci_interpreter::kernels::SISOKernel::input(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::SISOKernel::output().

◆ configure_kernel_CircleSplit()

void luci_interpreter::configure_kernel_CircleSplit ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 24 of file Split.cpp.

25{
26 const auto input_index = cur_op->inputs()->operator[](0);
27 const auto axis_index = cur_op->inputs()->operator[](1);
28
29 LUCI_INTERPRETER_CHECK(input_index != -1);
30 LUCI_INTERPRETER_CHECK(axis_index != -1);
31
32 const auto input = runtime_graph->getCircleTensorByIndex(input_index);
33 const auto axis = runtime_graph->getCircleTensorByIndex(axis_index);
34
35 LUCI_INTERPRETER_CHECK(input != nullptr);
36 LUCI_INTERPRETER_CHECK(axis != nullptr);
37}

References luci_interpreter::RuntimeGraph::getCircleTensorByIndex(), and LUCI_INTERPRETER_CHECK.

◆ configure_kernel_CircleSplitV()

void luci_interpreter::configure_kernel_CircleSplitV ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 25 of file SplitV.cpp.

26{
27 const auto axis_index = cur_op->inputs()->operator[](2);
28 LUCI_INTERPRETER_CHECK(axis_index != -1);
29
30 const auto axis = runtime_graph->getCircleTensorByIndex(axis_index);
31 LUCI_INTERPRETER_CHECK(axis != nullptr);
32
33 // Dynamic output tensors are needed if axis tensor is not constant
34 // Now doesn't support dynamic shapes for SplitV
35 LUCI_INTERPRETER_CHECK(runtime_graph->getConstDataByTensor(axis) != nullptr);
36}

References luci_interpreter::RuntimeGraph::getCircleTensorByIndex(), luci_interpreter::RuntimeGraph::getConstDataByTensor(), and LUCI_INTERPRETER_CHECK.

◆ configure_kernel_CircleSqrt()

void luci_interpreter::configure_kernel_CircleSqrt ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 26 of file Sqrt.cpp.

27{
28 kernels::SISOKernel kernel(cur_op, runtime_graph);
29
30 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input()) ==
31 Tensor::element_type(kernel.output()));
32 LUCI_INTERPRETER_CHECK(Tensor::num_elements(kernel.input()) ==
33 Tensor::num_elements(kernel.output()));
34 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input()) == Tensor::num_dims(kernel.output()));
35}

References luci_interpreter::kernels::SISOKernel::input(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::SISOKernel::output().

◆ configure_kernel_CircleSquare()

void luci_interpreter::configure_kernel_CircleSquare ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 24 of file Square.cpp.

25{
26 kernels::SISOKernel kernel(cur_op, runtime_graph);
27
28 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input()) ==
29 Tensor::element_type(kernel.output()));
30
31 // check that input and output dimensions are equal
32 int N = Tensor::num_dims(kernel.input());
33 LUCI_INTERPRETER_CHECK(N == Tensor::num_dims(kernel.output()));
34
35 // check that sizes of all dimensions are equal
36 for (int i = 0; i < N; ++i)
37 {
38 LUCI_INTERPRETER_CHECK(kernels::getTensorShape(kernel.input()).dims(i) ==
39 kernels::getTensorShape(kernel.output()).dims(i));
40 }
41}

References luci_interpreter::kernels::getTensorShape(), luci_interpreter::kernels::SISOKernel::input(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::SISOKernel::output().

◆ configure_kernel_CircleSquaredDifference()

void luci_interpreter::configure_kernel_CircleSquaredDifference ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 27 of file SquaredDifference.cpp.

29{
30 kernels::TISOKernel kernel(cur_op, runtime_graph);
31
32 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
33 Tensor::element_type(kernel.output()));
34 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
35 Tensor::element_type(kernel.input2()));
36 LUCI_INTERPRETER_CHECK(Tensor::num_elements(kernel.input1()) ==
37 Tensor::num_elements(kernel.output()));
38 LUCI_INTERPRETER_CHECK(Tensor::num_elements(kernel.input1()) ==
39 Tensor::num_elements(kernel.input2()));
40 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input1()) == Tensor::num_dims(kernel.output()));
41}

References luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::TISOKernel::output().

◆ configure_kernel_CircleSqueeze()

void luci_interpreter::configure_kernel_CircleSqueeze ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 26 of file Squeeze.cpp.

27{
28 kernels::SISOKernel kernel(cur_op, runtime_graph);
29
30 assert(cur_op->inputs()->size() == 1);
31
32 const circle::Tensor *input = kernel.input();
33 const circle::Tensor *output = kernel.output();
34
35 assert(Tensor::num_elements(input) == Tensor::num_elements(output));
36
37 const uint8_t *input_data = runtime_graph->getDataByTensor(input);
38 uint8_t *output_data = runtime_graph->getDataByTensor(output);
39
40 int input_num_dims = kernels::getTensorShape(input).dimensionsCount();
41
42 // Get parameters
43 const circle::SqueezeOptions *op_params = cur_op->builtin_options_as_SqueezeOptions();
44
45 // Verification of the Squeeze parameters
46 int num_squeeze_dims = op_params->squeeze_dims()->size();
47 assert(input_num_dims <= 8);
48 bool should_squeeze[8] = {false};
49 int num_squeezed_dims = 0;
50 if (num_squeeze_dims == 0)
51 {
52 for (int idx = 0; idx < input_num_dims; ++idx)
53 {
54
55 if (kernels::getTensorShape(input).dims(idx) == 1)
56 {
57 should_squeeze[idx] = true;
58 ++num_squeezed_dims;
59 }
60 }
61 }
62 else
63 {
64 for (int idx = 0; idx < num_squeeze_dims; ++idx)
65 {
66 int current = (*op_params->squeeze_dims())[idx] < 0
67 ? (*op_params->squeeze_dims())[idx] + input_num_dims
68 : (*op_params->squeeze_dims())[idx];
69 assert(current >= 0 && current < input_num_dims &&
70 kernels::getTensorShape(input).dims(current) == 1);
71 if (!should_squeeze[current])
72 ++num_squeezed_dims;
73 should_squeeze[current] = true;
74 }
75 }
76}
uint8_t * getDataByTensor(const circle::Tensor *raw_tensor)

References luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorShape(), luci_interpreter::kernels::SISOKernel::input(), and luci_interpreter::kernels::SISOKernel::output().

◆ configure_kernel_CircleStridedSlice()

void luci_interpreter::configure_kernel_CircleStridedSlice ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 55 of file StridedSlice.cpp.

57{
58 kernels::MISOKernel miso_kernel(cur_op, runtime_graph);
59
60 const circle::Tensor *input = miso_kernel.input1();
61 const circle::Tensor *begin = miso_kernel.input2();
62 const circle::Tensor *end = miso_kernel.input3();
63 const circle::Tensor *strides = miso_kernel.input4();
64
65 LUCI_INTERPRETER_CHECK(strides != nullptr);
66
67 const circle::Tensor *output = miso_kernel.output();
68
69 LUCI_INTERPRETER_CHECK(Tensor::element_type(begin) == DataType::S32);
70 LUCI_INTERPRETER_CHECK(Tensor::element_type(end) == DataType::S32);
71 LUCI_INTERPRETER_CHECK(Tensor::element_type(strides) == DataType::S32);
72 LUCI_INTERPRETER_CHECK(Tensor::element_type(input) == Tensor::element_type(output));
73}

References begin, luci_interpreter::kernels::MISOKernel::input1(), luci_interpreter::kernels::MISOKernel::input2(), luci_interpreter::kernels::MISOKernel::input3(), luci_interpreter::kernels::MISOKernel::input4(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::MISOKernel::output().

◆ configure_kernel_CircleSub()

void luci_interpreter::configure_kernel_CircleSub ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 27 of file Sub.cpp.

28{
29 kernels::TISOKernel kernel(cur_op, runtime_graph);
30
31 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
32 Tensor::element_type(kernel.input2()));
33 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
34 Tensor::element_type(kernel.input2()));
35#ifndef DIS_QUANT
36 if (Tensor::element_type(kernel.input1()) == DataType::S16)
37 {
38 LUCI_INTERPRETER_CHECK(Tensor::zero_points(kernel.input1()).size() == 1 &&
39 Tensor::zero_points(kernel.input2()).size() == 1);
40 LUCI_INTERPRETER_CHECK(Tensor::zero_point(kernel.input1()) == 0 &&
41 Tensor::zero_point(kernel.input2()) == 0 &&
42 Tensor::zero_point(kernel.output()) == 0);
43 }
44#endif // DIS_QUANT
45}

References luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::TISOKernel::output().

◆ configure_kernel_CircleSum()

void luci_interpreter::configure_kernel_CircleSum ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 51 of file Sum.cpp.

52{
53 kernels::TISOKernel kernel(cur_op, runtime_graph);
54
55 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
56 Tensor::element_type(kernel.output()));
57 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input2()) == DataType::S32);
58
59 const int32_t axis_value =
60 kernels::getTensorData<int>(runtime_graph->getConstDataByTensor(kernel.input2()))[0];
61 LUCI_INTERPRETER_CHECK(axis_value >= 0);
62}

References luci_interpreter::RuntimeGraph::getConstDataByTensor(), luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::TISOKernel::output().

◆ configure_kernel_CircleSVDF()

void luci_interpreter::configure_kernel_CircleSVDF ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 37 of file SVDF.cpp.

38{
39 // Validate Tensor Inputs (dtype depends on quantization):
40 // [0] = Input, {2, batch_size, input_size}
41 // [1] = Weights Feature, {2, num_filters, input_size}
42 // [2] = Weights Time, {2, num_filters, memory_size}
43 // [3] = Bias (optional), {1, num_units}
44 // [4] = Activation State (variable),
45 // {2, batch_size, memory_size * num_filters}
46 const auto input_index = cur_op->inputs()->operator[](kSvdfInputTensor);
47 const auto weights_feature_index = cur_op->inputs()->operator[](kSvdfWeightsFeatureTensor);
48 const auto weights_time_index = cur_op->inputs()->operator[](kSvdfWeightsTimeTensor);
49 const auto bias_index = cur_op->inputs()->operator[](kSvdfBiasTensor);
50 const auto activation_state_index = cur_op->inputs()->operator[](kSvdfInputActivationStateTensor);
51 const auto output_index = cur_op->outputs()->operator[](kSvdfOutputTensor);
52
53 assert(input_index != -1);
54 assert(weights_feature_index != -1);
55 assert(weights_time_index != -1);
56 assert(activation_state_index != -1);
57 assert(output_index != -1);
58
59 const auto input = runtime_graph->getCircleTensorByIndex(input_index);
60 const auto weights_feature = runtime_graph->getCircleTensorByIndex(weights_feature_index);
61 const auto weights_time = runtime_graph->getCircleTensorByIndex(weights_time_index);
62 const auto bias = runtime_graph->getCircleTensorByIndex(bias_index);
63 const auto activation_state = runtime_graph->getCircleTensorByIndex(activation_state_index);
64 const auto output = runtime_graph->getCircleTensorByIndex(output_index);
65
66 assert(input != nullptr);
67 assert(weights_feature != nullptr);
68 assert(weights_time != nullptr);
69 assert(activation_state != nullptr);
70 assert(output != nullptr);
71
72 const auto *options = cur_op->builtin_options_as_SVDFOptions();
73
74 // Define input constants based on input tensor definition above:
75 const int rank = options->rank();
76 const int input_size = Tensor::dim(input, 1);
77 const int batch_size = Tensor::dim(input, 0);
78 const int num_filters = Tensor::dim(weights_feature, 0);
79 LUCI_INTERPRETER_CHECK(num_filters % rank == 0);
80
81 const int num_units = num_filters / rank;
82 const int memory_size = Tensor::dim(weights_time, 1);
83
84 LUCI_INTERPRETER_CHECK(Tensor::element_type(input) == DataType::FLOAT32 or
85 Tensor::element_type(input) == DataType::S8);
86 LUCI_INTERPRETER_CHECK(Tensor::num_dims(input) == 2);
87
88 // Validate Tensor Output:
89 // [0] = float/int8_t, {2, batch_size, num_units}
90 LUCI_INTERPRETER_CHECK(Tensor::num_dims(output) == 2);
91 LUCI_INTERPRETER_CHECK(Tensor::dim(output, 0) == batch_size);
92 LUCI_INTERPRETER_CHECK(Tensor::dim(output, 1) == num_units);
93
94 // Validate Weights Feature Input Tensor
95 LUCI_INTERPRETER_CHECK(Tensor::num_dims(weights_feature) == 2);
96 LUCI_INTERPRETER_CHECK(Tensor::dim(weights_feature, 1) == input_size);
97
98 // Validate Weights Time Input Tensor:
99 LUCI_INTERPRETER_CHECK(Tensor::num_dims(weights_time) == 2);
100 LUCI_INTERPRETER_CHECK(Tensor::dim(weights_time, 0) == num_filters);
101 LUCI_INTERPRETER_CHECK(Tensor::dim(weights_time, 1) == memory_size);
102
103 // Validate Optional Bias Input Tensor:
104 if (bias != nullptr)
105 {
106 LUCI_INTERPRETER_CHECK(Tensor::dim(bias, 0) == num_units);
107 }
108
109 // Validate Activation State Input Tensor:
110 LUCI_INTERPRETER_CHECK(Tensor::num_dims(activation_state) == 2);
111 LUCI_INTERPRETER_CHECK(Tensor::dim(activation_state, 0) == batch_size);
112 LUCI_INTERPRETER_CHECK(Tensor::dim(activation_state, 1) == memory_size * num_filters);
113
114 if (Tensor::element_type(input) == DataType::FLOAT32)
115 {
116 LUCI_INTERPRETER_CHECK(Tensor::element_type(weights_feature) == DataType::FLOAT32);
117 LUCI_INTERPRETER_CHECK(Tensor::element_type(weights_time) == DataType::FLOAT32);
118 LUCI_INTERPRETER_CHECK(Tensor::element_type(activation_state) == DataType::FLOAT32);
119 if (bias)
120 LUCI_INTERPRETER_CHECK(Tensor::element_type(bias) == DataType::FLOAT32);
121 LUCI_INTERPRETER_CHECK(Tensor::element_type(output) == DataType::FLOAT32);
122 }
123}

References circle_eval_diff::TensorShape::dim(), luci_interpreter::RuntimeGraph::getCircleTensorByIndex(), and LUCI_INTERPRETER_CHECK.

◆ configure_kernel_CircleTanh()

void luci_interpreter::configure_kernel_CircleTanh ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 148 of file Tanh.cpp.

149{
150 kernels::SISOKernel kernel(cur_op, runtime_graph);
151
152 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input()) ==
153 Tensor::element_type(kernel.output()));
154}

References luci_interpreter::kernels::SISOKernel::input(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::SISOKernel::output().

◆ configure_kernel_CircleTranspose()

void luci_interpreter::configure_kernel_CircleTranspose ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 26 of file Transpose.cpp.

28{
29 kernels::TISOKernel kernel(cur_op, runtime_graph);
30
31 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input2()) == DataType::S32);
32
33 const int32_t dims = Tensor::num_dims(kernel.input1());
34 const int32_t *perm_data =
35 kernels::getTensorData<int32_t>(runtime_graph->getConstDataByTensor(kernel.input2()));
36
37 // Ensure validity of the permutations tensor as a 1D tensor
38 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input2()) == 1);
39 LUCI_INTERPRETER_CHECK(Tensor::dim(kernel.input2(), 0) == dims);
40
41 for (int idx = 0; idx < dims; ++idx)
42 LUCI_INTERPRETER_CHECK(perm_data[idx] >= 0 and perm_data[idx] < dims);
43}

References circle_eval_diff::TensorShape::dim(), luci_interpreter::RuntimeGraph::getConstDataByTensor(), luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), and LUCI_INTERPRETER_CHECK.

◆ configure_kernel_CircleTransposeConv()

void luci_interpreter::configure_kernel_CircleTransposeConv ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 107 of file TransposeConv.cpp.

109{
110 const auto input_index = cur_op->inputs()->operator[](kInputTensor);
111 const auto filter_index = cur_op->inputs()->operator[](kFilterTensor);
112 const auto output_index = cur_op->outputs()->operator[](kOutputTensor);
113
114 assert(input_index != -1);
115 assert(filter_index != -1);
116 assert(output_index != -1);
117
118 const auto input = runtime_graph->getCircleTensorByIndex(input_index);
119 const auto filter = runtime_graph->getCircleTensorByIndex(filter_index);
120 const auto output = runtime_graph->getCircleTensorByIndex(output_index);
121
122 assert(input != nullptr);
123 assert(filter != nullptr);
124
125 auto filter_data = runtime_graph->getConstDataByTensor(filter);
126
127 assert(filter_data != nullptr);
128
129 LUCI_INTERPRETER_CHECK(Tensor::element_type(output) == Tensor::element_type(input));
130 LUCI_INTERPRETER_CHECK(Tensor::element_type(filter) == Tensor::element_type(input));
131
132 LUCI_INTERPRETER_CHECK(Tensor::num_dims(input) == 4 && Tensor::num_dims(filter) == 4);
133}

References luci_interpreter::RuntimeGraph::getCircleTensorByIndex(), luci_interpreter::RuntimeGraph::getConstDataByTensor(), and LUCI_INTERPRETER_CHECK.

◆ configure_kernel_CircleUnidirectionalSequenceLSTM()

void luci_interpreter::configure_kernel_CircleUnidirectionalSequenceLSTM ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 392 of file UnidirectionalSequenceLSTM.cpp.

394{
395 lstm::LSTMStruct lstm_struct(cur_op, runtime_graph);
396
397 LUCI_INTERPRETER_CHECK(Tensor::element_type(lstm_struct.input()) == DataType::FLOAT32 or
398 Tensor::element_type(lstm_struct.input()) == DataType::S8);
399
400 lstm_struct.validateTensorTypes();
401
402 const bool time_major = lstm_struct.options->time_major();
403
404 validateTensorsSize(&lstm_struct, time_major);
405
406 // No peephole
407 for (int32_t i = 9; i < 12; ++i)
408 LUCI_INTERPRETER_CHECK(lstm_struct.get_internal_tensor(i) == nullptr);
409
410 // No projection
411 for (int32_t i = 16; i < 18; ++i)
412 LUCI_INTERPRETER_CHECK(lstm_struct.get_internal_tensor(i) == nullptr);
413
414 // No internal layer norm
415 for (int32_t i = 20; i < 24; ++i)
416 LUCI_INTERPRETER_CHECK(lstm_struct.get_internal_tensor(i) == nullptr);
417}

References luci_interpreter::lstm::LSTMStruct::get_internal_tensor(), luci_interpreter::lstm::LSTMStruct::input(), LUCI_INTERPRETER_CHECK, luci_interpreter::lstm::LSTMStruct::options, and luci_interpreter::lstm::LSTMStruct::validateTensorTypes().

◆ configure_kernel_CircleUnpack()

void luci_interpreter::configure_kernel_CircleUnpack ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 84 of file Unpack.cpp.

85{
86 const auto input_index = cur_op->inputs()->operator[](0);
87 const auto output_index = cur_op->outputs()->operator[](0);
88
89 assert(input_index != -1);
90 assert(output_index != -1);
91
92 const auto input = runtime_graph->getCircleTensorByIndex(input_index);
93 const auto output = runtime_graph->getCircleTensorByIndex(output_index);
94
95 assert(input != nullptr);
96 assert(output != nullptr);
97
98 const auto *options = cur_op->builtin_options_as_UnpackOptions();
99
100 LUCI_INTERPRETER_CHECK(cur_op->outputs()->size() == options->num());
101 LUCI_INTERPRETER_CHECK(Tensor::element_type(input) == Tensor::element_type(output));
102
103 for (int i = 0; i < Tensor::num_dims(input); ++i)
104 {
105 if (i == options->axis())
106 continue;
107
108 if (i < options->axis())
109 {
110 LUCI_INTERPRETER_CHECK(Tensor::dim(input, i) == Tensor::dim(output, i));
111 }
112 else
113 {
114 LUCI_INTERPRETER_CHECK(Tensor::dim(input, i) == Tensor::dim(output, i - 1));
115 }
116 }
117}

References circle_eval_diff::TensorShape::dim(), luci_interpreter::RuntimeGraph::getCircleTensorByIndex(), and LUCI_INTERPRETER_CHECK.

◆ configure_kernel_CircleWhile()

void luci_interpreter::configure_kernel_CircleWhile ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 26 of file While.cpp.

27{
28 auto *main_runtime_graph = runtime_graph;
29
30 auto *runtime_module = runtime_graph->getRuntimeModule();
31
32 const auto *options = cur_op->builtin_options_as_WhileOptions();
33 const auto body_subgraph_index = options->body_subgraph_index();
34 const auto cond_subgraph_index = options->cond_subgraph_index();
35
36 auto *cond_runtime_graph = runtime_module->getRuntimeGraphAt(cond_subgraph_index);
37 auto *body_runtime_graph = runtime_module->getRuntimeGraphAt(body_subgraph_index);
38
39 body_runtime_graph->selectOwnSubgraph();
40 const auto body_input_size = body_runtime_graph->getNumOfInputTensors();
41 const auto body_output_size = body_runtime_graph->getNumOfOutputTensors();
42 LUCI_INTERPRETER_CHECK(body_input_size == cur_op->inputs()->size());
43 LUCI_INTERPRETER_CHECK(body_output_size == cur_op->outputs()->size());
44 LUCI_INTERPRETER_CHECK(body_output_size == cur_op->inputs()->size());
45 body_runtime_graph->invalidate();
46 body_runtime_graph->configure(false);
47
48 cond_runtime_graph->selectOwnSubgraph();
49 const auto cond_input_size = cond_runtime_graph->getNumOfInputTensors();
50 const auto cond_output_size = cond_runtime_graph->getNumOfOutputTensors();
51 LUCI_INTERPRETER_CHECK(cond_input_size == cur_op->inputs()->size());
52 LUCI_INTERPRETER_CHECK(cond_output_size == 1);
53 const circle::Tensor *cond_output_tensor = cond_runtime_graph->getOutputTensorByIndex(0);
54 LUCI_INTERPRETER_CHECK(Tensor::element_type(cond_output_tensor) == DataType::BOOL);
55 cond_runtime_graph->invalidate();
56 cond_runtime_graph->configure(false);
57
58 main_runtime_graph->selectOwnSubgraph();
59}

References luci_interpreter::RuntimeGraph::getRuntimeModule(), and LUCI_INTERPRETER_CHECK.

◆ configure_kernel_CircleZerosLike()

void luci_interpreter::configure_kernel_CircleZerosLike ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 34 of file ZerosLike.cpp.

36{
37 kernels::SISOKernel kernel(cur_op, runtime_graph);
38
39 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input()) ==
40 Tensor::element_type(kernel.output()));
41 LUCI_INTERPRETER_CHECK(Tensor::num_elements(kernel.input()) ==
42 Tensor::num_elements(kernel.output()));
43 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input()) == Tensor::num_dims(kernel.output()));
44}

References luci_interpreter::kernels::SISOKernel::input(), LUCI_INTERPRETER_CHECK, and luci_interpreter::kernels::SISOKernel::output().

◆ createConv2DParams()

luci_interpreter_pal::ConvParams luci_interpreter::createConv2DParams ( const circle::Tensor *  input,
const circle::Tensor *  filter,
const circle::Tensor *  output,
const circle::Conv2DOptions *  options 
)

Definition at line 54 of file ConvolutionCommon.cpp.

58{
60
61 if (isSupportedQuantized(input, filter))
62 {
63#ifndef DIS_QUANT
64 const auto input_scale = static_cast<double>(Tensor::scale(input));
65 const auto filter_scale = static_cast<double>(Tensor::scale(filter));
66 const auto output_scale = static_cast<double>(Tensor::scale(output));
67
68 const double real_multiplier = input_scale * filter_scale / output_scale;
69 int32_t output_multiplier{};
70 int output_shift{};
71 kernels::quantizeMultiplier(real_multiplier, &output_multiplier, &output_shift);
72
73 params.output_multiplier = output_multiplier;
74 params.output_shift = output_shift;
75
76 int32_t activation_min{};
77 int32_t activation_max{};
78 kernels::calculateActivationRangeQuantized(luci_actfunc(options->fused_activation_function()),
79 output, &activation_min, &activation_max);
80
81 // The kernel expects input and filter zero points to be negated.
82 params.input_offset = -Tensor::zero_point(input); // Note the '-'.
83 params.weights_offset = -Tensor::zero_point(filter); // Note the '-'.
84 params.output_offset = Tensor::zero_point(output);
85 params.quantized_activation_min = activation_min;
86 params.quantized_activation_max = activation_max;
87#endif // DIS_QUANT
88 }
89 else if (isSupportedQuantizedPerChannel(input, filter))
90 {
91#ifndef DIS_QUANT
92 int32_t activation_min{};
93 int32_t activation_max{};
94 kernels::calculateActivationRangeQuantized(luci_actfunc(options->fused_activation_function()),
95 output, &activation_min, &activation_max);
96
97 const std::vector<double> effective_output_scale = kernels::getQuantizedConvolutionMultiplers(
98 Tensor::scale(input), Tensor::scales(filter), Tensor::scale(output));
99
100 size_t n = effective_output_scale.size();
101 params.per_channel_output_shift.resize(n);
102 params.per_channel_output_multiplier.resize(n);
103 for (size_t i = 0; i < n; ++i)
104 {
105 kernels::quantizeMultiplier(effective_output_scale[i],
106 &params.per_channel_output_multiplier[i],
107 &params.per_channel_output_shift[i]);
108
109 // The kernel expects input and filter zero points to be negated.
110 params.input_offset = -Tensor::zero_point(input); // Note the '-'.
111 params.weights_offset = -Tensor::zero_point(filter); // Note the '-'.
112 params.output_offset = Tensor::zero_point(output);
113 params.quantized_activation_min = activation_min;
114 params.quantized_activation_max = activation_max;
115 }
116#endif // DIS_QUANT
117 }
118 else if (Tensor::element_type(input) == DataType::FLOAT32 and
119 Tensor::element_type(filter) == DataType::FLOAT32)
120 {
121#ifndef DIS_FLOAT
122 float activation_min{};
123 float activation_max{};
124 kernels::calculateActivationRange(luci_actfunc(options->fused_activation_function()),
125 &activation_min, &activation_max);
126
127 params.float_activation_min = activation_min;
128 params.float_activation_max = activation_max;
129#endif // DIS_FLOAT
130 }
131 else
132 {
133 assert(false && "Not supported type");
134 }
135
136 const auto padding = options->padding();
137 const auto stride_height = options->stride_h();
138 const auto stride_width = options->stride_w();
139 const auto dilation_height_factor = options->dilation_h_factor();
140 const auto dilation_width_factor = options->dilation_h_factor();
141
142 params.padding_values.height =
143 computeConvPadding(input, filter, padding, stride_height, dilation_height_factor, 1);
144 params.padding_values.width =
145 computeConvPadding(input, filter, padding, stride_width, dilation_width_factor, 2);
146 params.stride_height = stride_height;
147 params.stride_width = stride_width;
148 params.dilation_height_factor = dilation_height_factor;
149 params.dilation_width_factor = dilation_width_factor;
150
151 return params;
152}
int32_t computeConvPadding(const circle::Tensor *input, const circle::Tensor *filter, circle::Padding padding_type, int32_t stride, int32_t dilation, int axis)

References luci_interpreter::kernels::calculateActivationRange(), luci_interpreter::kernels::calculateActivationRangeQuantized(), computeConvPadding(), luci_interpreter::kernels::getQuantizedConvolutionMultiplers(), luci::luci_actfunc(), and luci_interpreter::kernels::quantizeMultiplier().

◆ createPoolParams()

luci_interpreter_pal::PoolParams luci_interpreter::createPoolParams ( const circle::Operator *  cur_op,
const kernels::SISOKernel siso_kernel 
)
inline

Definition at line 56 of file Pool2DCommon.h.

58{
59 const auto input = siso_kernel.input();
60 const auto output = siso_kernel.output();
61
62 const auto *options = cur_op->builtin_options_as_Pool2DOptions();
63
64 const int32_t input_height = Tensor::dim(input, 1);
65 const int32_t input_width = Tensor::dim(input, 2);
66
67 const int32_t output_height = kernels::computeOutputSize(
68 luci_padding(options->padding()), input_height, options->filter_height(), options->stride_h());
69 const int32_t output_width = kernels::computeOutputSize(
70 luci_padding(options->padding()), input_width, options->filter_width(), options->stride_w());
71
72 const auto padding_height = kernels::computePadding(options->stride_h(), 1, input_height,
73 options->filter_height(), output_height);
74 const auto padding_width = kernels::computePadding(options->stride_w(), 1, input_width,
75 options->filter_width(), output_width);
76
77 const DataType input_type = Tensor::element_type(input);
78
79 float activation_min{};
80 float activation_max{};
81
82 int32_t quantized_activation_min{};
83 int32_t quantized_activation_max{};
84
85 if (input_type == DataType::S8 or input_type == DataType::S16)
86 {
87#ifndef DIS_QUANT
88 kernels::calculateActivationRangeQuantized(luci_actfunc(options->fused_activation_function()),
89 output, &quantized_activation_min,
90 &quantized_activation_max);
91#endif // DIS_QUANT
92 }
93 else if (input_type == DataType::FLOAT32)
94 {
95#ifndef DIS_FLOAT
96 kernels::calculateActivationRange(luci_actfunc(options->fused_activation_function()),
97 &activation_min, &activation_max);
98#endif // DIS_FLOAT
99 }
100 else
101 {
102 assert(false && "Not supported type");
103 }
104
106 params.padding_values.height = padding_height;
107 params.padding_values.width = padding_width;
108 params.stride_height = options->stride_h();
109 params.stride_width = options->stride_w();
110 params.filter_height = options->filter_height();
111 params.filter_width = options->filter_width();
112 params.float_activation_min = activation_min;
113 params.float_activation_max = activation_max;
114 params.quantized_activation_max = quantized_activation_max;
115 params.quantized_activation_min = quantized_activation_min;
116
117 return params;
118}
const circle::Tensor * output() const
Definition SISOKernel.h:47
const circle::Tensor * input() const
Definition SISOKernel.h:46

References luci_interpreter::kernels::calculateActivationRange(), luci_interpreter::kernels::calculateActivationRangeQuantized(), luci_interpreter::kernels::computeOutputSize(), luci_interpreter::kernels::computePadding(), circle_eval_diff::TensorShape::dim(), luci_interpreter_pal::PaddingValues::height, luci_interpreter::kernels::SISOKernel::input(), luci::luci_actfunc(), luci::luci_padding(), luci_interpreter::kernels::SISOKernel::output(), and luci_interpreter_pal::PoolParams::padding_values.

Referenced by execute_kernel_CircleAveragePool2D(), execute_kernel_CircleL2Pool2D(), and execute_kernel_CircleMaxPool2D().

◆ evalInteger()

void luci_interpreter::evalInteger ( const circle::Tensor *  input,
const circle::Tensor *  output,
BaseRuntimeGraph runtime_graph 
)

Definition at line 107 of file Tanh.cpp.

109{
110 int32_t input_zero_point = 0;
111 int32_t input_range_radius = 0;
112 int32_t input_multiplier = 0;
113 int input_left_shift = 0;
114
115 calculateArithmeticData(input, output, input_zero_point, input_range_radius, input_multiplier,
116 input_left_shift);
117
118 const auto *input_data = runtime_graph->getDataByTensor(input);
119 assert(input_data);
120
121 auto *output_data = runtime_graph->getDataByTensor(output);
122 assert(output_data);
123
124 const int flat_size = kernels::getTensorRuntimeShape(input, runtime_graph).flatSize();
125
126 const auto input_dtype = Tensor::element_type(input);
127 switch (input_dtype)
128 {
129 // TODO: enable it
130#if 0
131 case DataType::S8:
133 input_zero_point, input_range_radius, input_multiplier, input_left_shift,
134 flat_size, kernels::getTensorData<int8_t>(input_data), kernels::getTensorData<int8_t>(output_data));
135 break;
136#endif // 0
137 case DataType::S16:
138 luci_interpreter_pal::Tanh(input_multiplier, input_left_shift, flat_size,
139 kernels::getTensorData<int16_t>(input_data),
140 kernels::getTensorData<int16_t>(output_data));
141 break;
142 default:
143 assert(false && "Not support yet");
144 }
145}
void Tanh(const int flat_size, const float *input_data, float *output_data)
Definition PALTanh.h:26

References luci_interpreter::RuntimeShape::flatSize(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), and luci_interpreter_pal::Tanh().

Referenced by execute_kernel_CircleTanh().

◆ execute_kernel_CircleAbs()

void luci_interpreter::execute_kernel_CircleAbs ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 36 of file Abs.cpp.

37{
38 kernels::SISOKernel kernel(cur_op, runtime_graph);
39
40 const auto input = kernel.input();
41 const auto output = kernel.output();
42
43 bool is_inplace = runtime_graph->is_inplace_op(cur_op);
44
45 const uint8_t *input_data = runtime_graph->getDataByTensor(input);
46 uint8_t *output_data = runtime_graph->getDataByTensor(output);
47
48 if (is_inplace)
49 {
50 output_data = const_cast<uint8_t *>(input_data);
51 }
52
53 assert(input_data != nullptr);
54 assert(output_data != nullptr);
55
56 const int flat_size = kernels::getTensorRuntimeShape(input, runtime_graph).flatSize();
57
58 switch (Tensor::element_type(input))
59 {
60#ifndef DIS_FLOAT
61 case DataType::FLOAT32:
62 luci_interpreter_pal::Abs(flat_size, kernels::getTensorData<float>(input_data),
63 kernels::getTensorData<float>(output_data));
64 break;
65#endif // DIS_FLOAT
66 default:
67 assert(false && "Unsupported type.");
68 }
69
70 if (is_inplace)
71 {
72 runtime_graph->makeInplaceOperation(input, output);
73 }
74}
void makeInplaceOperation(const circle::Tensor *src_tensor, const circle::Tensor *dst_tensor)
bool is_inplace_op(const circle::Operator *op)
void Abs(const int flat_size, const float *input_data, float *output_data)
Definition PALAbs.h:25

References luci_interpreter_pal::Abs(), luci_interpreter::RuntimeShape::flatSize(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::SISOKernel::input(), luci_interpreter::RuntimeGraph::is_inplace_op(), luci_interpreter::RuntimeGraph::makeInplaceOperation(), and luci_interpreter::kernels::SISOKernel::output().

◆ execute_kernel_CircleAdd()

void luci_interpreter::execute_kernel_CircleAdd ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 117 of file Add.cpp.

118{
119 kernels::TISOKernel kernel(cur_op, runtime_graph);
120
121 const auto *options = cur_op->builtin_options_as_AddOptions();
122
123 luci_interpreter::RuntimeShape input_shape1 =
124 kernels::getTensorRuntimeShape(kernel.input1(), runtime_graph);
125 luci_interpreter::RuntimeShape input_shape2 =
126 kernels::getTensorRuntimeShape(kernel.input2(), runtime_graph);
127
128 bool is_inplace = runtime_graph->is_inplace_op(cur_op);
129
130 // TODO remove code duplication, introduce func
131#ifndef DIS_DYN_SHAPES
133 kernels::getTensorRuntimeShape(kernel.output(), runtime_graph);
134 // Dynamic shape case
135 if (not is_inplace and not(input_shape1 == output_shape) and not(input_shape2 == output_shape))
136 {
137 int32_t num_dims;
138
139 if (input_shape1.flatSize() > input_shape2.flatSize())
140 {
141 output_shape = input_shape1;
142 num_dims = input_shape1.dimensionsCount();
143 }
144 else
145 {
146 output_shape = input_shape2;
147 num_dims = input_shape2.dimensionsCount();
148 }
149
150 luci_interpreter::RuntimeShape dynamic_shape(num_dims);
151 int32_t data_size = 1;
152 for (int i = 0; i < num_dims; ++i)
153 {
154 dynamic_shape.setDim(i, output_shape.dims(i));
155 data_size *= output_shape.dims(i);
156 }
157 data_size *= size(Tensor::element_type(kernel.output()));
158
159 runtime_graph->addDynamicShapeTensor(kernel.output(), std::move(dynamic_shape));
160
161 if (data_size == 0)
162 {
163 runtime_graph->resetTensorData(nullptr, kernel.output());
164 return;
165 }
166 auto new_output_data = new uint8_t[data_size];
167 runtime_graph->resetTensorData(new_output_data, kernel.output());
168 }
169#endif // DIS_DYN_SHAPES
170
171 const auto type = Tensor::element_type(kernel.input1());
172 switch (type)
173 {
174#ifndef DIS_FLOAT
175 case DataType::FLOAT32:
176 {
177 auto tiso_func = luci_interpreter_pal::Add<float>;
178 auto broadcast_tiso_func = luci_interpreter_pal::BroadcastAdd4DSlow<float>;
179 if (is_inplace)
180 {
181 kernels::evalTISOInplaceKernel<float>(tiso_func, broadcast_tiso_func, &kernel, options,
182 std::move(input_shape1), std::move(input_shape2),
183 std::move(output_shape));
184 }
185 else
186 {
187 kernels::TISOData kernel_data = kernel.readData();
188 kernels::evalTISOKernel<float>(tiso_func, broadcast_tiso_func, &kernel, &kernel_data,
189 options, std::move(input_shape1), std::move(input_shape2),
190 std::move(output_shape));
191 }
192 }
193 break;
194#endif // DIS_FLOAT
195 case DataType::S64:
196 {
197 auto tiso_func = luci_interpreter_pal::Add<int64_t>;
198 auto broadcast_tiso_func = luci_interpreter_pal::BroadcastAdd4DSlow<int64_t>;
199 if (is_inplace)
200 {
201 kernels::evalTISOInplaceKernel<int64_t>(tiso_func, broadcast_tiso_func, &kernel, options,
202 std::move(input_shape1), std::move(input_shape2),
203 std::move(output_shape));
204 }
205 else
206 {
207 kernels::TISOData kernel_data = kernel.readData();
208 kernels::evalTISOKernel<int64_t>(tiso_func, broadcast_tiso_func, &kernel, &kernel_data,
209 options, std::move(input_shape1), std::move(input_shape2),
210 std::move(output_shape));
211 }
212 }
213 break;
214 case DataType::S32:
215 {
216 auto tiso_func = luci_interpreter_pal::Add<int32_t>;
217 auto broadcast_tiso_func = luci_interpreter_pal::BroadcastAdd4DSlow<int32_t>;
218 if (is_inplace)
219 {
220 kernels::evalTISOInplaceKernel<int32_t>(tiso_func, broadcast_tiso_func, &kernel, options,
221 std::move(input_shape1), std::move(input_shape2),
222 std::move(output_shape));
223 }
224 else
225 {
226 kernels::TISOData kernel_data = kernel.readData();
227 kernels::evalTISOKernel<int32_t>(tiso_func, broadcast_tiso_func, &kernel, &kernel_data,
228 options, std::move(input_shape1), std::move(input_shape2),
229 std::move(output_shape));
230 }
231 }
232 break;
233#ifndef DIS_QUANT
234 case DataType::S8:
235 case DataType::S16:
236 {
237 evalQuantized(kernel.input1(), kernel.input2(), kernel.output(), options, runtime_graph,
238 type);
239 }
240 break;
241#endif
242 default:
243 assert(false && "Unsupported type.");
244 }
245}
void addDynamicShapeTensor(const circle::Tensor *tensor, luci_interpreter::RuntimeShape &&shapes)
void resetTensorData(uint8_t *new_data, const circle::Tensor *tensor)
int32_t dimensionsCount() const
Definition Tensor.h:106
int32_t dims(int i) const
Definition Tensor.h:108
const luci_interpreter::RuntimeShape output_shape
type
Definition infer.py:18

References luci_interpreter::RuntimeGraph::addDynamicShapeTensor(), luci_interpreter::RuntimeShape::dimensionsCount(), luci_interpreter::RuntimeShape::dims(), luci_interpreter::RuntimeShape::flatSize(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), luci_interpreter::RuntimeGraph::is_inplace_op(), luci_interpreter::kernels::TISOKernel::output(), output_shape, luci_interpreter::kernels::TISOKernel::readData(), luci_interpreter::RuntimeGraph::resetTensorData(), luci_interpreter::RuntimeShape::setDim(), and size.

◆ execute_kernel_CircleAddN()

void luci_interpreter::execute_kernel_CircleAddN ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 93 of file AddN.cpp.

94{
95 const auto output_index = cur_op->outputs()->operator[](0);
96 assert(output_index != -1);
97 const auto output = runtime_graph->getCircleTensorByIndex(output_index);
98
99 switch (Tensor::element_type(output))
100 {
101#ifndef DIS_FLOAT
102 case DataType::FLOAT32:
103 {
104 evalGeneric<float>(cur_op, runtime_graph);
105 }
106 break;
107#endif // DIS_FLOAT
108 default:
109 assert(false && "Unsupported type.");
110 }
111}

References luci_interpreter::RuntimeGraph::getCircleTensorByIndex().

◆ execute_kernel_CircleArgMax()

void luci_interpreter::execute_kernel_CircleArgMax ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 39 of file ArgMax.cpp.

40{
41 kernels::TISOKernel kernel(cur_op, runtime_graph);
42
43 const circle::Tensor *input = kernel.input1();
44 const circle::Tensor *output = kernel.output();
45
46 kernels::TISOData tiso_data = kernel.readData();
47 const auto input_data = tiso_data.input1_data;
48 const auto axis_data = tiso_data.input2_data;
49 auto output_data = tiso_data.output_data;
50
51 switch (Tensor::element_type(input))
52 {
53#ifndef DIS_FLOAT
54 case DataType::FLOAT32:
55 {
56 luci_interpreter_pal::ArgMinMax(
57 kernels::getTensorRuntimeShape(input, runtime_graph),
58 kernels::getTensorData<float>(input_data), kernels::getTensorData<int32_t>(axis_data),
59 kernels::getTensorRuntimeShape(output, runtime_graph),
60 kernels::getTensorData<int32_t>(output_data), std::greater<float>());
61 }
62 break;
63#endif // DIS_FLOAT
64 default:
65 assert(false && "Unsupported ArgMax input type");
66 }
67}

References luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOData::input1_data, luci_interpreter::kernels::TISOData::input2_data, luci_interpreter::kernels::TISOKernel::output(), luci_interpreter::kernels::TISOData::output_data, and luci_interpreter::kernels::TISOKernel::readData().

◆ execute_kernel_CircleArgMin()

void luci_interpreter::execute_kernel_CircleArgMin ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 40 of file ArgMin.cpp.

41{
42 kernels::TISOKernel kernel(cur_op, runtime_graph);
43
44 const circle::Tensor *input = kernel.input1();
45 const circle::Tensor *output = kernel.output();
46
47 kernels::TISOData tiso_data = kernel.readData();
48 const auto input_data = tiso_data.input1_data;
49 const auto axis_data = tiso_data.input2_data;
50 auto output_data = tiso_data.output_data;
51
52 switch (Tensor::element_type(input))
53 {
54#ifndef DIS_FLOAT
55 case DataType::FLOAT32:
56 {
57 luci_interpreter_pal::ArgMinMax(
58 kernels::getTensorRuntimeShape(input, runtime_graph),
59 kernels::getTensorData<float>(input_data), kernels::getTensorData<int32_t>(axis_data),
60 kernels::getTensorRuntimeShape(output, runtime_graph),
61 kernels::getTensorData<int32_t>(output_data), std::less<float>());
62 }
63 break;
64#endif // DIS_FLOAT
65 default:
66 assert(false && "Unsupported ArgMax input type");
67 }
68}

References luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOData::input1_data, luci_interpreter::kernels::TISOData::input2_data, luci_interpreter::kernels::TISOKernel::output(), luci_interpreter::kernels::TISOData::output_data, and luci_interpreter::kernels::TISOKernel::readData().

◆ execute_kernel_CircleAveragePool2D()

void luci_interpreter::execute_kernel_CircleAveragePool2D ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 31 of file AveragePool2D.cpp.

33{
34 const kernels::SISOKernel siso_kernel(cur_op, runtime_graph);
35
36 const auto input = siso_kernel.input();
37 const auto output = siso_kernel.output();
38
39 const auto *input_data = runtime_graph->getDataByTensor(input);
40 auto *output_data = runtime_graph->getDataByTensor(output);
41
42 const DataType input_type = Tensor::element_type(input);
43
44 const auto params = createPoolParams(cur_op, siso_kernel);
45
46 switch (input_type)
47 {
48#ifndef DIS_FLOAT
49 case DataType::FLOAT32:
50 luci_interpreter_pal::AveragePool(
51 params, kernels::getTensorShape(input), kernels::getTensorData<float>(input_data),
52 kernels::getTensorShape(output), kernels::getTensorData<float>(output_data));
53 break;
54#endif // DIS_FLOAT
55#ifndef DIS_QUANT
56 case DataType::S8:
57 case DataType::S16:
58 luci_interpreter_pal::AveragePool(
59 params, kernels::getTensorShape(input), kernels::getTensorData<uint8_t>(input_data),
60 kernels::getTensorShape(output), kernels::getTensorData<uint8_t>(output_data), input_type);
61 break;
62#endif // DIS_QUANT
63 default:
64 assert(false && "Unsupported type.");
65 }
66}
luci_interpreter_pal::PoolParams createPoolParams(const circle::Operator *cur_op, const kernels::SISOKernel &siso_kernel)

References createPoolParams(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorShape(), luci_interpreter::kernels::SISOKernel::input(), and luci_interpreter::kernels::SISOKernel::output().

◆ execute_kernel_CircleBatchToSpaceND()

void luci_interpreter::execute_kernel_CircleBatchToSpaceND ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 42 of file BatchToSpaceND.cpp.

44{
45 kernels::MISOKernel kernel(cur_op, runtime_graph);
46
47 switch (Tensor::element_type(kernel.input1()))
48 {
49#ifndef DIS_FLOAT
50 case DataType::FLOAT32:
51 {
52 luci_interpreter_pal::BatchToSpaceND(
53 kernels::getTensorRuntimeShape(kernel.input1(), runtime_graph),
54 kernels::getTensorData<float>(runtime_graph->getDataByTensor(kernel.input1())),
55 kernels::getTensorRuntimeShape(kernel.input2(), runtime_graph),
56 kernels::getTensorData<int32_t>(runtime_graph->getConstDataByTensor(kernel.input2())),
57 kernels::getTensorRuntimeShape(kernel.input3(), runtime_graph),
58 kernels::getTensorData<int32_t>(runtime_graph->getConstDataByTensor(kernel.input3())),
59 kernels::getTensorRuntimeShape(kernel.output(), runtime_graph),
60 kernels::getTensorData<float>(runtime_graph->getDataByTensor(kernel.output())));
61 break;
62 }
63#endif // DIS_FLOAT
64 default:
65 assert(false && "Unsupported type");
66 }
67}

References luci_interpreter::RuntimeGraph::getConstDataByTensor(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::MISOKernel::input1(), luci_interpreter::kernels::MISOKernel::input2(), luci_interpreter::kernels::MISOKernel::input3(), and luci_interpreter::kernels::MISOKernel::output().

◆ execute_kernel_CircleBroadcastTo()

void luci_interpreter::execute_kernel_CircleBroadcastTo ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 50 of file BroadcastTo.cpp.

52{
53 kernels::TISOKernel kernel(cur_op, runtime_graph);
54
55 const auto *input_data = runtime_graph->getDataByTensor(kernel.input1());
56 assert(input_data);
57
58 auto *output_data = runtime_graph->getDataByTensor(kernel.output());
59
60 luci_interpreter_pal::BroadcastTo<kMaxDims>(
61 kernels::getTensorRuntimeShape(kernel.input1(), runtime_graph), input_data,
62 kernels::getTensorRuntimeShape(kernel.output(), runtime_graph), output_data,
63 Tensor::element_type(kernel.input1()));
64}

References luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::TISOKernel::input1(), and luci_interpreter::kernels::TISOKernel::output().

◆ execute_kernel_CircleCast()

void luci_interpreter::execute_kernel_CircleCast ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 43 of file Cast.cpp.

44{
45 kernels::SISOKernel kernel(cur_op, runtime_graph);
46
47 const auto *input_data = runtime_graph->getDataByTensor(kernel.input());
48 assert(input_data);
49
50 auto *output_data = runtime_graph->getDataByTensor(kernel.output());
51 assert(output_data);
52
53 const int flat_size = kernels::getTensorRuntimeShape(kernel.input(), runtime_graph).flatSize();
54
55 switch (Tensor::element_type(kernel.input()))
56 {
57#ifndef DIS_FLOAT
58 case DataType::FLOAT32:
59 {
60 const float *input_data_float = kernels::getTensorData<float>(input_data);
61
62 switch (Tensor::element_type(kernel.output()))
63 {
64 case DataType::S8:
65 copyCast(input_data_float, kernels::getTensorData<int8_t>(output_data), flat_size);
66 break;
67 case DataType::S16:
68 copyCast(input_data_float, kernels::getTensorData<int16_t>(output_data), flat_size);
69 break;
70 case DataType::S32:
71 copyCast(input_data_float, kernels::getTensorData<int32_t>(output_data), flat_size);
72 break;
73 default:
74 assert(false && "Not supported type");
75 }
76 break;
77 }
78#endif // DIS_FLOAT
79 default:
80 assert(false && "Unsupported type");
81 }
82}

References luci_interpreter::RuntimeShape::flatSize(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::SISOKernel::input(), and luci_interpreter::kernels::SISOKernel::output().

◆ execute_kernel_CircleCeil()

void luci_interpreter::execute_kernel_CircleCeil ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 37 of file Ceil.cpp.

38{
39 kernels::SISOKernel kernel(cur_op, runtime_graph);
40
41 const auto *input_data = runtime_graph->getDataByTensor(kernel.input());
42 assert(input_data);
43
44 auto *output_data = runtime_graph->getDataByTensor(kernel.output());
45
46 bool is_inplace = runtime_graph->is_inplace_op(cur_op);
47
48 switch (Tensor::element_type(kernel.input()))
49 {
50#ifndef DIS_FLOAT
51 case DataType::FLOAT32:
52 {
53 const float *input_data_float = kernels::getTensorData<float>(input_data);
54 float *output_data_float = kernels::getTensorData<float>(output_data);
55 if (is_inplace)
56 {
57 output_data_float = const_cast<float *>(input_data_float);
58 }
59
60 assert(output_data_float);
61
62 const int flat_size =
63 kernels::getTensorRuntimeShape(kernel.input(), runtime_graph).flatSize();
64
65 luci_interpreter_pal::Ceil(flat_size, input_data_float, output_data_float);
66 break;
67 }
68#endif // DIS_FLOAT
69 default:
70 assert(false && "Unsupported type");
71 }
72
73 if (is_inplace)
74 runtime_graph->makeInplaceOperation(kernel.input(), kernel.output());
75}
void Ceil(const int32_t flat_size, const float *input_data, float *output_data)
Definition PALCeil.h:28

References luci_interpreter_pal::Ceil(), luci_interpreter::RuntimeShape::flatSize(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::SISOKernel::input(), luci_interpreter::RuntimeGraph::is_inplace_op(), luci_interpreter::RuntimeGraph::makeInplaceOperation(), and luci_interpreter::kernels::SISOKernel::output().

◆ execute_kernel_CircleConcatenation()

void luci_interpreter::execute_kernel_CircleConcatenation ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 136 of file Concatenation.cpp.

138{
139 int num_inputs = cur_op->inputs()->size();
140 LUCI_INTERPRETER_CHECK(num_inputs > 0);
141
142 const auto input_index = cur_op->inputs()->operator[](0);
143 assert(input_index != -1);
144 const auto *t0 = runtime_graph->getCircleTensorByIndex(input_index);
145
146 switch (Tensor::element_type(t0))
147 {
148#ifndef DIS_FLOAT
149 case DataType::FLOAT32:
150 evalGeneric<float>(cur_op, runtime_graph);
151 break;
152#endif // DIS_FLOAT
153#ifndef DIS_QUANT
154 case DataType::S8:
155 evalGeneric<int8_t>(cur_op, runtime_graph);
156 break;
157#endif // DIS_QUANT
158 case DataType::S32:
159 evalGeneric<int32_t>(cur_op, runtime_graph);
160 break;
161 case DataType::S64:
162 evalGeneric<int64_t>(cur_op, runtime_graph);
163 break;
164 default:
165 assert(false && "Unsupported type.");
166 }
167}

References luci_interpreter::RuntimeGraph::getCircleTensorByIndex(), and LUCI_INTERPRETER_CHECK.

◆ execute_kernel_CircleConv2D()

void luci_interpreter::execute_kernel_CircleConv2D ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 282 of file Conv2D.cpp.

283{
284 kernels::DownsamplingConv2DKernel kernel(cur_op, runtime_graph);
285
286 const auto input = kernel.input();
287 const auto weights = kernel.filter();
288 const auto bias = kernel.bias();
289 const auto output = kernel.output();
290
291 const auto *options = cur_op->builtin_options_as_Conv2DOptions();
292
293 const auto type = Tensor::element_type(input);
294 switch (type)
295 {
296#ifndef DIS_FLOAT
297 case DataType::FLOAT32:
298 if (Tensor::element_type(weights) == DataType::FLOAT32)
299 {
300 evalFloat(input, weights, bias, output, options, runtime_graph);
301 break;
302 }
303#endif // DIS_FLOAT
304#ifndef DIS_QUANT
305 case DataType::U8:
306 case DataType::S8:
307 if (Tensor::scales(weights).size() == 1 and type == DataType::U8)
308 {
309 evalQuantized(input, weights, bias, output, options, runtime_graph);
310 }
311 else if (Tensor::scales(weights).size() > 1)
312 {
313 LUCI_INTERPRETER_CHECK(Tensor::num_dims(weights) == 4);
314 LUCI_INTERPRETER_CHECK(Tensor::scales(weights).size() ==
315 static_cast<size_t>(Tensor::dim(weights, 0)));
316 evalQuantizedPerChannel(input, weights, bias, output, options, runtime_graph, type);
317 }
318 else
319 {
320 assert(false && "Unsupported yet.");
321 }
322 break;
323#endif // DIS_QUANT
324 default:
325 assert(false && "Unsupported type.");
326 }
327}

References luci_interpreter::kernels::DownsamplingConv2DKernel::bias(), circle_eval_diff::TensorShape::dim(), luci_interpreter::kernels::DownsamplingConv2DKernel::filter(), luci_interpreter::kernels::DownsamplingConv2DKernel::input(), LUCI_INTERPRETER_CHECK, luci_interpreter::kernels::DownsamplingConv2DKernel::output(), and size.

◆ execute_kernel_CircleCos()

void luci_interpreter::execute_kernel_CircleCos ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 37 of file Cos.cpp.

38{
39 kernels::SISOKernel kernel(cur_op, runtime_graph);
40
41 const auto *input_data = runtime_graph->getDataByTensor(kernel.input());
42 assert(input_data);
43
44 auto *output_data = runtime_graph->getDataByTensor(kernel.output());
45
46 bool is_inplace = runtime_graph->is_inplace_op(cur_op);
47
48 switch (Tensor::element_type(kernel.input()))
49 {
50#ifndef DIS_FLOAT
51 case DataType::FLOAT32:
52 {
53 const float *input_data_float = kernels::getTensorData<float>(input_data);
54 float *output_data_float = kernels::getTensorData<float>(output_data);
55 if (is_inplace)
56 {
57 output_data_float = const_cast<float *>(input_data_float);
58 }
59
60 assert(output_data_float);
61
62 const int flat_size =
63 kernels::getTensorRuntimeShape(kernel.input(), runtime_graph).flatSize();
64
65 luci_interpreter_pal::Cos(flat_size, input_data_float, output_data_float);
66 break;
67 }
68#endif // DIS_FLOAT
69 default:
70 assert(false && "Unsupported type");
71 }
72
73 if (is_inplace)
74 runtime_graph->makeInplaceOperation(kernel.input(), kernel.output());
75}
void Cos(const int flat_size, const float *input_data, float *output_data)

References luci_interpreter_pal::Cos(), luci_interpreter::RuntimeShape::flatSize(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::SISOKernel::input(), luci_interpreter::RuntimeGraph::is_inplace_op(), luci_interpreter::RuntimeGraph::makeInplaceOperation(), and luci_interpreter::kernels::SISOKernel::output().

◆ execute_kernel_CircleDepthToSpace()

void luci_interpreter::execute_kernel_CircleDepthToSpace ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 55 of file DepthToSpace.cpp.

57{
58 kernels::SISOKernel kernel(cur_op, runtime_graph);
59
60 const auto *options = cur_op->builtin_options_as_DepthToSpaceOptions();
61 const int32_t block_size = options->block_size();
62
63 switch (Tensor::element_type(kernel.input()))
64 {
65#ifndef DIS_FLOAT
66 case DataType::FLOAT32:
67 {
68 assert(block_size != 0);
69 luci_interpreter_pal::DepthToSpace(
70 block_size, kernels::getTensorRuntimeShape(kernel.input(), runtime_graph),
71 kernels::getTensorData<float>(runtime_graph->getDataByTensor(kernel.input())),
72 kernels::getTensorRuntimeShape(kernel.output(), runtime_graph),
73 kernels::getTensorData<float>(runtime_graph->getDataByTensor(kernel.output())));
74 break;
75 }
76#endif // DIS_FLOAT
77 default:
78 assert(false && "Unsupported type");
79 }
80}

References luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::SISOKernel::input(), and luci_interpreter::kernels::SISOKernel::output().

◆ execute_kernel_CircleDepthwiseConv2D()

void luci_interpreter::execute_kernel_CircleDepthwiseConv2D ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 122 of file DepthwiseConv2D.cpp.

124{
125 kernels::DownsamplingConv2DKernel kernel(cur_op, runtime_graph);
126
127 const auto input = kernel.input();
128 const auto weights = kernel.filter();
129 const auto bias = kernel.bias();
130 const auto output = kernel.output();
131
132 const auto *options = cur_op->builtin_options_as_DepthwiseConv2DOptions();
133
134 switch (Tensor::element_type(input))
135 {
136#ifndef DIS_FLOAT
137 case DataType::FLOAT32:
138 if (Tensor::element_type(weights) == DataType::FLOAT32)
139 {
140 evalFloat(input, weights, bias, output, options, runtime_graph);
141 break;
142 }
143#endif // DIS_FLOAT
144 default:
145 assert(false && "Unsupported type.");
146 }
147}

References luci_interpreter::kernels::DownsamplingConv2DKernel::bias(), luci_interpreter::kernels::DownsamplingConv2DKernel::filter(), luci_interpreter::kernels::DownsamplingConv2DKernel::input(), and luci_interpreter::kernels::DownsamplingConv2DKernel::output().

◆ execute_kernel_CircleDequantize()

void luci_interpreter::execute_kernel_CircleDequantize ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 42 of file Dequantize.cpp.

44{
45#ifndef DIS_QUANT
46 kernels::SISOKernel kernel(cur_op, runtime_graph);
47
48 const auto *input_data = runtime_graph->getDataByTensor(kernel.input());
49 assert(input_data);
50
51 auto *output_data = runtime_graph->getDataByTensor(kernel.output());
52 assert(output_data);
53
54 const int flat_size = kernels::getTensorRuntimeShape(kernel.input(), runtime_graph).flatSize();
55
56 switch (Tensor::element_type(kernel.output()))
57 {
58#ifndef DIS_FLOAT
59 case DataType::FLOAT32:
60 {
62 params.zero_point = Tensor::zero_point(kernel.input());
63 params.scale = Tensor::scale(kernel.input());
64 switch (Tensor::element_type(kernel.input()))
65 {
66 case DataType::S8:
67 luci_interpreter_pal::Dequantize(params, flat_size,
68 kernels::getTensorData<int8_t>(input_data),
69 kernels::getTensorData<float>(output_data));
70 break;
71 case DataType::U8:
72 luci_interpreter_pal::Dequantize(params, flat_size,
73 kernels::getTensorData<uint8_t>(input_data),
74 kernels::getTensorData<float>(output_data));
75 break;
76 case DataType::S16:
77 luci_interpreter_pal::Dequantize(params, flat_size,
78 kernels::getTensorData<int16_t>(input_data),
79 kernels::getTensorData<float>(output_data));
80 break;
81 default:
82 assert(false && "Unsupported type");
83 }
84 break;
85 }
86#endif // DIS_FLOAT
87 default:
88 assert(false && "Unsupported type");
89 }
90#else
91 assert(false && "Remove DIS_QUANT flag");
92#endif // DIS_QUANT
93}

References luci_interpreter::RuntimeShape::flatSize(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::SISOKernel::input(), luci_interpreter::kernels::SISOKernel::output(), and luci_interpreter_pal::QuantizationParams::zero_point.

◆ execute_kernel_CircleDiv()

void luci_interpreter::execute_kernel_CircleDiv ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 38 of file Div.cpp.

39{
40 kernels::TISOKernel kernel(cur_op, runtime_graph);
41
42 const auto *options = cur_op->builtin_options_as_DivOptions();
43
45 kernels::getTensorRuntimeShape(kernel.input1(), runtime_graph);
47 kernels::getTensorRuntimeShape(kernel.input2(), runtime_graph);
48
49 bool is_inplace = runtime_graph->is_inplace_op(cur_op);
50
52 kernels::getTensorRuntimeShape(kernel.output(), runtime_graph);
53
54 switch (Tensor::element_type(kernel.input1()))
55 {
56#ifndef DIS_FLOAT
57 case DataType::FLOAT32:
58 {
59 auto tiso_func = luci_interpreter_pal::Div<float>;
60 auto broadcast_tiso_func = luci_interpreter_pal::BroadcastDiv4DSlow<float>;
61 if (is_inplace)
62 {
63 kernels::evalTISOInplaceKernel<float>(tiso_func, broadcast_tiso_func, &kernel, options,
64 std::move(input_shape1), std::move(input_shape2),
65 std::move(output_shape));
66 }
67 else
68 {
69 kernels::TISOData kernel_data = kernel.readData();
70 kernels::evalTISOKernel<float>(tiso_func, broadcast_tiso_func, &kernel, &kernel_data,
71 options, std::move(input_shape1), std::move(input_shape2),
72 std::move(output_shape));
73 }
74 }
75 break;
76#endif // DIS_FLOAT
77 default:
78 assert(false && "Unsupported type.");
79 }
80}

References luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), luci_interpreter::RuntimeGraph::is_inplace_op(), luci_interpreter::kernels::TISOKernel::output(), output_shape, and luci_interpreter::kernels::TISOKernel::readData().

◆ execute_kernel_CircleElu()

void luci_interpreter::execute_kernel_CircleElu ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 37 of file Elu.cpp.

38{
39 kernels::SISOKernel kernel(cur_op, runtime_graph);
40
41 const auto *input_data = runtime_graph->getDataByTensor(kernel.input());
42 assert(input_data);
43
44 auto *output_data = runtime_graph->getDataByTensor(kernel.output());
45
46 bool is_inplace = runtime_graph->is_inplace_op(cur_op);
47
48 switch (Tensor::element_type(kernel.input()))
49 {
50#ifndef DIS_FLOAT
51 case DataType::FLOAT32:
52 {
53 const float *input_data_float = kernels::getTensorData<float>(input_data);
54 float *output_data_float = kernels::getTensorData<float>(output_data);
55 if (is_inplace)
56 {
57 output_data_float = const_cast<float *>(input_data_float);
58 }
59
60 assert(output_data_float);
61
62 const int flat_size =
63 kernels::getTensorRuntimeShape(kernel.input(), runtime_graph).flatSize();
64
65 luci_interpreter_pal::Elu(flat_size, input_data_float, output_data_float);
66 break;
67 }
68#endif // DIS_FLOAT
69 default:
70 assert(false && "Unsupported type");
71 }
72
73 if (is_inplace)
74 runtime_graph->makeInplaceOperation(kernel.input(), kernel.output());
75}

References luci_interpreter::RuntimeShape::flatSize(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::SISOKernel::input(), luci_interpreter::RuntimeGraph::is_inplace_op(), luci_interpreter::RuntimeGraph::makeInplaceOperation(), and luci_interpreter::kernels::SISOKernel::output().

◆ execute_kernel_CircleEqual()

void luci_interpreter::execute_kernel_CircleEqual ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 33 of file Equal.cpp.

34{
35 kernels::TISOKernel kernel(cur_op, runtime_graph);
36
37 switch (Tensor::element_type(kernel.input1()))
38 {
39 case DataType::S64:
40 kernels::evalComparisonGeneric<int64_t>(kernel.input1(), kernel.input2(), kernel.output(),
41 runtime_graph, luci_interpreter_pal::EqualFn);
42 break;
43 case DataType::S32:
44 kernels::evalComparisonGeneric<int32_t>(kernel.input1(), kernel.input2(), kernel.output(),
45 runtime_graph, luci_interpreter_pal::EqualFn);
46 break;
47#ifndef DIS_FLOAT
48 case DataType::FLOAT32:
49 kernels::evalComparisonGeneric<float>(kernel.input1(), kernel.input2(), kernel.output(),
50 runtime_graph, luci_interpreter_pal::EqualFn);
51 break;
52#endif // DIS_FLOAT
53 default:
54 assert(false && "Unsupported type.");
55 }
56}
bool EqualFn(T lhs, T rhs)

References luci_interpreter_pal::EqualFn(), luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), and luci_interpreter::kernels::TISOKernel::output().

◆ execute_kernel_CircleExp()

void luci_interpreter::execute_kernel_CircleExp ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 38 of file Exp.cpp.

39{
40 kernels::SISOKernel kernel(cur_op, runtime_graph);
41
42 const auto *input_data = runtime_graph->getDataByTensor(kernel.input());
43 assert(input_data);
44
45 auto *output_data = runtime_graph->getDataByTensor(kernel.output());
46
47 bool is_inplace = runtime_graph->is_inplace_op(cur_op);
48
49 switch (Tensor::element_type(kernel.input()))
50 {
51#ifndef DIS_FLOAT
52 case DataType::FLOAT32:
53 {
54 const float *input_data_float = kernels::getTensorData<float>(input_data);
55 float *output_data_float = kernels::getTensorData<float>(output_data);
56 if (is_inplace)
57 {
58 output_data_float = const_cast<float *>(input_data_float);
59 }
60
61 assert(output_data_float);
62
63 const int flat_size =
64 kernels::getTensorRuntimeShape(kernel.input(), runtime_graph).flatSize();
65
66 luci_interpreter_pal::Exp(flat_size, input_data_float, output_data_float);
67 break;
68 }
69#endif // DIS_FLOAT
70 default:
71 assert(false && "Unsupported type");
72 }
73
74 if (is_inplace)
75 runtime_graph->makeInplaceOperation(kernel.input(), kernel.output());
76}
void Exp(const int flat_size, const float *input_data, float *output_data)
Definition PALExp.h:26

References luci_interpreter_pal::Exp(), luci_interpreter::RuntimeShape::flatSize(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::SISOKernel::input(), luci_interpreter::RuntimeGraph::is_inplace_op(), luci_interpreter::RuntimeGraph::makeInplaceOperation(), and luci_interpreter::kernels::SISOKernel::output().

◆ execute_kernel_CircleExpandDims()

void luci_interpreter::execute_kernel_CircleExpandDims ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 67 of file ExpandDims.cpp.

69{
70 const auto input_index = cur_op->inputs()->operator[](0);
71 const auto output_index = cur_op->outputs()->operator[](0);
72
73 assert(input_index != -1);
74 assert(output_index != -1);
75
76 const auto input = runtime_graph->getCircleTensorByIndex(input_index);
77 const auto output = runtime_graph->getCircleTensorByIndex(output_index);
78
79 bool is_inplace = runtime_graph->is_inplace_op(cur_op);
80
81 if (is_inplace)
82 {
83 runtime_graph->makeInplaceOperation(input, output);
84 return;
85 }
86
87 // Just copy input to output
88 const auto input_data = runtime_graph->getDataByTensor(input);
89 auto output_data = runtime_graph->getDataByTensor(output);
90
91 assert(input_data != nullptr);
92 assert(output_data != nullptr);
93
94 const size_t element_size = getDataTypeSize(Tensor::element_type(input));
95 const int32_t num_elements = Tensor::num_elements(input);
96 std::memcpy(output_data, input_data, num_elements * element_size);
97}

References luci_interpreter::RuntimeGraph::getCircleTensorByIndex(), luci_interpreter::RuntimeGraph::getDataByTensor(), getDataTypeSize(), luci_interpreter::RuntimeGraph::is_inplace_op(), and luci_interpreter::RuntimeGraph::makeInplaceOperation().

◆ execute_kernel_CircleFill()

void luci_interpreter::execute_kernel_CircleFill ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 48 of file Fill.cpp.

49{
50 kernels::TISOKernel kernel(cur_op, runtime_graph);
51
52 const circle::Tensor *value = kernel.input2();
53 const circle::Tensor *output = kernel.output();
54
55 kernels::TISOData tiso_data = kernel.readData();
56 const uint8_t *value_data = tiso_data.input2_data;
57 uint8_t *output_data = tiso_data.output_data;
58
59 const size_t flat_size = Tensor::num_elements(output);
60
61 switch (Tensor::element_type(value))
62 {
63#ifndef DIS_FLOAT
64 case DataType::FLOAT32:
65 fillImpl<float>(flat_size, kernels::getTensorData<float>(value_data),
66 kernels::getTensorData<float>(output_data));
67 break;
68#endif // DIS_FLOAT
69 case DataType::S32:
70 fillImpl<int32_t>(flat_size, kernels::getTensorData<int32_t>(value_data),
71 kernels::getTensorData<int32_t>(output_data));
72 break;
73#ifndef DIS_QUANT
74 case DataType::U8:
75 fillImpl<uint8_t>(flat_size, kernels::getTensorData<uint8_t>(value_data),
76 kernels::getTensorData<uint8_t>(output_data));
77 break;
78#endif // DIS_QUANT
79 default:
80 assert(false && "Not impl yet");
81 }
82}

References luci_interpreter::kernels::TISOKernel::input2(), luci_interpreter::kernels::TISOData::input2_data, luci_interpreter::kernels::TISOKernel::output(), luci_interpreter::kernels::TISOData::output_data, and luci_interpreter::kernels::TISOKernel::readData().

◆ execute_kernel_CircleFloor()

void luci_interpreter::execute_kernel_CircleFloor ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 49 of file Floor.cpp.

50{
51
52 const auto input_index = cur_op->inputs()->operator[](0);
53 const auto output_index = cur_op->outputs()->operator[](0);
54
55 assert(input_index != -1);
56 assert(output_index != -1);
57
58 const auto input = runtime_graph->getCircleTensorByIndex(input_index);
59 const auto output = runtime_graph->getCircleTensorByIndex(output_index);
60
61 const uint8_t *input_data = runtime_graph->getDataByTensor(input);
62 uint8_t *output_data = runtime_graph->getDataByTensor(output);
63
64 assert(input_data != nullptr);
65 assert(output_data != nullptr);
66
67 switch (Tensor::element_type(input))
68 {
69#ifndef DIS_FLOAT
70 case DataType::FLOAT32:
71
73 kernels::getTensorShape(input), kernels::getTensorData<float>(input_data),
74 kernels::getTensorShape(output), kernels::getTensorData<float>(output_data));
75
76 break;
77#endif // DIS_FLOAT
78 default:
79 assert(false && "Unsupported type.");
80 }
81}
void Floor(const luci_interpreter::RuntimeShape &input_shape, const float *input_data, const luci_interpreter::RuntimeShape &output_shape, float *output_data)

References luci_interpreter_pal::Floor(), luci_interpreter::RuntimeGraph::getCircleTensorByIndex(), luci_interpreter::RuntimeGraph::getDataByTensor(), and luci_interpreter::kernels::getTensorShape().

◆ execute_kernel_CircleFloorDiv()

void luci_interpreter::execute_kernel_CircleFloorDiv ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 35 of file FloorDiv.cpp.

36{
37 kernels::TISOKernel kernel(cur_op, runtime_graph);
38
39 const auto *options = cur_op->builtin_options_as_FloorDivOptions();
40
42 kernels::getTensorRuntimeShape(kernel.input1(), runtime_graph);
44 kernels::getTensorRuntimeShape(kernel.input2(), runtime_graph);
46 kernels::getTensorRuntimeShape(kernel.output(), runtime_graph);
47
48 const uint8_t *input_data1 = runtime_graph->getDataByTensor(kernel.input1());
49 const uint8_t *input_data2 = runtime_graph->getDataByTensor(kernel.input2());
50 uint8_t *output_data = runtime_graph->getDataByTensor(kernel.output());
51
52 assert(input_data1 != nullptr);
53 assert(input_data2 != nullptr);
54 assert(output_data != nullptr);
55
56 switch (Tensor::element_type(kernel.input1()))
57 {
58#ifndef DIS_FLOAT
59 case DataType::FLOAT32:
60 {
61 // Check the denominator
62 for (int i = 0; i < input_shape2.flatSize(); ++i)
63 {
64 LUCI_INTERPRETER_CHECK(kernels::getTensorData<float>(input_data2)[i] != 0);
65 }
66 // check that input and output dimensions are equal
67 if (kernels::areShapesEqual(input_shape1, input_shape2))
68 {
69 const int flat_size = input_shape1.flatSize();
70 luci_interpreter_pal::FloorDiv(flat_size, kernels::getTensorData<float>(input_data1),
71 kernels::getTensorData<float>(input_data2),
72 kernels::getTensorData<float>(output_data));
73 }
74 else
75 {
77 input_shape1, kernels::getTensorData<float>(input_data1), input_shape2,
78 kernels::getTensorData<float>(input_data2), output_shape,
79 kernels::getTensorData<float>(output_data));
80 }
81 }
82 break;
83#endif // DIS_FLOAT
84 default:
85 assert(false && "Unsupported type.");
86 }
87}
void FloorDiv(const int flat_size, const float *input1_data, const float *input2_data, float *output_data)
void BroadcastFloorDiv4DSlow(const luci_interpreter::RuntimeShape &input1_shape, const float *input1_data, const luci_interpreter::RuntimeShape &input2_shape, const float *input2_data, const luci_interpreter::RuntimeShape &output_shape, float *output_data)

References luci_interpreter::kernels::areShapesEqual(), luci_interpreter_pal::BroadcastFloorDiv4DSlow(), luci_interpreter::RuntimeShape::flatSize(), luci_interpreter_pal::FloorDiv(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), LUCI_INTERPRETER_CHECK, luci_interpreter::kernels::TISOKernel::output(), and output_shape.

◆ execute_kernel_CircleFloorMod()

void luci_interpreter::execute_kernel_CircleFloorMod ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 35 of file FloorMod.cpp.

36{
37 kernels::TISOKernel kernel(cur_op, runtime_graph);
38
39 const auto *options = cur_op->builtin_options_as_FloorModOptions();
40
42 kernels::getTensorRuntimeShape(kernel.input1(), runtime_graph);
44 kernels::getTensorRuntimeShape(kernel.input2(), runtime_graph);
46 kernels::getTensorRuntimeShape(kernel.output(), runtime_graph);
47
48 const uint8_t *input_data1 = runtime_graph->getDataByTensor(kernel.input1());
49 const uint8_t *input_data2 = runtime_graph->getDataByTensor(kernel.input2());
50 uint8_t *output_data = runtime_graph->getDataByTensor(kernel.output());
51
52 assert(input_data1 != nullptr);
53 assert(input_data2 != nullptr);
54 assert(output_data != nullptr);
55
56 switch (Tensor::element_type(kernel.input1()))
57 {
58#ifndef DIS_FLOAT
59 case DataType::FLOAT32:
60 {
61 // Check the denominator
62 for (int i = 0; i < input_shape2.flatSize(); ++i)
63 {
64 LUCI_INTERPRETER_CHECK(kernels::getTensorData<float>(input_data2)[i] != 0);
65 }
66 // check that input and output dimensions are equal
67 if (kernels::areShapesEqual(input_shape1, input_shape2))
68 {
69 const int flat_size = input_shape1.flatSize();
70 luci_interpreter_pal::FloorMod(flat_size, kernels::getTensorData<float>(input_data1),
71 kernels::getTensorData<float>(input_data2),
72 kernels::getTensorData<float>(output_data));
73 }
74 else
75 {
77 input_shape1, kernels::getTensorData<float>(input_data1), input_shape2,
78 kernels::getTensorData<float>(input_data2), output_shape,
79 kernels::getTensorData<float>(output_data));
80 }
81 }
82 break;
83#endif // DIS_FLOAT
84 default:
85 assert(false && "Unsupported type.");
86 }
87}
void BroadcastFloorMod4DSlow(const luci_interpreter::RuntimeShape &input1_shape, const float *input1_data, const luci_interpreter::RuntimeShape &input2_shape, const float *input2_data, const luci_interpreter::RuntimeShape &output_shape, float *output_data)
void FloorMod(const int flat_size, const float *input1_data, const float *input2_data, float *output_data)

References luci_interpreter::kernels::areShapesEqual(), luci_interpreter_pal::BroadcastFloorMod4DSlow(), luci_interpreter::RuntimeShape::flatSize(), luci_interpreter_pal::FloorMod(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), LUCI_INTERPRETER_CHECK, luci_interpreter::kernels::TISOKernel::output(), and output_shape.

◆ execute_kernel_CircleFullyConnected()

void luci_interpreter::execute_kernel_CircleFullyConnected ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 282 of file FullyConnected.cpp.

284{
285 const auto input_index = cur_op->inputs()->operator[](0);
286 const auto weight_index = cur_op->inputs()->operator[](1);
287 const auto bias_index = cur_op->inputs()->operator[](2);
288 const auto output_index = cur_op->outputs()->operator[](0);
289
290 assert(input_index != -1);
291 assert(weight_index != -1);
292 assert(output_index != -1);
293
294 const auto input = runtime_graph->getCircleTensorByIndex(input_index);
295 const auto weights = runtime_graph->getCircleTensorByIndex(weight_index);
296 const auto bias = runtime_graph->getCircleTensorByIndex(bias_index);
297 const auto output = runtime_graph->getCircleTensorByIndex(output_index);
298
299 assert(input != nullptr);
300 assert(weights != nullptr);
301 assert(output != nullptr);
302
303 const auto *options = cur_op->builtin_options_as_FullyConnectedOptions();
304 const auto input_type = Tensor::element_type(input);
305 switch (input_type)
306 {
307#ifndef DIS_QUANT
308 case DataType::U8:
309 case DataType::S8:
310 case DataType::S16:
311 evalQuantized(input, weights, bias, output, options, runtime_graph, input_type);
312 break;
313#endif // DIS_QUANT
314#ifndef DIS_FLOAT
315 case DataType::FLOAT32:
316 evalFloat(input, weights, bias, output, options, runtime_graph);
317 break;
318#endif // DIS_FLOAT
319 default:
320 assert(false && "Unsupported type.");
321 }
322}

References luci_interpreter::RuntimeGraph::getCircleTensorByIndex().

◆ execute_kernel_CircleGather()

void luci_interpreter::execute_kernel_CircleGather ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 137 of file Gather.cpp.

138{
139 kernels::TISOKernel kernel(cur_op, runtime_graph);
140
141 const auto *options = cur_op->builtin_options_as_GatherOptions();
142
143 switch (Tensor::element_type(kernel.input1()))
144 {
145#ifndef DIS_FLOAT
146 case DataType::FLOAT32:
147 return gather<float, int32_t>(options, &kernel);
148#endif // DIS_FLOAT
149#ifndef DIS_QUANT
150 case DataType::S8:
151 return gather<int8_t, int32_t>(options, &kernel);
152#endif // DIS_QUANT
153 case DataType::S32:
154 return gather<int32_t, int32_t>(options, &kernel);
155 default:
156 assert(false && "Unsupported type");
157 }
158}

References luci_interpreter::kernels::TISOKernel::input1().

◆ execute_kernel_CircleGatherND()

void luci_interpreter::execute_kernel_CircleGatherND ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 47 of file GatherND.cpp.

48{
49 kernels::TISOKernel kernel(cur_op, runtime_graph);
50
51 const uint8_t *params_data = runtime_graph->getDataByTensor(kernel.input1());
52 const uint8_t *indies_data = runtime_graph->getConstDataByTensor(kernel.input2());
53 uint8_t *output_data = runtime_graph->getDataByTensor(kernel.output());
54
55 switch (Tensor::element_type(kernel.input1()))
56 {
57#ifndef DIS_FLOAT
58 case DataType::FLOAT32:
59 return luci_interpreter_pal::GatherND<float, int32_t>(
60 kernels::getTensorRuntimeShape(kernel.input1(), runtime_graph),
61 kernels::getTensorData<float>(params_data),
62 kernels::getTensorRuntimeShape(kernel.input2(), runtime_graph),
63 kernels::getTensorData<int32_t>(indies_data), kernels::getTensorData<float>(output_data));
64#endif // DIS_FLOAT
65 default:
66 assert(false && "Unsupported type");
67 }
68}

References luci_interpreter::RuntimeGraph::getConstDataByTensor(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), and luci_interpreter::kernels::TISOKernel::output().

◆ execute_kernel_CircleGreater()

void luci_interpreter::execute_kernel_CircleGreater ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 33 of file Greater.cpp.

34{
35 kernels::TISOKernel kernel(cur_op, runtime_graph);
36
37 switch (Tensor::element_type(kernel.input1()))
38 {
39 case DataType::S64:
40 kernels::evalComparisonGeneric<int64_t>(kernel.input1(), kernel.input2(), kernel.output(),
41 runtime_graph, luci_interpreter_pal::GreaterFn);
42 break;
43 case DataType::S32:
44 kernels::evalComparisonGeneric<int32_t>(kernel.input1(), kernel.input2(), kernel.output(),
45 runtime_graph, luci_interpreter_pal::GreaterFn);
46 break;
47#ifndef DIS_FLOAT
48 case DataType::FLOAT32:
49 kernels::evalComparisonGeneric<float>(kernel.input1(), kernel.input2(), kernel.output(),
50 runtime_graph, luci_interpreter_pal::GreaterFn);
51 break;
52#endif // DIS_FLOAT
53 default:
54 assert(false && "Unsupported type.");
55 }
56}
bool GreaterFn(T lhs, T rhs)

References luci_interpreter_pal::GreaterFn(), luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), and luci_interpreter::kernels::TISOKernel::output().

◆ execute_kernel_CircleGreaterEqual()

void luci_interpreter::execute_kernel_CircleGreaterEqual ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 34 of file GreaterEqual.cpp.

36{
37 kernels::TISOKernel kernel(cur_op, runtime_graph);
38
39 switch (Tensor::element_type(kernel.input1()))
40 {
41 case DataType::S64:
42 kernels::evalComparisonGeneric<int64_t>(kernel.input1(), kernel.input2(), kernel.output(),
44 break;
45 case DataType::S32:
46 kernels::evalComparisonGeneric<int32_t>(kernel.input1(), kernel.input2(), kernel.output(),
48 break;
49#ifndef DIS_FLOAT
50 case DataType::FLOAT32:
51 kernels::evalComparisonGeneric<float>(kernel.input1(), kernel.input2(), kernel.output(),
53 break;
54#endif // DIS_FLOAT
55 default:
56 assert(false && "Unsupported type.");
57 }
58}
bool GreaterEqualFn(T lhs, T rhs)

References luci_interpreter_pal::GreaterEqualFn(), luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), and luci_interpreter::kernels::TISOKernel::output().

◆ execute_kernel_CircleIf()

void luci_interpreter::execute_kernel_CircleIf ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 64 of file If.cpp.

65{
66 auto *main_runtime_graph = runtime_graph;
67 auto *runtime_module = runtime_graph->getRuntimeModule();
68
69 const auto input_size = cur_op->inputs()->size() - 1;
70 const auto output_size = cur_op->outputs()->size();
71
72 std::vector<uint8_t *> operation_inputs_data(input_size);
73 std::vector<uint8_t *> operation_outputs_data(output_size);
74
75 std::vector<int32_t> input_sizes(input_size);
76 std::vector<int32_t> output_sizes(output_size);
77
78 const auto *options = cur_op->builtin_options_as_IfOptions();
79 const auto cond_index = cur_op->inputs()->operator[](0);
80
81 const auto then_subgraph_index = options->then_subgraph_index();
82 const auto else_subgraph_index = options->else_subgraph_index();
83
84 auto *then_subgraph = runtime_module->getRuntimeGraphAt(then_subgraph_index);
85 auto *else_subgraph = runtime_module->getRuntimeGraphAt(else_subgraph_index);
86
87 const auto cond = runtime_graph->getCircleTensorByIndex(cond_index);
88
89 const uint8_t *cond_data = runtime_graph->getDataByTensor(cond);
90 const bool cond_value = kernels::getTensorData<bool>(cond_data)[0];
91
92 RuntimeGraph *active_graph = cond_value ? then_subgraph : else_subgraph;
93
94 for (int32_t i = 0; i < input_size; ++i)
95 {
96 const auto op_input_index = cur_op->inputs()->operator[](i + 1);
97 assert(op_input_index != -1);
98 const auto input = main_runtime_graph->getCircleTensorByIndex(op_input_index);
99 input_sizes[i] = Tensor::num_elements(input) * size(Tensor::element_type(input));
100
101 auto *input_data = main_runtime_graph->getDataByTensor(input);
102
103 uint8_t *tensor_data = nullptr;
104 if (input_data == nullptr)
105 input_data = main_runtime_graph->getConstDataByTensor(input);
106 assert(input_data != nullptr);
107 tensor_data = main_runtime_graph->getDataByTensor(input);
108 assert(tensor_data != nullptr);
109
110 operation_inputs_data[i] = tensor_data;
111 }
112 for (int32_t i = 0; i < output_size; ++i)
113 {
114 const auto op_output_index = cur_op->outputs()->operator[](i);
115 assert(op_output_index != -1);
116 const auto output = main_runtime_graph->getCircleTensorByIndex(op_output_index);
117 output_sizes[i] = Tensor::num_elements(output) * size(Tensor::element_type(output));
118
119 auto *output_data = main_runtime_graph->getDataByTensor(output);
120
121 uint8_t *tensor_data = nullptr;
122 if (output_data == nullptr)
123 output_data = main_runtime_graph->getConstDataByTensor(output);
124 assert(output_data != nullptr);
125 tensor_data = main_runtime_graph->getDataByTensor(output);
126 assert(tensor_data != nullptr);
127
128 operation_outputs_data[i] = tensor_data;
129 }
130 active_graph->selectOwnSubgraph();
131 for (int32_t i = 0; i < input_size; ++i)
132 active_graph->configureGraphInput(i, operation_inputs_data[i]);
133 active_graph->execute();
134
135 for (int32_t i = 0; i < output_size; ++i)
136 {
137 auto cur_output_active_data = active_graph->getOutputDataByIndex(i);
138 if (cur_output_active_data == nullptr)
139 continue;
140 std::memcpy(operation_outputs_data[i], cur_output_active_data, output_sizes[i]);
141 }
142 active_graph->resetOutputTensorsData();
143 active_graph->clearTensors();
144 main_runtime_graph->selectOwnSubgraph();
145}
uint8_t * getOutputDataByIndex(int32_t output_index)
uint8_t * configureGraphInput(int32_t input_index)

References luci_interpreter::RuntimeGraph::clearTensors(), luci_interpreter::RuntimeGraph::configureGraphInput(), luci_interpreter::RuntimeGraph::execute(), luci_interpreter::RuntimeGraph::getCircleTensorByIndex(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::RuntimeGraph::getOutputDataByIndex(), luci_interpreter::RuntimeGraph::getRuntimeModule(), luci_interpreter::RuntimeGraph::resetOutputTensorsData(), luci_interpreter::RuntimeGraph::selectOwnSubgraph(), and size.

◆ execute_kernel_CircleL2Normalize()

void luci_interpreter::execute_kernel_CircleL2Normalize ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 38 of file L2Normalize.cpp.

40{
41 kernels::SISOKernel kernel(cur_op, runtime_graph);
42
43 const auto *input_data = runtime_graph->getDataByTensor(kernel.input());
44 assert(input_data);
45
46 auto *output_data = runtime_graph->getDataByTensor(kernel.output());
47
48 switch (Tensor::element_type(kernel.input()))
49 {
50#ifndef DIS_FLOAT
51 case DataType::FLOAT32:
52 {
53 const auto *input_data_float = kernels::getTensorData<float>(input_data);
54 auto *output_data_float = kernels::getTensorData<float>(output_data);
55
56 assert(output_data_float);
57
58 luci_interpreter_pal::L2Normalization(
59 kernels::getTensorRuntimeShape(kernel.input(), runtime_graph), input_data_float,
60 kernels::getTensorRuntimeShape(kernel.output(), runtime_graph), output_data_float);
61 break;
62 }
63#endif // DIS_FLOAT
64 default:
65 assert(false && "Unsupported type");
66 }
67}

References luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::SISOKernel::input(), and luci_interpreter::kernels::SISOKernel::output().

◆ execute_kernel_CircleL2Pool2D()

void luci_interpreter::execute_kernel_CircleL2Pool2D ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 30 of file L2Pool2D.cpp.

31{
32 const kernels::SISOKernel siso_kernel(cur_op, runtime_graph);
33
34 const auto input = siso_kernel.input();
35 const auto output = siso_kernel.output();
36
37 const auto *input_data = runtime_graph->getDataByTensor(input);
38 auto *output_data = runtime_graph->getDataByTensor(output);
39
40 const DataType input_type = Tensor::element_type(input);
41
42 const auto params = createPoolParams(cur_op, siso_kernel);
43
44 switch (input_type)
45 {
46#ifndef DIS_FLOAT
47 case DataType::FLOAT32:
48 luci_interpreter_pal::L2Pool(
49 params, kernels::getTensorShape(input), kernels::getTensorData<float>(input_data),
50 kernels::getTensorShape(output), kernels::getTensorData<float>(output_data));
51 break;
52#endif // DIS_FLOAT
53 default:
54 assert(false && "Unsupported type.");
55 }
56}

References createPoolParams(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorShape(), luci_interpreter::kernels::SISOKernel::input(), and luci_interpreter::kernels::SISOKernel::output().

◆ execute_kernel_CircleLeakyRelu()

void luci_interpreter::execute_kernel_CircleLeakyRelu ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 38 of file LeakyRelu.cpp.

39{
40 kernels::SISOKernel kernel(cur_op, runtime_graph);
41
42 const auto *input_data = runtime_graph->getDataByTensor(kernel.input());
43 assert(input_data);
44
45 auto *output_data = runtime_graph->getDataByTensor(kernel.output());
46
47 bool is_inplace = runtime_graph->is_inplace_op(cur_op);
48
49 const auto options = cur_op->builtin_options_as_LeakyReluOptions();
50
51 switch (Tensor::element_type(kernel.input()))
52 {
53#ifndef DIS_FLOAT
54 case DataType::FLOAT32:
55 {
56 const float *input_data_float = kernels::getTensorData<float>(input_data);
57 float *output_data_float = kernels::getTensorData<float>(output_data);
58 if (is_inplace)
59 {
60 output_data_float = const_cast<float *>(input_data_float);
61 }
62
63 assert(output_data_float);
64 const int flat_size =
65 kernels::getTensorRuntimeShape(kernel.input(), runtime_graph).flatSize();
66
67 luci_interpreter_pal::ReLUCommon(flat_size, input_data_float, output_data_float,
68 options->alpha(), false);
69 break;
70 }
71#endif // DIS_FLOAT
72 default:
73 assert(false && "Unsupported type");
74 }
75
76 if (is_inplace)
77 runtime_graph->makeInplaceOperation(kernel.input(), kernel.output());
78}
void ReLUCommon(const int flat_size, const float *input_data, float *output_data, const float alpha, const bool is_relu_6)

References luci_interpreter::RuntimeShape::flatSize(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::SISOKernel::input(), luci_interpreter::RuntimeGraph::is_inplace_op(), luci_interpreter::RuntimeGraph::makeInplaceOperation(), luci_interpreter::kernels::SISOKernel::output(), and luci_interpreter_pal::ReLUCommon().

◆ execute_kernel_CircleLess()

void luci_interpreter::execute_kernel_CircleLess ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 89 of file Less.cpp.

90{
91 kernels::TISOKernel kernel(cur_op, runtime_graph);
92
93 switch (Tensor::element_type(kernel.input1()))
94 {
95 case DataType::S64:
96 kernels::evalComparisonGeneric<int64_t>(kernel.input1(), kernel.input2(), kernel.output(),
97 runtime_graph, luci_interpreter_pal::LessFn);
98 break;
99 case DataType::S32:
100 kernels::evalComparisonGeneric<int32_t>(kernel.input1(), kernel.input2(), kernel.output(),
101 runtime_graph, luci_interpreter_pal::LessFn);
102 break;
103#ifndef DIS_QUANT
104 case DataType::U8:
105 evalQuantized(kernel.input1(), kernel.input2(), kernel.output(), runtime_graph);
106 break;
107#endif // DIS_QUANT
108#ifndef DIS_FLOAT
109 case DataType::FLOAT32:
110 kernels::evalComparisonGeneric<float>(kernel.input1(), kernel.input2(), kernel.output(),
111 runtime_graph, luci_interpreter_pal::LessFn);
112 break;
113#endif // DIS_FLOAT
114 default:
115 assert(false && "Unsupported type.");
116 }
117}
bool LessFn(T lhs, T rhs)

References luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), luci_interpreter_pal::LessFn(), and luci_interpreter::kernels::TISOKernel::output().

◆ execute_kernel_CircleLessEqual()

void luci_interpreter::execute_kernel_CircleLessEqual ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 34 of file LessEqual.cpp.

35{
36 kernels::TISOKernel kernel(cur_op, runtime_graph);
37
38 switch (Tensor::element_type(kernel.input1()))
39 {
40 case DataType::S64:
41 kernels::evalComparisonGeneric<int64_t>(kernel.input1(), kernel.input2(), kernel.output(),
43 break;
44 case DataType::S32:
45 kernels::evalComparisonGeneric<int32_t>(kernel.input1(), kernel.input2(), kernel.output(),
47 break;
48#ifndef DIS_FLOAT
49 case DataType::FLOAT32:
50 kernels::evalComparisonGeneric<float>(kernel.input1(), kernel.input2(), kernel.output(),
52 break;
53#endif // DIS_FLOAT
54 default:
55 assert(false && "Unsupported type.");
56 }
57}
bool LessEqualFn(T lhs, T rhs)

References luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), luci_interpreter_pal::LessEqualFn(), and luci_interpreter::kernels::TISOKernel::output().

◆ execute_kernel_CircleLog()

void luci_interpreter::execute_kernel_CircleLog ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 37 of file Log.cpp.

38{
39 kernels::SISOKernel kernel(cur_op, runtime_graph);
40
41 const auto *input_data = runtime_graph->getDataByTensor(kernel.input());
42 assert(input_data);
43
44 auto *output_data = runtime_graph->getDataByTensor(kernel.output());
45
46 bool is_inplace = runtime_graph->is_inplace_op(cur_op);
47
48 switch (Tensor::element_type(kernel.input()))
49 {
50#ifndef DIS_FLOAT
51 case DataType::FLOAT32:
52 {
53 const float *input_data_float = kernels::getTensorData<float>(input_data);
54 float *output_data_float = kernels::getTensorData<float>(output_data);
55 if (is_inplace)
56 {
57 output_data_float = const_cast<float *>(input_data_float);
58 }
59
60 assert(output_data_float);
61
62 const int flat_size =
63 kernels::getTensorRuntimeShape(kernel.input(), runtime_graph).flatSize();
64
65 luci_interpreter_pal::Log(flat_size, input_data_float, output_data_float);
66 break;
67 }
68#endif // DIS_FLOAT
69 default:
70 assert(false && "Unsupported type");
71 }
72
73 if (is_inplace)
74 runtime_graph->makeInplaceOperation(kernel.input(), kernel.output());
75}
void Log(const int flat_size, const float *input_data, float *output_data)
Definition PALLog.h:26

References luci_interpreter::RuntimeShape::flatSize(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::SISOKernel::input(), luci_interpreter::RuntimeGraph::is_inplace_op(), luci_interpreter_pal::Log(), luci_interpreter::RuntimeGraph::makeInplaceOperation(), and luci_interpreter::kernels::SISOKernel::output().

◆ execute_kernel_CircleLogicalAnd()

void luci_interpreter::execute_kernel_CircleLogicalAnd ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 48 of file LogicalAnd.cpp.

50{
51 kernels::TISOKernel kernel(cur_op, runtime_graph);
52
53 auto x_data = kernels::getTensorData<bool>(runtime_graph->getDataByTensor(kernel.input1()));
54 if (x_data == nullptr)
55 x_data = kernels::getTensorData<bool>(runtime_graph->getConstDataByTensor(kernel.input1()));
56
57 assert(x_data != nullptr);
58
59 auto y_data = kernels::getTensorData<bool>(runtime_graph->getDataByTensor(kernel.input2()));
60 if (y_data == nullptr)
61 y_data = kernels::getTensorData<bool>(runtime_graph->getConstDataByTensor(kernel.input2()));
62
63 assert(y_data != nullptr);
64
65 auto output_data = kernels::getTensorData<bool>(runtime_graph->getDataByTensor(kernel.output()));
66
67 const int64_t flat_size = kernels::getTensorShape(kernel.input1()).flatSize();
68 luci_interpreter_pal::LogicalCommon(flat_size, x_data, y_data, output_data, LogicalAnd);
69}
void LogicalCommon(const int flat_size, const bool *input1_data, const bool *input2_data, bool *output_data, bool(*f)(bool, bool))

References luci_interpreter::RuntimeGraph::getConstDataByTensor(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorShape(), luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), luci_interpreter_pal::LogicalCommon(), and luci_interpreter::kernels::TISOKernel::output().

◆ execute_kernel_CircleLogicalNot()

void luci_interpreter::execute_kernel_CircleLogicalNot ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 44 of file LogicalNot.cpp.

46{
47 kernels::SISOKernel kernel(cur_op, runtime_graph);
48
49 auto data = kernels::getTensorData<bool>(runtime_graph->getDataByTensor(kernel.input()));
50 if (data == nullptr)
51 data = kernels::getTensorData<bool>(runtime_graph->getConstDataByTensor(kernel.input()));
52
53 assert(data != nullptr);
54
55 auto output_data = kernels::getTensorData<bool>(runtime_graph->getDataByTensor(kernel.output()));
56
57 const int64_t flat_size = kernels::getTensorShape(kernel.input()).flatSize();
58 luci_interpreter_pal::LogicalNot(flat_size, data, output_data);
59}
void LogicalNot(const int flat_size, const bool *input_data, bool *output_data)

References flatbuffers::data(), luci_interpreter::RuntimeGraph::getConstDataByTensor(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorShape(), luci_interpreter::kernels::SISOKernel::input(), luci_interpreter_pal::LogicalNot(), and luci_interpreter::kernels::SISOKernel::output().

◆ execute_kernel_CircleLogicalOr()

void luci_interpreter::execute_kernel_CircleLogicalOr ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 49 of file LogicalOr.cpp.

50{
51 kernels::TISOKernel kernel(cur_op, runtime_graph);
52
53 auto x_data = kernels::getTensorData<bool>(runtime_graph->getDataByTensor(kernel.input1()));
54 if (x_data == nullptr)
55 x_data = kernels::getTensorData<bool>(runtime_graph->getConstDataByTensor(kernel.input1()));
56
57 assert(x_data != nullptr);
58
59 auto y_data = kernels::getTensorData<bool>(runtime_graph->getDataByTensor(kernel.input2()));
60 if (y_data == nullptr)
61 y_data = kernels::getTensorData<bool>(runtime_graph->getConstDataByTensor(kernel.input2()));
62
63 assert(y_data != nullptr);
64
65 auto output_data = kernels::getTensorData<bool>(runtime_graph->getDataByTensor(kernel.output()));
66
67 const int64_t flat_size = kernels::getTensorShape(kernel.input1()).flatSize();
68 luci_interpreter_pal::LogicalCommon(flat_size, x_data, y_data, output_data, LogicalOr);
69}

References luci_interpreter::RuntimeGraph::getConstDataByTensor(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorShape(), luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), luci_interpreter_pal::LogicalCommon(), and luci_interpreter::kernels::TISOKernel::output().

◆ execute_kernel_CircleLogistic()

void luci_interpreter::execute_kernel_CircleLogistic ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 41 of file Logistic.cpp.

42{
43 kernels::SISOKernel kernel(cur_op, runtime_graph);
44
45 const auto input = kernel.input();
46 const auto output = kernel.output();
47
48 bool is_inplace = runtime_graph->is_inplace_op(cur_op);
49
50 const uint8_t *input_data = runtime_graph->getDataByTensor(input);
51 uint8_t *output_data = runtime_graph->getDataByTensor(output);
52
53 if (is_inplace)
54 {
55 output_data = const_cast<uint8_t *>(input_data);
56 }
57
58 assert(input_data != nullptr);
59 assert(output_data != nullptr);
60
61 const int flat_size = kernels::getTensorRuntimeShape(input, runtime_graph).flatSize();
62
63 switch (Tensor::element_type(input))
64 {
65#ifndef DIS_FLOAT
66 case DataType::FLOAT32:
67 luci_interpreter_pal::Logistic(flat_size, kernels::getTensorData<float>(input_data),
68 kernels::getTensorData<float>(output_data));
69 break;
70#endif // DIS_FLOAT
71#ifndef DIS_QUANT
72 case DataType::S8:
73 luci_interpreter_pal::Logistic(flat_size, kernels::getTensorData<int8_t>(input_data),
74 Tensor::scale(input), Tensor::zero_point(input),
75 kernels::getTensorData<int8_t>(output_data),
76 Tensor::scale(output), Tensor::zero_point(output));
77 break;
78#endif // DIS_QUANT
79 default:
80 assert(false && "Unsupported type.");
81 }
82
83 if (is_inplace)
84 {
85 runtime_graph->makeInplaceOperation(input, output);
86 }
87}
void Logistic(const int flat_size, const float *input_data, float *output_data)
Definition PALGRU.h:26

References luci_interpreter::RuntimeShape::flatSize(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::SISOKernel::input(), luci_interpreter::RuntimeGraph::is_inplace_op(), luci_interpreter_pal::Logistic(), luci_interpreter::RuntimeGraph::makeInplaceOperation(), and luci_interpreter::kernels::SISOKernel::output().

◆ execute_kernel_CircleLogSoftmax()

void luci_interpreter::execute_kernel_CircleLogSoftmax ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 38 of file LogSoftmax.cpp.

40{
41 kernels::SISOKernel kernel(cur_op, runtime_graph);
42
43 const auto *input_data = runtime_graph->getDataByTensor(kernel.input());
44 assert(input_data);
45 auto *output_data = runtime_graph->getDataByTensor(kernel.output());
46
47 switch (Tensor::element_type(kernel.input()))
48 {
49#ifndef DIS_FLOAT
50 case DataType::FLOAT32:
51 {
52 const float *input_data_float = kernels::getTensorData<float>(input_data);
53 float *output_data_float = kernels::getTensorData<float>(output_data);
54 assert(output_data_float);
55
56 luci_interpreter_pal::LogSoftmax(
57 kernels::getTensorRuntimeShape(kernel.input(), runtime_graph), input_data_float,
58 kernels::getTensorRuntimeShape(kernel.output(), runtime_graph), output_data_float);
59 break;
60 }
61#endif // DIS_FLOAT
62 default:
63 assert(false && "Unsupported type");
64 }
65}

References luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::SISOKernel::input(), and luci_interpreter::kernels::SISOKernel::output().

◆ execute_kernel_CircleMaximum()

void luci_interpreter::execute_kernel_CircleMaximum ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 34 of file Maximum.cpp.

35{
36 kernels::TISOKernel kernel(cur_op, runtime_graph);
38 kernels::getTensorRuntimeShape(kernel.input1(), runtime_graph);
40 kernels::getTensorRuntimeShape(kernel.input2(), runtime_graph);
42 kernels::getTensorRuntimeShape(kernel.output(), runtime_graph);
43
44 const uint8_t *input_data1 = runtime_graph->getDataByTensor(kernel.input1());
45 const uint8_t *input_data2 = runtime_graph->getDataByTensor(kernel.input2());
46 uint8_t *output_data = runtime_graph->getDataByTensor(kernel.output());
47
48 assert(input_data1 != nullptr);
49 assert(input_data2 != nullptr);
50 assert(output_data != nullptr);
51
52 switch (Tensor::element_type(kernel.input1()))
53 {
54#ifndef DIS_FLOAT
55 case DataType::FLOAT32:
56 {
57 // check that input and output dimensions are equal
58 if (kernels::areShapesEqual(input_shape1, input_shape2))
59 {
60 const int flat_size = input_shape1.flatSize();
61 luci_interpreter_pal::Maximum(flat_size, kernels::getTensorData<float>(input_data1),
62 kernels::getTensorData<float>(input_data2),
63 kernels::getTensorData<float>(output_data));
64 }
65 else
66 {
68 input_shape1, kernels::getTensorData<float>(input_data1), input_shape2,
69 kernels::getTensorData<float>(input_data2), output_shape,
70 kernels::getTensorData<float>(output_data));
71 }
72 }
73 break;
74#endif // DIS_FLOAT
75 default:
76 assert(false && "Unsupported type.");
77 }
78}
void Maximum(const int flat_size, const float *input1_data, const float *input2_data, float *output_data)
void BroadcastMaximum4DSlow(const luci_interpreter::RuntimeShape &input1_shape, const float *input1_data, const luci_interpreter::RuntimeShape &input2_shape, const float *input2_data, const luci_interpreter::RuntimeShape &output_shape, float *output_data)

References luci_interpreter::kernels::areShapesEqual(), luci_interpreter_pal::BroadcastMaximum4DSlow(), luci_interpreter::RuntimeShape::flatSize(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), luci_interpreter_pal::Maximum(), luci_interpreter::kernels::TISOKernel::output(), and output_shape.

◆ execute_kernel_CircleMaxPool2D()

void luci_interpreter::execute_kernel_CircleMaxPool2D ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 29 of file MaxPool2D.cpp.

30{
31 const kernels::SISOKernel siso_kernel(cur_op, runtime_graph);
32
33 const auto input = siso_kernel.input();
34 const auto output = siso_kernel.output();
35
36 const auto *input_data = runtime_graph->getDataByTensor(input);
37 auto *output_data = runtime_graph->getDataByTensor(output);
38
39 const DataType input_type = Tensor::element_type(input);
40
41 const auto params = createPoolParams(cur_op, siso_kernel);
42
43 switch (input_type)
44 {
45#ifndef DIS_FLOAT
46 case DataType::FLOAT32:
48 params, kernels::getTensorShape(input), kernels::getTensorData<float>(input_data),
49 kernels::getTensorShape(output), kernels::getTensorData<float>(output_data));
50 break;
51#endif // DIS_FLOAT
52#ifndef DIS_QUANT
53 case DataType::S8:
54 case DataType::S16:
56 params, kernels::getTensorShape(input), kernels::getTensorData<uint8_t>(input_data),
57 kernels::getTensorShape(output), kernels::getTensorData<uint8_t>(output_data), input_type);
58 break;
59#endif // DIS_QUANT
60 default:
61 assert(false && "Unsupported type.");
62 }
63}
void MaxPool(const PoolParams &params, const luci_interpreter::RuntimeShape &input_shape, const uint8_t *input_data, const luci_interpreter::RuntimeShape &output_shape, uint8_t *output_data, luci_interpreter::DataType data_type)

References createPoolParams(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorShape(), luci_interpreter::kernels::SISOKernel::input(), luci_interpreter_pal::MaxPool(), and luci_interpreter::kernels::SISOKernel::output().

◆ execute_kernel_CircleMean()

void luci_interpreter::execute_kernel_CircleMean ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 61 of file Mean.cpp.

62{
63 kernels::TISOKernel kernel(cur_op, runtime_graph);
64 kernels::TISOData tiso_data = kernel.readData();
65
66 const auto *input = kernel.input1();
67 const auto *axis = kernel.input2();
68 const auto *output = kernel.output();
69
70 const auto *options = cur_op->builtin_options_as_ReducerOptions();
71
72 int num_axis = static_cast<int>(Tensor::num_elements(axis));
73 int temp_index[kMaxNumberOfAxis];
74 int resolved_axis[kMaxNumberOfReducedAxis];
75
76 switch (Tensor::element_type(kernel.input1()))
77 {
78#ifndef DIS_FLOAT
79 case DataType::FLOAT32:
80 {
82 ResolveAxis(kernels::getTensorData<int>(tiso_data.input2_data), num_axis, &op_params);
83
84 // Special case mean implementation exists for 4D mean across axes 1
85 // and 2.
86 bool special_case_4d_axes_1_and_2 = Tensor::num_dims(input) == 4 &&
87 op_params.axis_count == 2 &&
88 ((op_params.axis[0] == 1 && op_params.axis[1] == 2) ||
89 (op_params.axis[0] == 2 && op_params.axis[1] == 1));
90
91 // Defer to specialized implementation for 4D Mean across axes 1 & 2.
92 if (options->keep_dims() && special_case_4d_axes_1_and_2)
93 {
94 luci_interpreter_pal::Mean(op_params, kernels::getTensorShape(input),
95 kernels::getTensorData<float>(tiso_data.input1_data),
96 kernels::getTensorShape(output),
97 kernels::getTensorData<float>(tiso_data.output_data));
98 }
99 else
100 {
102 kernels::getTensorData<float>(tiso_data.input1_data),
103 reinterpret_cast<const int *>(wrap(input->shape()).data()), Tensor::num_dims(input),
104 kernels::getTensorData<float>(tiso_data.output_data),
105 reinterpret_cast<const int *>(wrap(output->shape()).data()), Tensor::num_dims(output),
106 kernels::getTensorData<int>(tiso_data.input2_data), num_axis, options->keep_dims(),
107 temp_index, resolved_axis, kernels::getTensorData<float>(tiso_data.output_data));
108 }
109 }
110 break;
111#endif // DIS_FLOAT
112 default:
113 assert(false && "Unsupported type");
114 }
115}
bool Mean(const T *input_data, const int *input_dims, const int input_num_dims, T *output_data, const int *output_dims, const int output_num_dims, const int *axis, const int num_axis_dimensions, bool, int *temp_index, int *resolved_axis, U *temp_sum)
Definition PALMean.h:108

References luci_interpreter_pal::MeanParams::axis, luci_interpreter_pal::MeanParams::axis_count, luci_interpreter::kernels::getTensorShape(), luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOData::input1_data, luci_interpreter::kernels::TISOKernel::input2(), luci_interpreter::kernels::TISOData::input2_data, luci_interpreter_pal::Mean(), luci_interpreter::kernels::TISOKernel::output(), luci_interpreter::kernels::TISOData::output_data, luci_interpreter::kernels::TISOKernel::readData(), and luci::wrap().

◆ execute_kernel_CircleMinimum()

void luci_interpreter::execute_kernel_CircleMinimum ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 34 of file Minimum.cpp.

35{
36 kernels::TISOKernel kernel(cur_op, runtime_graph);
38 kernels::getTensorRuntimeShape(kernel.input1(), runtime_graph);
40 kernels::getTensorRuntimeShape(kernel.input2(), runtime_graph);
42 kernels::getTensorRuntimeShape(kernel.output(), runtime_graph);
43
44 const uint8_t *input_data1 = runtime_graph->getDataByTensor(kernel.input1());
45 const uint8_t *input_data2 = runtime_graph->getDataByTensor(kernel.input2());
46 uint8_t *output_data = runtime_graph->getDataByTensor(kernel.output());
47
48 assert(input_data1 != nullptr);
49 assert(input_data2 != nullptr);
50 assert(output_data != nullptr);
51
52 switch (Tensor::element_type(kernel.input1()))
53 {
54#ifndef DIS_FLOAT
55 case DataType::FLOAT32:
56 {
57 // check that input and output dimensions are equal
58 if (kernels::areShapesEqual(input_shape1, input_shape2))
59 {
60 const int flat_size = input_shape1.flatSize();
61 luci_interpreter_pal::Minimum(flat_size, kernels::getTensorData<float>(input_data1),
62 kernels::getTensorData<float>(input_data2),
63 kernels::getTensorData<float>(output_data));
64 }
65 else
66 {
67 luci_interpreter_pal::BroadcastMinimum4DSlow<float>(
68 input_shape1, kernels::getTensorData<float>(input_data1), input_shape2,
69 kernels::getTensorData<float>(input_data2), output_shape,
70 kernels::getTensorData<float>(output_data));
71 }
72 }
73 break;
74#endif // DIS_FLOAT
75 default:
76 assert(false && "Unsupported type.");
77 }
78}
void Minimum(const int flat_size, const float *input1_data, const float *input2_data, float *output_data)

References luci_interpreter::kernels::areShapesEqual(), luci_interpreter::RuntimeShape::flatSize(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), luci_interpreter_pal::Minimum(), luci_interpreter::kernels::TISOKernel::output(), and output_shape.

◆ execute_kernel_CircleMirrorPad()

void luci_interpreter::execute_kernel_CircleMirrorPad ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 42 of file MirrorPad.cpp.

43{
44 kernels::TISOKernel kernel(cur_op, runtime_graph);
45
46 kernels::TISOData data = kernel.readData();
47
48 const auto *options = cur_op->builtin_options_as_MirrorPadOptions();
49
50 const auto offset = options->mode() != circle::MirrorPadMode_REFLECT ? 0 : 1;
51 const auto input_dims = Tensor::num_dims(kernel.input1());
52 const auto output_size = Tensor::num_elements(kernel.output());
53
54 int output_dims_num_elements[5];
55 int input_dims_num_elements[5];
56
57 for (int i = 0; i < input_dims; i++)
58 {
59 output_dims_num_elements[i] = 1;
60 input_dims_num_elements[i] = 1;
61 }
62
63 for (int i = input_dims - 2; i >= 0; i--)
64 {
65 output_dims_num_elements[i] =
66 output_dims_num_elements[i + 1] * Tensor::dim(kernel.output(), i + 1);
67
68 input_dims_num_elements[i] =
69 input_dims_num_elements[i + 1] * Tensor::dim(kernel.input1(), i + 1);
70 }
71
72 switch (Tensor::element_type(kernel.input1()))
73 {
74#ifndef DIS_FLOAT
75 case DataType::FLOAT32:
76 {
78 Tensor::element_type(kernel.input2()), data.input2_data,
79 wrap(kernel.input1()->shape()).data(), output_dims_num_elements, input_dims_num_elements,
80 kernels::getTensorData<float>(data.input1_data),
81 kernels::getTensorData<float>(data.output_data), offset, input_dims, output_size);
82
83 break;
84 }
85#endif // DIS_FLOAT
86 default:
87 assert(false && "Unsupported type");
88 }
89}
__global uchar * offset(const Image *img, int x, int y)
Definition helpers.h:540
std::function< Ret(Arg)> wrap(Ret(*p)(Arg))
Convert a function pointer as a callable std::function.
Definition fipe.h:31
void MirrorPad(const luci_interpreter::DataType padding_matrix_type, const uint8_t *padding_matrix_data, const int32_t *input_dims, int *output_dims_num_elements, int *input_dims_num_elements, const T *input_data, T *output_data, const int offset, const int num_dims, const int output_size)

References flatbuffers::data(), circle_eval_diff::TensorShape::dim(), luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), luci_interpreter_pal::MirrorPad(), offset(), luci_interpreter::kernels::TISOKernel::output(), luci_interpreter::kernels::TISOKernel::readData(), and luci::wrap().

◆ execute_kernel_CircleMul()

void luci_interpreter::execute_kernel_CircleMul ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 105 of file Mul.cpp.

106{
107 kernels::TISOKernel kernel(cur_op, runtime_graph);
108
109 const auto *options = cur_op->builtin_options_as_MulOptions();
110
111 luci_interpreter::RuntimeShape input_shape1 =
112 kernels::getTensorRuntimeShape(kernel.input1(), runtime_graph);
113 luci_interpreter::RuntimeShape input_shape2 =
114 kernels::getTensorRuntimeShape(kernel.input2(), runtime_graph);
115
117 kernels::getTensorRuntimeShape(kernel.output(), runtime_graph);
118
119 bool is_inplace = runtime_graph->is_inplace_op(cur_op);
120 const auto type = Tensor::element_type(kernel.input1());
121 switch (type)
122 {
123#ifndef DIS_FLOAT
124 case DataType::FLOAT32:
125 {
126 auto tiso_func = luci_interpreter_pal::Mul<float>;
127 auto broadcast_tiso_func = luci_interpreter_pal::BroadcastMul4DSlow<float>;
128 if (is_inplace)
129 {
130 kernels::evalTISOInplaceKernel<float>(tiso_func, broadcast_tiso_func, &kernel, options,
131 std::move(input_shape1), std::move(input_shape2),
132 std::move(output_shape));
133 }
134 else
135 {
136 kernels::TISOData kernel_data = kernel.readData();
137 kernels::evalTISOKernel<float>(tiso_func, broadcast_tiso_func, &kernel, &kernel_data,
138 options, std::move(input_shape1), std::move(input_shape2),
139 std::move(output_shape));
140 }
141 }
142 break;
143#endif // DIS_FLOAT
144 case DataType::S64:
145 {
146 auto tiso_func = luci_interpreter_pal::Mul<int64_t>;
147 auto broadcast_tiso_func = luci_interpreter_pal::BroadcastMul4DSlow<int64_t>;
148 if (is_inplace)
149 {
150 kernels::evalTISOInplaceKernel<int64_t>(tiso_func, broadcast_tiso_func, &kernel, options,
151 std::move(input_shape1), std::move(input_shape2),
152 std::move(output_shape));
153 }
154 else
155 {
156 kernels::TISOData kernel_data = kernel.readData();
157 kernels::evalTISOKernel<int64_t>(tiso_func, broadcast_tiso_func, &kernel, &kernel_data,
158 options, std::move(input_shape1), std::move(input_shape2),
159 std::move(output_shape));
160 }
161 }
162 break;
163 case DataType::S32:
164 {
165 auto tiso_func = luci_interpreter_pal::Mul<int32_t>;
166 auto broadcast_tiso_func = luci_interpreter_pal::BroadcastMul4DSlow<int32_t>;
167 if (is_inplace)
168 {
169 kernels::evalTISOInplaceKernel<int32_t>(tiso_func, broadcast_tiso_func, &kernel, options,
170 std::move(input_shape1), std::move(input_shape2),
171 std::move(output_shape));
172 }
173 else
174 {
175 kernels::TISOData kernel_data = kernel.readData();
176 kernels::evalTISOKernel<int32_t>(tiso_func, broadcast_tiso_func, &kernel, &kernel_data,
177 options, std::move(input_shape1), std::move(input_shape2),
178 std::move(output_shape));
179 }
180 }
181 break;
182#ifndef DIS_QUANT
183 case DataType::S8:
184 case DataType::S16:
185 {
186 evalQuantized(kernel.input1(), kernel.input2(), kernel.output(), options, runtime_graph,
187 type);
188 }
189 break;
190#endif // DIS_QUANT
191 default:
192 assert(false && "Unsupported type.");
193 }
194}

References luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), luci_interpreter::RuntimeGraph::is_inplace_op(), luci_interpreter::kernels::TISOKernel::output(), output_shape, and luci_interpreter::kernels::TISOKernel::readData().

◆ execute_kernel_CircleNeg()

void luci_interpreter::execute_kernel_CircleNeg ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 46 of file Neg.cpp.

47{
48 const auto input_index = cur_op->inputs()->operator[](0);
49 const auto output_index = cur_op->outputs()->operator[](0);
50
51 assert(input_index != -1);
52 assert(output_index != -1);
53
54 const auto input = runtime_graph->getCircleTensorByIndex(input_index);
55 const auto output = runtime_graph->getCircleTensorByIndex(output_index);
56
57 const uint8_t *input_data = runtime_graph->getDataByTensor(input);
58 uint8_t *output_data = runtime_graph->getDataByTensor(output);
59
60 assert(input_data != nullptr);
61 assert(output_data != nullptr);
62
63 switch (Tensor::element_type(input))
64 {
65#ifndef DIS_FLOAT
66 case DataType::FLOAT32:
67
68 luci_interpreter_pal::Negate(
69 kernels::getTensorShape(input), kernels::getTensorData<float>(input_data),
70 kernels::getTensorShape(output), kernels::getTensorData<float>(output_data));
71
72 break;
73#endif // DIS_FLOAT
74 default:
75 assert(false && "Unsupported type.");
76 }
77}

References luci_interpreter::RuntimeGraph::getCircleTensorByIndex(), luci_interpreter::RuntimeGraph::getDataByTensor(), and luci_interpreter::kernels::getTensorShape().

◆ execute_kernel_CircleNotEqual()

void luci_interpreter::execute_kernel_CircleNotEqual ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 34 of file NotEqual.cpp.

35{
36 kernels::TISOKernel kernel(cur_op, runtime_graph);
37
38 switch (Tensor::element_type(kernel.input1()))
39 {
40 case DataType::S64:
41 kernels::evalComparisonGeneric<int64_t>(kernel.input1(), kernel.input2(), kernel.output(),
43 break;
44 case DataType::S32:
45 kernels::evalComparisonGeneric<int32_t>(kernel.input1(), kernel.input2(), kernel.output(),
47 break;
48#ifndef DIS_FLOAT
49 case DataType::FLOAT32:
50 kernels::evalComparisonGeneric<float>(kernel.input1(), kernel.input2(), kernel.output(),
52 break;
53#endif // DIS_FLOAT
54 default:
55 assert(false && "Unsupported type.");
56 }
57}
bool NotEqualFn(T lhs, T rhs)

References luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), luci_interpreter_pal::NotEqualFn(), and luci_interpreter::kernels::TISOKernel::output().

◆ execute_kernel_CirclePack()

void luci_interpreter::execute_kernel_CirclePack ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 90 of file Pack.cpp.

91{
92 const auto input_index = cur_op->inputs()->operator[](0);
93 const auto output_index = cur_op->outputs()->operator[](0);
94 assert(output_index != -1);
95 assert(input_index != -1);
96 const auto input = runtime_graph->getCircleTensorByIndex(input_index);
97 const auto output = runtime_graph->getCircleTensorByIndex(output_index);
98
99 auto output_data = runtime_graph->getDataByTensor(output);
100 assert(output_data != nullptr);
101
102 switch (Tensor::element_type(output))
103 {
104#ifndef DIS_FLOAT
105 case DataType::FLOAT32:
106 packImpl<float>(input, output, cur_op, runtime_graph, output_data);
107 break;
108#endif // DIS_FLOAT
109#ifndef DIS_QUANT
110 case DataType::S8:
111 packImpl<int8_t>(input, output, cur_op, runtime_graph, output_data);
112 break;
113 case DataType::U8:
114 packImpl<uint8_t>(input, output, cur_op, runtime_graph, output_data);
115 break;
116#endif // DIS_QUANT
117 case DataType::S32:
118 packImpl<int32_t>(input, output, cur_op, runtime_graph, output_data);
119 break;
120 case DataType::S64:
121 packImpl<int64_t>(input, output, cur_op, runtime_graph, output_data);
122 break;
123 default:
124 assert(false && "Unsupported types");
125 }
126}

References luci_interpreter::RuntimeGraph::getCircleTensorByIndex(), and luci_interpreter::RuntimeGraph::getDataByTensor().

◆ execute_kernel_CirclePad()

void luci_interpreter::execute_kernel_CirclePad ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 27 of file Pad.cpp.

28{
29 execute_kernel_CirclePadCommon(cur_op, runtime_graph);
30}
void execute_kernel_CirclePadCommon(const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)

References execute_kernel_CirclePadCommon().

◆ execute_kernel_CirclePadCommon()

void luci_interpreter::execute_kernel_CirclePadCommon ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 128 of file PadCommon.cpp.

129{
130 PadKernel kernel(cur_op, runtime_graph);
131
132 const auto input1_tensor = kernel.input1();
133 const auto input2_tensor = kernel.input2();
134 const auto input3_tensor = kernel.input3();
135 const auto output_tensor = kernel.output();
136
137 auto pad_params = kernel.getPadParams();
138
139 auto *input1_data = runtime_graph->getDataByTensor(input1_tensor);
140 if (input1_data == nullptr)
141 input1_data = runtime_graph->getConstDataByTensor(input1_tensor);
142 assert(input1_data);
143
144 auto *input2_data = runtime_graph->getConstDataByTensor(input2_tensor);
145 assert(input2_data);
146
147 auto *output_data = runtime_graph->getDataByTensor(output_tensor);
148 assert(output_data);
149
150 switch (Tensor::element_type(input1_tensor))
151 {
152#ifndef DIS_FLOAT
153 case DataType::FLOAT32:
154 {
155 float pad_value =
156 input3_tensor == nullptr
157 ? 0.f
158 : *kernels::getTensorData<float>(runtime_graph->getConstDataByTensor(input3_tensor));
159 luci_interpreter_pal::Pad(pad_params, kernels::getTensorShape(input1_tensor),
160 kernels::getTensorData<float>(input1_data), &pad_value,
161 kernels::getTensorShape(output_tensor),
162 kernels::getTensorData<float>(output_data));
163 }
164 break;
165#endif // DIS_FLOAT
166 default:
167 assert(false && "Unsupported type");
168 }
169}
void Pad(const PadParams &op_params, const luci_interpreter::RuntimeShape &input_shape, const float *input_data, const float *pad_value_ptr, const luci_interpreter::RuntimeShape &output_shape, float *output_data)
Definition PALPad.h:28

References luci_interpreter::RuntimeGraph::getConstDataByTensor(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorShape(), and luci_interpreter_pal::Pad().

Referenced by execute_kernel_CirclePad(), and execute_kernel_CirclePadV2().

◆ execute_kernel_CirclePadV2()

void luci_interpreter::execute_kernel_CirclePadV2 ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 27 of file PadV2.cpp.

28{
29 execute_kernel_CirclePadCommon(cur_op, runtime_graph);
30}

References execute_kernel_CirclePadCommon().

◆ execute_kernel_CirclePRelu()

void luci_interpreter::execute_kernel_CirclePRelu ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 40 of file PRelu.cpp.

41{
42 kernels::TISOKernel kernel(cur_op, runtime_graph);
43 kernels::TISOData kernel_data = kernel.readData();
44
45 switch (Tensor::element_type(kernel.input1()))
46 {
47#ifndef DIS_FLOAT
48 case DataType::FLOAT32:
49 {
50 const float *input_data_float = kernels::getTensorData<float>(kernel_data.input1_data);
51 const float *alpha_data_float = kernels::getTensorData<float>(kernel_data.input2_data);
52 float *output_data_float = kernels::getTensorData<float>(kernel_data.output_data);
53 assert(output_data_float);
54 assert(input_data_float);
55 assert(alpha_data_float);
56
58 kernels::getTensorRuntimeShape(kernel.input1(), runtime_graph), input_data_float,
59 kernels::getTensorRuntimeShape(kernel.input2(), runtime_graph), alpha_data_float,
60 kernels::getTensorRuntimeShape(kernel.output(), runtime_graph), output_data_float);
61 break;
62 }
63#endif // DIS_FLOAT
64 default:
65 assert(false && "Unsupported type");
66 }
67}
void BroadcastPrelu4DSlowFloat(const luci_interpreter::RuntimeShape &unextended_input1_shape, const float *input1_data, const luci_interpreter::RuntimeShape &unextended_input2_shape, const float *input2_data, const luci_interpreter::RuntimeShape &unextended_output_shape, float *output_data)

References luci_interpreter_pal::BroadcastPrelu4DSlowFloat(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOData::input1_data, luci_interpreter::kernels::TISOKernel::input2(), luci_interpreter::kernels::TISOData::input2_data, luci_interpreter::kernels::TISOKernel::output(), luci_interpreter::kernels::TISOData::output_data, and luci_interpreter::kernels::TISOKernel::readData().

◆ execute_kernel_CircleQuantize()

void luci_interpreter::execute_kernel_CircleQuantize ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 42 of file Quantize.cpp.

43{
44#ifndef DIS_QUANT
45 kernels::SISOKernel kernel(cur_op, runtime_graph);
46
47 const auto *input_data = runtime_graph->getDataByTensor(kernel.input());
48 assert(input_data);
49
50 auto *output_data = runtime_graph->getDataByTensor(kernel.output());
51 assert(output_data);
52
53 const int flat_size = kernels::getTensorRuntimeShape(kernel.input(), runtime_graph).flatSize();
54
55 switch (Tensor::element_type(kernel.input()))
56 {
57#ifndef DIS_FLOAT
58 case DataType::FLOAT32:
59 {
61 params.zero_point = Tensor::zero_point(kernel.output());
62 params.scale = Tensor::scale(kernel.output());
63 switch (Tensor::element_type(kernel.output()))
64 {
65 case DataType::S8:
66 luci_interpreter_pal::Quantize(params, flat_size,
67 kernels::getTensorData<float>(input_data),
68 kernels::getTensorData<int8_t>(output_data));
69 break;
70 case DataType::U8:
71 luci_interpreter_pal::Quantize(params, flat_size,
72 kernels::getTensorData<float>(input_data),
73 kernels::getTensorData<uint8_t>(output_data));
74 break;
75 case DataType::S16:
76 luci_interpreter_pal::Quantize(params, flat_size,
77 kernels::getTensorData<float>(input_data),
78 kernels::getTensorData<int16_t>(output_data));
79 break;
80 default:
81 assert(false && "Unsupported type");
82 }
83 break;
84 }
85#endif // DIS_FLOAT
86 default:
87 assert(false && "Unsupported type");
88 }
89#else
90 assert(false && "Remove DIS_QUANT flag");
91#endif // DIS_QUANT
92}

References luci_interpreter::RuntimeShape::flatSize(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::SISOKernel::input(), luci_interpreter::kernels::SISOKernel::output(), and luci_interpreter_pal::QuantizationParams::zero_point.

◆ execute_kernel_CircleReduceCommon()

void luci_interpreter::execute_kernel_CircleReduceCommon ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 62 of file ReduceCommon.cpp.

64{
65 kernels::TISOKernel kernel(cur_op, runtime_graph);
66 kernels::TISOData tiso_data = kernel.readData();
67
68 const auto *input = kernel.input1();
69 const auto *axis = kernel.input2();
70 const auto *output = kernel.output();
71
72 const auto *options = cur_op->builtin_options_as_ReducerOptions();
73
74 switch (Tensor::element_type(kernel.input1()))
75 {
76#ifndef DIS_FLOAT
77 case DataType::FLOAT32:
78 reduceProdGeneric<float>(&tiso_data, input, axis, output, options->keep_dims());
79 break;
80#endif // DIS_FLOAT
81 case DataType::S32:
82 reduceProdGeneric<int32_t>(&tiso_data, input, axis, output, options->keep_dims());
83 break;
84 case DataType::S64:
85 reduceProdGeneric<int64_t>(&tiso_data, input, axis, output, options->keep_dims());
86 break;
87 default:
88 assert(false && "Unsupported type");
89 }
90}

References luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), luci_interpreter::kernels::TISOKernel::output(), and luci_interpreter::kernels::TISOKernel::readData().

◆ execute_kernel_CircleReduceMax()

void luci_interpreter::execute_kernel_CircleReduceMax ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 66 of file ReduceMax.cpp.

67{
68 kernels::TISOKernel kernel(cur_op, runtime_graph);
69 kernels::TISOData tiso_data = kernel.readData();
70
71 const auto *input = kernel.input1();
72 const auto *axis = kernel.input2();
73 const auto *output = kernel.output();
74
75 switch (Tensor::element_type(kernel.input1()))
76 {
77#ifndef DIS_FLOAT
78 case DataType::FLOAT32:
79 reduceMaxGeneric<float>(&tiso_data, input, axis, output);
80 break;
81#endif // DIS_FLOAT
82 default:
83 assert(false && "Unsupported type");
84 }
85}

References luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), luci_interpreter::kernels::TISOKernel::output(), and luci_interpreter::kernels::TISOKernel::readData().

◆ execute_kernel_CircleRelu()

void luci_interpreter::execute_kernel_CircleRelu ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 37 of file Relu.cpp.

38{
39 kernels::SISOKernel kernel(cur_op, runtime_graph);
40
41 const auto *input_data = runtime_graph->getDataByTensor(kernel.input());
42 assert(input_data);
43
44 auto *output_data = runtime_graph->getDataByTensor(kernel.output());
45
46 bool is_inplace = runtime_graph->is_inplace_op(cur_op);
47
48 switch (Tensor::element_type(kernel.input()))
49 {
50#ifndef DIS_FLOAT
51 case DataType::FLOAT32:
52 {
53 const float *input_data_float = kernels::getTensorData<float>(input_data);
54 float *output_data_float = kernels::getTensorData<float>(output_data);
55 if (is_inplace)
56 {
57 output_data_float = const_cast<float *>(input_data_float);
58 }
59
60 assert(output_data_float);
61 const int flat_size =
62 kernels::getTensorRuntimeShape(kernel.input(), runtime_graph).flatSize();
63
64 luci_interpreter_pal::ReLUCommon(flat_size, input_data_float, output_data_float, 0.0f, false);
65 break;
66 }
67#endif // DIS_FLOAT
68 default:
69 assert(false && "Unsupported type");
70 }
71
72 if (is_inplace)
73 runtime_graph->makeInplaceOperation(kernel.input(), kernel.output());
74}

References luci_interpreter::RuntimeShape::flatSize(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::SISOKernel::input(), luci_interpreter::RuntimeGraph::is_inplace_op(), luci_interpreter::RuntimeGraph::makeInplaceOperation(), luci_interpreter::kernels::SISOKernel::output(), and luci_interpreter_pal::ReLUCommon().

◆ execute_kernel_CircleRelu6()

void luci_interpreter::execute_kernel_CircleRelu6 ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 37 of file Relu6.cpp.

38{
39 kernels::SISOKernel kernel(cur_op, runtime_graph);
40
41 const auto *input_data = runtime_graph->getDataByTensor(kernel.input());
42 assert(input_data);
43
44 auto *output_data = runtime_graph->getDataByTensor(kernel.output());
45
46 bool is_inplace = runtime_graph->is_inplace_op(cur_op);
47
48 switch (Tensor::element_type(kernel.input()))
49 {
50#ifndef DIS_FLOAT
51 case DataType::FLOAT32:
52 {
53 const float *input_data_float = kernels::getTensorData<float>(input_data);
54 float *output_data_float = kernels::getTensorData<float>(output_data);
55 if (is_inplace)
56 {
57 output_data_float = const_cast<float *>(input_data_float);
58 }
59
60 assert(output_data_float);
61 const int flat_size =
62 kernels::getTensorRuntimeShape(kernel.input(), runtime_graph).flatSize();
63
64 luci_interpreter_pal::ReLUCommon(flat_size, input_data_float, output_data_float, 0.0f, true);
65 break;
66 }
67#endif // DIS_FLOAT
68 default:
69 assert(false && "Unsupported type");
70 }
71
72 if (is_inplace)
73 runtime_graph->makeInplaceOperation(kernel.input(), kernel.output());
74}

References luci_interpreter::RuntimeShape::flatSize(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::SISOKernel::input(), luci_interpreter::RuntimeGraph::is_inplace_op(), luci_interpreter::RuntimeGraph::makeInplaceOperation(), luci_interpreter::kernels::SISOKernel::output(), and luci_interpreter_pal::ReLUCommon().

◆ execute_kernel_CircleReshape()

void luci_interpreter::execute_kernel_CircleReshape ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 33 of file Reshape.cpp.

34{
35 const auto input_index = cur_op->inputs()->operator[](0);
36 const auto shape_index = cur_op->inputs()->operator[](1);
37 const auto output_index = cur_op->outputs()->operator[](0);
38
39 assert(input_index != -1);
40 assert(shape_index != -1);
41 assert(output_index != -1);
42
43 const auto input = runtime_graph->getCircleTensorByIndex(input_index);
44 const auto shape = runtime_graph->getCircleTensorByIndex(shape_index);
45 const auto output = runtime_graph->getCircleTensorByIndex(output_index);
46 bool is_inplace = runtime_graph->is_inplace_op(cur_op);
47 if (is_inplace)
48 {
49 runtime_graph->makeInplaceOperation(input, output);
50 return;
51 }
52
53 const auto input_data = runtime_graph->getDataByTensor(input);
54 auto shape_data = runtime_graph->getConstDataByTensor(shape);
55 auto output_data = runtime_graph->getDataByTensor(output);
56
57 assert(input_data != nullptr);
58 assert(output_data != nullptr);
59
60 int32_t data_size = Tensor::num_elements(output) * getDataTypeSize(Tensor::element_type(output));
61
62#ifndef DIS_DYN_SHAPES
63 if (shape_data == nullptr)
64 {
65 shape_data = runtime_graph->getDataByTensor(shape);
66 assert(shape_data != nullptr);
67
68 assert(Tensor::element_type(shape) == DataType::S32);
69
70 const int32_t *shape_data_int = kernels::getTensorData<int32_t>(shape_data);
71 const auto num_dims = Tensor::num_dims(output);
72
73 luci_interpreter::RuntimeShape dynamic_shape(num_dims);
74 data_size = 1;
75 for (int i = 0; i < num_dims; ++i)
76 {
77 dynamic_shape.setDim(i, shape_data_int[i]);
78 data_size *= shape_data_int[i];
79 }
80 data_size *= size(Tensor::element_type(output));
81
82 runtime_graph->addDynamicShapeTensor(output, std::move(dynamic_shape));
83
84 if (data_size == 0)
85 {
86 runtime_graph->resetTensorData(nullptr, output);
87 return;
88 }
89
90 auto new_output_data = new uint8_t[data_size];
91 output_data = new_output_data;
92 runtime_graph->resetTensorData(new_output_data, output);
93 }
94#else
95 assert(shape_data != nullptr);
96#endif // DIS_DYN_SHAPES
97
98 std::memcpy(output_data, input_data, data_size);
99}

References luci_interpreter::RuntimeGraph::addDynamicShapeTensor(), luci_interpreter::RuntimeGraph::getCircleTensorByIndex(), luci_interpreter::RuntimeGraph::getConstDataByTensor(), luci_interpreter::RuntimeGraph::getDataByTensor(), getDataTypeSize(), luci_interpreter::RuntimeGraph::is_inplace_op(), luci_interpreter::RuntimeGraph::makeInplaceOperation(), luci_interpreter::RuntimeGraph::resetTensorData(), luci_interpreter::RuntimeShape::setDim(), and size.

◆ execute_kernel_CircleResizeBilinear()

void luci_interpreter::execute_kernel_CircleResizeBilinear ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 72 of file ResizeBilinear.cpp.

74{
75 assert(cur_op->inputs()->size() == 2);
76 const auto input_index = cur_op->inputs()->operator[](0);
77 const auto size_index = cur_op->inputs()->operator[](1);
78 const auto output_index = cur_op->outputs()->operator[](0);
79
80 assert(input_index != -1);
81 assert(size_index != -1);
82 assert(output_index != -1);
83
84 const auto input = runtime_graph->getCircleTensorByIndex(input_index);
85 const auto size = runtime_graph->getCircleTensorByIndex(size_index);
86 const auto output = runtime_graph->getCircleTensorByIndex(output_index);
87
88 const uint8_t *input_data = runtime_graph->getDataByTensor(input);
89 const uint8_t *size_data = runtime_graph->getConstDataByTensor(size);
90 uint8_t *output_data = runtime_graph->getDataByTensor(output);
91
92 assert(input_data != nullptr);
93 assert(size_data != nullptr);
94 assert(output_data != nullptr);
95
96 // Get parameters
97 const auto *op_params = cur_op->builtin_options_as_ResizeBilinearOptions();
98
99 switch (Tensor::element_type(output))
100 {
101 case DataType::FLOAT32:
102 luci_interpreter_pal::ResizeBilinear(
103 op_params, kernels::getTensorShape(input), kernels::getTensorData<float>(input_data),
104 kernels::getTensorShape(size), kernels::getTensorData<int32_t>(size_data),
105 kernels::getTensorShape(output), kernels::getTensorData<float>(output_data));
106 break;
107 case DataType::U8:
108 luci_interpreter_pal::ResizeBilinear(
109 op_params, kernels::getTensorShape(input), kernels::getTensorData<uint8_t>(input_data),
110 kernels::getTensorShape(size), kernels::getTensorData<int32_t>(size_data),
111 kernels::getTensorShape(output), kernels::getTensorData<uint8_t>(output_data));
112 break;
113 default:
114 assert(false && "Unsupported type.");
115 }
116}

References luci_interpreter::RuntimeGraph::getCircleTensorByIndex(), luci_interpreter::RuntimeGraph::getConstDataByTensor(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorShape(), and size.

◆ execute_kernel_CircleResizeNearestNeighbor()

void luci_interpreter::execute_kernel_CircleResizeNearestNeighbor ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 46 of file ResizeNearestNeighbor.cpp.

48{
49 kernels::TISOKernel tiso_kernel(cur_op, runtime_graph);
50 kernels::TISOData tiso_data = tiso_kernel.readData();
51
52 // Get parameters
53 const auto *op_params = cur_op->builtin_options_as_ResizeNearestNeighborOptions();
54
56 params.align_corners = op_params->align_corners();
57 params.half_pixel_centers = false;
58
59 const uint8_t *input_data = runtime_graph->getDataByTensor(tiso_kernel.input1());
60 const uint8_t *size_data = runtime_graph->getConstDataByTensor(tiso_kernel.input2());
61 uint8_t *output_data = runtime_graph->getDataByTensor(tiso_kernel.output());
62
63 switch (Tensor::element_type(tiso_kernel.output()))
64 {
65#ifndef DIS_FLOAT
66 case DataType::FLOAT32:
67 luci_interpreter_pal::ResizeNearestNeighbor(
68 params, kernels::getTensorRuntimeShape(tiso_kernel.input1(), runtime_graph),
69 kernels::getTensorData<float>(input_data),
70 kernels::getTensorRuntimeShape(tiso_kernel.input2(), runtime_graph),
71 kernels::getTensorData<int32_t>(size_data),
72 kernels::getTensorRuntimeShape(tiso_kernel.output(), runtime_graph),
73 kernels::getTensorData<float>(output_data));
74 break;
75#endif // DIS_FLOAT
76 default:
77 assert(false && "Unsupported type.");
78 }
79}

References luci_interpreter_pal::ResizeNearestNeighborParams::align_corners, luci_interpreter::RuntimeGraph::getConstDataByTensor(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter_pal::ResizeNearestNeighborParams::half_pixel_centers, luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), luci_interpreter::kernels::TISOKernel::output(), and luci_interpreter::kernels::TISOKernel::readData().

◆ execute_kernel_CircleRound()

void luci_interpreter::execute_kernel_CircleRound ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 37 of file Round.cpp.

38{
39 kernels::SISOKernel kernel(cur_op, runtime_graph);
40
41 const auto *input_data = runtime_graph->getDataByTensor(kernel.input());
42 assert(input_data);
43
44 auto *output_data = runtime_graph->getDataByTensor(kernel.output());
45
46 bool is_inplace = runtime_graph->is_inplace_op(cur_op);
47
48 switch (Tensor::element_type(kernel.input()))
49 {
50#ifndef DIS_FLOAT
51 case DataType::FLOAT32:
52 {
53 const float *input_data_float = kernels::getTensorData<float>(input_data);
54 float *output_data_float = kernels::getTensorData<float>(output_data);
55 if (is_inplace)
56 {
57 output_data_float = const_cast<float *>(input_data_float);
58 }
59
60 assert(output_data_float);
61
62 const int flat_size =
63 kernels::getTensorRuntimeShape(kernel.input(), runtime_graph).flatSize();
64
65 luci_interpreter_pal::Round(flat_size, input_data_float, output_data_float);
66 break;
67 }
68#endif // DIS_FLOAT
69 default:
70 assert(false && "Unsupported type");
71 }
72
73 if (is_inplace)
74 runtime_graph->makeInplaceOperation(kernel.input(), kernel.output());
75}
void Round(const int32_t flat_size, const float *input_data, float *output_data)
Definition PALRound.h:37

References luci_interpreter::RuntimeShape::flatSize(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::SISOKernel::input(), luci_interpreter::RuntimeGraph::is_inplace_op(), luci_interpreter::RuntimeGraph::makeInplaceOperation(), luci_interpreter::kernels::SISOKernel::output(), and luci_interpreter_pal::Round().

◆ execute_kernel_CircleRsqrt()

void luci_interpreter::execute_kernel_CircleRsqrt ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 37 of file Rsqrt.cpp.

38{
39 kernels::SISOKernel kernel(cur_op, runtime_graph);
40
41 const auto *input_data = runtime_graph->getDataByTensor(kernel.input());
42 assert(input_data);
43
44 auto *output_data = runtime_graph->getDataByTensor(kernel.output());
45
46 bool is_inplace = runtime_graph->is_inplace_op(cur_op);
47
48 switch (Tensor::element_type(kernel.input()))
49 {
50#ifndef DIS_FLOAT
51 case DataType::FLOAT32:
52 {
53 const float *input_data_float = kernels::getTensorData<float>(input_data);
54 float *output_data_float = kernels::getTensorData<float>(output_data);
55 if (is_inplace)
56 {
57 output_data_float = const_cast<float *>(input_data_float);
58 }
59
60 assert(output_data_float);
61
62 const int flat_size =
63 kernels::getTensorRuntimeShape(kernel.input(), runtime_graph).flatSize();
64
65 luci_interpreter_pal::Rsqrt(flat_size, input_data_float, output_data_float);
66 break;
67 }
68#endif // DIS_FLOAT
69 default:
70 assert(false && "Unsupported type");
71 }
72
73 if (is_inplace)
74 runtime_graph->makeInplaceOperation(kernel.input(), kernel.output());
75}
void Rsqrt(const int flat_size, const float *input_data, float *output_data)
Definition PALRsqrt.h:27

References luci_interpreter::RuntimeShape::flatSize(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::SISOKernel::input(), luci_interpreter::RuntimeGraph::is_inplace_op(), luci_interpreter::RuntimeGraph::makeInplaceOperation(), luci_interpreter::kernels::SISOKernel::output(), and luci_interpreter_pal::Rsqrt().

◆ execute_kernel_CircleSelectV2()

void luci_interpreter::execute_kernel_CircleSelectV2 ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 105 of file SelectV2.cpp.

106{
107 const auto input_cond_index = cur_op->inputs()->operator[](kInputTensorCondition);
108 const auto input_x_index = cur_op->inputs()->operator[](kInputTensorX);
109 const auto input_y_index = cur_op->inputs()->operator[](kInputTensorY);
110 const auto output_index = cur_op->outputs()->operator[](kOutputTensor);
111
112 assert(input_cond_index != -1);
113 assert(input_x_index != -1);
114 assert(input_y_index != -1);
115 assert(output_index != -1);
116
117 const auto input_cond = runtime_graph->getCircleTensorByIndex(input_cond_index);
118 const auto input_x = runtime_graph->getCircleTensorByIndex(input_x_index);
119 const auto input_y = runtime_graph->getCircleTensorByIndex(input_y_index);
120 const auto output = runtime_graph->getCircleTensorByIndex(output_index);
121
122 assert(input_cond != nullptr);
123 assert(input_x != nullptr);
124 assert(input_y != nullptr);
125
126 bool possible_mixed_scaler =
127 Tensor::num_elements(input_cond) == 1 && Tensor::num_elements(input_x) == 1 &&
128 Tensor::num_elements(input_y) == 1 && Tensor::num_elements(output) == 1;
129
130 bool same_shape = Tensor::num_elements(input_cond) == Tensor::num_elements(input_x) &&
131 Tensor::num_elements(input_x) == Tensor::num_elements(input_y);
132 bool is_broadcast = false;
133 if (not possible_mixed_scaler and not same_shape)
134 is_broadcast = true;
135
136 const auto type = Tensor::element_type(input_x);
137 switch (type)
138 {
139#ifndef DIS_FLOAT
140 case DataType::FLOAT32:
141 CallSelect<float>(input_cond, input_x, input_y, output, is_broadcast, runtime_graph);
142 break;
143#endif // DIS_FLOAT
144 default:
145 assert(false && "Unsupported type.");
146 }
147}

References luci_interpreter::RuntimeGraph::getCircleTensorByIndex().

◆ execute_kernel_CircleShape()

void luci_interpreter::execute_kernel_CircleShape ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 29 of file Shape.cpp.

30{
31 kernels::SISOKernel kernel(cur_op, runtime_graph);
32
33 const circle::Tensor *input = kernel.input();
34 const circle::Tensor *output = kernel.output();
35
36 assert(Tensor::element_type(output) == DataType::S32);
37 int32_t *output_data = kernels::getTensorData<int32_t>(runtime_graph->getDataByTensor(output));
38
39 const int rank = Tensor::num_dims(input);
40 for (int i = 0; i < rank; ++i)
41 {
42 output_data[i] = Tensor::dim(input, i);
43 }
44}

References circle_eval_diff::TensorShape::dim(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::SISOKernel::input(), and luci_interpreter::kernels::SISOKernel::output().

◆ execute_kernel_CircleSin()

void luci_interpreter::execute_kernel_CircleSin ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 37 of file Sin.cpp.

38{
39 kernels::SISOKernel kernel(cur_op, runtime_graph);
40
41 const auto *input_data = runtime_graph->getDataByTensor(kernel.input());
42 assert(input_data);
43
44 auto *output_data = runtime_graph->getDataByTensor(kernel.output());
45
46 bool is_inplace = runtime_graph->is_inplace_op(cur_op);
47
48 switch (Tensor::element_type(kernel.input()))
49 {
50#ifndef DIS_FLOAT
51 case DataType::FLOAT32:
52 {
53 const float *input_data_float = kernels::getTensorData<float>(input_data);
54 float *output_data_float = kernels::getTensorData<float>(output_data);
55 if (is_inplace)
56 {
57 output_data_float = const_cast<float *>(input_data_float);
58 }
59
60 assert(output_data_float);
61
62 const int flat_size =
63 kernels::getTensorRuntimeShape(kernel.input(), runtime_graph).flatSize();
64
65 luci_interpreter_pal::Sin(flat_size, input_data_float, output_data_float);
66 break;
67 }
68#endif // DIS_FLOAT
69 default:
70 assert(false && "Unsupported type");
71 }
72
73 if (is_inplace)
74 runtime_graph->makeInplaceOperation(kernel.input(), kernel.output());
75}
void Sin(const int flat_size, const float *input_data, float *output_data)

References luci_interpreter::RuntimeShape::flatSize(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::SISOKernel::input(), luci_interpreter::RuntimeGraph::is_inplace_op(), luci_interpreter::RuntimeGraph::makeInplaceOperation(), luci_interpreter::kernels::SISOKernel::output(), and luci_interpreter_pal::Sin().

◆ execute_kernel_CircleSlice()

void luci_interpreter::execute_kernel_CircleSlice ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 109 of file Slice.cpp.

110{
111 kernels::MISOKernel kernel(cur_op, runtime_graph);
112
113 bool is_dynamic_shapes = false;
114
115 const circle::Tensor *input = kernel.input1();
116 const circle::Tensor *begin = kernel.input2();
117 const circle::Tensor *size_tensor = kernel.input3();
118 const circle::Tensor *output = kernel.output();
119
120 const auto *input_data = runtime_graph->getDataByTensor(input);
121 if (input_data == nullptr)
122 input_data = runtime_graph->getConstDataByTensor(input);
123 assert(input_data);
124
125 const auto *begin_data = runtime_graph->getDataByTensor(begin);
126 if (begin_data == nullptr)
127 {
128 begin_data = runtime_graph->getConstDataByTensor(begin);
129 is_dynamic_shapes = true;
130 }
131 assert(begin_data);
132
133 const auto *size_data = runtime_graph->getDataByTensor(size_tensor);
134 if (size_data == nullptr)
135 {
136 size_data = runtime_graph->getConstDataByTensor(size_tensor);
137 is_dynamic_shapes = true;
138 }
139 assert(size_data);
140
141 auto *output_data = runtime_graph->getDataByTensor(output);
142 assert(output_data);
143
144 SliceParams op_params{};
145 op_params.begin_count = max_dim;
146 op_params.size_count = max_dim;
147 for (int i = 0; i < max_dim; i++)
148 {
149 op_params.begin[i] = 0;
150 op_params.size[i] = 1;
151 }
152 auto num_dim = Tensor::num_dims(input);
153
154 if (Tensor::element_type(begin) == DataType::S32)
155 {
156 getBeginAndSizeVectors<int32_t>(num_dim, begin_data, size_data, op_params.begin,
157 op_params.size);
158 }
159 else if (Tensor::element_type(begin) == DataType::S64)
160 {
161 getBeginAndSizeVectors<int64_t>(num_dim, begin_data, size_data, op_params.begin,
162 op_params.size);
163 }
164 else
165 {
166 assert(false && "Unsupported type");
167 }
168
169#ifndef DIS_DYN_SHAPES
170 if (is_dynamic_shapes)
171 {
172 int32_t data_size = 1;
173 luci_interpreter::RuntimeShape dynamic_shapes(max_dim - num_dim + 1);
174 int offset = max_dim - Tensor::num_dims(input);
175 for (int i = 0; i <= max_dim - num_dim; ++i)
176 {
177 if (i + offset > 4)
178 return;
179 auto cur_size = op_params.size[i + offset] != -1
180 ? op_params.size[i + offset]
181 : Tensor::dim(input, i) - op_params.begin[i + offset];
182 data_size *= cur_size;
183
184 dynamic_shapes.setDim(i, cur_size);
185 }
186 data_size *= size(Tensor::element_type(output));
187
188 runtime_graph->addDynamicShapeTensor(output, std::move(dynamic_shapes));
189
190 if (data_size == 0)
191 {
192 runtime_graph->resetTensorData(nullptr, output);
193 return;
194 }
195
196 auto new_output_data = new uint8_t[data_size];
197 output_data = new_output_data;
198 runtime_graph->resetTensorData(new_output_data, output);
199 }
200#else
201 assert(is_dynamic_shapes == false);
202#endif // DIS_DYN_SHAPES
203
204 switch (Tensor::element_type(input))
205 {
206#ifndef DIS_FLOAT
207 case DataType::FLOAT32:
208 slice<float>(op_params, kernels::getTensorShape(input),
209 kernels::getTensorData<float>(input_data), kernels::getTensorShape(output),
210 kernels::getTensorData<float>(output_data));
211 break;
212#endif // DIS_FLOAT
213#ifndef DIS_QUANT
214 case DataType::U8:
215 slice<uint8_t>(op_params, kernels::getTensorShape(input),
216 kernels::getTensorData<uint8_t>(input_data), kernels::getTensorShape(output),
217 kernels::getTensorData<uint8_t>(output_data));
218 break;
219 case DataType::S8:
220 slice<int8_t>(op_params, kernels::getTensorShape(input),
221 kernels::getTensorData<int8_t>(input_data), kernels::getTensorShape(output),
222 kernels::getTensorData<int8_t>(output_data));
223 break;
224 case DataType::S16:
225 slice<int16_t>(op_params, kernels::getTensorShape(input),
226 kernels::getTensorData<int16_t>(input_data), kernels::getTensorShape(output),
227 kernels::getTensorData<int16_t>(output_data));
228 break;
229#endif // DIS_QUANT
230 default:
231 assert(false && "Unsupported input type.");
232 }
233}

References luci_interpreter::RuntimeGraph::addDynamicShapeTensor(), begin, circle_eval_diff::TensorShape::dim(), luci_interpreter::RuntimeGraph::getConstDataByTensor(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorShape(), luci_interpreter::kernels::MISOKernel::input1(), luci_interpreter::kernels::MISOKernel::input2(), luci_interpreter::kernels::MISOKernel::input3(), offset(), luci_interpreter::kernels::MISOKernel::output(), luci_interpreter::RuntimeGraph::resetTensorData(), luci_interpreter::RuntimeShape::setDim(), and size.

◆ execute_kernel_CircleSoftmax()

void luci_interpreter::execute_kernel_CircleSoftmax ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 144 of file Softmax.cpp.

145{
146 kernels::SISOKernel kernel(cur_op, runtime_graph);
147
148 const auto *options = cur_op->builtin_options_as_SoftmaxOptions();
149 const auto input_type = Tensor::element_type(kernel.input());
150 switch (input_type)
151 {
152#ifndef DIS_FLOAT
153 case DataType::FLOAT32:
154 evalFloat(kernel.input(), kernel.output(), options, runtime_graph);
155 break;
156#endif // DIS_FLOAT
157#ifndef DIS_QUANT
158 case DataType::S8:
159 case DataType::S16:
160 evalQuantize(kernel.input(), kernel.output(), options, runtime_graph);
161 break;
162#endif
163 default:
164 assert(false && "Unsupported type.");
165 }
166}

References luci_interpreter::kernels::SISOKernel::input(), and luci_interpreter::kernels::SISOKernel::output().

◆ execute_kernel_CircleSpaceToBatchND()

void luci_interpreter::execute_kernel_CircleSpaceToBatchND ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 42 of file SpaceToBatchND.cpp.

44{
45 kernels::MISOKernel kernel(cur_op, runtime_graph);
46 const int32_t pad_value = 0;
47 switch (Tensor::element_type(kernel.input1()))
48 {
49#ifndef DIS_FLOAT
50 case DataType::FLOAT32:
51 {
52 luci_interpreter_pal::SpaceToBatchND(
53 pad_value, kernels::getTensorRuntimeShape(kernel.input1(), runtime_graph),
54 kernels::getTensorData<float>(runtime_graph->getDataByTensor(kernel.input1())),
55 kernels::getTensorRuntimeShape(kernel.input2(), runtime_graph),
56 kernels::getTensorData<int32_t>(runtime_graph->getConstDataByTensor(kernel.input2())),
57 kernels::getTensorRuntimeShape(kernel.input3(), runtime_graph),
58 kernels::getTensorData<int32_t>(runtime_graph->getConstDataByTensor(kernel.input3())),
59 kernels::getTensorRuntimeShape(kernel.output(), runtime_graph),
60 kernels::getTensorData<float>(runtime_graph->getDataByTensor(kernel.output())));
61 break;
62 }
63#endif // DIS_FLOAT
64 default:
65 assert(false && "Unsupported type");
66 }
67}

References luci_interpreter::RuntimeGraph::getConstDataByTensor(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::MISOKernel::input1(), luci_interpreter::kernels::MISOKernel::input2(), luci_interpreter::kernels::MISOKernel::input3(), and luci_interpreter::kernels::MISOKernel::output().

◆ execute_kernel_CircleSpaceToDepth()

void luci_interpreter::execute_kernel_CircleSpaceToDepth ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 52 of file SpaceToDepth.cpp.

54{
55 kernels::SISOKernel kernel(cur_op, runtime_graph);
56
57 const auto *options = cur_op->builtin_options_as_SpaceToDepthOptions();
58 const int32_t block_size = options->block_size();
59
60 switch (Tensor::element_type(kernel.input()))
61 {
62#ifndef DIS_FLOAT
63 case DataType::FLOAT32:
64 {
65 assert(block_size != 0);
66 luci_interpreter_pal::SpaceToDepth(
67 block_size, kernels::getTensorRuntimeShape(kernel.input(), runtime_graph),
68 kernels::getTensorData<float>(runtime_graph->getDataByTensor(kernel.input())),
69 kernels::getTensorRuntimeShape(kernel.output(), runtime_graph),
70 kernels::getTensorData<float>(runtime_graph->getDataByTensor(kernel.output())));
71 break;
72 }
73#endif // DIS_FLOAT
74 default:
75 assert(false && "Unsupported type");
76 }
77}

References luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::SISOKernel::input(), and luci_interpreter::kernels::SISOKernel::output().

◆ execute_kernel_CircleSplit()

void luci_interpreter::execute_kernel_CircleSplit ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 39 of file Split.cpp.

40{
41 const auto input_index = cur_op->inputs()->operator[](1);
42 const auto axis_index = cur_op->inputs()->operator[](0);
43
44 assert(input_index != -1);
45 assert(axis_index != -1);
46
47 const auto input = runtime_graph->getCircleTensorByIndex(input_index);
48 const auto axis = runtime_graph->getCircleTensorByIndex(axis_index);
49
50 assert(input != nullptr);
51 assert(axis != nullptr);
52
53 const auto *axis_data = runtime_graph->getDataByTensor(axis);
54 if (axis_data == nullptr)
55 axis_data = runtime_graph->getConstDataByTensor(axis);
56
57 assert(axis_data);
58
59 int32_t axis_value = (kernels::getTensorData<int32_t>(axis_data))[0];
60 if (axis_value < 0)
61 axis_value += Tensor::num_dims(input);
62
63 assert(axis_value >= 0);
64 assert(axis_value < Tensor::num_dims(input));
65
66 switch (Tensor::element_type(input))
67 {
68#ifndef DIS_FLOAT
69 case DataType::FLOAT32:
70 {
71 return splitImpl<float>(cur_op, input, axis_value, runtime_graph);
72 }
73#endif // DIS_FLOAT
74#ifndef DIS_QUANT
75 case DataType::S8:
76 {
77 return splitImpl<int8_t>(cur_op, input, axis_value, runtime_graph);
78 }
79 case DataType::S16:
80 {
81 return splitImpl<int16_t>(cur_op, input, axis_value, runtime_graph);
82 }
83#endif // DIS_QUANT
84 case DataType::S32:
85 {
86 return splitImpl<int32_t>(cur_op, input, axis_value, runtime_graph);
87 }
88 default:
89 assert(false && "Unsupported type");
90 }
91}

References luci_interpreter::RuntimeGraph::getCircleTensorByIndex(), luci_interpreter::RuntimeGraph::getConstDataByTensor(), and luci_interpreter::RuntimeGraph::getDataByTensor().

◆ execute_kernel_CircleSplitV()

void luci_interpreter::execute_kernel_CircleSplitV ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 38 of file SplitV.cpp.

39{
40 const auto input_index = cur_op->inputs()->operator[](0);
41 const auto axis_index = cur_op->inputs()->operator[](2);
42
43 assert(input_index != -1);
44 assert(axis_index != -1);
45
46 const auto input = runtime_graph->getCircleTensorByIndex(input_index);
47 const auto axis = runtime_graph->getCircleTensorByIndex(axis_index);
48
49 assert(input != nullptr);
50 assert(axis != nullptr);
51
52 const auto *axis_data = runtime_graph->getDataByTensor(axis);
53 if (axis_data == nullptr)
54 axis_data = runtime_graph->getConstDataByTensor(axis);
55
56 assert(axis_data);
57
58 int32_t axis_value = (kernels::getTensorData<int32_t>(axis_data))[0];
59 if (axis_value < 0)
60 axis_value += Tensor::num_dims(input);
61
62 assert(axis_value >= 0);
63 assert(axis_value < Tensor::num_dims(input));
64
65 switch (Tensor::element_type(input))
66 {
67#ifndef DIS_FLOAT
68 case DataType::FLOAT32:
69 {
70 return splitImpl<float>(cur_op, input, axis_value, runtime_graph);
71 }
72#endif // DIS_FLOAT
73#ifndef DIS_QUANT
74 case DataType::S8:
75 {
76 return splitImpl<int8_t>(cur_op, input, axis_value, runtime_graph);
77 }
78 case DataType::S16:
79 {
80 return splitImpl<int16_t>(cur_op, input, axis_value, runtime_graph);
81 }
82#endif // DIS_QUANT
83 case DataType::S32:
84 {
85 return splitImpl<int32_t>(cur_op, input, axis_value, runtime_graph);
86 }
87 default:
88 assert(false && "Unsupported type");
89 }
90}

References luci_interpreter::RuntimeGraph::getCircleTensorByIndex(), luci_interpreter::RuntimeGraph::getConstDataByTensor(), and luci_interpreter::RuntimeGraph::getDataByTensor().

◆ execute_kernel_CircleSqrt()

void luci_interpreter::execute_kernel_CircleSqrt ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 37 of file Sqrt.cpp.

38{
39 kernels::SISOKernel kernel(cur_op, runtime_graph);
40
41 const auto *input_data = runtime_graph->getDataByTensor(kernel.input());
42 assert(input_data);
43
44 auto *output_data = runtime_graph->getDataByTensor(kernel.output());
45
46 bool is_inplace = runtime_graph->is_inplace_op(cur_op);
47
48 switch (Tensor::element_type(kernel.input()))
49 {
50#ifndef DIS_FLOAT
51 case DataType::FLOAT32:
52 {
53 const float *input_data_float = kernels::getTensorData<float>(input_data);
54 float *output_data_float = kernels::getTensorData<float>(output_data);
55 if (is_inplace)
56 {
57 output_data_float = const_cast<float *>(input_data_float);
58 }
59
60 assert(output_data_float);
61
62 const int flat_size =
63 kernels::getTensorRuntimeShape(kernel.input(), runtime_graph).flatSize();
64
65 luci_interpreter_pal::Sqrt(flat_size, input_data_float, output_data_float);
66 break;
67 }
68#endif // DIS_FLOAT
69 default:
70 assert(false && "Unsupported type");
71 }
72
73 if (is_inplace)
74 runtime_graph->makeInplaceOperation(kernel.input(), kernel.output());
75}
void Sqrt(const int flat_size, const float *input_data, float *output_data)
Definition PALSqrt.h:27

References luci_interpreter::RuntimeShape::flatSize(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::SISOKernel::input(), luci_interpreter::RuntimeGraph::is_inplace_op(), luci_interpreter::RuntimeGraph::makeInplaceOperation(), luci_interpreter::kernels::SISOKernel::output(), and luci_interpreter_pal::Sqrt().

◆ execute_kernel_CircleSquare()

void luci_interpreter::execute_kernel_CircleSquare ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 43 of file Square.cpp.

44{
45 kernels::SISOKernel kernel(cur_op, runtime_graph);
46
47 const auto *input_data = runtime_graph->getDataByTensor(kernel.input());
48 assert(input_data);
49
50 auto *output_data = runtime_graph->getDataByTensor(kernel.output());
51
52 bool is_inplace = runtime_graph->is_inplace_op(cur_op);
53
54 switch (Tensor::element_type(kernel.input()))
55 {
56#ifndef DIS_FLOAT
57 case DataType::FLOAT32:
58 {
59 const float *input_data_float = kernels::getTensorData<float>(input_data);
60 float *output_data_float = kernels::getTensorData<float>(output_data);
61 if (is_inplace)
62 {
63 output_data_float = const_cast<float *>(input_data_float);
64 }
65
66 assert(output_data_float);
67
68 const int flat_size =
69 kernels::getTensorRuntimeShape(kernel.input(), runtime_graph).flatSize();
70
71 luci_interpreter_pal::Square(flat_size, input_data_float, output_data_float);
72 break;
73 }
74#endif // DIS_FLOAT
75 default:
76 assert(false && "Unsupported type");
77 }
78
79 if (is_inplace)
80 runtime_graph->makeInplaceOperation(kernel.input(), kernel.output());
81}
void Square(const int flat_size, const float *input_data, float *output_data)

References luci_interpreter::RuntimeShape::flatSize(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::SISOKernel::input(), luci_interpreter::RuntimeGraph::is_inplace_op(), luci_interpreter::RuntimeGraph::makeInplaceOperation(), luci_interpreter::kernels::SISOKernel::output(), and luci_interpreter_pal::Square().

◆ execute_kernel_CircleSquaredDifference()

void luci_interpreter::execute_kernel_CircleSquaredDifference ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 43 of file SquaredDifference.cpp.

45{
46 kernels::TISOKernel kernel(cur_op, runtime_graph);
47
48 const auto *input_data_1 = runtime_graph->getDataByTensor(kernel.input1());
49 const auto *input_data_2 = runtime_graph->getDataByTensor(kernel.input2());
50 assert(input_data_1);
51 assert(input_data_2);
52
53 auto *output_data = runtime_graph->getDataByTensor(kernel.output());
54
55 switch (Tensor::element_type(kernel.input1()))
56 {
57#ifndef DIS_FLOAT
58 case DataType::FLOAT32:
59 {
60 const float *input_data_1_float = kernels::getTensorData<float>(input_data_1);
61 const float *input_data_2_float = kernels::getTensorData<float>(input_data_2);
62 float *output_data_float = kernels::getTensorData<float>(output_data);
63
64 assert(output_data_float);
65
66 const int flat_size =
67 kernels::getTensorRuntimeShape(kernel.input1(), runtime_graph).flatSize();
68
69 luci_interpreter_pal::SquaredDifference(flat_size, input_data_1_float, input_data_2_float,
70 output_data_float);
71 break;
72 }
73#endif // DIS_FLOAT
74 default:
75 assert(false && "Unsupported type");
76 }
77}
void SquaredDifference(const int flat_size, const float *input_data_1, const float *input_data_2, float *output_data)

References luci_interpreter::RuntimeShape::flatSize(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), luci_interpreter::kernels::TISOKernel::output(), and luci_interpreter_pal::SquaredDifference().

◆ execute_kernel_CircleSqueeze()

void luci_interpreter::execute_kernel_CircleSqueeze ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 78 of file Squeeze.cpp.

79{
80 kernels::SISOKernel kernel(cur_op, runtime_graph);
81
82 assert(cur_op->inputs()->size() == 1);
83
84 const circle::Tensor *input = kernel.input();
85 const circle::Tensor *output = kernel.output();
86
87 const uint8_t *input_data = runtime_graph->getDataByTensor(input);
88 uint8_t *output_data = runtime_graph->getDataByTensor(output);
89
90 assert(input_data != nullptr);
91 assert(output_data != nullptr);
92
93 assert(Tensor::num_elements(input) == Tensor::num_elements(output));
94
95 std::memcpy(output_data, input_data,
96 getDataTypeSize(Tensor::element_type(input)) * Tensor::num_elements(input));
97}
size_t getDataTypeSize(DataType data_type)
Definition DataType.h:33

References luci_interpreter::RuntimeGraph::getDataByTensor(), getDataTypeSize(), luci_interpreter::kernels::SISOKernel::input(), and luci_interpreter::kernels::SISOKernel::output().

◆ execute_kernel_CircleStridedSlice()

void luci_interpreter::execute_kernel_CircleStridedSlice ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 75 of file StridedSlice.cpp.

77{
78 kernels::MISOKernel miso_kernel(cur_op, runtime_graph);
79
80 const circle::Tensor *input = miso_kernel.input1();
81 const circle::Tensor *begin = miso_kernel.input2();
82 const circle::Tensor *end = miso_kernel.input3();
83 const circle::Tensor *strides = miso_kernel.input4();
84 const circle::Tensor *output = miso_kernel.output();
85
86 const int32_t dims = Tensor::num_dims(input);
87
88 const uint8_t *input_data = runtime_graph->getDataByTensor(input);
89 const int32_t *begin_data =
90 kernels::getTensorData<int32_t>(runtime_graph->getConstDataByTensor(begin));
91 const int32_t *end_data =
92 kernels::getTensorData<int32_t>(runtime_graph->getConstDataByTensor(end));
93 const int32_t *strides_data =
94 kernels::getTensorData<int32_t>(runtime_graph->getConstDataByTensor(strides));
95 uint8_t *output_data = runtime_graph->getDataByTensor(output);
96
97 LUCI_INTERPRETER_CHECK(input_data != nullptr);
98 LUCI_INTERPRETER_CHECK(begin_data != nullptr);
99 LUCI_INTERPRETER_CHECK(end_data != nullptr);
100 LUCI_INTERPRETER_CHECK(strides_data != nullptr);
101 LUCI_INTERPRETER_CHECK(output_data != nullptr);
102
103 const auto *options = cur_op->builtin_options_as_StridedSliceOptions();
104
105 auto op_params = buildStridedSliceParams(dims, begin_data, end_data, strides_data, options);
106
107 switch (Tensor::element_type(input))
108 {
109#ifndef DIS_FLOAT
110 case DataType::FLOAT32:
111 luci_interpreter_pal::StridedSlice(op_params, kernels::getTensorShape(input),
112 kernels::getTensorData<float>(input_data),
113 kernels::getTensorData<float>(output_data));
114 break;
115#endif // DIS_FLOAT
116#ifndef DIS_QUANT
117 case DataType::U8:
118 luci_interpreter_pal::StridedSlice(op_params, kernels::getTensorShape(input), input_data,
119 output_data);
120 break;
121 case DataType::S8:
122 luci_interpreter_pal::StridedSlice(op_params, kernels::getTensorShape(input), input_data,
123 output_data);
124 break;
125#endif
126 case DataType::S32:
127 luci_interpreter_pal::StridedSlice(op_params, kernels::getTensorShape(input),
128 kernels::getTensorData<int32_t>(input_data),
129 kernels::getTensorData<int32_t>(output_data));
130 break;
131 default:
132 assert(false && "Unsupported type");
133 }
134}
void StridedSlice(StridedSliceParams &op_params, const luci_interpreter::RuntimeShape &unextended_input_shape, const T *input_data, T *output_data)

References begin, luci_interpreter::RuntimeGraph::getConstDataByTensor(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorShape(), luci_interpreter::kernels::MISOKernel::input1(), luci_interpreter::kernels::MISOKernel::input2(), luci_interpreter::kernels::MISOKernel::input3(), luci_interpreter::kernels::MISOKernel::input4(), LUCI_INTERPRETER_CHECK, luci_interpreter::kernels::MISOKernel::output(), and luci_interpreter_pal::StridedSlice().

◆ execute_kernel_CircleSub()

void luci_interpreter::execute_kernel_CircleSub ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 47 of file Sub.cpp.

48{
49 kernels::TISOKernel kernel(cur_op, runtime_graph);
50
51 const auto *options = cur_op->builtin_options_as_SubOptions();
52
54 kernels::getTensorRuntimeShape(kernel.input1(), runtime_graph);
56 kernels::getTensorRuntimeShape(kernel.input2(), runtime_graph);
57
59 kernels::getTensorRuntimeShape(kernel.output(), runtime_graph);
60
61 bool is_inplace = runtime_graph->is_inplace_op(cur_op);
62
63 switch (Tensor::element_type(kernel.input1()))
64 {
65#ifndef DIS_FLOAT
66 case DataType::FLOAT32:
67 {
68 auto tiso_func = luci_interpreter_pal::Sub<float>;
69
70 auto broadcast_tiso_func = luci_interpreter_pal::BroadcastSub4DSlow<float>;
71 if (is_inplace)
72 {
73 kernels::evalTISOInplaceKernel<float>(tiso_func, broadcast_tiso_func, &kernel, options,
74 std::move(input_shape1), std::move(input_shape2),
75 std::move(output_shape));
76 }
77 else
78 {
79 kernels::TISOData kernel_data = kernel.readData();
80 kernels::evalTISOKernel<float>(tiso_func, broadcast_tiso_func, &kernel, &kernel_data,
81 options, std::move(input_shape1), std::move(input_shape2),
82 std::move(output_shape));
83 }
84 }
85 break;
86#endif // DIS_FLOAT
87 case DataType::S64:
88 {
89 auto tiso_func = luci_interpreter_pal::Sub<int64_t>;
90
91 auto broadcast_tiso_func = luci_interpreter_pal::BroadcastSub4DSlow<int64_t>;
92
93 if (is_inplace)
94 {
95 kernels::evalTISOInplaceKernel<int64_t>(tiso_func, broadcast_tiso_func, &kernel, options,
96 std::move(input_shape1), std::move(input_shape2),
97 std::move(output_shape));
98 }
99 else
100 {
101 kernels::TISOData kernel_data = kernel.readData();
102 kernels::evalTISOKernel<int64_t>(tiso_func, broadcast_tiso_func, &kernel, &kernel_data,
103 options, std::move(input_shape1), std::move(input_shape2),
104 std::move(output_shape));
105 }
106 }
107 break;
108 case DataType::S32:
109 {
110 auto tiso_func = luci_interpreter_pal::Sub<int32_t>;
111
112 auto broadcast_tiso_func = luci_interpreter_pal::BroadcastSub4DSlow<int32_t>;
113
114 if (is_inplace)
115 {
116 kernels::evalTISOInplaceKernel<int32_t>(tiso_func, broadcast_tiso_func, &kernel, options,
117 std::move(input_shape1), std::move(input_shape2),
118 std::move(output_shape));
119 }
120 else
121 {
122 kernels::TISOData kernel_data = kernel.readData();
123 kernels::evalTISOKernel<int32_t>(tiso_func, broadcast_tiso_func, &kernel, &kernel_data,
124 options, std::move(input_shape1), std::move(input_shape2),
125 std::move(output_shape));
126 }
127 }
128 break;
129// TODO: fix it
130#if 0
131#ifndef DIS_QUANT
132 case DataType::U8:
133 {
134 auto tiso_func = [](const tflite::ArithmeticParams &params,
135 const tflite::RuntimeShape &input1_shape, const uint8_t *input1_data,
136 const tflite::RuntimeShape &input2_shape, const uint8_t *input2_data,
137 const tflite::RuntimeShape &output_shape, uint8_t *output_data) {
138 tflite::reference_ops::Sub(params, input1_shape, input1_data, input2_shape, input2_data,
139 output_shape, output_data);
140 };
141 auto broadcast_tiso_func =
142 [](const tflite::ArithmeticParams &params, const tflite::RuntimeShape &input1_shape,
143 const uint8_t *input1_data, const tflite::RuntimeShape &input2_shape,
144 const uint8_t *input2_data, const tflite::RuntimeShape &output_shape,
145 uint8_t *output_data) {
146 tflite::reference_ops::BroadcastSubSlow(params, input1_shape, input1_data, input2_shape,
147 input2_data, output_shape, output_data);
148 };
149 if (is_inplace)
150 {
151 kernels::evalTISOInplaceQuantizedKernel<uint8_t>(tiso_func, broadcast_tiso_func, &kernel,
152 options);
153 }
154 else
155 {
156 kernels::TISOData kernel_data = kernel.readData();
157 kernels::evalTISOQuantizedKernel<uint8_t>(tiso_func, broadcast_tiso_func, &kernel,
158 &kernel_data, options);
159 }
160 }
161 break;
162#endif // DIS_QUANT
163#endif // 0
164 default:
165 assert(false && "Unsupported type.");
166 }
167}

References luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), luci_interpreter::RuntimeGraph::is_inplace_op(), luci_interpreter::kernels::TISOKernel::output(), output_shape, and luci_interpreter::kernels::TISOKernel::readData().

◆ execute_kernel_CircleSum()

void luci_interpreter::execute_kernel_CircleSum ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 64 of file Sum.cpp.

65{
66 kernels::TISOKernel kernel(cur_op, runtime_graph);
67 kernels::TISOData tiso_data = kernel.readData();
68
69 const auto *input = kernel.input1();
70 const auto *axis = kernel.input2();
71 const auto *output = kernel.output();
72
73 const auto *options = cur_op->builtin_options_as_ReducerOptions();
74
75 switch (Tensor::element_type(kernel.input1()))
76 {
77#ifndef DIS_FLOAT
78 case DataType::FLOAT32:
79 sumGeneric<float>(&tiso_data, input, axis, output, options->keep_dims());
80 break;
81#endif // DIS_FLOAT
82 default:
83 assert(false && "Unsupported type");
84 }
85}

References luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOKernel::input2(), luci_interpreter::kernels::TISOKernel::output(), and luci_interpreter::kernels::TISOKernel::readData().

◆ execute_kernel_CircleSVDF()

void luci_interpreter::execute_kernel_CircleSVDF ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 125 of file SVDF.cpp.

126{
127 const auto input_index = cur_op->inputs()->operator[](kSvdfInputTensor);
128 const auto weights_feature_index = cur_op->inputs()->operator[](kSvdfWeightsFeatureTensor);
129 const auto weights_time_index = cur_op->inputs()->operator[](kSvdfWeightsTimeTensor);
130 const auto bias_index = cur_op->inputs()->operator[](kSvdfBiasTensor);
131 const auto activation_state_index = cur_op->inputs()->operator[](kSvdfInputActivationStateTensor);
132 const auto output_index = cur_op->outputs()->operator[](kSvdfOutputTensor);
133
134 assert(input_index != -1);
135 assert(weights_feature_index != -1);
136 assert(weights_time_index != -1);
137 assert(activation_state_index != -1);
138 assert(output_index != -1);
139
140 const auto input = runtime_graph->getCircleTensorByIndex(input_index);
141 const auto weights_feature = runtime_graph->getCircleTensorByIndex(weights_feature_index);
142 const auto weights_time = runtime_graph->getCircleTensorByIndex(weights_time_index);
143 const auto bias = runtime_graph->getCircleTensorByIndex(bias_index);
144 const auto activation_state = runtime_graph->getCircleTensorByIndex(activation_state_index);
145 const auto output = runtime_graph->getCircleTensorByIndex(output_index);
146
147 assert(input != nullptr);
148 assert(weights_feature != nullptr);
149 assert(weights_time != nullptr);
150 assert(activation_state != nullptr);
151 assert(output != nullptr);
152
153 const auto *options = cur_op->builtin_options_as_SVDFOptions();
154
155 // Define input constants based on input tensor definition above:
156 const int rank = options->rank();
157 const int input_size = Tensor::dim(input, 1);
158 const int batch_size = Tensor::dim(input, 0);
159 const int num_filters = Tensor::dim(weights_feature, 0);
160 LUCI_INTERPRETER_CHECK(num_filters % rank == 0);
161
162 const int num_units = num_filters / rank;
163 const int memory_size = Tensor::dim(weights_time, 1);
164
165 const uint8_t *input_data = runtime_graph->getDataByTensor(input);
166 const uint8_t *weights_feature_data = runtime_graph->getConstDataByTensor(weights_feature);
167 const uint8_t *weights_time_data = runtime_graph->getConstDataByTensor(weights_time);
168 const uint8_t *bias_data = runtime_graph->getConstDataByTensor(bias);
169 uint8_t *output_data = runtime_graph->getDataByTensor(output);
170
171 const auto type = Tensor::element_type(input);
172 switch (type)
173 {
174#ifndef DIS_FLOAT
175 case DataType::FLOAT32:
176 {
177 // Create and fill with 0 state tensor
178 auto state_data = std::make_unique<float[]>(Tensor::num_elements(activation_state));
179 std::fill_n(state_data.get(), Tensor::num_elements(activation_state), 0);
180
181 auto scratch_data = std::make_unique<uint8_t[]>(batch_size * num_filters * sizeof(float));
182
184 kernels::getTensorData<float>(input_data),
185 kernels::getTensorData<float>(weights_feature_data),
186 kernels::getTensorData<float>(weights_time_data), kernels::getTensorData<float>(bias_data),
187 state_data.get(), kernels::getTensorData<float>(scratch_data.get()),
188 kernels::getTensorData<float>(output_data), rank, input_size, batch_size, num_filters,
189 num_units, memory_size, options->fused_activation_function());
190 }
191 break;
192#endif // DIS_FLOAT
193 default:
194 assert(false && "Unsupported type.");
195 }
196}
void SVDF(const float *input_data, const float *weights_feature_data, const float *weights_time_data, const float *bias_data, float *state_data, float *scratch_data, float *output_data, const int rank, const int input_size, const int batch_size, const int num_filters, const int num_units, const int memory_size, const circle::ActivationFunctionType activation)

References circle_eval_diff::TensorShape::dim(), luci_interpreter::RuntimeGraph::getCircleTensorByIndex(), luci_interpreter::RuntimeGraph::getConstDataByTensor(), luci_interpreter::RuntimeGraph::getDataByTensor(), LUCI_INTERPRETER_CHECK, and luci_interpreter_pal::SVDF().

◆ execute_kernel_CircleTanh()

void luci_interpreter::execute_kernel_CircleTanh ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 156 of file Tanh.cpp.

157{
158 kernels::SISOKernel kernel(cur_op, runtime_graph);
159
160 const auto *input_data = runtime_graph->getDataByTensor(kernel.input());
161 assert(input_data);
162
163 auto *output_data = runtime_graph->getDataByTensor(kernel.output());
164
165 bool is_inplace = runtime_graph->is_inplace_op(cur_op);
166
167 switch (Tensor::element_type(kernel.input()))
168 {
169#ifndef DIS_FLOAT
170 case DataType::FLOAT32:
171 {
172 const float *input_data_float = kernels::getTensorData<float>(input_data);
173 float *output_data_float = kernels::getTensorData<float>(output_data);
174 if (is_inplace)
175 {
176 output_data_float = const_cast<float *>(input_data_float);
177 }
178
179 assert(output_data_float);
180
181 const int flat_size =
182 kernels::getTensorRuntimeShape(kernel.input(), runtime_graph).flatSize();
183
184 luci_interpreter_pal::Tanh(flat_size, input_data_float, output_data_float);
185 break;
186 }
187#endif // DIS_FLOAT
188#ifndef DIS_QUANT
189 case DataType::S16:
190 // TODO: enable it
191#if 0
192 case DataType::S8:
193#endif
194 evalInteger(kernel.input(), kernel.output(), runtime_graph);
195 break;
196#endif // DIS_QUANT
197 default:
198 assert(false && "Unsupported type");
199 }
200
201 if (is_inplace)
202 runtime_graph->makeInplaceOperation(kernel.input(), kernel.output());
203}
void evalInteger(const circle::Tensor *input, const circle::Tensor *output, BaseRuntimeGraph *runtime_graph)
Definition Tanh.cpp:107

References evalInteger(), luci_interpreter::RuntimeShape::flatSize(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::SISOKernel::input(), luci_interpreter::RuntimeGraph::is_inplace_op(), luci_interpreter::RuntimeGraph::makeInplaceOperation(), luci_interpreter::kernels::SISOKernel::output(), and luci_interpreter_pal::Tanh().

◆ execute_kernel_CircleTranspose()

void luci_interpreter::execute_kernel_CircleTranspose ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 45 of file Transpose.cpp.

46{
47 kernels::TISOKernel kernel(cur_op, runtime_graph);
48
49 const circle::Tensor *input = kernel.input1();
50 const circle::Tensor *perm = kernel.input2();
51 const circle::Tensor *output = kernel.output();
52
53 kernels::TISOData tiso_data = kernel.readData();
54 const int32_t *perm_data = kernels::getTensorData<int32_t>(tiso_data.input2_data);
55
56 const int32_t size = Tensor::dim(perm, 0);
58 params.perm_count = size;
59 for (int i = 0; i < size; ++i)
60 params.perm[i] = perm_data[i];
61
62 switch (Tensor::element_type(input))
63 {
64#ifndef DIS_FLOAT
65 case DataType::FLOAT32:
66 luci_interpreter_pal::Transpose(params, kernels::getTensorShape(input),
67 kernels::getTensorData<float>(tiso_data.input1_data),
68 kernels::getTensorShape(output),
69 kernels::getTensorData<float>(tiso_data.output_data));
70 break;
71#endif // DIS_FLOAT
72#ifndef DIS_QUANT
73 case DataType::U8:
74 luci_interpreter_pal::Transpose(params, kernels::getTensorShape(input),
75 kernels::getTensorData<uint8_t>(tiso_data.input1_data),
76 kernels::getTensorShape(output),
77 kernels::getTensorData<uint8_t>(tiso_data.output_data));
78 break;
79#endif // DIS_QUANT
80 default:
81 assert(false && "Unsupported type");
82 }
83}
void Transpose(const TransposeParams &params, const luci_interpreter::RuntimeShape &unextended_input_shape, const T *input_data, const luci_interpreter::RuntimeShape &unextended_output_shape, T *output_data)

References circle_eval_diff::TensorShape::dim(), luci_interpreter::kernels::getTensorShape(), luci_interpreter::kernels::TISOKernel::input1(), luci_interpreter::kernels::TISOData::input1_data, luci_interpreter::kernels::TISOKernel::input2(), luci_interpreter::kernels::TISOData::input2_data, luci_interpreter::kernels::TISOKernel::output(), luci_interpreter::kernels::TISOData::output_data, luci_interpreter_pal::TransposeParams::perm, luci_interpreter_pal::TransposeParams::perm_count, luci_interpreter::kernels::TISOKernel::readData(), size, and luci_interpreter_pal::Transpose().

◆ execute_kernel_CircleTransposeConv()

void luci_interpreter::execute_kernel_CircleTransposeConv ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 135 of file TransposeConv.cpp.

137{
138 const auto input_index = cur_op->inputs()->operator[](kInputTensor);
139 const auto weight_index = cur_op->inputs()->operator[](kFilterTensor);
140 const auto bias_index =
141 cur_op->inputs()->size() == 4 ? cur_op->inputs()->operator[](kBiasTensor) : -1;
142 const auto output_index = cur_op->outputs()->operator[](kOutputTensor);
143
144 assert(input_index != -1);
145 assert(weight_index != -1);
146 assert(output_index != -1);
147
148 const auto input = runtime_graph->getCircleTensorByIndex(input_index);
149 const auto weights = runtime_graph->getCircleTensorByIndex(weight_index);
150 const auto bias = runtime_graph->getCircleTensorByIndex(bias_index);
151 const auto output = runtime_graph->getCircleTensorByIndex(output_index);
152
153 assert(input != nullptr);
154 assert(weights != nullptr);
155 assert(output != nullptr);
156
157 const auto *options = cur_op->builtin_options_as_TransposeConvOptions();
158
159 const auto type = Tensor::element_type(input);
160 switch (type)
161 {
162#ifndef DIS_FLOAT
163 case DataType::FLOAT32:
164 if (Tensor::element_type(weights) == DataType::FLOAT32)
165 {
166 evalFloat(input, weights, bias, output, options, runtime_graph);
167 break;
168 }
169#endif // DIS_FLOAT
170 default:
171 assert(false && "Unsupported type.");
172 }
173}

References luci_interpreter::RuntimeGraph::getCircleTensorByIndex().

◆ execute_kernel_CircleUnidirectionalSequenceLSTM()

void luci_interpreter::execute_kernel_CircleUnidirectionalSequenceLSTM ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 419 of file UnidirectionalSequenceLSTM.cpp.

421{
422 const auto input_index = cur_op->inputs()->operator[](0);
423 assert(input_index != -1);
424
425 bool is_inplace = runtime_graph->is_inplace_op(cur_op);
426
427 const auto input = runtime_graph->getCircleTensorByIndex(input_index);
428
429 switch (Tensor::element_type(input))
430 {
431#ifndef DIS_FLOAT
432 case DataType::FLOAT32:
433 evalFloat(cur_op, runtime_graph, is_inplace);
434 break;
435#endif // DIS_FLOAT
436#ifndef DIS_QUANT
437 case DataType::S8:
438 evalInt8(cur_op, runtime_graph, is_inplace);
439 break;
440#endif // DIS_QUANT
441 default:
442 assert(false && "Unsupported type.");
443 }
444}

References luci_interpreter::RuntimeGraph::getCircleTensorByIndex(), and luci_interpreter::RuntimeGraph::is_inplace_op().

◆ execute_kernel_CircleUnpack()

void luci_interpreter::execute_kernel_CircleUnpack ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 119 of file Unpack.cpp.

120{
121 const auto input_index = cur_op->inputs()->operator[](0);
122 assert(input_index != -1);
123
124 const auto input = runtime_graph->getCircleTensorByIndex(input_index);
125 assert(input != nullptr);
126
127 const auto type = Tensor::element_type(input);
128
129 const auto *options = cur_op->builtin_options_as_UnpackOptions();
130
131 switch (type)
132 {
133#ifndef DIS_FLOAT
134 case DataType::FLOAT32:
135 {
136 UnpackImpl<float>(cur_op, input, options->num(), options->axis(), runtime_graph);
137 break;
138 }
139#endif // DIS_FLOAT
140 default:
141 assert(false && "Unsupported type");
142 }
143}

References luci_interpreter::RuntimeGraph::getCircleTensorByIndex().

◆ execute_kernel_CircleWhile()

void luci_interpreter::execute_kernel_CircleWhile ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 61 of file While.cpp.

62{
63 auto *main_runtime_graph = runtime_graph;
64 auto *runtime_module = runtime_graph->getRuntimeModule();
65
66 const auto input_size = cur_op->inputs()->size();
67
68 std::vector<uint8_t *> operation_inputs_data(input_size);
69 std::vector<uint8_t *> operation_outputs_data;
70
71 std::vector<int32_t> input_sizes(input_size);
72
73 bool is_inplace = runtime_graph->is_inplace_op(cur_op);
74
75 for (int32_t i = 0; i < input_size; ++i)
76 {
77 const auto op_input_index = cur_op->inputs()->operator[](i);
78 const auto op_output_index = cur_op->outputs()->operator[](i);
79 assert(op_input_index != -1);
80 assert(op_output_index != -1);
81 const auto input = main_runtime_graph->getCircleTensorByIndex(op_input_index);
82 const auto output = main_runtime_graph->getCircleTensorByIndex(op_output_index);
83
84 input_sizes[i] = Tensor::num_elements(input) * size(Tensor::element_type(input));
85
86 auto *input_data = main_runtime_graph->getDataByTensor(input);
87
88 uint8_t *tensor_data = nullptr;
89 if (is_inplace)
90 {
91 if (input_data == nullptr)
92 {
93 tensor_data = new uint8_t[input_sizes[i]];
94 input_data = main_runtime_graph->getConstDataByTensor(input);
95 assert(input_data != nullptr);
96 std::memcpy(tensor_data, input_data, input_sizes[i]);
97 }
98 else
99 {
100 tensor_data = input_data;
101 }
102 }
103 else
104 {
105 if (input_data == nullptr)
106 input_data = main_runtime_graph->getConstDataByTensor(input);
107 assert(input_data != nullptr);
108 tensor_data = main_runtime_graph->getDataByTensor(output);
109 assert(tensor_data != nullptr);
110 std::memcpy(tensor_data, input_data, input_sizes[i]);
111 }
112 assert(tensor_data != nullptr);
113
114 operation_inputs_data[i] = tensor_data;
115 }
116
117 const auto *options = cur_op->builtin_options_as_WhileOptions();
118 const auto body_subgraph_index = options->body_subgraph_index();
119 const auto cond_subgraph_index = options->cond_subgraph_index();
120
121 auto *cond_runtime_graph = runtime_module->getRuntimeGraphAt(cond_subgraph_index);
122 auto *body_runtime_graph = runtime_module->getRuntimeGraphAt(body_subgraph_index);
123
124 do
125 {
126 cond_runtime_graph->selectOwnSubgraph();
127
128 for (int32_t i = 0; i < input_size; ++i)
129 cond_runtime_graph->configureGraphInput(i, operation_inputs_data[i]);
130
131 cond_runtime_graph->execute();
132
133 bool cond_value = (cond_runtime_graph->getOutputDataByIndex(0))[0];
134 if (!cond_value)
135 break;
136
137 body_runtime_graph->selectOwnSubgraph();
138 for (int32_t i = 0; i < input_size; ++i)
139 body_runtime_graph->configureGraphInput(i, operation_inputs_data[i]);
140
141 body_runtime_graph->execute();
142
143 for (int32_t i = 0; i < input_size; ++i)
144 {
145 auto cur_output_body_data = body_runtime_graph->getOutputDataByIndex(i);
146 if (cur_output_body_data == nullptr)
147 continue;
148 std::memcpy(operation_inputs_data[i], cur_output_body_data, input_sizes[i]);
149 }
150 } while (true);
151
152 cond_runtime_graph->resetOutputTensorsData();
153 cond_runtime_graph->clearTensors();
154
155 body_runtime_graph->selectOwnSubgraph();
156 body_runtime_graph->resetOutputTensorsData();
157 body_runtime_graph->clearTensors();
158
159 main_runtime_graph->selectOwnSubgraph();
160
161 if (is_inplace)
162 {
163 for (int32_t i = 0; i < input_size; ++i)
164 {
165 const auto op_input_index = cur_op->inputs()->operator[](i);
166 const auto op_output_index = cur_op->outputs()->operator[](i);
167 assert(op_input_index != -1);
168 assert(op_output_index != -1);
169 const auto input = main_runtime_graph->getCircleTensorByIndex(op_input_index);
170 const auto output = main_runtime_graph->getCircleTensorByIndex(op_output_index);
171
172 if (main_runtime_graph->getDataByTensor(input))
173 {
174 main_runtime_graph->makeInplaceOperation(input, output);
175 }
176 else
177 {
178 main_runtime_graph->setDataToTensor(output, operation_inputs_data[i]);
179 }
180 }
181 }
182}
list input_data
Definition infer.py:29

References luci_interpreter::RuntimeGraph::getRuntimeModule(), luci_interpreter::RuntimeGraph::is_inplace_op(), and size.

◆ execute_kernel_CircleZerosLike()

void luci_interpreter::execute_kernel_CircleZerosLike ( const circle::Operator *  cur_op,
BaseRuntimeGraph runtime_graph 
)

Definition at line 46 of file ZerosLike.cpp.

47{
48 kernels::SISOKernel kernel(cur_op, runtime_graph);
49
50 const auto *input_data = runtime_graph->getDataByTensor(kernel.input());
51 assert(input_data);
52
53 auto *output_data = runtime_graph->getDataByTensor(kernel.output());
54
55 bool is_inplace = runtime_graph->is_inplace_op(cur_op);
56
57 if (is_inplace)
58 output_data = const_cast<uint8_t *>(input_data);
59
60 const int flat_size = kernels::getTensorRuntimeShape(kernel.input(), runtime_graph).flatSize();
61
62 assert(output_data);
63
64 switch (Tensor::element_type(kernel.input()))
65 {
66#ifndef DIS_FLOAT
67 case DataType::FLOAT32:
68 {
69 resetZeros(kernels::getTensorData<float>(output_data), flat_size);
70 break;
71 }
72#endif // DIS_FLOAT
73 default:
74 assert(false && "Unsupported type");
75 }
76
77 if (is_inplace)
78 runtime_graph->makeInplaceOperation(kernel.input(), kernel.output());
79}

References luci_interpreter::RuntimeShape::flatSize(), luci_interpreter::RuntimeGraph::getDataByTensor(), luci_interpreter::kernels::getTensorRuntimeShape(), luci_interpreter::kernels::SISOKernel::input(), luci_interpreter::RuntimeGraph::is_inplace_op(), luci_interpreter::RuntimeGraph::makeInplaceOperation(), and luci_interpreter::kernels::SISOKernel::output().

◆ get_builder_id()

constexpr BuilderID luci_interpreter::get_builder_id ( circle::BuiltinOperator  opcode)
constexpr

Definition at line 43 of file KernelBuilder.h.

44{
45 switch (opcode)
46 {
47#define REGISTER_KERNEL(builtin_operator, name) \
48 case circle::BuiltinOperator_##builtin_operator: \
49 return BuilderID::BuiltinOperator_##builtin_operator;
50
51#if USE_GENERATED_LIST
52#include "GeneratedKernelsToBuild.lst"
53#else
54#include "KernelsToBuild.lst"
55#endif
56
57#undef REGISTER_KERNEL
58 default:
59 assert(false && "Unsupported operation");
60 }
61}

◆ getDataTypeSize()

◆ luci_actfunc()

FusedActFunc luci_interpreter::luci_actfunc ( circle::ActivationFunctionType  type)

Definition at line 55 of file CircleMicroReader.cpp.

56{
57 switch (type)
58 {
59 case circle::ActivationFunctionType::ActivationFunctionType_NONE:
60 return FusedActFunc::NONE;
61 case circle::ActivationFunctionType::ActivationFunctionType_RELU:
62 return FusedActFunc::RELU;
63 case circle::ActivationFunctionType::ActivationFunctionType_RELU_N1_TO_1:
64 return FusedActFunc::RELU_N1_TO_1;
65 case circle::ActivationFunctionType::ActivationFunctionType_RELU6:
66 return FusedActFunc::RELU6;
67 case circle::ActivationFunctionType::ActivationFunctionType_TANH:
68 return FusedActFunc::TANH;
69 case circle::ActivationFunctionType::ActivationFunctionType_SIGN_BIT:
70 return FusedActFunc::SIGN_BIT;
71 default:
72 break;
73 }
74 assert(false);
75 return FusedActFunc::UNDEFINED;
76}

References NONE, RELU, RELU6, RELU_N1_TO_1, SIGN_BIT, TANH, and UNDEFINED.

◆ luci_datatype()

DataType luci_interpreter::luci_datatype ( circle::TensorType  type)

Definition at line 26 of file CircleMicroReader.cpp.

27{
28 switch (type)
29 {
30 case circle::TensorType_FLOAT32:
31 return DataType::FLOAT32;
32 case circle::TensorType_FLOAT16:
33 return DataType::FLOAT16;
34 case circle::TensorType_INT32:
35 return DataType::S32;
36 case circle::TensorType_UINT8:
37 return DataType::U8;
38 case circle::TensorType_INT64:
39 return DataType::S64;
40 case circle::TensorType_BOOL:
41 return DataType::BOOL;
42 case circle::TensorType_INT16:
43 return DataType::S16;
44 case circle::TensorType_COMPLEX64:
45 break;
46 case circle::TensorType_INT8:
47 return DataType::S8;
48 default:
49 break;
50 }
51 assert(false);
52 return DataType::Unknown;
53}

◆ luci_mirrorpad_mode()

MirrorPadMode luci_interpreter::luci_mirrorpad_mode ( circle::MirrorPadMode  mode)

Definition at line 91 of file CircleMicroReader.cpp.

92{
93 switch (mode)
94 {
95 case circle::MirrorPadMode::MirrorPadMode_REFLECT:
96 return MirrorPadMode::REFLECT;
97 case circle::MirrorPadMode::MirrorPadMode_SYMMETRIC:
98 return MirrorPadMode::SYMMETRIC;
99 }
100 assert(false);
101 return MirrorPadMode::UNDEFINED;
102}

◆ luci_padding()

Padding luci_interpreter::luci_padding ( circle::Padding  padding)

Definition at line 78 of file CircleMicroReader.cpp.

79{
80 switch (padding)
81 {
82 case circle::Padding::Padding_SAME:
83 return Padding::SAME;
84 case circle::Padding::Padding_VALID:
85 return Padding::VALID;
86 }
87 assert(false);
88 return Padding::UNDEFINED;
89}

◆ REGISTER_WRAPPER() [1/8]

luci_interpreter::REGISTER_WRAPPER ( flatbuffers::Offset< circle::Buffer >  )

◆ REGISTER_WRAPPER() [2/8]

luci_interpreter::REGISTER_WRAPPER ( flatbuffers::Offset< circle::Metadata >  )

◆ REGISTER_WRAPPER() [3/8]

luci_interpreter::REGISTER_WRAPPER ( flatbuffers::Offset< circle::Operator >  )

◆ REGISTER_WRAPPER() [4/8]

luci_interpreter::REGISTER_WRAPPER ( flatbuffers::Offset< circle::OperatorCode >  )

◆ REGISTER_WRAPPER() [5/8]

luci_interpreter::REGISTER_WRAPPER ( flatbuffers::Offset< circle::SubGraph >  )

◆ REGISTER_WRAPPER() [6/8]

luci_interpreter::REGISTER_WRAPPER ( flatbuffers::Offset< circle::Tensor >  )

◆ REGISTER_WRAPPER() [7/8]

luci_interpreter::REGISTER_WRAPPER ( int32_t  )

◆ REGISTER_WRAPPER() [8/8]

luci_interpreter::REGISTER_WRAPPER ( uint8_t  )

◆ size()

uint32_t luci_interpreter::size ( DataType  data_type)
inline

Returns the size of the data type.

Note
If you need the size at compile time, use sizeof(typename DataTypeImpl<DT>::Type).

Definition at line 141 of file DataType.h.

142{
143 switch (data_type)
144 {
145 case DataType::S8:
147 case DataType::U8:
149 case DataType::S16:
151 case DataType::U16:
153 case DataType::S32:
155 case DataType::U32:
157 case DataType::S64:
159 case DataType::U64:
161 case DataType::FLOAT16:
163 case DataType::FLOAT32:
165 case DataType::FLOAT64:
167 case DataType::BOOL:
169 default:
170 // TODO Support remaining data types.
171 assert(false);
172 return UINT32_MAX; // Avoid compiler warning.
173 }
174}
C++ scalar type corresponding to each DataType.
Definition DataType.h:58

◆ source_without_constant_copying()

std::unique_ptr< luci::GraphBuilderSource > luci_interpreter::source_without_constant_copying ( )

Creates and returns GraphBuilderSource, which allows to not copy constant buffers from model's file.

Warning
Use this source only in case when model's buffer alive longer than Interpreter.

Definition at line 22 of file GraphBuilderRegistry.cpp.

23{
24 auto builder = std::make_unique<luci::GraphBuilderRegistry>();
25 {
26 // redefine NodeBuilder of BUFFER type
27 builder->add(std::make_unique<CircleReferencingConstNodeBuilder>());
28 }
29
30 return builder;
31}

Referenced by entry().

◆ splitImpl()

template<typename T >
void luci_interpreter::splitImpl ( const circle::Operator *  cur_op,
const circle::Tensor *  input,
int  axis_value,
BaseRuntimeGraph runtime_graph 
)

Definition at line 27 of file Split.h.

29{
30 const int output_count = cur_op->outputs()->size();
31
32 const auto output0_index = cur_op->outputs()->operator[](0);
33 assert(output0_index != -1);
34
35 const auto output0 = runtime_graph->getCircleTensorByIndex(output0_index);
36 assert(output0 != nullptr);
37
38 const int split_dimensions = Tensor::num_dims(input);
39
40 assert(axis_value < split_dimensions);
41 assert(Tensor::num_dims(output0) == split_dimensions);
42
43 int64_t outer_size = 1;
44 for (int i = 0; i < axis_value; ++i)
45 {
46 outer_size *= Tensor::dim(input, i);
47 }
48
49 int64_t base_inner_size = 1;
50 for (int i = axis_value + 1; i < split_dimensions; ++i)
51 {
52 base_inner_size *= Tensor::dim(input, i);
53 }
54
55 const T *input_ptr = kernels::getTensorData<T>(runtime_graph->getDataByTensor(input));
56 assert(input_ptr != nullptr);
57 for (int k = 0; k < outer_size; ++k)
58 {
59 for (int i = 0; i < output_count; ++i)
60 {
61 const auto output_index = cur_op->outputs()->operator[](i);
62 assert(output_index != -1);
63
64 const auto output = runtime_graph->getCircleTensorByIndex(output_index);
65 assert(output != nullptr);
66
67 T *output_data = kernels::getTensorData<T>(runtime_graph->getDataByTensor(output));
68 assert(output_data != nullptr);
69 const int copy_size = Tensor::dim(output, axis_value) * base_inner_size;
70 T *output_ptr = output_data + k * copy_size;
71 assert(output_ptr != nullptr);
72 for (int j = 0; j < copy_size; ++j)
73 output_ptr[j] = input_ptr[j];
74 input_ptr += copy_size;
75 }
76 }
77}

References circle_eval_diff::TensorShape::dim(), luci_interpreter::RuntimeGraph::getCircleTensorByIndex(), and luci_interpreter::RuntimeGraph::getDataByTensor().

◆ wrap()

template<typename T >
VectorWrapper< T > luci_interpreter::wrap ( const flatbuffers::Vector< T > *  vec)

Definition at line 146 of file CircleMicroReader.h.

147{
148 return VectorWrapper<T>(vec);
149}
Wrapper to use flatbuffers::Vector pointer as std::vector entity.

Variable Documentation

◆ kernel_configure

constexpr KernelConfigureRegistry luci_interpreter::kernel_configure
constexpr

Definition at line 199 of file KernelBuilder.h.

Referenced by luci_interpreter::RuntimeGraph::configure().

◆ kernel_executor

constexpr KernelExecuteRegistry luci_interpreter::kernel_executor
constexpr

Definition at line 200 of file KernelBuilder.h.

Referenced by luci_interpreter::RuntimeGraph::execute().