Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[tmva][sofie] Inputs of unsupported type (e.g. float16) give code that does not compile instead of an error

未关闭 适合新手
#23,655 0 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@lmoneta 已经在做这个了。

开始于 2026年10月9日。

  • #23668 来自 @Maher-star-eng —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
65/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
cpp, python

调研方向

有问题的检查是 tmva/sofie/src/RModel.cxx 中 RModel::GenerateInferSignature 里与 "other" 的比较(约第 1202-1205 行)。tmva/sofie/src/SOFIE_common.cxx 中的 ConvertTypeToString(约第 102 行)对未知类型返回 "other_" + type,因此先比较这两处。运行 Python 复现脚本,检查对于 FLOAT16 输入,Generate() 是否抛出已有的“尚不支持”错误。应在 TestSofieParser.cxx 中添加解析器测试来覆盖该情况。

由索引模型根据 Issue 内容生成。

描述

AI-Assisted bug in:SOFIE
Check duplicate issues.
  • Checked for duplicates
Description

When a model input has a type that SOFIE does not support, RModel::Generate() is supposed to throw "input tensor ... is of a data type which is not yet supported." (RModel::GenerateInferSignature, tmva/sofie/src/RModel.cxx, lines 1202-1205). That check never fires: it compares the type name with "other", but ConvertTypeToString returns "other_" + std::to_string(type) for the types it does not know (tmva/sofie/src/SOFIE_common.cxx, line 102), e.g. "other_10" for FLOAT16.

So Generate() succeeds and writes a header with other_10 const* tensor_x in the signatures of infer() and doInfer(), and the user only gets an unknown type name 'other_10' compile error later. This affects every type that ConvertTypeToString does not handle (FLOAT16, BFLOAT16, STRING, COMPLEX64/128). Operators such as Relu or Identity reject such inputs themselves, but Shape and Cast let them through.

Expected: Generate() throws the existing "not yet supported" error.

Reproducer
import os
import re

import ROOT
from onnx import TensorProto, helper, save

os.chdir(os.path.dirname(os.path.abspath(__file__)))

node = helper.make_node("Shape", ["x"], ["y"])
graph = helper.make_graph(
    [node],
    "float16_input",
    [helper.make_tensor_value_info("x", TensorProto.FLOAT16, [2, 3])],
    [helper.make_tensor_value_info("y", TensorProto.INT64, [2])],
)
model = helper.make_model(graph, opset_imports=[helper.make_opsetid("", 13)], ir_version=8)
save(model, "float16_input.onnx")

ROOT.gInterpreter.Declare("""
#include "TMVA/RModelParser_ONNX.hxx"
std::string float16_generate() {
   using namespace TMVA::Experimental::SOFIE;
   try {
      RModelParser_ONNX parser;
      RModel model = parser.Parse("float16_input.onnx");
      model.Generate();
      model.OutputGenerated("float16_input.hxx");
   } catch (const std::exception &e) {
      return e.what();
   }
   return "no exception";
}
""")
print("Generate():", ROOT.float16_generate())
print("infer signature:", re.search(r"infer\((.*)\)", open("float16_input.hxx").read()).group(1))
print("compiles:", ROOT.gInterpreter.Declare('#include "float16_input.hxx"'))

Output (compiler errors shortened):

./float16_input.hxx:77:28: error: unknown type name 'other_10'
std::vector<int64_t> infer(other_10 const* tensor_x){
Generate(): no exception
infer signature: other_10 const* tensor_x
compiles: False
ROOT version

6.41.01, master at c619e8fbd7f (the code is unchanged in the current master)

Installation method

Built from source (CMake, Release, -Dtesting=ON)

Operating system

macOS 26 (arm64, Apple M4 Pro)

Additional context

I found this while running the ONNX operator tests (from the onnx Python package) through SOFIE. I used AI assistance (Claude) to investigate it I ran the reproducer and checked its output myself. I'll open a PR with a fix and a test in TestSofieParser.cxx.

主要语言
C++
星标
3.3k
派生
1.6k
平均合并
2 天 17 小时
30 天内合并 PR
188

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

root-project/root 的其他 Issue

查看 root-project/root 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。