Skip to content

[BUG] Passing wrong Tensor to tvm.build segfaults #7292

@tkonolige

Description

@tkonolige

On d7a9a7c, the following script segfaults:

import tvm
import numpy as np
def gen_ir(out_ptr):
    irb = tvm.tir.ir_builder.create()
    out = irb.buffer_ptr(out_ptr)
    out[0] = tvm.tir.const(0, "uint64")
    return irb.get()

target = "cuda"
ctx = tvm.gpu()
out = tvm.tir.decl_buffer((1,), dtype="uint64")
f = tvm.te.extern([out.shape], [], lambda ins, outs: gen_ir(outs[0]), dtype="uint64", out_buffers=[out])
s = tvm.te.create_schedule([f.op])
p = tvm.te.placeholder((1,), "uint64")
out_ary = tvm.nd.array(np.zeros((1,), "uint64"), ctx)
tvm.build(s, [p], target=target)(out_ary) # this should have [f] as the second parameter

The cause is that the wrong Tensor was passed to tvm.build.

Actionable item: we need to fix tvm.build so it provides a useful error message when the incorrect Tensor is provided instead of segfaulting.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions