Skip to content

op.Resize parameter sizes cannot accept Type tensor(int64) #1577

Open
@vincentme

Description

@vincentme

behavior

The sizes parameter computed on the fly works in onnxscript eager-mode. But the converted model run by onnxruntime complains

InvalidGraph: [ONNXRuntimeError] : 10 : INVALID_GRAPH : This is an invalid model. Type Error: Type 'tensor(int64)' of input parameter (new_shape) of operator (Resize) in node (n4) is invalid.

However, according to the doc of onnx, input sizes should indeed be a tensor(int64).

code to reproduce

import numpy as np
from onnxscript import script, FLOAT, opset20 as op


@script()
def test(data: FLOAT[None, None]) -> FLOAT[None, None]:
    shape = op.Shape(data)
    new_shape = shape/2
    print(new_shape)
    return op.Resize(data, sizes=new_shape)

data = np.random.randn(16, 32).astype(np.float32)
res_onnxscript = test(data)
model = test.to_model_proto()

from onnxruntime import InferenceSession
sess = InferenceSession(model.SerializeToString())
feeds = {'data': data,}
outpus_onnxruntime = sess.run(None, feeds)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions