Win32 API 日本語リファレンス
ホームAI.MachineLearning.DirectML › DML_LSTM_OPERATOR_DESC

DML_LSTM_OPERATOR_DESC

構造体
サイズx64: 120 バイト / x86: 68 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
InputTensorDML_TENSOR_DESC*8/4+0+0演算子の入力テンソルを記述するDML_TENSOR_DESCへのポインタ。
WeightTensorDML_TENSOR_DESC*8/4+8+4入力に乗じる重み行列を保持するテンソルを記述するDML_TENSOR_DESCへのポインタ。
RecurrenceTensorDML_TENSOR_DESC*8/4+16+8再帰結合に用いる重み行列を保持するテンソルを記述するDML_TENSOR_DESCへのポインタ。
BiasTensorDML_TENSOR_DESC*8/4+24+12各要素に加算するバイアス値を保持するテンソルを記述するDML_TENSOR_DESCへのポインタ。省略可。
HiddenInitTensorDML_TENSOR_DESC*8/4+32+16隠れ状態の初期値を保持するテンソルを記述するDML_TENSOR_DESCへのポインタ。省略可。
CellMemInitTensorDML_TENSOR_DESC*8/4+40+20セル状態(メモリ)の初期値を保持するテンソルを記述するDML_TENSOR_DESCへのポインタ。省略可。
SequenceLengthsTensorDML_TENSOR_DESC*8/4+48+24各バッチの有効シーケンス長を保持するテンソルを記述するDML_TENSOR_DESCへのポインタ。
PeepholeTensorDML_TENSOR_DESC*8/4+56+28ピープホール接続の重みを保持するテンソルを記述するDML_TENSOR_DESCへのポインタ。省略可。
OutputSequenceTensorDML_TENSOR_DESC*8/4+64+32各タイムステップの出力を保持するテンソルを記述するDML_TENSOR_DESCへのポインタ。省略可。
OutputSingleTensorDML_TENSOR_DESC*8/4+72+36最終タイムステップの出力(単一)を保持するテンソルを記述するDML_TENSOR_DESCへのポインタ。省略可。
OutputCellSingleTensorDML_TENSOR_DESC*8/4+80+40最終タイムステップのセル状態を保持する出力テンソルを記述するDML_TENSOR_DESCへのポインタ。省略可。
ActivationDescCountDWORD4+88+44ActivationDescsが指す活性化関数記述子の個数。
ActivationDescsDML_OPERATOR_DESC*8/4+96+48ゲートごとに適用する活性化関数を並べたDML_OPERATOR_DESC配列へのポインタ。
DirectionDML_RECURRENT_NETWORK_DIRECTION4+104+52再帰処理の方向(順方向・逆方向・双方向)を指定するDML_RECURRENT_NETWORK_DIRECTION値。
ClipThresholdFLOAT4+108+56セル値をクリップする際のしきい値。UseClipThresholdがTRUEのとき有効。
UseClipThresholdBOOL4+112+60ClipThresholdによるクリッピングを行うかを示すBOOL。
CoupleInputForgetBOOL4+116+64入力ゲートと忘却ゲートを結合(coupled)するかを示すBOOL。

各言語での定義

#include <windows.h>

