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

DML_ROI_ALIGN1_OPERATOR_DESC

構造体
サイズx64: 72 バイト / x86: 56 バイト

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

フィールド

フィールドサイズx64x86説明
InputTensorDML_TENSOR_DESC*8/4+0+0特徴マップを保持する入力テンソルへのポインタ。
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方向のスケール係数(単精度)。
InputPixelOffsetFLOAT4+48+32入力側のピクセル中心補正オフセット(単精度)。座標合わせに使う。
OutputPixelOffsetFLOAT4+52+36出力側のピクセル中心補正オフセット(単精度)。座標合わせに使う。
OutOfBoundsInputValueFLOAT4+56+40サンプル点が入力範囲外の場合に用いる代替値(単精度)。
MinimumSamplesPerOutputDWORD4+60+44出力1点あたりに取る最小サンプル数。
MaximumSamplesPerOutputDWORD4+64+48出力1点あたりに取る最大サンプル数。0で制限なし。
AlignRegionsToCornersBOOL4+68+52領域を角に揃えるか中心に揃えるかを指定するフラグ。

各言語での定義

#include <windows.h>

// DML_ROI_ALIGN1_OPERATOR_DESC  (x64 72 / x86 56 バイト)
typedef struct DML_ROI_ALIGN1_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 InputPixelOffset;
    FLOAT OutputPixelOffset;
    FLOAT OutOfBoundsInputValue;
    DWORD MinimumSamplesPerOutput;
    DWORD MaximumSamplesPerOutput;
    BOOL AlignRegionsToCorners;
} DML_ROI_ALIGN1_OPERATOR_DESC;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DML_ROI_ALIGN1_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 InputPixelOffset;
    public float OutputPixelOffset;
    public float OutOfBoundsInputValue;
    public uint MinimumSamplesPerOutput;
    public uint MaximumSamplesPerOutput;
    [MarshalAs(UnmanagedType.Bool)] public bool AlignRegionsToCorners;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DML_ROI_ALIGN1_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 InputPixelOffset As Single
    Public OutputPixelOffset As Single
    Public OutOfBoundsInputValue As Single
    Public MinimumSamplesPerOutput As UInteger
    Public MaximumSamplesPerOutput As UInteger
    <MarshalAs(UnmanagedType.Bool)> Public AlignRegionsToCorners As Boolean
End Structure
import ctypes
from ctypes import wintypes

class DML_ROI_ALIGN1_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),
        ("InputPixelOffset", ctypes.c_float),
        ("OutputPixelOffset", ctypes.c_float),
        ("OutOfBoundsInputValue", ctypes.c_float),
        ("MinimumSamplesPerOutput", wintypes.DWORD),
        ("MaximumSamplesPerOutput", wintypes.DWORD),
        ("AlignRegionsToCorners", wintypes.BOOL),
    ]
#[repr(C)]
pub struct DML_ROI_ALIGN1_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 InputPixelOffset: f32,
    pub OutputPixelOffset: f32,
    pub OutOfBoundsInputValue: f32,
    pub MinimumSamplesPerOutput: u32,
    pub MaximumSamplesPerOutput: u32,
    pub AlignRegionsToCorners: i32,
}
import "golang.org/x/sys/windows"

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

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_ALIGN1_OPERATOR_DESC サイズ: 56 バイト(x86)
dim st, 14    ; 4byte整数×14(構造体サイズ 56 / 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 も可)
; InputPixelOffset : FLOAT (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; OutputPixelOffset : FLOAT (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; OutOfBoundsInputValue : FLOAT (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; MinimumSamplesPerOutput : DWORD (+44, 4byte)  st.11 = 値  /  値 = st.11   (lpoke/lpeek も可)
; MaximumSamplesPerOutput : DWORD (+48, 4byte)  st.12 = 値  /  値 = st.12   (lpoke/lpeek も可)
; AlignRegionsToCorners : BOOL (+52, 4byte)  st.13 = 値  /  値 = st.13   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DML_ROI_ALIGN1_OPERATOR_DESC サイズ: 72 バイト(x64)
dim st, 18    ; 4byte整数×18(構造体サイズ 72 / 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 も可)
; InputPixelOffset : FLOAT (+48, 4byte)  st.12 = 値  /  値 = st.12   (lpoke/lpeek も可)
; OutputPixelOffset : FLOAT (+52, 4byte)  st.13 = 値  /  値 = st.13   (lpoke/lpeek も可)
; OutOfBoundsInputValue : FLOAT (+56, 4byte)  st.14 = 値  /  値 = st.14   (lpoke/lpeek も可)
; MinimumSamplesPerOutput : DWORD (+60, 4byte)  st.15 = 値  /  値 = st.15   (lpoke/lpeek も可)
; MaximumSamplesPerOutput : DWORD (+64, 4byte)  st.16 = 値  /  値 = st.16   (lpoke/lpeek も可)
; AlignRegionsToCorners : BOOL (+68, 4byte)  st.17 = 値  /  値 = st.17   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global DML_ROI_ALIGN1_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 InputPixelOffset
    #field float OutputPixelOffset
    #field float OutOfBoundsInputValue
    #field int MinimumSamplesPerOutput
    #field int MaximumSamplesPerOutput
    #field bool AlignRegionsToCorners
#endstruct

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