このRKNN2 V2.5.0プラットフォームリファレンスは、ArmSoM開発者がモデルを選択および適応するのに役立ちます。 すべてのArmSoMボードでのサポートを確立しません。ボードSOC、実際のツールキット2、ランタイム、NPUドライバ、BSPバージョンを確認します。 ソースは、ユニバーサルLinuxカーネルバージョンを指すものではありません。 ArmSoM ハードウェア検証は行いません。
出典:中国と英語のRKNN2サポートオペレータとコントレイント参照V2.5.0、374および384ページそれぞれ。 中国語は中国語版に続いています。英語、ロシア語、ドイツ語は英語版に従います。 プラットフォームの制約は分離されず、 英語PDF自体には中国語I/O図と出力テーブルが含まれており、その実証は編集可能なローカライズされたテーブルで保持されます。 ConvTranpose や元の LSTM/GRU などのソースのスペルが保存されます。これらの式は SDK 実装に修正されません。
出典ページ:CN 163–175;EN 168–180。
オペレータ参照シリーズ
RKNN2 V2.5.0・RK3566/RK3568:基本と進化
RKNN2 V2.5.0・RK3566/RK3568:再発ネットワーク、算術およびプール
RKNN2 V2.5.0・RK3566/RK3568:形状、スライシング、トランスポーズ
RKNN2 V2.5.0・RK3566/RK3568:活性化、正規化、拡張機能
RKNN2 V2.5.0・RK3588:再発ネットワーク、算術およびプール
RKNN2 V2.5.0・RK3588:形状、スライシング、トランスポーズ
RKNN2 V2.5.0・RK3588:アクティベーション、正規化、拡張機能
RKNN2 V2.5.0・RK3562:再発ネットワーク、算術およびプール
RKNN2 V2.5.0・RK3562:形状、スライシング、トランスポーズ
RKNN2 V2.5.0・RK3562:アクティベーション、正規化、拡張機能
RKNN2 V2.5.0・RV1103/RV1106:基本と進化
RKNN2 V2.5.0・RV1103/RV1106:再発ネットワーク、算術およびプール
RKNN2 V2.5.0・RV1103/RV1106:形状、スライシング、トランスポーズ
RKNN2 V2.5.0・RV1103/RV1106:活性化、正規化、拡張機能
RKNN2 V2.5.0・RK3576/RV1126B:基本と進化
RKNN2 V2.5.0・RK3576/RV1126B:再発ネットワーク、算術およびプール
RKNN2 V2.5.0・RK3576/RV1126B:形状、スライシング、トランスポーズ
RKNN2 V2.5.0・RK3576/RV1126B:活性化、正規化、拡張機能
RKNN2 V2.5.0・RK2118:再発ネットワーク、算術およびプール
RKNN2 V2.5.0・RK2118:形状、スライシング、トランスポーズ
RKNN2 V2.5.0・RK2118:アクティベーション、正規化、拡張機能
RKNN2 V2.5.0・RV1103B/RV1106B:基本と進化
RKNN2 V2.5.0・RV1103B/RV1106B:再発ネットワーク、算術およびプール
RKNN2 V2.5.0・RV1103B/RV1106B:形状、スライシング、トランスポーズ
シグモイド
入力テンソルを与えられた、関数 y=1/(1+exp(-x) は出力テンソルを生成するために入力テンソルに要素単位で加えられます
導入事例
- 入力:T1
- shape:[batch,channel,height,width]
- Quantization support
- per-layer
出力
- 出力:T1
- shape:[batch,channel,height,width]
- Quantization support
- per-layer
データ型制約
- T1:int8(センサー)、float16(センサー)
タン
指定した入力テンソル要素のハイパーボリックな形を計算します。
導入事例
- X:T1
- shape:[batch,channel,height,width]
- Quantization support:per-layer
出力
- Y:T1
- shape:[batch,channel,height,width]
- Quantization support:per-layer
データ型制約
- T1:int8(センサー)、float16(センサー)
ソフトプラス
Softplus 関数要素を y=ln(exp(x)+1) に指定します。
導入事例
- X:T1
- shape:[batch,channel,height,width]
- Quantization support:per-layer
出力
- Y:T1
- shape:[batch,channel,height,width]
- Quantization support:per-layer
データ型制約
- T1:int8(センサー)、float16(センサー)
硬いシグミノイド
入力テンソルを与えられた、関数 y=max(0,min(1,alpha*x+beta)) は、出力テンソルを生成するために入力テンソルに要素単位で適用されます。
導入事例
- 入力:T1
- shape:[batch,channel,height,width]
- Quantization support
- per-layer
出力
- 出力:T1
- shape:[batch,channel,height,width]
- Quantization support
- per-layer
データ型制約
- T1:int8(センサー)、float16(センサー)
硬いスウェーデン
HardSwish 関数要素を賢く、y = x * max(0, min(1, alpha * x + beta)) = x * HardSigmoid(x), alpha=1/6, beta=0.5
導入事例
- X:T1
- shape:[batch,channel,height,width]
- Quantization support:per-layer
出力
- Y:T1
- shape:[batch,channel,height,width]
- Quantization support:per-layer
データ型制約
- T1:int8(センサー)、float16(センサー)
ソリューション
入力テンソルを、x<0、f(x)=xのx>=0のための機能f(x)=alpha*(exp(x)-1.)は出力テンソルを作り出すために入力テンソルに要素単位で加えられます、 alpha=1
導入事例
- 入力:T1
- shape:[batch,channel,height,width]
- Quantization support
- per-layer
出力
- 出力:T1
- shape:[batch,channel,height,width]
- Quantization support
- per-layer
データ型制約
- T1:int8(センサー)、float16(センサー)
exSwish
ジグモイドリニアユニット関数要素を同様に適用します。 Swish 関数は SiLU 関数、y=x*sigmoid(x) とも呼ばれます
導入事例
- X:T1
- shape:[batch,channel,height,width]
- Quantization support:per-layer
出力
- Y:T1
- shape:[batch,channel,height,width]
- Quantization support:per-layer
データ型制約
- T1:int8(センサー)、float16(センサー)
exMish
入力テンソル、関数のimh(x)=xtanh(softplus(x))=xtanh(ln(1+e^{x}))を、出力テンソルを生成するために入力テンソルに要素単位で加えられます
導入事例
- 入力:T1
- shape:[batch,channel,height,width]
- Quantization support
- per-layer
出力
- 出力:T1
- shape:[batch,channel,height,width]
- Quantization support
- per-layer
データ型制約
- T1:int8(センサー)、float16(センサー)
exGelu
入力テンソルを与えられたy=x*Φ(x)は出力テンソルを生成するために要素単位で加えられます。 Φ(x) が tanh に設定されるとき: y=0.5*x*(1+Tanh(sqrt(2/π)*(x+0.044715*x^3)))))。
導入事例
- 入力:T1
- shape:[batch,channel,height,width]
- Quantization support
- per-layer
出力
- 出力:T1
- shape:[batch,channel,height,width]
- Quantization support
- per-layer
データ型制約
- T1:int8(センサー)、float16(センサー)
どこまでも
マスク_tensor の x_tensor や y_tensor の値を取得します。 マスク_tensor のポジションが真の場合、対応する位置の x_tensor の値が取られます。そうしないと、y_tensor の値が取り込まれます。
導入事例
- マスク_tensor:T1
- shape:[batch,channel,height,width]
- Broadcasting support
- Supports broadcasting along arbitrary dimensions
- Broadcasting constraints
- Broadcasting constraints are the same as the Expand operator
- x_tensor:*T2 の
- shape:[batch,channel,height,width]
- Quantization support
- per-layer
- Broadcasting support
- Supports broadcasting along arbitrary dimensions
- Broadcasting constraints
- Broadcasting constraints are the same as the Expand operator
- y_tensor:T1 の
- shape:[batch,channel,height,width]
- Quantization support
- per-layer
- Broadcasting support
- Supports broadcasting along arbitrary dimensions
- Broadcasting constraints
- Broadcasting constraints are the same as the Expand operator
出力
- 出力:T2
- shape:[batch,channel,height,width]
- Quantization support
- per-layer
データ型制約
- T1:bool (センサー)
- T2:int8(センサー)、float16(センサー)
exGlu
出力された線形単位機能、入力行列の先頭半分であり、bは2番目の半分のGLU(a,b)=aσ(b)です
導入事例
- 入力:T1
- shape:[batch,channel,height,width]
- Quantization support:per-layer
出力
- 出力:T1
- shape:[batch,channel/2,height,width]
- Quantization support:per-layer
データ型制約
- T1:int8(センサー)、float16(センサー)
属性
- axis: int (デフォルト値 = 1)
- The dimension to split the input
- Constraint: only 1 is supported
exMatMul
マトリックスの乗算操作
Y = A·B + C if c_type = "add"
Y = A·B * C if c_type = "mul"
導入事例
- A:T1
- shape:[b,k,1,n]
- k ∈(0,8192]
- Quantization support
- per-layer
- shape:[b,k,1,n]
- B:T1
- shape:[b,k,1,m]
- Quantization support
- per-layer
- C (任意):T1、T2
- shape:[b,n,1,m]
- Quantization support
- per-layer
- Broadcasting support
- Supports broadcasting along arbitrary dimensions
- Broadcasting constraints are the same as the Expand operator
出力
- Y:T1
- shape:[b,n,1,m]
- Quantization support
- per-layer
データ型制約
- T1:int8(センサー)、float16(センサー)
- T2:フロート(センサー)
属性
- c_type: 文字列 (デフォルト “add”)
- add and mul are optional, indicating whether C is added or multiplied
exNorm
入力データに各種正規化処理を実行します。 現在3種類以上がサポートされています。AceerNormalization、RMSNormalization、MeanVarianceNormalization:
LayerNorm(x) = ((x - μ) / sqrt(σ^2 + ε)) * W + B
RMSNorm(x) = (x / sqrt(RMS^2 + ε)) * W + B
MeanVarianceNorm(x) = ((x - μ) / sqrt(Variance + ε)) * W + B
ここで:x は入力ベクトルです。μ と σ2 は、それぞれ入力ベクトルの平均と分散です。
μ = (1/H) * Σ[i=1..H](x_i)
σ^2 = (1/H) * Σ[i=1..H]((x_i - μ)^2)
RMS は入力ベクトルの根本的な意味の正方形です:
RMS = sqrt((1/H) * Σ[i=1..H](x_i^2))
変異は入力ベクトルの同等な分散です:
Variance = (1/H) * Σ[i=1..H](x_i^2) - μ^2
εはゼロで分割を防ぐために使われる小数です。 W と B はオプションのパラメーターです。
導入事例
- X:T1
- shape:[batch,channel,height,width]
- W (任意):T1
- shape:[batch,channel,height,width]
- B (任意):T1
- shape:[batch,channel,height,width]
出力
- Y:T1
- shape:[batch,channel,height,width]
データ型制約
- T1:float16(センサー)
属性
- epsilon: フロート (デフォルト値 1e-05)
- The epsilon value used to prevent division by 0
- モード:string
- Three normalization modes are available: layer, rms, and mean_var
- axes: int64[] (デフォルト値[1])
- Normalization axes, currently only [1] and [1,2,3] are supported
その他のサポート
- マルチコア:未対応
exSDPAttention
クエリ、キー、値間のドットプロダクティブの注意(SDPA)を計算
導入事例
- クエリ:T1
- shape:[batch,channel,height,width]
- channel∈(0,8192]
- Quantization support
- per-layer
- shape:[batch,channel,height,width]
- キー:T1
- shape:[batch,channel,height,width]
- Quantization support
- per-layer
- 値:T1
- shape:[batch,channel,height,width]
- channel∈(0,8192]
- Quantization support
- per-layer
- shape:[batch,channel,height,width]
- マスク(任意):T1、T2
- shape:[batch,channel,height,width]
- Quantization support
- per-layer
- Broadcasting support
- By default, supports broadcasting along arbitrary dimensions
- After FA support is enabled, only three specifications are supported: [b,c,1,1], [1,c,1,1], and [1,c,h,w]
- スケール(任意):T3
出力
- 出力:T1
- shape:[batch,channel,height,width]
- Quantization support
- per-layer
データ型制約
- T1:int8(センサー)、float16(センサー)
- T2:フロート(センサー)
- T3:float(スカラー)
その他のサポート
- FlashAttentionV2(FA): 対応
- Implemented based on https://arxiv.org/abs/2307.08691. Acceleration is achieved by caching inner loops and reducing bandwidth usage, but this increases the model size. Please choose whether to enable it according to your specific scenario and model
- RKNPU driver version >= 0.8.8
- RKNPU Runtime library (librknnrt.so) version >= 2.0.0
- Supported data type: float16
exWindow
exWindowは、swin_transformerのwindow_partitionとwindow_reverse操作から始まります。 オリジナルの紙では、入力機能は複数の非重複ウィンドウに分割され、各サイズのウィンドウ_size×window_size。 入出力機能と出力機能は、高さと幅のどちらの方向でも4次元形状で分割する必要があります。 pytorch の実装は以下のとおりです。
def window_partition(x, window_size):
"""
Args:
x: (B, C, H, W)
window_size (int): window size
Returns:
windows: (B, C, num_windows * num_windows, window_size * window_size)
"""
B, C, H, W = x.shape
x = x.view(B, C, H // window_size, window_size, W // window_size, window_size)
windows = x.permute(0, 1, 2, 4, 3, 5).contiguous().view(B, C, -1, window_size * window_size)
return windows
def window_reverse(windows, window_size, H, W):
"""
Args:
windows: (B, C, num_windows * num_windows, window_size * window_size)
window_size (int): Window size
H (int): Height of image
W (int): Width of image
Returns:
x: (B, C, H, W)
"""
B, C, _, _ = windows.shape
x = windows.view(B, C, H // window_size, W // window_size, window_size, window_size)
x = x.permute(0, 1, 2, 4, 3, 5).contiguous().view(B, C, H, W)
return x
導入事例
- X:T1
- shape:[batch,channel,height,width]
出力
- Y:T1
- shape:[batch,channel,height,width]
データ型制約
- T1:int8(センサー)、float16(センサー)
属性
- モード:string
- Supported modes: partition, reverse, partition_num_first
- partition: implemented with reference to window_partition;
- reverse: implemented with reference to window_reverse;
- partition_num_first: the difference from partition is that the H,W of partition_num_first are divided according to num_windows, while the H,W of partition are divided according to window_sizes.
- Supported modes: partition, reverse, partition_num_first
- window_sizes:listofints の一覧
- A 2-dimensional vector, the window size. Defines the height and width of each window. Attention computation and feature extraction within the window are based on this size.
- num_windows:listofints(リストフォート)
- A 2-dimensional vector, the number of windows. Defines how many windows the height and width of the input feature are divided into.
その他のサポート
- マルチコア:未対応
