Rockchip · AI & Linux Hub

AI inference

RKNN2 V2.5.0 · RV1103/RV1106:Recurrent networks, arithmetic and pooling

RKNN2 V2.5.0 · RV1103/RV1106:Recurrent networks, arithmetic and pooling · Complete operator parameters and constraints from the V2.5.0 source.

· ArmSoM Editorial · Rockchip source documentation · 13 min read

This RKNN2 V2.5.0 platform reference helps ArmSoM developers select and adapt models. It does not establish support on every ArmSoM board: verify the board SoC, actual Toolkit2, Runtime, NPU driver and BSP versions. The source specifies no universal Linux kernel version. No ArmSoM hardware validation was performed.

Source: the supplied Chinese and English RKNN2 Supported Operators and Constraints Reference V2.5.0, 374 and 384 pages respectively. Chinese follows the Chinese edition; English, Russian and German follow the English edition. Platform constraints remain separate. The English PDF itself contains Chinese I/O figures and output tables; their provenance is retained with editable localized tables. Source spellings such as ConvTranpose and the original LSTM/GRU equations are preserved; these equations are not corrections to SDK implementations.

Source pages: CN 184–198; EN 189–204.

Rockchip RKNN2

Operator reference series

RKNN2 V2.5.0 · RK3566/RK3568:Basics and convolution

RKNN2 V2.5.0 · RK3566/RK3568:Recurrent networks, arithmetic and pooling

RKNN2 V2.5.0 · RK3566/RK3568:Shapes, slicing and transpose

RKNN2 V2.5.0 · RK3566/RK3568:Activations, normalization and extensions

RKNN2 V2.5.0 · RK3588:Basics and convolution

RKNN2 V2.5.0 · RK3588:Recurrent networks, arithmetic and pooling

RKNN2 V2.5.0 · RK3588:Shapes, slicing and transpose

RKNN2 V2.5.0 · RK3588:Activations, normalization and extensions

RKNN2 V2.5.0 · RK3562:Basics and convolution

RKNN2 V2.5.0 · RK3562:Recurrent networks, arithmetic and pooling

RKNN2 V2.5.0 · RK3562:Shapes, slicing and transpose

RKNN2 V2.5.0 · RK3562:Activations, normalization and extensions

RKNN2 V2.5.0 · RV1103/RV1106:Basics and convolution

RKNN2 V2.5.0 · RV1103/RV1106:Recurrent networks, arithmetic and pooling

RKNN2 V2.5.0 · RV1103/RV1106:Shapes, slicing and transpose

RKNN2 V2.5.0 · RV1103/RV1106:Activations, normalization and extensions

RKNN2 V2.5.0 · RK3576/RV1126B:Basics and convolution

RKNN2 V2.5.0 · RK3576/RV1126B:Recurrent networks, arithmetic and pooling

RKNN2 V2.5.0 · RK3576/RV1126B:Shapes, slicing and transpose

RKNN2 V2.5.0 · RK3576/RV1126B:Activations, normalization and extensions

RKNN2 V2.5.0 · RK2118:Basics and convolution

RKNN2 V2.5.0 · RK2118:Recurrent networks, arithmetic and pooling

RKNN2 V2.5.0 · RK2118:Shapes, slicing and transpose

RKNN2 V2.5.0 · RK2118:Activations, normalization and extensions

RKNN2 V2.5.0 · RV1103B/RV1106B:Basics and convolution

RKNN2 V2.5.0 · RV1103B/RV1106B:Recurrent networks, arithmetic and pooling

RKNN2 V2.5.0 · RV1103B/RV1106B:Shapes, slicing and transpose

RKNN2 V2.5.0 · RV1103B/RV1106B:Activations, normalization and extensions

RKNN2 V2.5.0 · CPU operator support and constraints

RKNN2 V2.5.0 · GPU operator support and constraints

RKNN2 V2.5.0 · Model I/O, alignment and convolution limits

Div

Performs element-wise binary division (C=A/B), supporting multi-directional NumPy-style broadcasting

Inputs

  • A:T1,T2
    • shape:[batch,channel,height,width]
    • Quantization support
      • per-layer
    • Broadcasting support
      • Supports broadcasting along arbitrary dimensions
      • Broadcasting constraints are the same as the Expand operator
  • B:T1,T2
    • shape:[batch,channel,height,width]
    • Quantization support
      • per-layer
    • Broadcasting support
      • Supports broadcasting along arbitrary dimensions
      • Broadcasting constraints are the same as the Expand operator

Outputs

  • C:T1
    • shape:[batch,channel,height,width]
    • Quantization support
      • per-layer

Data Type Constraints

  • T1:float16(Tensor)
  • T2:float(constTensor)

Expand

Broadcast the input tensor according to the given shape and broadcasting rules. The broadcasting rule is similar to numpy.array(input) * numpy.ones(shape): dimensions are right- aligned; two corresponding dimensions must have the same value, or one of them equals 1

Inputs

  • input:T1
    • shape:[batch,channel,height,width]
    • Quantization support
      • per-layer
  • shape:T2
    • shape:[batch,channel,height,width]

Outputs

  • output:T1
    • shape:[batch,channel,height,width]
    • Quantization support
      • per-layer

Data Type Constraints

  • T1:int8(Tensor)
  • T2:int64(Tensor)

Broadcasting constraints

  • [b,c,1,w]->[b,c,h,w],h∈[1,8192]
  • [b,1,1,w]->[b,c,h,w],h∈[1,8192]
  • [b,c,h,1]->[b,c,h,w],w ∈[1,8192]
  • [b,1,h,1]->[b,c,h,w],w ∈[1,8192]
  • [b,c,1,1]->[b,c,h,w],h∈[1,8192],w ∈[1,8192]

Hardmax

Inputs

  • input:T1
    • shape:[batch,channel,height,width]
      • channel∗height∗width<=8192
      • axis=1, height∗width<16384 and height∗width equal to 1 or greater than 8;
      • axis=3/-1, channel ∗ height < 16384, and channel ∗ height equal to 1 or greater than 8, and subject to the transpose specification constraints

Outputs

  • output:T1
    • shape:[batch,channel,height,width]

Data Type Constraints

  • T1:int8(Tensor),float16(Tensor)

Attributes

  • axis:int
    • The axis for hardmax: 1,3/-1, i.e., channel and width directions

Other Support

  • Multi-core: Not yet supported

LSTM

Long Short-Term Memory (LSTM). LSTM extensions and variants are named exLSTM operators. Parameter items marked (extern) are parameters exclusive to exLSTM. The computation formulas are as follows:

Equations(Default:f=Sigmoid,g=Tanh,h=Tanh):
i_t = f(x_t · W_i + h_{t−1} · R_i + Wb_i + Rb_i)
f_t = f(x_t · W_f + h_{t−1} · R_f + Wb_f + Rb_f)
c_t = f(x_t · W_c + h_{t−1} · R_c + Wb_c + Rb_c)
o_t = f(x_t · W_o + h_{t−1} · R_o + Wb_o + Rb_o)
C_t = f_t ⊙ C_{t−1} + i_t ⊙ c_t
h_t = o_t ⊙ h(C_t)

Inputs

  • X:T1
    • shape:[seq_length,batch_size,input_size]
      • seqlength∈(0,8192]
      • batchsize∈(0,8192], when greater than 1, only multiples of 4 are supported
      • inputsize∈(0,8192]
    • Quantization support
      • per-layer
  • W:T1
    • shape:[num_directions,4*hidden_size,input_size]
      • inputsize∈(0,8192]
      • hiddensize∈(0,8192]
      • numdirections:1or2
    • Quantization support
      • per-layer
      • per-channel
  • R:T1
    • shape:[num_directions,4*hidden_size,hidden_size]
      • hiddensize∈(0,8192]
      • numdirections:1or2
    • Quantization support
      • per-layer
      • per-channel
  • B:T2
    • shape:[num_directions,8*hidden_size]
      • hiddensize∈(0,8192]
      • numdirections:1or2
    • Quantization support
      • per-layer
      • per-channel
  • sequence_lens:T3(optional)
    • shape:[batch_size]
      • batchsize∈(0,8192], when greater than 1, only multiples of 4 are supported
  • initial_h:T1(optional)
    • shape:[num_directions,batch_size,hidden_size]
      • numdirections:1or2
      • batchsize∈(0,8192], when greater than 1, only multiples of 4 are supported
      • hiddensize∈(0,8192]
    • Quantization support
      • per-layer
  • initial_c:T3(optional)
    • shape:[num_directions,batch_size,hidden_size]
      • numdirections:1or2
      • batchsize∈(0,8192], when greater than 1, only multiples of 4 are supported
      • hiddensize∈(0,8192]
    • Quantization support
      • per-layer

