Skip to content

[Bug] R.isnan, R.isinf, R.isfinite crash at build time — CodeGenVM intrinsic not implemented #19452

@wuyii8941

Description

@wuyii8941

Expected behavior

R.isnan(), R.isinf(), and R.isfinite() should compile and produce correct boolean tensor outputs on both CPU and CUDA targets.

Actual behavior

All three ops crash during relax.build() with:

InternalError: CodeGenVM cannot handle this intrinsic now:
Op(relax.isnan)

This occurs on both CPU (llvm) and CUDA targets.

Environment

  • TVM: main branch @ commit 0b0afd8dd (2026-04-25)
  • OS: Ubuntu 20.04

Steps to reproduce

import numpy as np
import tvm
from tvm import relax
import tvm.relax.op as R

bb = relax.BlockBuilder()
x = relax.Var("x", relax.TensorStructInfo((4, 8), "float32"))
with bb.function("main", [x]):
    with bb.dataflow():
        out = bb.emit(R.isnan(x))
        gv = bb.emit_output(out)
    bb.emit_func_output(gv)
mod = bb.get()

pipeline = tvm.ir.transform.Sequential([relax.transform.LegalizeOps()])
mod_l = pipeline(mod)
exe = relax.build(mod_l, target="llvm")  # CRASH

Same crash for R.isinf(x) and R.isfinite(x).

Notes

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
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions