optimize() crashes when constant folding produces a string tensor
メンテナーはふだん 3 日以内に返信
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- python
調査の方向性
Start with onnxscript.optimizer._constant_folding._prepare_folded_tensor, which the issue identifies as wrapping folded NumPy results with ir.tensor(output_array). Reproduce with the provided constant string tensor model and check that onnxscript.optimizer.optimize() serializes and runs it successfully; account for the open linked pull request when assessing whether work remains.
索引モデルが issue の本文から書いたものです。
説明
onnxscript.optimizer.optimize() fails on valid models when constant folding produces a string tensor, for example an Identity or Concat on a constant list of class labels.
import numpy as np
import onnx
import onnxruntime as ort
import onnxscript.optimizer
model = onnx.parser.parse_model(
"""
<ir_version: 8, opset_import: ["" : 18]>
agraph (int64[1] idx) => (string[1] label)
<string[3] classes = {"cat", "dog", "bird"}>
{
labels = Identity(classes)
label = Gather(labels, idx)
}
"""
)
def run(m):
sess = ort.InferenceSession(m.SerializeToString(), providers=["CPUExecutionProvider"])
return sess.run(None, {"idx": np.array([2], np.int64)})[0]
print("before optimize:", run(model))
print("after optimize:", run(onnxscript.optimizer.optimize(model)))
Output:
before optimize: ['bird']
...
TypeError: Bitwidth not available for ONNX data type: STRING
...
onnx_ir.passes.PassError: An error occurred when running the '<onnxscript.optimizer._constant_folding.FoldConstantsPass ...>' pass ...
_prepare_folded_tensor wraps the folded numpy result with ir.tensor(output_array). For a string array that gives a numeric Tensor with dtype STRING instead of a StringTensor, and serializing it fails.
Versions: onnxscript main (4002c079), onnx 1.23.2, onnxruntime 1.31.0, onnx_ir 1.0.0 (same with 1.1.0), Python 3.12.15, macOS arm64.
This is separate from #3110, which fixes non-ASCII strings in Constant attributes. I have a small fix and can open a PR.
- 主要言語
- Python
- スター
- 456
- フォーク
- 148
- 平均マージ
- 3日 19時間
- マージ済み PR(30日)
- 20
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/onnxscript のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
microsoft/onnxscript#3003 · コメント 3 件 ·
メンテナーはふだん 3 日以内に返信
-
CI : Pin github actions to full commit SHA対応中かも @Aniketsy が 177 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
microsoft/onnxscript#2903 · コメント 6 件 ·
メンテナーはふだん 3 日以内に返信
-
bug module: torchlib
難易度 3/5 1〜2日 初心者へのやさしさ 64/100
microsoft/onnxscript#3124 · コメント 3 件 · リアクション 1 件 ·
メンテナーはふだん 3 日以内に返信
-
[torchlib] Python floats in float64 models are exported with float32 precision対応中かも @usmanmateen が 7 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 56/100
microsoft/onnxscript#3117 ·
メンテナーはふだん 3 日以内に返信
-
[torchlib] Float remainder is off by the divisor when the quotient rounds up, and nan for an infinite divisor対応中かも @usmanmateen が 7 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
microsoft/onnxscript#3116 ·
メンテナーはふだん 3 日以内に返信
microsoft/onnxscript の issue をすべて見る
似ている issue
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
glossyio/traffic-monitor#264 ·
メンテナーはふだん 1 日以内に返信
-
Add self-hostオープン
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
Atarity/deploy-your-own-saas#102 ·
-
[Bug]: RDFlex silently drops the covariate adjustment when the outcome or treatment column is integer-typed対応中かも @vrjdev が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
DoubleML/doubleml-for-py#424 ·
メンテナーはふだん 1 日以内に返信
-
agentic-dmx docs enhancement
難易度 1/5 1〜3時間 初心者へのやさしさ 86/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
521xueweihan/HelloGitHub#4150 ·