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

DML_ROI_ALIGN_GRAD_OPERATOR_DESC

構造体
サイズx64: 88 バイト / x86: 60 バイト

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

フィールド

フィールドサイズx64x86説明
InputTensorDML_TENSOR_DESC*8/4+0+0ROIAlign順方向の入力特徴マップを保持する入力テンソルへのポインタ。NULL可。
InputGradientTensorDML_TENSOR_DESC*8/4+8+4上流から逆伝播してきた勾配を保持する入力テンソルへのポインタ。
ROITensorDML_TENSOR_DESC*8/4+16+8関心領域(ROI)の座標群を保持する入力テンソルへのポインタ。
BatchIndicesTensorDML_TENSOR_DESC*8/4+24+12各ROIが属するバッチ番号を保持する入力テンソルへのポインタ。
OutputGradientTensorDML_TENSOR_DESC*8/4+32+16入力特徴マップに対する勾配を格納する出力テンソルへのポインタ。NULL可。
OutputROIGradientTensorDML_TENSOR_DESC*8/4+40+20ROI座標に対する勾配を格納する出力テンソルへのポインタ。NULL可。
ReductionFunctionDML_REDUCE_FUNCTION4+48+24順方向で使った縮約関数を指定する列挙値。
InterpolationModeDML_INTERPOLATION_MODE4+52+28順方向で使った補間方法を指定する列挙値。
SpatialScaleXFLOAT4+56+32ROI座標を特徴マップ座標へ変換するX方向のスケール係数(単精度)。
SpatialScaleYFLOAT4+60+36ROI座標を特徴マップ座標へ変換するY方向のスケール係数(単精度)。
InputPixelOffsetFLOAT4+64+40入力側のピクセル中心補正オフセット(単精度)。
OutputPixelOffsetFLOAT4+68+44出力側のピクセル中心補正オフセット(単精度)。
MinimumSamplesPerOutputDWORD4+72+48出力1点あたりに取る最小サンプル数。
MaximumSamplesPerOutputDWORD4+76+52出力1点あたりに取る最大サンプル数。0で制限なし。
AlignRegionsToCornersBOOL4+80+56領域を角に揃えるか中心に揃えるかを指定するフラグ。

各言語での定義

#include <windows.h>

