Skip to content

Resize operator fails with 2D tensors #1641

Description

@fdwr

Describe the bug
The Resize operator fails with the following simple 2D test case.

{
  "op_type": "Resize",
  "mode": "linear",
  "X": [[1, 1],
        [1, 1]],
  "scales": [2, 2],
  "Y": [[1, 1, 1, 1],
        [1, 1, 1, 1],
        [1, 1, 1, 1],
        [1, 1, 1, 1]],
  "T": "float32"
},

Apparently one has to wrap the 2D tensor inside a 4D tensor with dummy 1's to get it to work, even though the two cases are equivalent o_O. (The error message is also confusing because it says it only handles 4D when it doesn't actually handle quadrilinear interpolation.)

Urgency
Vibranium preferred.

System information

  • OS Platform and Distribution: Windows 10 Vibranium
  • ONNX Runtime installed from: source
  • ONNX Runtime version: engine/lotus (v0.1.4-709-gbf6f19c6)
  • Python version: NA
  • Visual Studio version (if applicable): Visual Studio 2017
  • GCC/Compiler version (if compiling from source): NA
  • CUDA/cuDNN version: NA
  • GPU model and memory: AMD Radeon, 32GB

To Reproduce
Run the attached model.

HRESULT=0x80004005 message=Exception during initialization: S:\WindowsAI\engine\lotus\onnxruntime\core/providers/cpu/tensor/upsample.h:75
 onnxruntime::UpsampleBase::ScalesValidation scales.size() == 4 was false. Upsample: linear mode upsample only support bilinear with 4 dimension.

Expected behavior
I understand ORT's Resize only handling 2D for now (rather than full 3D or 4D which DML supports), but the validation code should just treat the squeezed dimensions all the same: [1,1,m,n], [1,m,n], [m,n], [m,n,1,1]. *assuming the corresponding scales would yield in nop's.

Additional context
Found while testing WindowsAI DML GPU vs CPU paths.

ir_version: 3
producer_name: "OnnxConformanceTest"
graph {
  node {
    input: "X"
    input: "scales"
    output: "Y"
    op_type: "Resize"
    attribute {
      name: "mode"
      s: "linear"
      type: STRING
    }
    domain: ""
  }
  initializer {
    dims: 2
    dims: 2
    data_type: FLOAT
    name: "X"
    raw_data: "\000\000\200?\000\000\000@\000\000@@\000\000\200@"
  }
  initializer {
    dims: 2
    data_type: FLOAT
    float_data: 2
    float_data: 2
    name: "scales"
  }
  input {
    name: "X"
    type {
      tensor_type {
        elem_type: FLOAT
        shape {
          dim {
            dim_value: 2
          }
          dim {
            dim_value: 2
          }
        }
      }
    }
  }
  input {
    name: "scales"
    type {
      tensor_type {
        elem_type: FLOAT
        shape {
          dim {
            dim_value: 2
          }
        }
      }
    }
  }
  output {
    name: "Y"
    type {
      tensor_type {
        elem_type: FLOAT
        shape {
          dim {
            dim_value: 4
          }
          dim {
            dim_value: 4
          }
        }
      }
    }
  }
}
opset_import {
  version: 7
}
opset_import {
  version: 10
}

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions