Skip to content

[Bug] topi.acos accepts integer input and crashes in LowerIntrin with InternalError #18729

@Cookiee235

Description

@Cookiee235

Actual behavior

Calling opi.acos with an integer-typed input tensor (e.g. int16) leads to a tvm.error.InternalError during LowerIntrin / IntrinInjecter in the TIR build pipeline.
Instead of reporting a user-facing dtype validation error (or inserting an implicit cast), TVM crashes while constructing an IntImm with a value outside the valid range.

This appears to be missing dtype validation in TOPI for floating-point–only math intrinsics.

Environment

tvm: v0.22-dev

Steps to reproduce

import tvm
from tvm import te, topi, tir
import numpy as np

def model_func(x):
    return topi.acos(x)

x = te.placeholder((1, 128, 256), dtype="int16", name="x")
out = model_func(x)

func = te.create_prim_func([x, out]).with_attr(
    "target", tvm.target.Target("llvm")
)

sch = tir.Schedule(func)
np_input = np.random.uniform(-1, 1, size=(1, 128, 256)).astype("int16")
with tvm.transform.PassContext(opt_level=0):
    mod = tvm.build(sch.mod, target="llvm")

Triage

  • lowering
  • TOPI
  • needs-triage

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triagePRs or issues that need to be investigated by maintainers to find the right assignees to address ittype: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions