Hello, I’m new to vta. I have went through vta tutorials in the documentation and I tried to implement my own code, to clarify what is happening actually there. When I implement the following code I’m getting an error “AttributeError: <class ‘tvm.tir.stmt.SeqStmt’> has no attribute buffer_var” .
from __future__ import absolute_import, print_function
import os
import tvm
from tvm import te
import vta
import numpy as np
env = vta.get_env()
# We'll need the TVM RPC module and the VTA simulator module
from tvm import rpc
from tvm.contrib import util
from vta.testing import simulator
# We read the Pynq RPC host IP address and port number from the OS environment
host = os.environ.get("VTA_RPC_HOST", "192.168.2.99")
port = int(os.environ.get("VTA_RPC_PORT", "9091"))
# We configure both the bitstream and the runtime system on the Pynq
# to match the VTA configuration specified by the vta_config.json file.
if env.TARGET == "pynq" or env.TARGET == "de10nano":
# Make sure that TVM was compiled with RPC=1
assert tvm.runtime.enabled("rpc")
remote = rpc.connect(host, port)
# Reconfigure the JIT runtime
vta.reconfig_runtime(remote)
# Program the FPGA with a pre-compiled VTA bitstream.
# You can program the FPGA with your own custom bitstream
# by passing the path to the bitstream file instead of None.
vta.program_fpga(remote, bitstream=None)
# In simulation mode, host the RPC server locally.
elif env.TARGET == "sim":
remote = rpc.LocalSession()
# Defining Computation rule
input_width = 64
input_height = 64
num_of_elements = te.var(name='num_of_elements', dtype=env.acc_dtype)
w_in_factor = int(input_width / env.BLOCK_IN)
h_in_factor = int(input_height / env.BATCH)
input_shape = (h_in_factor, w_in_factor, env.BATCH, env.BLOCK_IN)
output_shape = (env.BATCH, env.BLOCK_OUT)
A = te.placeholder(input_shape, name='A',dtype=env.acc_dtype)
A_buff = te.compute(input_shape, lambda *i: A(*i), name='A_buff')
k0 = te.reduce_axis((0,h_in_factor), name='k0')
k1 = te.reduce_axis((0,w_in_factor), name='k1')
k2 = te.reduce_axis((0,env.BATCH), name='k2')
k3 = te.reduce_axis((0,env.BLOCK_IN), name='k3')
S_buff = te.compute(output_shape, lambda i,j: te.sum(A_buff[k0,k1,i,j].astype(env.acc_dtype), axis=[k0,k1]), name='S_buff')
D_buff = te.compute(output_shape, lambda *i: te.div(S_buff(*i), num_of_elements).astype(env.acc_dtype), name='D_buff')
C = te.compute(output_shape, lambda *i: D_buff(*i).astype(env.inp_dtype), name='C')
s = te.create_schedule(C.op)
# Scheduling Operations
s[A_buff].set_scope(env.acc_scope)
s[S_buff].set_scope(env.acc_scope)
s[D_buff].set_scope(env.acc_scope)
s[A_buff].pragma(s[A_buff].op.axis[0], env.dma_copy)
s[S_buff].pragma(s[S_buff].op.axis[0], env.alu)
s[D_buff].pragma(s[D_buff].op.axis[0], env.alu)
s[C].pragma(s[C].op.axis[0], env.dma_copy)
print(vta.lower(s, [A,C], simple_mode=True))
Full error message is as follows:
Traceback (most recent call last):
File "avgpool.py", line 74, in <module>
print(vta.lower(s, [A,C], simple_mode=True))
File "/usr/tvm/vta/python/vta/build_module.py", line 109, in lower
return tvm.lower(*args, **kwargs)
File "/usr/tvm/python/tvm/driver/build_module.py", line 215, in lower
mod = optimize(mod)
File "/usr/tvm/python/tvm/ir/transform.py", line 130, in __call__
return _ffi_transform_api.RunPass(self, mod)
File "/usr/tvm/python/tvm/_ffi/_ctypes/packed_func.py", line 225, in __call__
raise get_last_ffi_error()
AttributeError: Traceback (most recent call last):
[bt] (4) /usr/tvm/build/libtvm.so(TVMFuncCall+0x61) [0x7f3621a62e01]
[bt] (3) /usr/tvm/build/libtvm.so(+0x63ce17) [0x7f3620f6ee17]
[bt] (2) /usr/tvm/build/libtvm.so(tvm::transform::SequentialNode::operator()(tvm::IRModule, tvm::transform::PassContext const&) const+0x3e6) [0x7f3620f6e8b6]
[bt] (1) /usr/tvm/build/libtvm.so(tvm::tir::transform::PrimFuncPassNode::operator()(tvm::IRModule, tvm::transform::PassContext const&) const+0x54c) [0x7f3621203a4c]
[bt] (0) /usr/tvm/build/libtvm.so(+0x112d7fb) [0x7f3621a5f7fb]
File "/usr/tvm/python/tvm/_ffi/_ctypes/packed_func.py", line 78, in cfun
rv = local_pyfunc(*pyargs)
File "/usr/tvm/vta/python/vta/transform.py", line 960, in _ftransform
func.body, None, _do_fold, ["tir.AttrStmt"]))
File "/usr/tvm/python/tvm/tir/stmt_functor.py", line 46, in ir_transform
return _ffi_api.IRTransform(stmt, preorder, postorder, only_enable)
File "/usr/tvm/python/tvm/_ffi/_ctypes/packed_func.py", line 225, in __call__
raise get_last_ffi_error()
[bt] (8) /usr/tvm/build/libtvm.so(tvm::tir::StmtFunctor<tvm::tir::Stmt (tvm::tir::Stmt const&)>::InitVTable()::{lambda(tvm::runtime::ObjectRef const&, tvm::tir::StmtFunctor<tvm::tir::Stmt (tvm::tir::Stmt const&)>*)#11}::_FUN(tvm::runtime::ObjectRef const&, tvm::tir::StmtFunctor<tvm::tir::Stmt (tvm::tir::Stmt const&)>*)+0x27) [0x7f3620fe4577]
[bt] (7) /usr/tvm/build/libtvm.so(tvm::tir::StmtMutator::VisitStmt_(tvm::tir::SeqStmtNode const*)+0x6c) [0x7f36211c1b4c]
[bt] (6) /usr/tvm/build/libtvm.so(void tvm::runtime::Array<tvm::tir::Stmt, void>::MutateByApply<tvm::tir::StmtMutator::Internal::Mutate(tvm::tir::StmtMutator*, tvm::runtime::Array<tvm::tir::Stmt, void> const&)::{lambda(tvm::tir::Stmt const&)#1}>(tvm::tir::StmtMutator::Internal::Mutate(tvm::tir::StmtMutator*, tvm::runtime::Array<tvm::tir::Stmt, void> const&)::{lambda(tvm::tir::Stmt const&)#1})+0xe8) [0x7f36211c67e8]
[bt] (5) /usr/tvm/build/libtvm.so(tvm::tir::IRTransformer::VisitStmt(tvm::tir::Stmt const&)+0x170) [0x7f36211c6270]
[bt] (4) /usr/tvm/build/libtvm.so(tvm::tir::StmtFunctor<tvm::tir::Stmt (tvm::tir::Stmt const&)>::VisitStmt(tvm::tir::Stmt const&)+0x86) [0x7f362101cb76]
[bt] (3) /usr/tvm/build/libtvm.so(tvm::tir::StmtFunctor<tvm::tir::Stmt (tvm::tir::Stmt const&)>::InitVTable()::{lambda(tvm::runtime::ObjectRef const&, tvm::tir::StmtFunctor<tvm::tir::Stmt (tvm::tir::Stmt const&)>*)#2}::_FUN(tvm::runtime::ObjectRef const&, tvm::tir::StmtFunctor<tvm::tir::Stmt (tvm::tir::Stmt const&)>*)+0x27) [0x7f3620fe42a7]
[bt] (2) /usr/tvm/build/libtvm.so(tvm::tir::StmtMutator::VisitStmt_(tvm::tir::AttrStmtNode const*)+0x45) [0x7f36211c0f25]
[bt] (1) /usr/tvm/build/libtvm.so(tvm::tir::IRTransformer::VisitStmt(tvm::tir::Stmt const&)+0x1ee) [0x7f36211c62ee]
[bt] (0) /usr/tvm/build/libtvm.so(+0x112d7fb) [0x7f3621a5f7fb]
File "/usr/tvm/python/tvm/runtime/object.py", line 56, in __getattr__
return _ffi_node_api.NodeGetAttr(self, name)
File "/usr/tvm/python/tvm/_ffi/_ctypes/packed_func.py", line 225, in __call__
raise get_last_ffi_error()
[bt] (4) /usr/tvm/build/libtvm.so(TVMFuncCall+0x61) [0x7f3621a62e01]
[bt] (3) /usr/tvm/build/libtvm.so(std::_Function_handler<void (tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*), void (*)(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)>::_M_invoke(std::_Any_data const&, tvm::runtime::TVMArgs&&, tvm::runtime::TVMRetValue*&&)+0x14) [0x7f3620f06eb4]
[bt] (2) /usr/tvm/build/libtvm.so(tvm::NodeGetAttr(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)+0x28b) [0x7f3620f0350b]
[bt] (1) /usr/tvm/build/libtvm.so(tvm::ReflectionVTable::GetAttr(tvm::runtime::Object*, tvm::runtime::String const&) const+0x2a7) [0x7f3620f02d67]
[bt] (0) /usr/tvm/build/libtvm.so(dmlc::LogMessageFatal::~LogMessageFatal()+0x61) [0x7f3620e366e1]
File "/usr/tvm/src/node/reflection.cc", line 110
File "/usr/tvm/python/tvm/_ffi/_ctypes/packed_func.py", line 78, in cfun
rv = local_pyfunc(*pyargs)
File "/usr/tvm/vta/python/vta/transform.py", line 805, in _do_fold
dst_var = loop_body.buffer_var
File "/usr/tvm/python/tvm/runtime/object.py", line 59, in __getattr__
"%s has no attribute %s" % (str(type(self)), name))
AttributeError: tir.SeqStmt object has no attributed buffer_var
During handling of the above exception, another exception occurred:
AttributeError: <class 'tvm.tir.stmt.SeqStmt'> has no attribute buffer_var
Can some one please clarify me the cause of this error, and how can I rectify this. Thank you