[Bug] [Relax][ONNX] MaxUnpool calls tolist on its output_shape expression

オープン 初心者向け
#20,888 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
compilers

調査の方向性

Relax ONNX フロントエンドの MaxUnpool コンバータから始めてください。ここでは inputs[2] から total_output_shape を取得し、それに対して .tolist() を呼び出しています。explicit_shape を True に設定して再現スクリプトを実行すると、GenericConst に対する AttributeError が発生します。明示的な output_shape のケースがインポートでき、2入力モデルと3入力モデルの両方で ReferenceEvaluator の結果 [[[[5, 0], [0, 0]]]] と一致すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

needs-triage type: bug
Expected behavior

Providing the optional constant output_shape=[1, 1, 2, 2] should preserve the result of the equivalent two-input MaxUnpool.

Actual behavior

The two-input model imports. Adding the same explicit output shape passes ONNX full checking and reference evaluation, then fails during import:

AttributeError: 'GenericConst' object has no attribute 'tolist'

The converter assigns inputs[2] to total_output_shape and calls .tolist() on that Relax expression.

Environment

TVM 0.28.dev0 (local build; build commit unavailable), Python 3.12.3, Linux x86_64; ONNX 1.22.0, NumPy 2.5.4.

Steps to reproduce

Run with python repro.py:

import numpy as np
import onnx
from onnx import TensorProto as T, helper as h, numpy_helper as nh
from onnx.reference import ReferenceEvaluator
from tvm.relax.frontend.onnx import from_onnx

x = np.array([[[[5.0]]]], dtype="float32")
for explicit_shape in [False, True]:
    initializers = [nh.from_array(np.zeros((1, 1, 1, 1), dtype="int64"), "indices")]
    inputs = ["x", "indices"]
    if explicit_shape:
        initializers.append(nh.from_array(np.array([1, 1, 2, 2], dtype="int64"), "shape"))
        inputs.append("shape")
    node = h.make_node("MaxUnpool", inputs, ["y"], kernel_shape=[2, 2], strides=[2, 2])
    model = h.make_model(h.make_graph([node], "unpool",
        [h.make_tensor_value_info("x", T.FLOAT, [1, 1, 1, 1])],
        [h.make_tensor_value_info("y", T.FLOAT, [1, 1, 2, 2])], initializers),
        opset_imports=[h.make_opsetid("", 18)], ir_version=10)
    onnx.checker.check_model(model, full_check=True)
    expected = np.array([[[[5, 0], [0, 0]]]], dtype="float32")
    np.testing.assert_array_equal(ReferenceEvaluator(model).run(None, {"x": x})[0], expected)
    try:
        from_onnx(model, keep_params_in_input=False)
        print("explicit_shape", explicit_shape, "imported")
    except Exception as error:
        print("explicit_shape", explicit_shape, type(error).__name__, str(error).splitlines()[-1])
Triage
  • needs-triage
主要言語
Python
スター
13.9k
フォーク
4k
平均マージ
8時間 10分
マージ済み PR(30日)
186

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/tvm のほかの issue

apache/tvm の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。