Outputs

  • Y:T1
    • shape:[seq_length,num_directions,batch_size,hidden_size]
      • seqlength∈(0,8192]
      • numdirections:1or2
      • batchsize∈(0,8192], when greater than 1, only multiples of 4 are supported
      • hiddensize∈(0,8192]
    • Quantization support
      • per-layer
  • Y_h:T1(optional)
    • shape:[num_directions,batch_size,hidden_size]
      • numdirections:1or2
      • batchsize∈(0,8192], when greater than 1, only multiples of 4 are supported
      • hiddensize∈(0,8192]
    • Quantization support
      • per-layer
  • Y_c:T1(optional)
    • shape:[num_directions,batch_size,hidden_size]
      • numdirections:1or2
      • batchsize∈(0,8192], when greater than 1, only multiples of 4 are supported
      • hiddensize∈(0,8192]
    • Quantization support
      • per-layer

Attributes

  • direction(extern):string
    • Specifies the computation direction of the LSTM
    • forward: specifies the computation direction of the LSTM as forward
    • reverse: specifies the computation direction of the LSTM as reverse
    • bidirectional: specifies the computation direction of the LSTM as bidirectional
  • sequence_size(extern):int
    • The seqsize of the LSTM input, no limitation, 4-alignment recommended
  • hidden_size(extern):int
    • The hiddensize in the LSTM cell, no limitation, 8-alignment recommended
  • proj_size(extern):int
    • The proj_size for projection, projsize∈[0,hiddensize]
    • Currently limited to 0, i.e. projection is not yet supported
  • input_forget(extern):int
    • cifgvariant selection: 1(T) or 0(F), currently limited to 0, i.e. not yet supported
  • has_projection(extern):int
    • projection variant: 1(T) or 0(F), currently limited to 0, i.e. not yet supported
  • input_layout(extern):int
    • Specifies the layout consistent with the meaning of the corresponding input shape
    • Requires filling in the specified layout, and also requires filling in the batch_size, sequence_size, hidden_size。
    • snc: specifies the input shape corresponding to the layout as [seqs,batches,input_size]
    • (sn)c: specifies the input shape corresponding to the layout as [seqs*batches,input_size,1,1]
  • output_layout(extern):int
    • Specifies the layout consistent with the meaning of the corresponding output shape
    • Requires filling in the specified layout, and also requires filling in the batch_size, sequence_size, hidden_size、directions。
    • sbnc: specifies the output shape corresponding to the layout as [seqs,directions,batches,hidden_size]
    • (sn)c: specifies the output shape corresponding to the layout as [seqsbatches,directionsinput_size,1,1]

Data Type Constraints

  • T1:int8(Tensor)
  • T2:int32(Tensor)
  • T3:int(Scalar)

Other Support

  • Multi-core: Not yet supported

Max

Computes the element-wise maximum value of the input tensor

Inputs

  • A:T1
    • shape:[batch,channel,height,width]
    • Quantization support
      • per-layer
    • Broadcasting support
      • Supports broadcasting along arbitrary dimensions
      • Broadcasting constraints are the same as the Expand operator
  • B:T1
    • shape:[batch,channel,height,width]
    • Quantization support
      • per-layer
    • Broadcasting support
      • Supports broadcasting along arbitrary dimensions
      • Broadcasting constraints are the same as the Expand operator

Outputs

  • C:T1
    • shape:[batch,channel,height,width]
    • Quantization support
      • per-layer/per-channel

Data Type Constraints

  • T1:int8(Tensor),float16(Tensor)

Other Support

  • Multi-core: Not yet supported

Min

Computes the element-wise minimum value of the input tensor

Inputs

  • A:T1
    • shape:[batch,channel,height,width]
    • Quantization support
      • per-layer
    • Broadcasting support
      • Supports broadcasting along arbitrary dimensions
      • Broadcasting constraints are the same as the Expand operator
  • B:T1
    • shape:[batch,channel,height,width]
    • Quantization support
      • per-layer
    • Broadcasting support
      • Supports broadcasting along arbitrary dimensions
      • Broadcasting constraints are the same as the Expand operator

Outputs

  • C:T1
    • shape:[batch,channel,height,width]
    • Quantization support
      • per-layer/per-channel