// DML_ROI_ALIGN_GRAD_OPERATOR_DESC  (x64 88 / x86 60 バイト)
typedef struct DML_ROI_ALIGN_GRAD_OPERATOR_DESC {
    DML_TENSOR_DESC* InputTensor;
    DML_TENSOR_DESC* InputGradientTensor;
    DML_TENSOR_DESC* ROITensor;
    DML_TENSOR_DESC* BatchIndicesTensor;
    DML_TENSOR_DESC* OutputGradientTensor;
    DML_TENSOR_DESC* OutputROIGradientTensor;
    DML_REDUCE_FUNCTION ReductionFunction;
    DML_INTERPOLATION_MODE InterpolationMode;
    FLOAT SpatialScaleX;
    FLOAT SpatialScaleY;
    FLOAT InputPixelOffset;
    FLOAT OutputPixelOffset;
    DWORD MinimumSamplesPerOutput;
    DWORD MaximumSamplesPerOutput;
    BOOL AlignRegionsToCorners;
} DML_ROI_ALIGN_GRAD_OPERATOR_DESC;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DML_ROI_ALIGN_GRAD_OPERATOR_DESC
{
    public IntPtr InputTensor;
    public IntPtr InputGradientTensor;
    public IntPtr ROITensor;
    public IntPtr BatchIndicesTensor;
    public IntPtr OutputGradientTensor;
    public IntPtr OutputROIGradientTensor;
    public int ReductionFunction;
    public int InterpolationMode;
    public float SpatialScaleX;
    public float SpatialScaleY;
    public float InputPixelOffset;
    public float OutputPixelOffset;
    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_ALIGN_GRAD_OPERATOR_DESC
    Public InputTensor As IntPtr
    Public InputGradientTensor As IntPtr
    Public ROITensor As IntPtr
    Public BatchIndicesTensor As IntPtr
    Public OutputGradientTensor As IntPtr
    Public OutputROIGradientTensor 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 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_ALIGN_GRAD_OPERATOR_DESC(ctypes.Structure):
    _fields_ = [
        ("InputTensor", ctypes.c_void_p),
        ("InputGradientTensor", ctypes.c_void_p),
        ("ROITensor", ctypes.c_void_p),
        ("BatchIndicesTensor", ctypes.c_void_p),
        ("OutputGradientTensor", ctypes.c_void_p),
        ("OutputROIGradientTensor", 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),
        ("MinimumSamplesPerOutput", wintypes.DWORD),
        ("MaximumSamplesPerOutput", wintypes.DWORD),
        ("AlignRegionsToCorners", wintypes.BOOL),
    ]
#[repr(C)]
pub struct DML_ROI_ALIGN_GRAD_OPERATOR_DESC {
    pub InputTensor: *mut core::ffi::c_void,
    pub InputGradientTensor: *mut core::ffi::c_void,
    pub ROITensor: *mut core::ffi::c_void,
    pub BatchIndicesTensor: *mut core::ffi::c_void,
    pub OutputGradientTensor: *mut core::ffi::c_void,
    pub OutputROIGradientTensor: *mut core::ffi::c_void,
    pub ReductionFunction: i32,
    pub InterpolationMode: i32,
    pub SpatialScaleX: f32,
    pub SpatialScaleY: f32,
    pub InputPixelOffset: f32,
    pub OutputPixelOffset: f32,
    pub MinimumSamplesPerOutput: u32,
    pub MaximumSamplesPerOutput: u32,
    pub AlignRegionsToCorners: i32,
}
import "golang.org/x/sys/windows"

type DML_ROI_ALIGN_GRAD_OPERATOR_DESC struct {
	InputTensor uintptr
	InputGradientTensor uintptr
	ROITensor uintptr
	BatchIndicesTensor uintptr
	OutputGradientTensor uintptr
	OutputROIGradientTensor uintptr
	ReductionFunction int32
	InterpolationMode int32
	SpatialScaleX float32
	SpatialScaleY float32
	InputPixelOffset float32
	OutputPixelOffset float32
	MinimumSamplesPerOutput uint32
	MaximumSamplesPerOutput uint32
	AlignRegionsToCorners int32
}
type
  DML_ROI_ALIGN_GRAD_OPERATOR_DESC = record
    InputTensor: Pointer;
    InputGradientTensor: Pointer;
    ROITensor: Pointer;
    BatchIndicesTensor: Pointer;
    OutputGradientTensor: Pointer;
    OutputROIGradientTensor: Pointer;
    ReductionFunction: Integer;
    InterpolationMode: Integer;
    SpatialScaleX: Single;
    SpatialScaleY: Single;
    InputPixelOffset: Single;
    OutputPixelOffset: Single;
    MinimumSamplesPerOutput: DWORD;
    MaximumSamplesPerOutput: DWORD;
    AlignRegionsToCorners: BOOL;
  end;
const DML_ROI_ALIGN_GRAD_OPERATOR_DESC = extern struct {
    InputTensor: ?*anyopaque,
    InputGradientTensor: ?*anyopaque,
    ROITensor: ?*anyopaque,
    BatchIndicesTensor: ?*anyopaque,
    OutputGradientTensor: ?*anyopaque,
    OutputROIGradientTensor: ?*anyopaque,
    ReductionFunction: i32,
    InterpolationMode: i32,
    SpatialScaleX: f32,
    SpatialScaleY: f32,
    InputPixelOffset: f32,
    OutputPixelOffset: f32,
    MinimumSamplesPerOutput: u32,
    MaximumSamplesPerOutput: u32,
    AlignRegionsToCorners: i32,
};
type
  DML_ROI_ALIGN_GRAD_OPERATOR_DESC {.bycopy.} = object
    InputTensor: pointer
    InputGradientTensor: pointer
    ROITensor: pointer
    BatchIndicesTensor: pointer
    OutputGradientTensor: pointer
    OutputROIGradientTensor: pointer
    ReductionFunction: int32
    InterpolationMode: int32
    SpatialScaleX: float32
    SpatialScaleY: float32
    InputPixelOffset: float32
    OutputPixelOffset: float32
    MinimumSamplesPerOutput: uint32
    MaximumSamplesPerOutput: uint32
    AlignRegionsToCorners: int32
struct DML_ROI_ALIGN_GRAD_OPERATOR_DESC
{
    void* InputTensor;
    void* InputGradientTensor;
    void* ROITensor;
    void* BatchIndicesTensor;
    void* OutputGradientTensor;
    void* OutputROIGradientTensor;
    int ReductionFunction;
    int InterpolationMode;
    float SpatialScaleX;
    float SpatialScaleY;
    float InputPixelOffset;
    float OutputPixelOffset;
    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_ALIGN_GRAD_OPERATOR_DESC サイズ: 60 バイト(x86)
dim st, 15    ; 4byte整数×15(構造体サイズ 60 / 4 切り上げ)
; InputTensor : DML_TENSOR_DESC* (+0, 4byte)  varptr(st)+0 を基点に操作(4byte:入れ子/配列)
; InputGradientTensor : DML_TENSOR_DESC* (+4, 4byte)  varptr(st)+4 を基点に操作(4byte:入れ子/配列)
; ROITensor : DML_TENSOR_DESC* (+8, 4byte)  varptr(st)+8 を基点に操作(4byte:入れ子/配列)
; BatchIndicesTensor : DML_TENSOR_DESC* (+12, 4byte)  varptr(st)+12 を基点に操作(4byte:入れ子/配列)
; OutputGradientTensor : DML_TENSOR_DESC* (+16, 4byte)  varptr(st)+16 を基点に操作(4byte:入れ子/配列)
; OutputROIGradientTensor : DML_TENSOR_DESC* (+20, 4byte)  varptr(st)+20 を基点に操作(4byte:入れ子/配列)
; ReductionFunction : DML_REDUCE_FUNCTION (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; InterpolationMode : DML_INTERPOLATION_MODE (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; SpatialScaleX : FLOAT (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; SpatialScaleY : FLOAT (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; InputPixelOffset : FLOAT (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; OutputPixelOffset : FLOAT (+44, 4byte)  st.11 = 値  /  値 = st.11   (lpoke/lpeek も可)
; MinimumSamplesPerOutput : DWORD (+48, 4byte)  st.12 = 値  /  値 = st.12   (lpoke/lpeek も可)
; MaximumSamplesPerOutput : DWORD (+52, 4byte)  st.13 = 値  /  値 = st.13   (lpoke/lpeek も可)
; AlignRegionsToCorners : BOOL (+56, 4byte)  st.14 = 値  /  値 = st.14   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DML_ROI_ALIGN_GRAD_OPERATOR_DESC サイズ: 88 バイト(x64)
dim st, 22    ; 4byte整数×22(構造体サイズ 88 / 4 切り上げ)
; InputTensor : DML_TENSOR_DESC* (+0, 8byte)  varptr(st)+0 を基点に操作(8byte:入れ子/配列)
; InputGradientTensor : DML_TENSOR_DESC* (+8, 8byte)  varptr(st)+8 を基点に操作(8byte:入れ子/配列)
; ROITensor : DML_TENSOR_DESC* (+16, 8byte)  varptr(st)+16 を基点に操作(8byte:入れ子/配列)
; BatchIndicesTensor : DML_TENSOR_DESC* (+24, 8byte)  varptr(st)+24 を基点に操作(8byte:入れ子/配列)
; OutputGradientTensor : DML_TENSOR_DESC* (+32, 8byte)  varptr(st)+32 を基点に操作(8byte:入れ子/配列)
; OutputROIGradientTensor : DML_TENSOR_DESC* (+40, 8byte)  varptr(st)+40 を基点に操作(8byte:入れ子/配列)
; ReductionFunction : DML_REDUCE_FUNCTION (+48, 4byte)  st.12 = 値  /  値 = st.12   (lpoke/lpeek も可)
; InterpolationMode : DML_INTERPOLATION_MODE (+52, 4byte)  st.13 = 値  /  値 = st.13   (lpoke/lpeek も可)
; SpatialScaleX : FLOAT (+56, 4byte)  st.14 = 値  /  値 = st.14   (lpoke/lpeek も可)
; SpatialScaleY : FLOAT (+60, 4byte)  st.15 = 値  /  値 = st.15   (lpoke/lpeek も可)
; InputPixelOffset : FLOAT (+64, 4byte)  st.16 = 値  /  値 = st.16   (lpoke/lpeek も可)
; OutputPixelOffset : FLOAT (+68, 4byte)  st.17 = 値  /  値 = st.17   (lpoke/lpeek も可)
; MinimumSamplesPerOutput : DWORD (+72, 4byte)  st.18 = 値  /  値 = st.18   (lpoke/lpeek も可)
; MaximumSamplesPerOutput : DWORD (+76, 4byte)  st.19 = 値  /  値 = st.19   (lpoke/lpeek も可)
; AlignRegionsToCorners : BOOL (+80, 4byte)  st.20 = 値  /  値 = st.20   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global DML_ROI_ALIGN_GRAD_OPERATOR_DESC
    #field intptr InputTensor
    #field intptr InputGradientTensor
    #field intptr ROITensor
    #field intptr BatchIndicesTensor
    #field intptr OutputGradientTensor
    #field intptr OutputROIGradientTensor
    #field int ReductionFunction
    #field int InterpolationMode
    #field float SpatialScaleX
    #field float SpatialScaleY
    #field float InputPixelOffset
    #field float OutputPixelOffset
    #field int MinimumSamplesPerOutput
    #field int MaximumSamplesPerOutput
    #field bool AlignRegionsToCorners
#endstruct

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