Error: Undefined variable: Tensor

I used unity branch code to build a tvm with relax, but I ran the following code sample incorrectly:

from __future__ import annotations
import numpy as np
import tvm
from tvm import relax, topi
from tvm.ir.module import IRModule
from tvm.script import relax as R
from tvm.script import tir as T
# from torch import Tensor


@tvm.script.ir_module
class MyModule:
    @R.function
    def main(x: Tensor((3, 4), "float32"), y: Tensor((3, 4), "float32")):
        with relax.dataflow():
            lv0 = relax.multiply(x, y)
            gv0 = relax.add(lv0, y)
            relax.output(gv0)
        return gv0


relax_func = MyModule["main"]
print(relax_func.params)

下面是我的报错截图

you should use R.Tensor :slight_smile:

1 Like

Thank you, but I have a new problem:

I am using the latest unity branch to build tvm, do I need to use the BlockBuilder class to build relax? Can you tell me how to use the latest relax? I just want to learn about this example code on ChengTianqi’s MLC class

I solved this problem, all using R just fine, thanks