Data Type Constraints

  • T1:int8(Tensor),float16(Tensor)

Other Support

  • Multi-core: Not yet supported

Mul

Performs element-wise binary multiplication (C=A*B), supporting multi-directional NumPy-style broadcasting

Inputs

  • A:T1,T2
    • shape:[batch,channel,height,width]
    • Quantization support
      • per-layer
    • Broadcasting support
      • Supports broadcasting along arbitrary dimensions
      • Broadcasting constraints are the same as the Expand operator
  • B:T1,T2
    • shape:[batch,channel,height,width]
    • Quantization support
      • per-layer
    • Broadcasting support
      • Supports broadcasting along arbitrary dimensions
      • Broadcasting constraints are the same as the Expand operator

Outputs

  • C:T1
    • shape:[batch,channel,height,width]
    • Quantization support
      • per-layer

Data Type Constraints

  • T1:int8(Tensor)
  • T2:float(constTensor)

MulRelu

Mul and Relu fused computation, C=Relu(A*B)

Inputs

  • Same as Mul

Outputs

  • Same as Mul

Other Support

  • Multi-core: Supported

Pad

Given a tensor (data) containing the data to be padded, a tensor (pads) containing the start and end padding values for each axis, a mode (mode), and a constant value (constant_value), generate a padded tensor (output)

Inputs

  • data:T1
    • shape:[batch,channel,height,width]
    • Quantization support
      • per-layer
  • pads:T2
    • shape : [batch_begin, channel_begin, height_begin, width_begin, batch_end, channel_end,height_end,width_end]
  • constant_value(optional):T3
    • shape:[1]
    • Quantization support
      • per-layer

Outputs

  • output:T1
    • shape:[batch,channel,height,width]
    • Quantization support
      • per-layer

Data Type Constraints

  • T1:int8(Tensor)
  • T2:int64(Tensor)
  • T3:float(Scalar),int8(Scalar),float16(Scalar)

Attributes

  • mode: string (default value constant)
    • Supported modes: constant, reflect
      • constantNo limitation
      • reflectchannel∈(0,8192],height∈(0,8192],width∈(0,8176]

Other Support

  • Multi-core: Not yet supported

MaxPool

MaxPool consumes an input tensor X and applies max pooling to the tensor according to kernel size, stride size, and padding length. Max pooling consists of computing the maximum over all values of a subset of the input tensor according to the kernel size, and downsampling the data into output tensor Y for further processing. The output spatial shape calculation differs depending on whether explicit padding (when using pads) or automatic padding (when using auto_pad) is used. Only explicit padding is used

Inputs

  • input:T1
    • shape:[batch,channel,height,width]
      • channel∈(0,8192]
      • height∈(0,8192]
      • width∈(0,8192]

Outputs

  • output:T1
    • shape:[batch,channel,height,width]

Attributes

  • kernel_shape:int64(kernel_h,kernel_w)
    • kernel_h∈(0,7]
    • kernel_w∈(0,7]
  • auto_pad:string
    • Padding mode: only NOTSET is supported
  • ceil_mode:int64
    • Whether to use ceil or floor to compute the output shape: not supported
  • strides:int64(strides_h,strides_w)
    • strides_h∈(0,8]
    • strides_w∈(0,8]
  • count_include_pad:int64[]
    • count_include_pad, whether to include pad values in computation: 1
  • pad:int64(pad_top,pad_left,pad_bottom,pad_right)
    • pad_top∈[0,7]
    • pad_left∈[0,7]
    • pad_bottom∈[0,7]
    • pad_right∈[0,7]
  • storage_order:int64[]
    • The preferred storage mode: 0

Data Type Constraints

  • T1:int8(Tensor),float16(Tensor)
  • T2:float(Tensor)
  • T3:float(Scalar)

GlobalMaxPool

GlobalMaxPool consumes an input tensor X and applies max pooling over the values in the same channel. This is equivalent to a MaxPool with kernel_shape equal to the spatial dimensions of the input.

Inputs

  • input:T1
    • shape:[batch,channel,height,width]
      • channel∈(0,8192]
      • height∈(0,7]
      • width∈(0,7]

Outputs

  • output:T1
    • shape:[batch,channel,height,width]