// DML_LSTM_OPERATOR_DESC  (x64 120 / x86 68 バイト)
typedef struct DML_LSTM_OPERATOR_DESC {
    DML_TENSOR_DESC* InputTensor;
    DML_TENSOR_DESC* WeightTensor;
    DML_TENSOR_DESC* RecurrenceTensor;
    DML_TENSOR_DESC* BiasTensor;
    DML_TENSOR_DESC* HiddenInitTensor;
    DML_TENSOR_DESC* CellMemInitTensor;
    DML_TENSOR_DESC* SequenceLengthsTensor;
    DML_TENSOR_DESC* PeepholeTensor;
    DML_TENSOR_DESC* OutputSequenceTensor;
    DML_TENSOR_DESC* OutputSingleTensor;
    DML_TENSOR_DESC* OutputCellSingleTensor;
    DWORD ActivationDescCount;
    DML_OPERATOR_DESC* ActivationDescs;
    DML_RECURRENT_NETWORK_DIRECTION Direction;
    FLOAT ClipThreshold;
    BOOL UseClipThreshold;
    BOOL CoupleInputForget;
} DML_LSTM_OPERATOR_DESC;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DML_LSTM_OPERATOR_DESC
{
    public IntPtr InputTensor;
    public IntPtr WeightTensor;
    public IntPtr RecurrenceTensor;
    public IntPtr BiasTensor;
    public IntPtr HiddenInitTensor;
    public IntPtr CellMemInitTensor;
    public IntPtr SequenceLengthsTensor;
    public IntPtr PeepholeTensor;
    public IntPtr OutputSequenceTensor;
    public IntPtr OutputSingleTensor;
    public IntPtr OutputCellSingleTensor;
    public uint ActivationDescCount;
    public IntPtr ActivationDescs;
    public int Direction;
    public float ClipThreshold;
    [MarshalAs(UnmanagedType.Bool)] public bool UseClipThreshold;
    [MarshalAs(UnmanagedType.Bool)] public bool CoupleInputForget;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DML_LSTM_OPERATOR_DESC
    Public InputTensor As IntPtr
    Public WeightTensor As IntPtr
    Public RecurrenceTensor As IntPtr
    Public BiasTensor As IntPtr
    Public HiddenInitTensor As IntPtr
    Public CellMemInitTensor As IntPtr
    Public SequenceLengthsTensor As IntPtr
    Public PeepholeTensor As IntPtr
    Public OutputSequenceTensor As IntPtr
    Public OutputSingleTensor As IntPtr
    Public OutputCellSingleTensor As IntPtr
    Public ActivationDescCount As UInteger
    Public ActivationDescs As IntPtr
    Public Direction As Integer
    Public ClipThreshold As Single
    <MarshalAs(UnmanagedType.Bool)> Public UseClipThreshold As Boolean
    <MarshalAs(UnmanagedType.Bool)> Public CoupleInputForget As Boolean
End Structure
import ctypes
from ctypes import wintypes

class DML_LSTM_OPERATOR_DESC(ctypes.Structure):
    _fields_ = [
        ("InputTensor", ctypes.c_void_p),
        ("WeightTensor", ctypes.c_void_p),
        ("RecurrenceTensor", ctypes.c_void_p),
        ("BiasTensor", ctypes.c_void_p),
        ("HiddenInitTensor", ctypes.c_void_p),
        ("CellMemInitTensor", ctypes.c_void_p),
        ("SequenceLengthsTensor", ctypes.c_void_p),
        ("PeepholeTensor", ctypes.c_void_p),
        ("OutputSequenceTensor", ctypes.c_void_p),
        ("OutputSingleTensor", ctypes.c_void_p),
        ("OutputCellSingleTensor", ctypes.c_void_p),
        ("ActivationDescCount", wintypes.DWORD),
        ("ActivationDescs", ctypes.c_void_p),
        ("Direction", ctypes.c_int),
        ("ClipThreshold", ctypes.c_float),
        ("UseClipThreshold", wintypes.BOOL),
        ("CoupleInputForget", wintypes.BOOL),
    ]
#[repr(C)]
pub struct DML_LSTM_OPERATOR_DESC {
    pub InputTensor: *mut core::ffi::c_void,
    pub WeightTensor: *mut core::ffi::c_void,
    pub RecurrenceTensor: *mut core::ffi::c_void,
    pub BiasTensor: *mut core::ffi::c_void,
    pub HiddenInitTensor: *mut core::ffi::c_void,
    pub CellMemInitTensor: *mut core::ffi::c_void,
    pub SequenceLengthsTensor: *mut core::ffi::c_void,
    pub PeepholeTensor: *mut core::ffi::c_void,
    pub OutputSequenceTensor: *mut core::ffi::c_void,
    pub OutputSingleTensor: *mut core::ffi::c_void,
    pub OutputCellSingleTensor: *mut core::ffi::c_void,
    pub ActivationDescCount: u32,
    pub ActivationDescs: *mut core::ffi::c_void,
    pub Direction: i32,
    pub ClipThreshold: f32,
    pub UseClipThreshold: i32,
    pub CoupleInputForget: i32,
}
import "golang.org/x/sys/windows"

type DML_LSTM_OPERATOR_DESC struct {
	InputTensor uintptr
	WeightTensor uintptr
	RecurrenceTensor uintptr
	BiasTensor uintptr
	HiddenInitTensor uintptr
	CellMemInitTensor uintptr
	SequenceLengthsTensor uintptr
	PeepholeTensor uintptr
	OutputSequenceTensor uintptr
	OutputSingleTensor uintptr
	OutputCellSingleTensor uintptr
	ActivationDescCount uint32
	ActivationDescs uintptr
	Direction int32
	ClipThreshold float32
	UseClipThreshold int32
	CoupleInputForget int32
}
type
  DML_LSTM_OPERATOR_DESC = record
    InputTensor: Pointer;
    WeightTensor: Pointer;
    RecurrenceTensor: Pointer;
    BiasTensor: Pointer;
    HiddenInitTensor: Pointer;
    CellMemInitTensor: Pointer;
    SequenceLengthsTensor: Pointer;
    PeepholeTensor: Pointer;
    OutputSequenceTensor: Pointer;
    OutputSingleTensor: Pointer;
    OutputCellSingleTensor: Pointer;
    ActivationDescCount: DWORD;
    ActivationDescs: Pointer;
    Direction: Integer;
    ClipThreshold: Single;
    UseClipThreshold: BOOL;
    CoupleInputForget: BOOL;
  end;
const DML_LSTM_OPERATOR_DESC = extern struct {
    InputTensor: ?*anyopaque,
    WeightTensor: ?*anyopaque,
    RecurrenceTensor: ?*anyopaque,
    BiasTensor: ?*anyopaque,
    HiddenInitTensor: ?*anyopaque,
    CellMemInitTensor: ?*anyopaque,
    SequenceLengthsTensor: ?*anyopaque,
    PeepholeTensor: ?*anyopaque,
    OutputSequenceTensor: ?*anyopaque,
    OutputSingleTensor: ?*anyopaque,
    OutputCellSingleTensor: ?*anyopaque,
    ActivationDescCount: u32,
    ActivationDescs: ?*anyopaque,
    Direction: i32,
    ClipThreshold: f32,
    UseClipThreshold: i32,
    CoupleInputForget: i32,
};
type
  DML_LSTM_OPERATOR_DESC {.bycopy.} = object
    InputTensor: pointer
    WeightTensor: pointer
    RecurrenceTensor: pointer
    BiasTensor: pointer
    HiddenInitTensor: pointer
    CellMemInitTensor: pointer
    SequenceLengthsTensor: pointer
    PeepholeTensor: pointer
    OutputSequenceTensor: pointer
    OutputSingleTensor: pointer
    OutputCellSingleTensor: pointer
    ActivationDescCount: uint32
    ActivationDescs: pointer
    Direction: int32
    ClipThreshold: float32
    UseClipThreshold: int32
    CoupleInputForget: int32
struct DML_LSTM_OPERATOR_DESC
{
    void* InputTensor;
    void* WeightTensor;
    void* RecurrenceTensor;
    void* BiasTensor;
    void* HiddenInitTensor;
    void* CellMemInitTensor;
    void* SequenceLengthsTensor;
    void* PeepholeTensor;
    void* OutputSequenceTensor;
    void* OutputSingleTensor;
    void* OutputCellSingleTensor;
    uint ActivationDescCount;
    void* ActivationDescs;
    int Direction;
    float ClipThreshold;
    int UseClipThreshold;
    int CoupleInputForget;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; DML_LSTM_OPERATOR_DESC サイズ: 68 バイト(x86)
dim st, 17    ; 4byte整数×17(構造体サイズ 68 / 4 切り上げ)
; InputTensor : DML_TENSOR_DESC* (+0, 4byte)  varptr(st)+0 を基点に操作(4byte:入れ子/配列)
; WeightTensor : DML_TENSOR_DESC* (+4, 4byte)  varptr(st)+4 を基点に操作(4byte:入れ子/配列)
; RecurrenceTensor : DML_TENSOR_DESC* (+8, 4byte)  varptr(st)+8 を基点に操作(4byte:入れ子/配列)
; BiasTensor : DML_TENSOR_DESC* (+12, 4byte)  varptr(st)+12 を基点に操作(4byte:入れ子/配列)
; HiddenInitTensor : DML_TENSOR_DESC* (+16, 4byte)  varptr(st)+16 を基点に操作(4byte:入れ子/配列)
; CellMemInitTensor : DML_TENSOR_DESC* (+20, 4byte)  varptr(st)+20 を基点に操作(4byte:入れ子/配列)
; SequenceLengthsTensor : DML_TENSOR_DESC* (+24, 4byte)  varptr(st)+24 を基点に操作(4byte:入れ子/配列)
; PeepholeTensor : DML_TENSOR_DESC* (+28, 4byte)  varptr(st)+28 を基点に操作(4byte:入れ子/配列)
; OutputSequenceTensor : DML_TENSOR_DESC* (+32, 4byte)  varptr(st)+32 を基点に操作(4byte:入れ子/配列)
; OutputSingleTensor : DML_TENSOR_DESC* (+36, 4byte)  varptr(st)+36 を基点に操作(4byte:入れ子/配列)
; OutputCellSingleTensor : DML_TENSOR_DESC* (+40, 4byte)  varptr(st)+40 を基点に操作(4byte:入れ子/配列)
; ActivationDescCount : DWORD (+44, 4byte)  st.11 = 値  /  値 = st.11   (lpoke/lpeek も可)
; ActivationDescs : DML_OPERATOR_DESC* (+48, 4byte)  varptr(st)+48 を基点に操作(4byte:入れ子/配列)
; Direction : DML_RECURRENT_NETWORK_DIRECTION (+52, 4byte)  st.13 = 値  /  値 = st.13   (lpoke/lpeek も可)
; ClipThreshold : FLOAT (+56, 4byte)  st.14 = 値  /  値 = st.14   (lpoke/lpeek も可)
; UseClipThreshold : BOOL (+60, 4byte)  st.15 = 値  /  値 = st.15   (lpoke/lpeek も可)
; CoupleInputForget : BOOL (+64, 4byte)  st.16 = 値  /  値 = st.16   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DML_LSTM_OPERATOR_DESC サイズ: 120 バイト(x64)
dim st, 30    ; 4byte整数×30(構造体サイズ 120 / 4 切り上げ)
; InputTensor : DML_TENSOR_DESC* (+0, 8byte)  varptr(st)+0 を基点に操作(8byte:入れ子/配列)
; WeightTensor : DML_TENSOR_DESC* (+8, 8byte)  varptr(st)+8 を基点に操作(8byte:入れ子/配列)
; RecurrenceTensor : DML_TENSOR_DESC* (+16, 8byte)  varptr(st)+16 を基点に操作(8byte:入れ子/配列)
; BiasTensor : DML_TENSOR_DESC* (+24, 8byte)  varptr(st)+24 を基点に操作(8byte:入れ子/配列)
; HiddenInitTensor : DML_TENSOR_DESC* (+32, 8byte)  varptr(st)+32 を基点に操作(8byte:入れ子/配列)
; CellMemInitTensor : DML_TENSOR_DESC* (+40, 8byte)  varptr(st)+40 を基点に操作(8byte:入れ子/配列)
; SequenceLengthsTensor : DML_TENSOR_DESC* (+48, 8byte)  varptr(st)+48 を基点に操作(8byte:入れ子/配列)
; PeepholeTensor : DML_TENSOR_DESC* (+56, 8byte)  varptr(st)+56 を基点に操作(8byte:入れ子/配列)
; OutputSequenceTensor : DML_TENSOR_DESC* (+64, 8byte)  varptr(st)+64 を基点に操作(8byte:入れ子/配列)
; OutputSingleTensor : DML_TENSOR_DESC* (+72, 8byte)  varptr(st)+72 を基点に操作(8byte:入れ子/配列)
; OutputCellSingleTensor : DML_TENSOR_DESC* (+80, 8byte)  varptr(st)+80 を基点に操作(8byte:入れ子/配列)
; ActivationDescCount : DWORD (+88, 4byte)  st.22 = 値  /  値 = st.22   (lpoke/lpeek も可)
; ActivationDescs : DML_OPERATOR_DESC* (+96, 8byte)  varptr(st)+96 を基点に操作(8byte:入れ子/配列)
; Direction : DML_RECURRENT_NETWORK_DIRECTION (+104, 4byte)  st.26 = 値  /  値 = st.26   (lpoke/lpeek も可)
; ClipThreshold : FLOAT (+108, 4byte)  st.27 = 値  /  値 = st.27   (lpoke/lpeek も可)
; UseClipThreshold : BOOL (+112, 4byte)  st.28 = 値  /  値 = st.28   (lpoke/lpeek も可)
; CoupleInputForget : BOOL (+116, 4byte)  st.29 = 値  /  値 = st.29   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global DML_LSTM_OPERATOR_DESC
    #field intptr InputTensor
    #field intptr WeightTensor
    #field intptr RecurrenceTensor
    #field intptr BiasTensor
    #field intptr HiddenInitTensor
    #field intptr CellMemInitTensor
    #field intptr SequenceLengthsTensor
    #field intptr PeepholeTensor
    #field intptr OutputSequenceTensor
    #field intptr OutputSingleTensor
    #field intptr OutputCellSingleTensor
    #field int ActivationDescCount
    #field intptr ActivationDescs
    #field int Direction
    #field float ClipThreshold
    #field bool UseClipThreshold
    #field bool CoupleInputForget
#endstruct

stdim st, DML_LSTM_OPERATOR_DESC        ; NSTRUCT 変数を確保
st->ActivationDescCount = 100
mes "ActivationDescCount=" + st->ActivationDescCount