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

DML_TOP_K1_OPERATOR_DESC

構造体
サイズx64: 40 バイト / x86: 24 バイト

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

フィールド

フィールドサイズx64x86説明
InputTensorDML_TENSOR_DESC*8/4+0+0演算子の入力テンソルを記述するDML_TENSOR_DESCへのポインタ。
OutputValueTensorDML_TENSOR_DESC*8/4+8+4上位K個の値を格納する出力テンソルを記述するDML_TENSOR_DESCへのポインタ。
OutputIndexTensorDML_TENSOR_DESC*8/4+16+8上位K個の元インデックスを格納する出力テンソルを記述するDML_TENSOR_DESCへのポインタ。
AxisDWORD4+24+12演算を適用する軸のインデックス(0始まり)。
KDWORD4+28+16抽出する上位要素の個数K。
AxisDirectionDML_AXIS_DIRECTION4+32+20最大側か最小側のどちらから選ぶかを指定するDML_AXIS_DIRECTION値。

各言語での定義

#include <windows.h>

// DML_TOP_K1_OPERATOR_DESC  (x64 40 / x86 24 バイト)
typedef struct DML_TOP_K1_OPERATOR_DESC {
    DML_TENSOR_DESC* InputTensor;
    DML_TENSOR_DESC* OutputValueTensor;
    DML_TENSOR_DESC* OutputIndexTensor;
    DWORD Axis;
    DWORD K;
    DML_AXIS_DIRECTION AxisDirection;
} DML_TOP_K1_OPERATOR_DESC;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DML_TOP_K1_OPERATOR_DESC
{
    public IntPtr InputTensor;
    public IntPtr OutputValueTensor;
    public IntPtr OutputIndexTensor;
    public uint Axis;
    public uint K;
    public int AxisDirection;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DML_TOP_K1_OPERATOR_DESC
    Public InputTensor As IntPtr
    Public OutputValueTensor As IntPtr
    Public OutputIndexTensor As IntPtr
    Public Axis As UInteger
    Public K As UInteger
    Public AxisDirection As Integer
End Structure
import ctypes
from ctypes import wintypes

class DML_TOP_K1_OPERATOR_DESC(ctypes.Structure):
    _fields_ = [
        ("InputTensor", ctypes.c_void_p),
        ("OutputValueTensor", ctypes.c_void_p),
        ("OutputIndexTensor", ctypes.c_void_p),
        ("Axis", wintypes.DWORD),
        ("K", wintypes.DWORD),
        ("AxisDirection", ctypes.c_int),
    ]
#[repr(C)]
pub struct DML_TOP_K1_OPERATOR_DESC {
    pub InputTensor: *mut core::ffi::c_void,
    pub OutputValueTensor: *mut core::ffi::c_void,
    pub OutputIndexTensor: *mut core::ffi::c_void,
    pub Axis: u32,
    pub K: u32,
    pub AxisDirection: i32,
}
import "golang.org/x/sys/windows"

type DML_TOP_K1_OPERATOR_DESC struct {
	InputTensor uintptr
	OutputValueTensor uintptr
	OutputIndexTensor uintptr
	Axis uint32
	K uint32
	AxisDirection int32
}
type
  DML_TOP_K1_OPERATOR_DESC = record
    InputTensor: Pointer;
    OutputValueTensor: Pointer;
    OutputIndexTensor: Pointer;
    Axis: DWORD;
    K: DWORD;
    AxisDirection: Integer;
  end;
const DML_TOP_K1_OPERATOR_DESC = extern struct {
    InputTensor: ?*anyopaque,
    OutputValueTensor: ?*anyopaque,
    OutputIndexTensor: ?*anyopaque,
    Axis: u32,
    K: u32,
    AxisDirection: i32,
};
type
  DML_TOP_K1_OPERATOR_DESC {.bycopy.} = object
    InputTensor: pointer
    OutputValueTensor: pointer
    OutputIndexTensor: pointer
    Axis: uint32
    K: uint32
    AxisDirection: int32
struct DML_TOP_K1_OPERATOR_DESC
{
    void* InputTensor;
    void* OutputValueTensor;
    void* OutputIndexTensor;
    uint Axis;
    uint K;
    int AxisDirection;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; DML_TOP_K1_OPERATOR_DESC サイズ: 24 バイト(x86)
dim st, 6    ; 4byte整数×6(構造体サイズ 24 / 4 切り上げ)
; InputTensor : DML_TENSOR_DESC* (+0, 4byte)  varptr(st)+0 を基点に操作(4byte:入れ子/配列)
; OutputValueTensor : DML_TENSOR_DESC* (+4, 4byte)  varptr(st)+4 を基点に操作(4byte:入れ子/配列)
; OutputIndexTensor : DML_TENSOR_DESC* (+8, 4byte)  varptr(st)+8 を基点に操作(4byte:入れ子/配列)
; Axis : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; K : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; AxisDirection : DML_AXIS_DIRECTION (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DML_TOP_K1_OPERATOR_DESC サイズ: 40 バイト(x64)
dim st, 10    ; 4byte整数×10(構造体サイズ 40 / 4 切り上げ)
; InputTensor : DML_TENSOR_DESC* (+0, 8byte)  varptr(st)+0 を基点に操作(8byte:入れ子/配列)
; OutputValueTensor : DML_TENSOR_DESC* (+8, 8byte)  varptr(st)+8 を基点に操作(8byte:入れ子/配列)
; OutputIndexTensor : DML_TENSOR_DESC* (+16, 8byte)  varptr(st)+16 を基点に操作(8byte:入れ子/配列)
; Axis : DWORD (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; K : DWORD (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; AxisDirection : DML_AXIS_DIRECTION (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global DML_TOP_K1_OPERATOR_DESC
    #field intptr InputTensor
    #field intptr OutputValueTensor
    #field intptr OutputIndexTensor
    #field int Axis
    #field int K
    #field int AxisDirection
#endstruct

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