ホーム › AI.MachineLearning.WinML › WINML_RESOURCE_BINDING_DESC
WINML_RESOURCE_BINDING_DESC
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| ElementType | WINML_TENSOR_DATA_TYPE | 4 | +0 | +0 | テンソル要素のデータ型を指定する列挙値。 |
| NumDimensions | DWORD | 4 | +4 | +4 | テンソルの次元数。pShape配列の要素数。 |
| pShape | LONGLONG* | 8/4 | +8 | +8 | 各次元のサイズを並べた配列へのポインタ(64ビット整数)。 |
| pResource | ID3D12Resource* | 8/4 | +16 | +12 | データを格納するDirect3D 12リソースへのポインタ。 |
各言語での定義
#include <windows.h>
// WINML_RESOURCE_BINDING_DESC (x64 24 / x86 16 バイト)
typedef struct WINML_RESOURCE_BINDING_DESC {
WINML_TENSOR_DATA_TYPE ElementType;
DWORD NumDimensions;
LONGLONG* pShape;
ID3D12Resource* pResource;
} WINML_RESOURCE_BINDING_DESC;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WINML_RESOURCE_BINDING_DESC
{
public int ElementType;
public uint NumDimensions;
public IntPtr pShape;
public IntPtr pResource;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WINML_RESOURCE_BINDING_DESC
Public ElementType As Integer
Public NumDimensions As UInteger
Public pShape As IntPtr
Public pResource As IntPtr
End Structureimport ctypes
from ctypes import wintypes
class WINML_RESOURCE_BINDING_DESC(ctypes.Structure):
_fields_ = [
("ElementType", ctypes.c_int),
("NumDimensions", wintypes.DWORD),
("pShape", ctypes.c_void_p),
("pResource", ctypes.c_void_p),
]#[repr(C)]
pub struct WINML_RESOURCE_BINDING_DESC {
pub ElementType: i32,
pub NumDimensions: u32,
pub pShape: *mut core::ffi::c_void,
pub pResource: *mut core::ffi::c_void,
}import "golang.org/x/sys/windows"
type WINML_RESOURCE_BINDING_DESC struct {
ElementType int32
NumDimensions uint32
pShape uintptr
pResource uintptr
}type
WINML_RESOURCE_BINDING_DESC = record
ElementType: Integer;
NumDimensions: DWORD;
pShape: Pointer;
pResource: Pointer;
end;const WINML_RESOURCE_BINDING_DESC = extern struct {
ElementType: i32,
NumDimensions: u32,
pShape: ?*anyopaque,
pResource: ?*anyopaque,
};type
WINML_RESOURCE_BINDING_DESC {.bycopy.} = object
ElementType: int32
NumDimensions: uint32
pShape: pointer
pResource: pointerstruct WINML_RESOURCE_BINDING_DESC
{
int ElementType;
uint NumDimensions;
void* pShape;
void* pResource;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; WINML_RESOURCE_BINDING_DESC サイズ: 16 バイト(x86)
dim st, 4 ; 4byte整数×4(構造体サイズ 16 / 4 切り上げ)
; ElementType : WINML_TENSOR_DATA_TYPE (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; NumDimensions : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; pShape : LONGLONG* (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; pResource : ID3D12Resource* (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; WINML_RESOURCE_BINDING_DESC サイズ: 24 バイト(x64)
dim st, 6 ; 4byte整数×6(構造体サイズ 24 / 4 切り上げ)
; ElementType : WINML_TENSOR_DATA_TYPE (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; NumDimensions : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; pShape : LONGLONG* (+8, 8byte) qpoke st,8,値 / qpeek(st,8) ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; pResource : ID3D12Resource* (+16, 8byte) qpoke st,16,値 / qpeek(st,16) ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global WINML_RESOURCE_BINDING_DESC
#field int ElementType
#field int NumDimensions
#field intptr pShape
#field intptr pResource
#endstruct
stdim st, WINML_RESOURCE_BINDING_DESC ; NSTRUCT 変数を確保
st->ElementType = 100
mes "ElementType=" + st->ElementType