updat ops validations
This commit is contained in:
+270
-136
@@ -1,174 +1,308 @@
|
||||
# Validation Operations
|
||||
# Operation Validation Suite
|
||||
|
||||
ONNX test models used by `validate.py` to verify the Raptor compiler + PIM simulator pipeline.
|
||||
This directory contains the ONNX models used by `validation/validate.py` to
|
||||
validate individual operations through compilation, PIM simulation, and
|
||||
comparison with the ONNX-MLIR reference runtime.
|
||||
|
||||
Generated tests can be regenerated with:
|
||||
## Naming
|
||||
|
||||
```
|
||||
python3 validation/operations/gen_tests.py
|
||||
Every model uses the same path convention:
|
||||
|
||||
```text
|
||||
<category>/<case>/<category>_<case>.onnx
|
||||
```
|
||||
|
||||
## Conv
|
||||
The `<category>/<case>` pair is the operation ID printed by the validator.
|
||||
Use lowercase `snake_case` for both components. Keep the generator function,
|
||||
graph name, directory, and filename based on the same operation ID when adding
|
||||
a test.
|
||||
|
||||
| Test | Directory | Input | Output | Kernel | Stride | Padding | Bias | Notes |
|
||||
|------------------|-------------------------|-----------|-----------|--------|--------|------------|------|------------------------------------|
|
||||
| Simple | `conv/simple` | [1,3,3,3] | [1,1,2,2] | 2x2 | 1 | none | no | Basic conv, hand-crafted |
|
||||
| With constant | `conv/with_constant` | [1,3,3,3] | [1,1,3,3] | 2x2 | 1 | SAME_UPPER | yes | Hand-crafted, constant weight+bias |
|
||||
| Batch 2 | `conv/batch_2` | [2,3,3,3] | [2,1,3,3] | 2x2 | 1 | SAME_UPPER | yes | Batched input |
|
||||
| Kernel 3x3 | `conv/kernel_3x3` | [1,1,5,5] | [1,1,3,3] | 3x3 | 1 | none | no | Larger kernel |
|
||||
| Stride 2 | `conv/stride_2` | [1,1,6,6] | [1,1,2,2] | 3x3 | 2 | none | no | Strided convolution |
|
||||
| Multi channel | `conv/multi_channel` | [1,3,5,5] | [1,4,3,3] | 3x3 | 1 | none | no | 3 in channels, 4 out channels |
|
||||
| Pointwise 1x1 | `conv/pointwise_1x1` | [1,8,4,4] | [1,4,4,4] | 1x1 | 1 | none | no | Channel mixing |
|
||||
| SAME padding 3x3 | `conv/same_padding_3x3` | [1,1,5,5] | [1,1,5,5] | 3x3 | 1 | SAME_UPPER | no | Spatial dims preserved |
|
||||
| Explicit padding | `conv/explicit_padding` | [1,1,4,4] | [1,1,4,4] | 3x3 | 1 | [1,1,1,1] | no | Symmetric explicit pads |
|
||||
| With bias 3x3 | `conv/with_bias_3x3` | [1,3,5,5] | [1,2,3,3] | 3x3 | 1 | none | yes | Multi-channel with bias |
|
||||
| Large spatial | `conv/large_spatial` | [1,1,8,8] | [1,1,6,6] | 3x3 | 1 | none | no | Larger spatial input |
|
||||
| Grouped two groups | `conv/grouped_two_groups` | [1,4,4,4] | [1,4,4,4] | 1x1 | 1 | none | yes | group=2 channel partitioning |
|
||||
| Depthwise grouped | `conv/depthwise_grouped` | [1,3,4,4] | [1,3,2,2] | 3x3 | 1 | none | no | group=3, one input channel per group |
|
||||
| Dynamic | `conv/dynamic` | [1,1,4,4] | [1,1,2,2] | 3x3 | 1 | none | no | Runtime input and weight |
|
||||
## Generate and validate
|
||||
|
||||
## Gemm
|
||||
Regenerate all generated models from the repository root:
|
||||
|
||||
| Test | Directory | A (input) | B/W tensor | Output | transB | alpha | beta | Bias | Notes |
|
||||
|---------------|-------------------------|-----------|------------|----------|--------|-------|------|-------|------------------------------|
|
||||
| Simple | `gemm/simple` | [10,132] | [132,132] | [10,132] | no | 1 | 1 | no | Square weights |
|
||||
| Non-square | `gemm/non_square` | [4,128] | [128,64] | [4,64] | no | 1 | 1 | no | K != N |
|
||||
| With bias | `gemm/with_bias` | [4,128] | [128,128] | [4,128] | no | 1 | 1 | [128] | Bias vector |
|
||||
| transB | `gemm/transB` | [4,128] | [64,128] | [4,64] | yes | 1 | 1 | no | Transposed weight |
|
||||
| Alpha/beta | `gemm/alpha_beta` | [4,64] | [64,64] | [4,64] | no | 0.5 | 0.25 | [64] | Scaled matmul + bias |
|
||||
| Small | `gemm/small` | [2,8] | [8,4] | [2,4] | no | 1 | 1 | no | Tiny matrices |
|
||||
| Large | `gemm/large` | [8,256] | [256,128] | [8,128] | no | 1 | 1 | no | Larger matrices |
|
||||
| transB + bias | `gemm/transB_with_bias` | [4,128] | [64,128] | [4,64] | yes | 1 | 1 | [64] | Combined |
|
||||
| Dynamic | `gemm/dynamic` | [2,8] | [8,4] | [2,4] | no | 1 | 1 | no | Runtime matrix operands |
|
||||
| Dynamic transB | `gemm/dynamic_transB` | [2,8] | [4,8] | [2,4] | yes | 1 | 1 | no | Runtime transpose handling |
|
||||
| Dynamic bias | `gemm/dynamic_bias` | [2,8] | [8,4] | [2,4] | no | 1 | 1 | [4] | Runtime bias broadcast |
|
||||
| Dynamic alpha | `gemm/dynamic_alpha` | [2,8] | [8,4] | [2,4] | no | 0.5 | 1 | no | Runtime alpha scaling |
|
||||
| Dynamic beta | `gemm/dynamic_beta` | [2,8] | [8,4] | [2,4] | no | 1 | 2 | [4] | Runtime beta scaling |
|
||||
| Dynamic bias + scale | `gemm/dynamic_bias_alpha_beta` | [2,8] | [8,4] | [2,4] | no | 0.5 | 2 | [4] | Runtime operands and bias |
|
||||
```bash
|
||||
.venv/bin/python validation/operations/gen_tests.py
|
||||
```
|
||||
|
||||
## MatMul
|
||||
Run the complete suite with deadlock detection:
|
||||
|
||||
| Test | Directory | A input | B tensor | Output | Notes |
|
||||
|---------------------|----------------------------------|----------|----------|---------|-------------------------------------------------|
|
||||
| Basic | `matmul/basic` | [2,3] | [3,4] | [2,4] | Direct 2D MatMul rewrite path |
|
||||
| Left constant | `matmul/left_constant` | [2,3] | [3,4] | [2,4] | Constant LHS transpose rewrite path |
|
||||
| Dynamic | `matmul/dynamic` | [2,3] | [3,4] | [2,4] | Runtime matrix operands |
|
||||
| Batched 3D | `matmul/batched_3d` | [2,2,3] | [2,3,4] | [2,2,4] | Matching-batch direct batched lowering |
|
||||
| Batched 3D dynamic | `matmul/batched_3d_dynamic` | [2,2,3] | [2,3,4] | [2,2,4] | Batched runtime operands |
|
||||
| Batched left const | `matmul/batched_left_constant` | [2,2,3] | [2,3,4] | [2,2,4] | Batched constant-LHS transpose path |
|
||||
| Batched RHS broadcast | `matmul/batched_rhs_broadcast` | [2,2,3] | [3,4] | [2,2,4] | Rank-2 RHS broadcast across batch |
|
||||
| Batched LHS broadcast | `matmul/batched_lhs_broadcast` | [2,3] | [2,3,4] | [2,2,4] | Rank-2 LHS broadcast across batched RHS |
|
||||
```bash
|
||||
.venv/bin/python validation/validate.py \
|
||||
--raptor-path build_release/Release/bin/onnx-mlir \
|
||||
--onnx-include-dir onnx-mlir/include \
|
||||
--operations-dir validation/operations \
|
||||
--crossbar-count 64 \
|
||||
--crossbar-size 128 \
|
||||
--core-count 144 \
|
||||
--raptor-extra-arg=--pim-detect-communication-deadlock \
|
||||
--raptor-extra-arg=--pim-export-spatial-dataflow=none
|
||||
```
|
||||
|
||||
## Gemv
|
||||
Use `--compile-only` for compiler and deadlock checks, then `--run-only` to
|
||||
reuse those artifacts for reference execution, simulation, and comparison.
|
||||
The validator prints the complete operation results table before its summary.
|
||||
|
||||
| Test | Directory | Input | W (weight) | Output | Bias | Notes |
|
||||
|---------------------|------------------------------------|----------|------------|---------|---------|----------------------------|
|
||||
| Simple | `gemv/simple` | [1,132] | [132,132] | [1,132] | no | Single-sample matmul |
|
||||
| Constant | `gemv/constant` | _(none)_ | [132,132] | [1,132] | no | All inputs constant |
|
||||
| Homogeneous const | `gemv/with_homogeneous_constant` | [1,132] | [132,132] | [1,132] | [1,132] | Bias matches output shape |
|
||||
| Heterogeneous const | `gemv/with_heterogeneous_constant` | [1,132] | [132,132] | [1,132] | [1,132] | Different constant pattern |
|
||||
| Scalar const | `gemv/with_scalar_constant` | [1,132] | [132,132] | [1,132] | [1,1] | Scalar bias, broadcast |
|
||||
## Complete inventory
|
||||
|
||||
## Pool
|
||||
The suite contains 164 models. Tensor shapes, attributes, and constants are
|
||||
defined in `gen_tests.py` and in the checked-in ONNX models.
|
||||
|
||||
| Test | Directory | Input | Output | Kernel | Stride | Padding | Notes |
|
||||
|----------------------------|---------------------------------|-----------|-----------|------------------------|--------|------------|----------------------------------|
|
||||
| Max basic | `pool/max_basic` | [1,1,4,4] | [1,1,3,3] | 2x2 | 1 | none | Basic max pooling |
|
||||
| Max stride 2 multi-channel | `pool/max_stride2_multichannel` | [1,5,6,6] | [1,5,3,3] | 2x2 | 2 | none | Channel-preserving max pool |
|
||||
| Max SAME_UPPER | `pool/max_same_upper` | [1,1,5,5] | [1,1,3,3] | 3x3 | 2 | SAME_UPPER | Deprecated auto_pad path |
|
||||
| Avg basic | `pool/avg_basic` | [1,3,4,4] | [1,3,3,3] | 2x2 | 1 | none | Basic average pooling |
|
||||
| Avg explicit padding | `pool/avg_explicit_padding` | [1,2,4,4] | [1,2,2,2] | 3x3 | 2 | [1,1,1,1] | `count_include_pad=0` |
|
||||
| Avg include pad | `pool/avg_include_pad` | [1,2,4,4] | [1,2,2,2] | 3x3 | 2 | [1,1,1,1] | `count_include_pad=1` |
|
||||
| Max after Conv | `pool/max_after_conv` | [1,3,6,6] | [1,4,2,2] | Conv 3x3 then Pool 2x2 | 2 | none | Regression for `pool(conv(...))` |
|
||||
### Add (5)
|
||||
|
||||
## ReduceMean
|
||||
| Case | Description |
|
||||
|---|---|
|
||||
| `after_gemm` | Gemm followed by Add with a broadcast bias vector. |
|
||||
| `basic` | Elementwise Add on two inputs with identical shapes. |
|
||||
| `broadcast_row` | Elementwise Add with row-vector broadcasting. |
|
||||
| `channel_broadcast_1024` | NCHW per-channel broadcasting over 1024 channels. |
|
||||
| `leading_dimension_broadcast` | Trailing-dimension broadcasting across leading dimensions. |
|
||||
|
||||
| Test | Directory | Input | Output | Axes | Keepdims | Notes |
|
||||
|------------|--------------------------|-----------|-----------|-------|----------|-------------------------------------------------|
|
||||
| Basic | `reduce_mean/basic` | [4,8] | [4,1] | [1] | 1 | Reduce feature dimension, preserving rank |
|
||||
| Keepdims 0 | `reduce_mean/keepdims_0` | [4,8] | [4] | [1] | 0 | Reduce feature dimension, dropping reduced axis |
|
||||
| 4D spatial | `reduce_mean/4d_spatial` | [1,3,4,4] | [1,3,1,1] | [2,3] | 1 | Reduce H and W on NCHW input |
|
||||
| After Conv | `reduce_mean/after_conv` | [1,3,5,5] | [1,2,1,1] | [2,3] | 1 | Conv 3x3 + bias, then spatial ReduceMean |
|
||||
### Concat (3)
|
||||
|
||||
## Relu
|
||||
| Case | Description |
|
||||
|---|---|
|
||||
| `channel_axis` | Concatenates two runtime NCHW tensors along the channel axis. |
|
||||
| `negative_axis` | Concatenates tensors using a negative axis. |
|
||||
| `three_inputs_channel_axis` | Concatenates three runtime NCHW tensors along the channel axis. |
|
||||
|
||||
| Test | Directory | Input | Output | Notes |
|
||||
|------------|-------------------|-----------|-----------|----------------------------|
|
||||
| Basic | `relu/basic` | [4,8] | [4,8] | Standalone 2D Relu |
|
||||
| 4D | `relu/4d` | [2,3,4,4] | [2,3,4,4] | Standalone NCHW Relu |
|
||||
| After Conv | `relu/after_conv` | [1,3,5,5] | [1,2,3,3] | Conv 3x3 + bias, then Relu |
|
||||
| After Gemm | `relu/after_gemm` | [4,64] | [4,32] | Gemm + bias, then Relu |
|
||||
### Conv (31)
|
||||
|
||||
## Sigmoid
|
||||
| Case | Description |
|
||||
|---|---|
|
||||
| `batch_2` | Batched Conv with SAME_UPPER padding and bias. |
|
||||
| `batch_4_pointwise` | Pointwise Conv with batch size four. |
|
||||
| `depthwise_1024_channels` | Depthwise pointwise Conv with 1024 groups. |
|
||||
| `depthwise_grouped` | Depthwise-style grouped Conv with one input channel per group. |
|
||||
| `dilated_3x3` | Conv with a dilated 3x3 kernel. |
|
||||
| `dynamic` | Conv with runtime input and weight tensors. |
|
||||
| `explicit_padding` | 3x3 Conv with symmetric explicit padding. |
|
||||
| `grouped_many_groups` | Pointwise Conv with many groups and high channel counts. |
|
||||
| `grouped_two_groups` | Two-group pointwise Conv with bias. |
|
||||
| `huge_pointwise_1024` | Pointwise Conv with 1024 input and output channels. |
|
||||
| `huge_pointwise_1024_dynamic` | The 1024-channel pointwise Conv with runtime weights. |
|
||||
| `kernel_3x3` | Basic 3x3 Conv without padding. |
|
||||
| `kernel_equals_input_spatial` | Conv whose kernel covers the full spatial input. |
|
||||
| `large_input_channels_1x1` | Pointwise Conv with 1024 input channels and modest output width. |
|
||||
| `large_output_channels_1x1` | Pointwise Conv with modest input width and 1024 output channels. |
|
||||
| `large_spatial` | 3x3 Conv on a larger spatial input. |
|
||||
| `multi_channel` | 3x3 Conv with multiple input and output channels. |
|
||||
| `non_square_kernel_1x3` | Conv with a non-square 1x3 kernel. |
|
||||
| `non_square_kernel_3x1` | Conv with a non-square 3x1 kernel. |
|
||||
| `non_uniform_stride` | Conv with different height and width strides. |
|
||||
| `pointwise_1x1` | Basic pointwise channel-mixing Conv. |
|
||||
| `pointwise_tiled_chain` | Relu and chained pointwise Convs with a tiled intermediate. |
|
||||
| `real_asymmetric_padding` | Conv with asymmetric explicit padding. |
|
||||
| `relu_conv_store` | Conv, Relu, and a second Conv to validate an intermediate stored result. |
|
||||
| `same_lower_3x3` | 3x3 Conv with SAME_LOWER padding. |
|
||||
| `same_padding_3x3` | 3x3 Conv with SAME_UPPER padding. |
|
||||
| `simple` | Hand-authored basic 2x2 Conv. |
|
||||
| `stride_2` | 3x3 Conv with stride two. |
|
||||
| `with_bias_3x3` | Multi-channel 3x3 Conv with bias. |
|
||||
| `with_constant` | Hand-authored SAME_UPPER Conv with constant weight and bias. |
|
||||
| `without_kernel_shape_attr` | Conv whose kernel shape is inferred from its weight tensor. |
|
||||
|
||||
| Test | Directory | Input | Output | Notes |
|
||||
|------------|----------------------|-----------|-----------|---------------------------|
|
||||
| Basic | `sigmoid/basic` | [4,8] | [4,8] | Standalone 2D Sigmoid |
|
||||
| 4D | `sigmoid/4d` | [2,3,4,4] | [2,3,4,4] | Standalone NCHW Sigmoid |
|
||||
| After Gemm | `sigmoid/after_gemm` | [4,64] | [4,32] | Gemm + bias, then Sigmoid |
|
||||
### Div (6)
|
||||
|
||||
## Softmax
|
||||
| Case | Description |
|
||||
|---|---|
|
||||
| `after_gemm` | Gemm followed by Div with a broadcast divisor vector. |
|
||||
| `basic` | Elementwise Div by a same-shape constant tensor. |
|
||||
| `channel_broadcast_1024` | Div with NCHW per-channel broadcasting over 1024 channels. |
|
||||
| `leading_dimension_broadcast` | Div with trailing-dimension broadcasting. |
|
||||
| `runtime_scalar_rhs` | Div of a runtime tensor by a scalar initializer. |
|
||||
| `scalar_constant` | Div with scalar broadcasting on a 2D tensor. |
|
||||
|
||||
| Test | Directory | Input | Output | Axis | Notes |
|
||||
|--------------|--------------------------|-------------|-------------|------|---------------------------------|
|
||||
| Basic | `softmax/basic` | [3,5] | [3,5] | 1 | Row-wise softmax over features |
|
||||
| 3D last axis | `softmax/3d_last_axis` | [2,3,4] | [2,3,4] | 2 | Last-dimension normalization |
|
||||
| Channel axis | `softmax/channel_axis` | [1,3,2,2] | [1,3,2,2] | 1 | NCHW channel-wise softmax |
|
||||
### Gather (5)
|
||||
|
||||
## Resize
|
||||
| Case | Description |
|
||||
|---|---|
|
||||
| `3d_input_axis1` | Gathers along axis one of a 3D input. |
|
||||
| `axis0_matrix_indices` | Gathers rows using a 2D indices tensor. |
|
||||
| `axis1` | Gathers selected columns from a 2D tensor. |
|
||||
| `negative_axis` | Gathers using a negative axis. |
|
||||
| `negative_indices` | Gathers with negative indices along axis zero. |
|
||||
|
||||
| Test | Directory | Input | Output | Mode | Notes |
|
||||
|---------------------|-------------------------|-----------|-----------|---------|-----------------------------------------|
|
||||
| Nearest 2x | `resize/nearest_2x` | [1,1,2,3] | [1,1,4,6] | nearest | NCHW upsampling with scales [1,1,2,2] |
|
||||
| Non-uniform scales | `resize/non_uniform` | [1,1,2,3] | [1,1,6,6] | nearest | Different height/width scaling factors |
|
||||
| Explicit sizes | `resize/with_sizes` | [1,1,2,3] | [1,1,3,5] | nearest | Sizes input used instead of scales |
|
||||
### Gemm (21)
|
||||
|
||||
## Split
|
||||
| Case | Description |
|
||||
|---|---|
|
||||
| `alpha_beta` | Applies non-default alpha and beta scaling with bias. |
|
||||
| `bias_rank2_broadcast` | Broadcasts a rank-2 bias across output rows. |
|
||||
| `dynamic` | Uses both matrix operands at runtime. |
|
||||
| `dynamic_alpha` | Uses runtime operands with non-default alpha scaling. |
|
||||
| `dynamic_beta` | Uses runtime operands and bias with non-default beta scaling. |
|
||||
| `dynamic_bias` | Uses runtime matrix operands and runtime bias. |
|
||||
| `dynamic_bias_alpha_beta` | Combines runtime operands and bias with alpha and beta scaling. |
|
||||
| `dynamic_transB` | Transposes a runtime right-hand matrix. |
|
||||
| `huge_1024` | Uses 1024-wide inner and output dimensions. |
|
||||
| `large` | Exercises larger rectangular matrices. |
|
||||
| `large_k_small_n` | Uses a large reduction dimension and narrow output. |
|
||||
| `non_square` | Uses different reduction and output widths. |
|
||||
| `scalar_bias` | Broadcasts a scalar bias to the full output. |
|
||||
| `simple` | Basic Gemm with square weights. |
|
||||
| `small` | Tiny Gemm for fast focused validation. |
|
||||
| `small_k_large_n` | Uses a modest reduction dimension and wide output. |
|
||||
| `transA` | Transposes the left-hand matrix. |
|
||||
| `transA_transB` | Transposes both matrix operands. |
|
||||
| `transB` | Transposes the right-hand weight matrix. |
|
||||
| `transB_with_bias` | Combines a transposed weight matrix with bias. |
|
||||
| `with_bias` | Basic matrix product with vector bias. |
|
||||
|
||||
| Test | Directory | Input | Outputs | Axis | Notes |
|
||||
|-----------------|---------------------------|-------|----------------------|------|-------------------------------------|
|
||||
| Basic | `split/basic` | [2,6] | [2,2], [2,4] | 1 | Two-way split with explicit sizes |
|
||||
| Equal three-way | `split/equal_three_way` | [2,6] | [2,2], [2,2], [2,2] | 1 | Optional split input omitted |
|
||||
### Gemv (5)
|
||||
|
||||
## Gather
|
||||
| Case | Description |
|
||||
|---|---|
|
||||
| `constant` | Vector-matrix product with all inputs constant. |
|
||||
| `simple` | Basic single-row vector-matrix product. |
|
||||
| `with_heterogeneous_constant` | Adds a non-uniform constant bias pattern. |
|
||||
| `with_homogeneous_constant` | Adds a constant bias matching the output shape. |
|
||||
| `with_scalar_constant` | Adds a scalar broadcast bias. |
|
||||
|
||||
| Test | Directory | Input | Indices | Output | Axis | Notes |
|
||||
|----------------------|--------------------------------|-------|---------|----------|------|--------------------------------|
|
||||
| Axis 1 | `gather/axis1` | [3,4] | [2] | [3,2] | 1 | Select two columns |
|
||||
| Axis 0 matrix indices| `gather/axis0_matrix_indices` | [4,3] | [2,2] | [2,2,3] | 0 | Gather rows with 2D indices |
|
||||
### MatMul (11)
|
||||
|
||||
## Concat
|
||||
| Case | Description |
|
||||
|---|---|
|
||||
| `basic` | Direct 2D MatMul with constant right-hand matrix. |
|
||||
| `batched_3d` | Batched 3D MatMul with matching batch dimensions. |
|
||||
| `batched_3d_dynamic` | Batched 3D MatMul with both operands at runtime. |
|
||||
| `batched_left_constant` | Batched 3D MatMul with constant left-hand matrix. |
|
||||
| `batched_lhs_broadcast` | Broadcasts a 2D left-hand matrix across a batched right-hand tensor. |
|
||||
| `batched_rhs_broadcast` | Broadcasts a 2D right-hand matrix across a batched left-hand tensor. |
|
||||
| `dynamic` | Direct 2D MatMul with both operands at runtime. |
|
||||
| `huge_1024` | Uses 1024-wide inner and output dimensions. |
|
||||
| `left_constant` | Direct 2D MatMul with constant left-hand matrix. |
|
||||
| `matrix_vector` | Matrix-vector multiplication producing a 1D output. |
|
||||
| `vector_matrix` | Vector-matrix multiplication producing a 1D output. |
|
||||
|
||||
| Test | Directory | Input(s) | Output | Axis | Notes |
|
||||
|--------------|-----------------------|---------------------------|-----------|------|-----------------------------|
|
||||
| Channel axis | `concat/channel_axis` | A:[1,1,2,2], B:[1,2,2,2] | [1,3,2,2] | 1 | Runtime NCHW channel concat |
|
||||
### Mul (5)
|
||||
|
||||
## Reshape
|
||||
| Case | Description |
|
||||
|---|---|
|
||||
| `after_conv` | Conv followed by per-channel scaling. |
|
||||
| `basic` | Elementwise Mul on two inputs with identical shapes. |
|
||||
| `channel_broadcast_1024` | Mul with NCHW per-channel broadcasting over 1024 channels. |
|
||||
| `leading_dimension_broadcast` | Mul with trailing-dimension broadcasting. |
|
||||
| `scalar_constant` | Mul with scalar broadcasting. |
|
||||
|
||||
| Test | Directory | Input | Output | Notes |
|
||||
|-----------|---------------------|-------|--------|----------------------------------------------|
|
||||
| Same rank | `reshape/same_rank` | [2,3] | [3,2] | Runtime tensor with static shape initializer |
|
||||
### Pool (15)
|
||||
|
||||
## Add
|
||||
| Case | Description |
|
||||
|---|---|
|
||||
| `avg_basic` | AveragePool with a 2x2 kernel and unit stride. |
|
||||
| `avg_ceil_mode` | AveragePool with ceil mode enabled. |
|
||||
| `avg_explicit_padding` | Explicitly padded AveragePool excluding pad from the divisor. |
|
||||
| `avg_include_pad` | Explicitly padded AveragePool including pad in the divisor. |
|
||||
| `avg_large_channels` | AveragePool with a large channel count and small spatial extent. |
|
||||
| `avg_non_uniform_stride` | AveragePool with different height and width strides. |
|
||||
| `avg_real_asymmetric_padding` | AveragePool with asymmetric explicit padding. |
|
||||
| `max_after_conv` | Conv followed by MaxPool. |
|
||||
| `max_basic` | MaxPool with a 2x2 kernel and unit stride. |
|
||||
| `max_ceil_mode` | MaxPool with ceil mode enabled. |
|
||||
| `max_global_style_kernel_equals_input` | MaxPool whose kernel covers the full spatial input. |
|
||||
| `max_non_square_kernel` | MaxPool with a non-square kernel. |
|
||||
| `max_real_asymmetric_padding` | MaxPool with asymmetric explicit padding. |
|
||||
| `max_same_upper` | MaxPool with SAME_UPPER padding. |
|
||||
| `max_stride2_multichannel` | Multi-channel MaxPool with stride two. |
|
||||
|
||||
| Test | Directory | Input(s) | Output | Notes |
|
||||
|---------------|---------------------|------------------|--------|---------------------------------------------|
|
||||
| Basic | `add/basic` | A:[4,8], B:[4,8] | [4,8] | Elementwise add, same-shape inputs |
|
||||
| Broadcast row | `add/broadcast_row` | A:[4,8], B:[8] | [4,8] | Row-vector broadcasting via initializer |
|
||||
| After Gemm | `add/after_gemm` | A:[4,64], D:[32] | [4,32] | Gemm + bias, then Add with broadcast vector |
|
||||
### ReduceMean (17)
|
||||
|
||||
## Mul
|
||||
| Case | Description |
|
||||
|---|---|
|
||||
| `4d_spatial` | Reduces height and width of an NCHW tensor while preserving rank. |
|
||||
| `4d_spatial_keepdims_0` | Reduces NCHW height and width while dropping those axes. |
|
||||
| `after_conv` | Conv followed by a spatial ReduceMean. |
|
||||
| `all_axes_keepdims_0` | Reduces all axes to a scalar. |
|
||||
| `all_axes_keepdims_1` | Reduces all axes while preserving rank. |
|
||||
| `basic` | Reduces a feature dimension while preserving rank. |
|
||||
| `channel_axis_nchw` | Reduces the channel axis of an NCHW tensor. |
|
||||
| `keepdims_0` | Reduces a feature dimension and drops that axis. |
|
||||
| `large_dimension_1024` | Reduces a dimension of length 1024. |
|
||||
| `legacy_axes_1_2_keepdims_1` | Opset-18 reduction over multiple positive axes. |
|
||||
| `legacy_axis1_keepdims_0` | Opset-18 reduction over one axis while dropping it. |
|
||||
| `legacy_axis1_keepdims_1` | Opset-18 reduction over one axis while preserving rank. |
|
||||
| `legacy_empty_axes_noop` | Opset-18 empty-axes no-op followed by Relu. |
|
||||
| `legacy_nchw_spatial` | Opset-18 spatial reduction on NCHW input. |
|
||||
| `legacy_negative_axis` | Opset-18 reduction using a negative axis. |
|
||||
| `legacy_reduce_all_keepdims_1` | Opset-18 all-axis reduction with the axes input omitted. |
|
||||
| `negative_axis` | ReduceMean using a negative axis. |
|
||||
|
||||
| Test | Directory | Input(s) | Output | Notes |
|
||||
|-----------------|-----------------------|--------------------------|-----------|-------------------------------------------|
|
||||
| Basic | `mul/basic` | A:[4,8], B:[4,8] | [4,8] | Elementwise multiply, same-shape inputs |
|
||||
| Scalar constant | `mul/scalar_constant` | X:[4,8], S:[1] | [4,8] | Scalar broadcasting via initializer |
|
||||
| After Conv | `mul/after_conv` | X:[1,3,5,5], S:[1,2,1,1] | [1,2,3,3] | Conv 3x3 + bias, then per-channel scaling |
|
||||
### Relu (4)
|
||||
|
||||
## Div
|
||||
| Case | Description |
|
||||
|---|---|
|
||||
| `4d` | Standalone Relu on an NCHW tensor. |
|
||||
| `after_conv` | Conv followed by Relu. |
|
||||
| `after_gemm` | Gemm followed by Relu. |
|
||||
| `basic` | Standalone Relu on a 2D tensor. |
|
||||
|
||||
| Test | Directory | Input(s) | Output | Notes |
|
||||
|-----------------|-----------------------|------------------|--------|------------------------------------------------------|
|
||||
| Basic | `div/basic` | X:[4,8], D:[4,8] | [4,8] | Elementwise divide by same-shape constant tensor |
|
||||
| Scalar constant | `div/scalar_constant` | X:[4,8], S:[1] | [4,8] | Scalar broadcasting via initializer |
|
||||
| After Gemm | `div/after_gemm` | A:[4,64], D:[32] | [4,32] | Gemm + bias, then Div with positive broadcast vector |
|
||||
### Reshape (4)
|
||||
|
||||
| Case | Description |
|
||||
|---|---|
|
||||
| `4d_to_2d_flatten` | Flattens a 4D tensor into a 2D view. |
|
||||
| `infer_dim_minus_one` | Uses `-1` to infer one output dimension. |
|
||||
| `same_rank` | Changes shape without changing rank. |
|
||||
| `zero_copies_input_dim` | Uses `0` to copy an input dimension. |
|
||||
|
||||
### Resize (6)
|
||||
|
||||
| Case | Description |
|
||||
|---|---|
|
||||
| `height_only` | Nearest-neighbor resize of only the height dimension. |
|
||||
| `nearest_2x` | Nearest-neighbor upsampling by a factor of two. |
|
||||
| `nearest_downsample` | Nearest-neighbor downsampling. |
|
||||
| `non_uniform` | Nearest-neighbor resize with different spatial scales. |
|
||||
| `width_only` | Nearest-neighbor resize of only the width dimension. |
|
||||
| `with_sizes` | Resize using explicit output sizes instead of scales. |
|
||||
|
||||
### Sigmoid (3)
|
||||
|
||||
| Case | Description |
|
||||
|---|---|
|
||||
| `4d` | Standalone Sigmoid on an NCHW tensor. |
|
||||
| `after_gemm` | Gemm followed by Sigmoid. |
|
||||
| `basic` | Standalone Sigmoid on a 2D tensor. |
|
||||
|
||||
### Slice (8)
|
||||
|
||||
| Case | Description |
|
||||
|---|---|
|
||||
| `2d_basic` | Slices a 2D tensor with explicit axes and unit steps. |
|
||||
| `after_conv` | Conv followed by a spatial crop. |
|
||||
| `default_axes` | Omits axes and steps to use positional defaults. |
|
||||
| `large_channel_1024` | Slices a channel range from a 1024-channel tensor. |
|
||||
| `nchw_spatial_crop` | Crops the spatial axes of an NCHW tensor. |
|
||||
| `negative_axis` | Slices using a negative axis. |
|
||||
| `negative_indices` | Slices using negative indices. |
|
||||
| `step2` | Slices using a positive step greater than one. |
|
||||
|
||||
### Softmax (5)
|
||||
|
||||
| Case | Description |
|
||||
|---|---|
|
||||
| `3d_last_axis` | Softmax over the last axis of a 3D tensor. |
|
||||
| `basic` | Softmax over the last dimension of a 2D tensor. |
|
||||
| `channel_axis` | Softmax over the channel axis of an NCHW tensor. |
|
||||
| `large_dimension_1024` | Softmax over a last dimension of length 1024. |
|
||||
| `negative_axis` | Softmax using a negative axis. |
|
||||
|
||||
### Split (4)
|
||||
|
||||
| Case | Description |
|
||||
|---|---|
|
||||
| `basic` | Splits a 2D tensor into two explicit output sizes. |
|
||||
| `equal_three_way` | Splits a 2D tensor evenly into three outputs. |
|
||||
| `negative_axis` | Splits using a negative axis. |
|
||||
| `uneven_channel_axis_4d` | Splits an NCHW channel axis into uneven outputs. |
|
||||
|
||||
### Sub (6)
|
||||
|
||||
| Case | Description |
|
||||
|---|---|
|
||||
| `after_gemm` | Gemm followed by Sub with a broadcast constant vector. |
|
||||
| `basic` | Elementwise Sub on two runtime inputs with identical shapes. |
|
||||
| `broadcast_row` | Sub with a broadcast row-vector right-hand constant. |
|
||||
| `channel_broadcast_1024` | Sub with NCHW per-channel broadcasting over 1024 channels. |
|
||||
| `constant_lhs_broadcast` | Sub with a broadcast constant left-hand operand. |
|
||||
| `leading_dimension_broadcast` | Sub with trailing-dimension broadcasting. |
|
||||
|
||||
Binary file not shown.
@@ -80,7 +80,7 @@ def conv_1x1():
|
||||
kernel_shape=[1, 1], strides=[1, 1], pads=[0, 0, 0, 0])
|
||||
graph = helper.make_graph([node], "conv_1x1", [X], [Y], initializer=[W])
|
||||
model = helper.make_model(graph, opset_imports=[helper.make_opsetid("", 13)])
|
||||
save_model(model, "conv/pointwise_1x1", "conv_1x1.onnx")
|
||||
save_model(model, "conv/pointwise_1x1", "conv_pointwise_1x1.onnx")
|
||||
|
||||
|
||||
def conv_same_padding_3x3():
|
||||
@@ -218,6 +218,33 @@ def conv_huge_pointwise_1024_dynamic():
|
||||
save_model(model, "conv/huge_pointwise_1024_dynamic", "conv_huge_pointwise_1024_dynamic.onnx")
|
||||
|
||||
|
||||
def conv_pointwise_tiled_chain():
|
||||
"""Chained pointwise Convs with a tiled intermediate."""
|
||||
X = helper.make_tensor_value_info("X", TensorProto.FLOAT, [1, 1024, 1, 1])
|
||||
Y = helper.make_tensor_value_info("Y", TensorProto.FLOAT, [1, 256, 1, 1])
|
||||
rng = np.random.default_rng(79)
|
||||
W1 = numpy_helper.from_array(
|
||||
rng.uniform(-1, 1, (1024, 1024, 1, 1)).astype(np.float32), name="W1")
|
||||
B1 = numpy_helper.from_array(
|
||||
rng.uniform(-1, 1, 1024).astype(np.float32), name="B1")
|
||||
W2 = numpy_helper.from_array(
|
||||
rng.uniform(-1, 1, (256, 1024, 1, 1)).astype(np.float32), name="W2")
|
||||
B2 = numpy_helper.from_array(
|
||||
rng.uniform(-1, 1, 256).astype(np.float32), name="B2")
|
||||
nodes = [
|
||||
helper.make_node("Relu", ["X"], ["X_relu"]),
|
||||
helper.make_node("Conv", ["X_relu", "W1", "B1"], ["hidden"],
|
||||
kernel_shape=[1, 1], strides=[1, 1], pads=[0, 0, 0, 0]),
|
||||
helper.make_node("Relu", ["hidden"], ["hidden_relu"]),
|
||||
helper.make_node("Conv", ["hidden_relu", "W2", "B2"], ["Y"],
|
||||
kernel_shape=[1, 1], strides=[1, 1], pads=[0, 0, 0, 0]),
|
||||
]
|
||||
graph = helper.make_graph(
|
||||
nodes, "conv_pointwise_tiled_chain", [X], [Y], initializer=[W1, B1, W2, B2])
|
||||
model = helper.make_model(graph, opset_imports=[helper.make_opsetid("", 13)])
|
||||
save_model(model, "conv/pointwise_tiled_chain", "conv_pointwise_tiled_chain.onnx")
|
||||
|
||||
|
||||
def conv_large_output_channels_1x1():
|
||||
"""1x1 Conv with modest inputs and very large output channel count."""
|
||||
X = helper.make_tensor_value_info("X", TensorProto.FLOAT, [1, 64, 1, 1])
|
||||
@@ -790,7 +817,7 @@ def maxpool_basic():
|
||||
node = helper.make_node("MaxPool", ["X"], ["Y"], kernel_shape=[2, 2], strides=[1, 1], pads=[0, 0, 0, 0])
|
||||
graph = helper.make_graph([node], "maxpool_basic", [X], [Y])
|
||||
model = helper.make_model(graph, opset_imports=[helper.make_opsetid("", 13)])
|
||||
save_model(model, "pool/max_basic", "maxpool_basic.onnx")
|
||||
save_model(model, "pool/max_basic", "pool_max_basic.onnx")
|
||||
|
||||
|
||||
def maxpool_stride2_multichannel():
|
||||
@@ -800,7 +827,7 @@ def maxpool_stride2_multichannel():
|
||||
node = helper.make_node("MaxPool", ["X"], ["Y"], kernel_shape=[2, 2], strides=[2, 2], pads=[0, 0, 0, 0])
|
||||
graph = helper.make_graph([node], "maxpool_stride2_multichannel", [X], [Y])
|
||||
model = helper.make_model(graph, opset_imports=[helper.make_opsetid("", 13)])
|
||||
save_model(model, "pool/max_stride2_multichannel", "maxpool_stride2_multichannel.onnx")
|
||||
save_model(model, "pool/max_stride2_multichannel", "pool_max_stride2_multichannel.onnx")
|
||||
|
||||
|
||||
def maxpool_same_upper():
|
||||
@@ -810,7 +837,7 @@ def maxpool_same_upper():
|
||||
node = helper.make_node("MaxPool", ["X"], ["Y"], kernel_shape=[3, 3], strides=[2, 2], auto_pad="SAME_UPPER")
|
||||
graph = helper.make_graph([node], "maxpool_same_upper", [X], [Y])
|
||||
model = helper.make_model(graph, opset_imports=[helper.make_opsetid("", 13)])
|
||||
save_model(model, "pool/max_same_upper", "maxpool_same_upper.onnx")
|
||||
save_model(model, "pool/max_same_upper", "pool_max_same_upper.onnx")
|
||||
|
||||
|
||||
def avgpool_basic():
|
||||
@@ -820,7 +847,7 @@ def avgpool_basic():
|
||||
node = helper.make_node("AveragePool", ["X"], ["Y"], kernel_shape=[2, 2], strides=[1, 1], pads=[0, 0, 0, 0])
|
||||
graph = helper.make_graph([node], "avgpool_basic", [X], [Y])
|
||||
model = helper.make_model(graph, opset_imports=[helper.make_opsetid("", 13)])
|
||||
save_model(model, "pool/avg_basic", "avgpool_basic.onnx")
|
||||
save_model(model, "pool/avg_basic", "pool_avg_basic.onnx")
|
||||
|
||||
|
||||
def avgpool_explicit_padding():
|
||||
@@ -831,7 +858,7 @@ def avgpool_explicit_padding():
|
||||
kernel_shape=[3, 3], strides=[2, 2], pads=[1, 1, 1, 1], count_include_pad=0)
|
||||
graph = helper.make_graph([node], "avgpool_explicit_padding", [X], [Y])
|
||||
model = helper.make_model(graph, opset_imports=[helper.make_opsetid("", 13)])
|
||||
save_model(model, "pool/avg_explicit_padding", "avgpool_explicit_padding.onnx")
|
||||
save_model(model, "pool/avg_explicit_padding", "pool_avg_explicit_padding.onnx")
|
||||
|
||||
|
||||
def avgpool_include_pad():
|
||||
@@ -842,7 +869,7 @@ def avgpool_include_pad():
|
||||
kernel_shape=[3, 3], strides=[2, 2], pads=[1, 1, 1, 1], count_include_pad=1)
|
||||
graph = helper.make_graph([node], "avgpool_include_pad", [X], [Y])
|
||||
model = helper.make_model(graph, opset_imports=[helper.make_opsetid("", 13)])
|
||||
save_model(model, "pool/avg_include_pad", "avgpool_include_pad.onnx")
|
||||
save_model(model, "pool/avg_include_pad", "pool_avg_include_pad.onnx")
|
||||
|
||||
|
||||
def maxpool_after_conv():
|
||||
@@ -855,7 +882,7 @@ def maxpool_after_conv():
|
||||
pool = helper.make_node("MaxPool", ["C"], ["Y"], kernel_shape=[2, 2], strides=[2, 2], pads=[0, 0, 0, 0])
|
||||
graph = helper.make_graph([conv, pool], "maxpool_after_conv", [X], [Y], initializer=[W])
|
||||
model = helper.make_model(graph, opset_imports=[helper.make_opsetid("", 13)])
|
||||
save_model(model, "pool/max_after_conv", "maxpool_after_conv.onnx")
|
||||
save_model(model, "pool/max_after_conv", "pool_max_after_conv.onnx")
|
||||
|
||||
|
||||
def maxpool_ceil_mode():
|
||||
@@ -866,7 +893,7 @@ def maxpool_ceil_mode():
|
||||
kernel_shape=[2, 2], strides=[2, 2], pads=[0, 0, 0, 0], ceil_mode=1)
|
||||
graph = helper.make_graph([node], "maxpool_ceil_mode", [X], [Y])
|
||||
model = helper.make_model(graph, opset_imports=[helper.make_opsetid("", 13)])
|
||||
save_model(model, "pool/max_ceil_mode", "maxpool_ceil_mode.onnx")
|
||||
save_model(model, "pool/max_ceil_mode", "pool_max_ceil_mode.onnx")
|
||||
|
||||
|
||||
def avgpool_ceil_mode():
|
||||
@@ -877,7 +904,7 @@ def avgpool_ceil_mode():
|
||||
kernel_shape=[2, 2], strides=[2, 2], pads=[0, 0, 0, 0], ceil_mode=1)
|
||||
graph = helper.make_graph([node], "avgpool_ceil_mode", [X], [Y])
|
||||
model = helper.make_model(graph, opset_imports=[helper.make_opsetid("", 13)])
|
||||
save_model(model, "pool/avg_ceil_mode", "avgpool_ceil_mode.onnx")
|
||||
save_model(model, "pool/avg_ceil_mode", "pool_avg_ceil_mode.onnx")
|
||||
|
||||
|
||||
def maxpool_real_asymmetric_padding():
|
||||
@@ -888,7 +915,7 @@ def maxpool_real_asymmetric_padding():
|
||||
kernel_shape=[3, 3], strides=[1, 2], pads=[0, 1, 2, 1])
|
||||
graph = helper.make_graph([node], "maxpool_real_asymmetric_padding", [X], [Y])
|
||||
model = helper.make_model(graph, opset_imports=[helper.make_opsetid("", 13)])
|
||||
save_model(model, "pool/max_real_asymmetric_padding", "maxpool_real_asymmetric_padding.onnx")
|
||||
save_model(model, "pool/max_real_asymmetric_padding", "pool_max_real_asymmetric_padding.onnx")
|
||||
|
||||
|
||||
def avgpool_real_asymmetric_padding():
|
||||
@@ -899,7 +926,7 @@ def avgpool_real_asymmetric_padding():
|
||||
kernel_shape=[3, 3], strides=[1, 2], pads=[0, 1, 2, 1], count_include_pad=0)
|
||||
graph = helper.make_graph([node], "avgpool_real_asymmetric_padding", [X], [Y])
|
||||
model = helper.make_model(graph, opset_imports=[helper.make_opsetid("", 13)])
|
||||
save_model(model, "pool/avg_real_asymmetric_padding", "avgpool_real_asymmetric_padding.onnx")
|
||||
save_model(model, "pool/avg_real_asymmetric_padding", "pool_avg_real_asymmetric_padding.onnx")
|
||||
|
||||
|
||||
def maxpool_non_square_kernel():
|
||||
@@ -910,7 +937,7 @@ def maxpool_non_square_kernel():
|
||||
kernel_shape=[2, 3], strides=[1, 2], pads=[0, 0, 0, 0])
|
||||
graph = helper.make_graph([node], "maxpool_non_square_kernel", [X], [Y])
|
||||
model = helper.make_model(graph, opset_imports=[helper.make_opsetid("", 13)])
|
||||
save_model(model, "pool/max_non_square_kernel", "maxpool_non_square_kernel.onnx")
|
||||
save_model(model, "pool/max_non_square_kernel", "pool_max_non_square_kernel.onnx")
|
||||
|
||||
|
||||
def avgpool_non_uniform_stride():
|
||||
@@ -921,7 +948,7 @@ def avgpool_non_uniform_stride():
|
||||
kernel_shape=[2, 3], strides=[1, 2], pads=[0, 0, 0, 0])
|
||||
graph = helper.make_graph([node], "avgpool_non_uniform_stride", [X], [Y])
|
||||
model = helper.make_model(graph, opset_imports=[helper.make_opsetid("", 13)])
|
||||
save_model(model, "pool/avg_non_uniform_stride", "avgpool_non_uniform_stride.onnx")
|
||||
save_model(model, "pool/avg_non_uniform_stride", "pool_avg_non_uniform_stride.onnx")
|
||||
|
||||
|
||||
def maxpool_global_style_kernel_equals_input():
|
||||
@@ -931,7 +958,7 @@ def maxpool_global_style_kernel_equals_input():
|
||||
node = helper.make_node("MaxPool", ["X"], ["Y"], kernel_shape=[4, 4], strides=[1, 1], pads=[0, 0, 0, 0])
|
||||
graph = helper.make_graph([node], "maxpool_global_style_kernel_equals_input", [X], [Y])
|
||||
model = helper.make_model(graph, opset_imports=[helper.make_opsetid("", 13)])
|
||||
save_model(model, "pool/max_global_style_kernel_equals_input", "maxpool_global_style_kernel_equals_input.onnx")
|
||||
save_model(model, "pool/max_global_style_kernel_equals_input", "pool_max_global_style_kernel_equals_input.onnx")
|
||||
|
||||
|
||||
def avgpool_large_channels():
|
||||
@@ -941,7 +968,7 @@ def avgpool_large_channels():
|
||||
node = helper.make_node("AveragePool", ["X"], ["Y"], kernel_shape=[2, 2], strides=[1, 1], pads=[0, 0, 0, 0])
|
||||
graph = helper.make_graph([node], "avgpool_large_channels", [X], [Y])
|
||||
model = helper.make_model(graph, opset_imports=[helper.make_opsetid("", 13)])
|
||||
save_model(model, "pool/avg_large_channels", "avgpool_large_channels.onnx")
|
||||
save_model(model, "pool/avg_large_channels", "pool_avg_large_channels.onnx")
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -2005,6 +2032,7 @@ if __name__ == "__main__":
|
||||
conv_dynamic()
|
||||
conv_huge_pointwise_1024()
|
||||
conv_huge_pointwise_1024_dynamic()
|
||||
conv_pointwise_tiled_chain()
|
||||
conv_large_output_channels_1x1()
|
||||
conv_large_input_channels_1x1()
|
||||
conv_depthwise_1024_channels()
|
||||
|
||||
Reference in New Issue
Block a user