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

DML_ROI_ALIGN_OPERATOR_DESC

構造体
サイズx64: 64 バイト / x86: 44 バイト

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

フィールド

フィールドサイズx64x86説明
InputTensorDML_TENSOR_DESC*8/4+0+0特徴マップを保持する入力テンソルへのポインタ。ROIAlignの対象画像特徴。
ROITensorDML_TENSOR_DESC*8/4+8+4関心領域(ROI)の座標群を保持する入力テンソルへのポインタ。
BatchIndicesTensorDML_TENSOR_DESC*8/4+16+8各ROIが属するバッチ番号を保持する入力テンソルへのポインタ。
OutputTensorDML_TENSOR_DESC*8/4+24+12各ROIをプールした結果を格納する出力テンソルへのポインタ。
ReductionFunctionDML_REDUCE_FUNCTION4+32+16サンプル点を集約する縮約関数(平均や最大など)を指定する列挙値。
InterpolationModeDML_INTERPOLATION_MODE4+36+20サンプリング時の補間方法(最近傍や線形など)を指定する列挙値。
SpatialScaleXFLOAT4+40+24ROI座標を特徴マップ座標へ変換するX方向のスケール係数(単精度)。
SpatialScaleYFLOAT4+44+28ROI座標を特徴マップ座標へ変換するY方向のスケール係数(単精度)。
OutOfBoundsInputValueFLOAT4+48+32サンプル点が入力範囲外の場合に用いる代替値(単精度)。
MinimumSamplesPerOutputDWORD4+52+36出力1点あたりに取る最小サンプル数。
MaximumSamplesPerOutputDWORD4+56+40出力1点あたりに取る最大サンプル数。0で制限なし。

各言語での定義

#include <windows.h>

// DML_ROI_ALIGN_OPERATOR_DESC  (x64 64 / x86 44 バイト)
typedef struct DML_ROI_ALIGN_OPERATOR_DESC {
    DML_TENSOR_DESC* InputTensor;
    DML_TENSOR_DESC* ROITensor;
    DML_TENSOR_DESC* BatchIndicesTensor;
    DML_TENSOR_DESC* OutputTensor;
    DML_REDUCE_FUNCTION ReductionFunction;
    DML_INTERPOLATION_MODE InterpolationMode;
    FLOAT SpatialScaleX;
    FLOAT SpatialScaleY;
    FLOAT OutOfBoundsInputValue;
    DWORD MinimumSamplesPerOutput;
    DWORD MaximumSamplesPerOutput;
} DML_ROI_ALIGN_OPERATOR_DESC;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DML_ROI_ALIGN_OPERATOR_DESC
{
    public IntPtr InputTensor;
    public IntPtr ROITensor;
    public IntPtr BatchIndicesTensor;
    public IntPtr OutputTensor;
    public int ReductionFunction;
    public int InterpolationMode;
    public float SpatialScaleX;
    public float SpatialScaleY;
    public float OutOfBoundsInputValue;
    public uint MinimumSamplesPerOutput;
    public uint MaximumSamplesPerOutput;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DML_ROI_ALIGN_OPERATOR_DESC
    Public InputTensor As IntPtr
    Public ROITensor As IntPtr
    Public BatchIndicesTensor As IntPtr
    Public OutputTensor As IntPtr
    Public ReductionFunction As Integer
    Public InterpolationMode As Integer
    Public SpatialScaleX As Single
    Public SpatialScaleY As Single
    Public OutOfBoundsInputValue As Single
    Public MinimumSamplesPerOutput As UInteger
    Public MaximumSamplesPerOutput As UInteger
End Structure
import ctypes
from ctypes import wintypes

class DML_ROI_ALIGN_OPERATOR_DESC(ctypes.Structure):
    _fields_ = [
        ("InputTensor", ctypes.c_void_p),
        ("ROITensor", ctypes.c_void_p),
        ("BatchIndicesTensor", ctypes.c_void_p),
        ("OutputTensor", ctypes.c_void_p),
        ("ReductionFunction", ctypes.c_int),
        ("InterpolationMode", ctypes.c_int),
        ("SpatialScaleX", ctypes.c_float),
        ("SpatialScaleY", ctypes.c_float),
        ("OutOfBoundsInputValue", ctypes.c_float),
        ("MinimumSamplesPerOutput", wintypes.DWORD),
        ("MaximumSamplesPerOutput", wintypes.DWORD),
    ]
#[repr(C)]
pub struct DML_ROI_ALIGN_OPERATOR_DESC {
    pub InputTensor: *mut core::ffi::c_void,
    pub ROITensor: *mut core::ffi::c_void,
    pub BatchIndicesTensor: *mut core::ffi::c_void,
    pub OutputTensor: *mut core::ffi::c_void,
    pub ReductionFunction: i32,
    pub InterpolationMode: i32,
    pub SpatialScaleX: f32,
    pub SpatialScaleY: f32,
    pub OutOfBoundsInputValue: f32,
    pub MinimumSamplesPerOutput: u32,
    pub MaximumSamplesPerOutput: u32,
}
import "golang.org/x/sys/windows"

type DML_ROI_ALIGN_OPERATOR_DESC struct {
	InputTensor uintptr
	ROITensor uintptr
	BatchIndicesTensor uintptr
	OutputTensor uintptr
	ReductionFunction int32
	InterpolationMode int32
	SpatialScaleX float32
	SpatialScaleY float32
	OutOfBoundsInputValue float32
	MinimumSamplesPerOutput uint32
	MaximumSamplesPerOutput uint32
}
type
  DML_ROI_ALIGN_OPERATOR_DESC = record
    InputTensor: Pointer;
    ROITensor: Pointer;
    BatchIndicesTensor: Pointer;
    OutputTensor: Pointer;
    ReductionFunction: Integer;
    InterpolationMode: Integer;
    SpatialScaleX: Single;
    SpatialScaleY: Single;
    OutOfBoundsInputValue: Single;
    MinimumSamplesPerOutput: DWORD;
    MaximumSamplesPerOutput: DWORD;
  end;
const DML_ROI_ALIGN_OPERATOR_DESC = extern struct {
    InputTensor: ?*anyopaque,
    ROITensor: ?*anyopaque,
    BatchIndicesTensor: ?*anyopaque,
    OutputTensor: ?*anyopaque,
    ReductionFunction: i32,
    InterpolationMode: i32,
    SpatialScaleX: f32,
    SpatialScaleY: f32,
    OutOfBoundsInputValue: f32,
    MinimumSamplesPerOutput: u32,
    MaximumSamplesPerOutput: u32,
};
type
  DML_ROI_ALIGN_OPERATOR_DESC {.bycopy.} = object
    InputTensor: pointer
    ROITensor: pointer
    BatchIndicesTensor: pointer
    OutputTensor: pointer
    ReductionFunction: int32
    InterpolationMode: int32
    SpatialScaleX: float32
    SpatialScaleY: float32
    OutOfBoundsInputValue: float32
    MinimumSamplesPerOutput: uint32
    MaximumSamplesPerOutput: uint32
struct DML_ROI_ALIGN_OPERATOR_DESC
{
    void* InputTensor;
    void* ROITensor;
    void* BatchIndicesTensor;
    void* OutputTensor;
    int ReductionFunction;
    int InterpolationMode;
    float SpatialScaleX;
    float SpatialScaleY;
    float OutOfBoundsInputValue;
    uint MinimumSamplesPerOutput;
    uint MaximumSamplesPerOutput;
}

HSP用 定義

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

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

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