Condividi tramite


struttura DML_ACTIVATION_HARDMAX1_OPERATOR_DESC (directml.h)

Esegue una funzione hardmax su ogni elemento di InputTensor, inserendo il risultato nell'elemento corrispondente di OutputTensor.

L'operatore calcola il valore hardmax (1 per il primo valore massimo lungo gli assi specificati e 0 per tutti gli altri valori) di ogni elemento nell'input specificato.

reducedTensor = ReduceArgMax(InputTensor, axes = Axes, axisDirection = DML_AXIS_DIRECTION_INCREASING)
broadcastedTensor = Broadcast the `reducedTensor` to `InputTensor`
for each coordinate in OutputTensor
    if broadcastedTensor[coordinate] == reducedIndexOf(coordinate)   // reducedIndexOf(coordinate) is the index of the coordinate within reduced axes `axes`.
        OutputTensor[coordinate] = 1
    else
        OutputTensor[coordinate] = 0
endfor

Dove ReduceArgMax(input = InputTensor, axis = Axes) è DML_REDUCE_OPERATOR con DML_REDUCE_FUNCTION_ARGMAX come funzione di riduzione.

Importante

Questa API è disponibile come parte del pacchetto ridistribuibile autonomo DirectML (vedere Microsoft.AI.DirectML versione 1.9 e successive. Vedere anche cronologia delle versioni di DirectML.

Sintassi

struct DML_ACTIVATION_HARDMAX1_OPERATOR_DESC
{
    const DML_TENSOR_DESC* InputTensor;
    const DML_TENSOR_DESC* OutputTensor;
    UINT AxisCount;
    _Field_size_(AxisCount) const UINT* Axes;
};

Membri

InputTensor

Tipo: const DML_TENSOR_DESC*

Tensore di input da cui leggere.

OutputTensor

Tipo: const DML_TENSOR_DESC*

Tensore di output in cui scrivere i risultati.

AxisCount

Tipo: UINT

Numero di assi da calcolare per ridurre hardmax. Questo campo determina le dimensioni della matrice Axes .

Axes

Tipo: _Field_size_(AxisCount) const UINT*

Assi lungo i quali ridurre hardmax. I valori devono trovarsi nell'intervallo [0, InputTensor.DimensionCount - 1].

Esempi

Tutti gli esempi seguenti usano questo stesso tensore di input tridimensionale:

InputTensor: (Sizes:{2, 2, 2}, DataType:FLOAT32)
[
    [
        [  12, 0],
        [-101, 11],
    ],
    [
        [  3,  234],
        [  0, -101],
    ]
]

Esempio 1

AxisCount: 1
Axes: {1}
OutputTensor: (Sizes:{2, 2, 2}, DataType:FLOAT32)
[
    [               // max element in {12, -101} is 12 and in {0, 11} is 11
        [1, 0],
        [0, 1],
    ],
    [               // max element in {3, 0} is 3 and in {234, -101} is 234
        [1, 1],
        [0, 0],
    ]
]

Esempio 2

AxisCount: 1
Axes: {0}
OutputTensor: (Sizes:{2, 2, 2}, DataType:FLOAT32)
[
    [               // max element in {12, 3} is 12, in {0, 234} is 234, in {-101, 0} is 0 and in {11, -101} is 11
        [1, 0],
        [0, 1],
    ],
    [
        [0, 1],
        [1, 0],
    ]
]

Esempio 3

AxisCount: 2
Axes: {0, 2}
OutputTensor: (Sizes:{2, 2, 2}, DataType:FLOAT32)
[
    [               // max element in {12, 0, 3, 234} is 234 and in {-101, 11, 0, -101} is 11
        [0, 0],
        [0, 1],
    ],
    [
        [0, 1],
        [0, 0],
    ]
]

Osservazioni:

Questo operatore equivale a DML_ACTIVATION_HARDMAX_OPERATOR_DESC quando AxisCount == 1 e Axes == {DimensionCount - 1}.

Disponibilità

Questo operatore è stato introdotto in DML_FEATURE_LEVEL_5_1.

Vincoli tensor

InputTensor e OutputTensor devono avere gli stessi Valori DataType, DimensionCount e Size.

Supporto tensor

Tensore Tipo Conteggi delle dimensioni supportati Tipi di dati supportati
InputTensor Inserimento Da 1 a 8 FLOAT32, FLOAT16
OutputTensor Risultato Da 1 a 8 FLOAT32, FLOAT16

Requisiti

   
Intestazione directml.h

Vedere anche