Attributes

  • kernel_shape:int64(kernel_h,kernel_w)
    • kernel_h∈(0,7]
    • kernel_w∈(0,7]
  • auto_pad:string
    • Padding mode: only NOTSET is supported
  • ceil_mode:int64
    • Whether to use ceil or floor to compute the output shape: not supported
  • strides:int64(strides_h,strides_w)
    • strides_h∈(0,8]
    • strides_w∈(0,8]
  • count_include_pad:int64[]
    • count_include_pad, whether to include pad values in computation: 1
  • pad:int64(pad_top,pad_left,pad_bottom,pad_right)
    • pad_top∈[0,7]
    • pad_left∈[0,7]
    • pad_bottom∈[0,7]
    • pad_right∈[0,7]

Data Type Constraints

  • T1:int8(Tensor),float16(Tensor)
  • T2:float(Tensor)
  • T3:float(Scalar)

AveragePool

AveragePool consumes an input tensor X and applies average pooling to the tensor according to kernel size, stride size, and padding length. Average pooling consists of computing the average over all values of a subset of the input tensor according to the kernel size, and downsampling the data into output tensor Y for further processing. The output spatial shape calculation differs depending on whether explicit padding (when using pads) or automatic padding (when using auto_pad) is used. Only explicit padding is used

Inputs

  • input:T1
    • shape:[batch,channel,height,width]
      • channel∈(0,8192]
      • height∈(0,8192]
      • width∈(0,8192]

Outputs

  • output:T1
    • shape:[batch,channel,height,width]

Attributes

  • kernel_shape:int64(kernel_h,kernel_w)
    • kernel_h∈(0,7]
    • kernel_w∈(0,7]
  • auto_pad:string
    • Padding mode: only NOTSET is supported
  • ceil_mode:int64
    • Whether to use ceil or floor to compute the output shape: not supported
  • strides:int64(strides_h,strides_w)
    • strides_h∈(0,8]
    • strides_w∈(0,8]
  • count_include_pad:int64[]
    • count_include_pad, whether to include pad values in computation: 1
  • pad:int64(pad_top,pad_left,pad_bottom,pad_right)
    • pad_top∈[0,7]
    • pad_left∈[0,7]
    • pad_bottom∈[0,7]
    • pad_right∈[0,7]

Data Type Constraints

  • T1:int8(Tensor),float16(Tensor)
  • T2:float(Tensor)
  • T3:float(Scalar)

GlobalAveragePool

GlobalAveragePool consumes an input tensor X and applies average pooling over the values in the same channel. This is equivalent to an AveragePool with kernel_shape equal to the spatial dimensions of the input tensor.

Inputs

  • input:T1
    • shape:[batch,channel,height,width]
      • channel∈(0,8192]
      • height∈(0,7]
      • width∈(0,7]

Outputs

  • output:T1
    • shape:[batch,channel,height,width]

Attributes

  • kernel_shape:int64(kernel_h,kernel_w)
    • kernel_h∈(0,7]
    • kernel_w∈(0,7]
  • auto_pad:string
    • Padding mode: only NOTSET is supported
  • ceil_mode:int64
    • Whether to use ceil or floor to compute the output shape: not supported
  • strides:int64(strides_h,strides_w)
    • strides_h∈(0,8]
    • strides_w∈(0,8]
  • count_include_pad:int64[]
    • count_include_pad, whether to include pad values in computation: 1
  • pad:int64(pad_top,pad_left,pad_bottom,pad_right)
    • pad_top∈[0,7]
    • pad_left∈[0,7]
    • pad_bottom∈[0,7]
    • pad_right∈[0,7]

Data Type Constraints

  • T1:int8(Tensor),float16(Tensor)
  • T2:float(Tensor)
  • T3:float(Scalar)

Pow

Z = X^Y exponentiation operation, taking input data (tensor) and exponents, and producing one output data (tensor)

Inputs

  • X:T1
    • shape:[batch,channel,height,width]
    • Quantization support
      • per-layer
  • Y:T2
    • shape:[1]
      • Currently only 0, 1, 2, 3, 0.5, -0.5 are supported

Outputs

  • Z:T1
    • shape:[batch,channel,height,width]
    • Quantization support
      • per-layer

Data Type Constraints

  • T1:int8(Tensor),float16(Tensor)
  • T2:int8(Tensor),int32(Tensor),int64(Tensor),float16(Tensor),float(Tensor)

Other Support

  • Multi-core: Not yet supported

Explore this topic → · Learning paths →