Skip to content

[Relax][Bug] Cannot find PackedFunc tir_zeros #17176

@Cookiee235

Description

@Cookiee235

Actual behavior

Traceback (most recent call last):
  File "demo.py", line 25, in <module>
    vm = relax.VirtualMachine(ex, tvm.cpu())
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/software/tvm/python/tvm/runtime/relax_vm.py", line 97, in __init__
    self._setup_device(device, memory_cfg)
  File "/software/tvm/python/tvm/runtime/relax_vm.py", line 133, in _setup_device
    self.module["vm_initialization"](*init_args)
  File "/software/tvm/python/tvm/_ffi/_ctypes/packed_func.py", line 239, in __call__
    raise_last_ffi_error()
  File "/software/tvm/python/tvm/_ffi/base.py", line 481, in raise_last_ffi_error
    raise py_err
tvm.error.InternalError: Traceback (most recent call last):
  3: _ZN3tvm7runtime13PackedFuncObj9ExtractorINS0_16PackedFuncSubObjIZNS0_8relax_vm18VirtualMachineImpl
  2: tvm::runtime::relax_vm::VirtualMachineImpl::_Init(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)
  1: tvm::runtime::relax_vm::VirtualMachineImpl::Init(std::vector<DLDevice, std::allocator<DLDevice> > const&, std::vector<tvm::runtime::memory::AllocatorType, std::allocator<tvm::runtime::memory::AllocatorType> > const&)
  0: tvm::runtime::relax_vm::VirtualMachineImpl::InitFuncPool()
  File "/software/tvm/src/runtime/relax_vm/vm.cc", line 705
InternalError: Check failed: (func.defined()) is false: Error: Cannot find PackedFunc tir_zeros in either Relax VM kernel library, or in TVM runtime PackedFunc registry, or in global Relax functions of the VM executable

Environment

  • TVM: 0.17.dev0
  • OS: Ubuntu20.04

Steps to reproduce

import tvm
from tvm import relax

from tvm.script import ir as I
from tvm.script import tir as T
from tvm.script import relax as R


@I.ir_module
class Module:
    I.module_attrs({"system_lib_prefix": "hello_"})
    @T.prim_func
    def tir_zeros(x: T.Buffer((2,), "float32")):
        x[0] = T.float32(0)

    @R.function
    def main() -> R.Tensor((2,), dtype="float32"):
        cls = Module
        gv0 = R.call_tir(cls.tir_zeros, R.tuple(), out_sinfo=R.Tensor((2,), dtype="float32"))
        return gv0

m = Module
m.show()
ex = relax.build(m, target='llvm')
vm = relax.VirtualMachine(ex, tvm.cpu())

cc @junrushao @Hzfengsy

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