I used the conda tool to set up a TVM development environment and then ran the official website examples, but I encountered problems.
Here is my python program:
import tvm
from tvm import relax
from tvm.relax.frontend import nn
import numpy as np
class MLPModel(nn.Module):
def init(self):
super(MLPModel, self).init()
self.fc1 = nn.Linear(784, 256)
self.relu1 = nn.ReLU()
self.fc2 = nn.Linear(256, 10)
def forward(self, x):
x = self.fc1(x)
x = self.relu1(x)
x = self.fc2(x)
return x
mod, param_spec = MLPModel().export_tvm(
spec={“forward”: {“x”: nn.spec.Tensor((1, 784), “float32”)}}
)
mod.show()
The following are the errors reported during operation:
[20:08:28] /home/xq/liupan/tvm/src/relax/ir/block_builder.cc:64: Warning: BlockBuilder destroyed with remaining blocks!
Traceback (most recent call last):
File “/home/xq/liupan/test.py”, line 27, in
mod = relax.get_pipeline(“zero”)(mod)
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
File “/home/xq/liupan/tvm/python/tvm/ir/transform.py”, line 167, in call
return _ffi_transform_api.RunPass(self, mod)
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
File “tvm/ffi/cython/./function.pxi”, line 247, in tvm.ffi.core.Function.call
File “/home/xq/liupan/tvm/src/ir/transform.cc”, line 538, in operator()
TVM_FFI_STATIC_INIT_BLOCK({
File “/home/xq/liupan/tvm/src/ir/transform.cc”, line 294, in tvm::transform::Pass::operator()(tvm::IRModule) const
return this->operator()(std::move(mod), PassContext::Current());
File “/home/xq/liupan/tvm/src/ir/transform.cc”, line 310, in tvm::transform::Pass::operator()(tvm::IRModule, tvm::transform::PassContext const&) const
ret = node->operator()(std::move(mod), pass_ctx);
File “/home/xq/liupan/tvm/src/ir/transform.cc”, line 419, in tvm::transform::ModulePassNode::operator()(tvm::IRModule, tvm::transform::PassContext const&) const
mod = pass_func(std::move(mod), pass_ctx);
File “/home/xq/liupan/tvm/src/ir/transform.cc”, line 538, in operator()
TVM_FFI_STATIC_INIT_BLOCK({
File “tvm/ffi/cython/./function.pxi”, line 409, in tvm.ffi.core.tvm_ffi_callback
File “/home/xq/liupan/tvm/python/tvm/relax/pipeline.py”, line 71, in f_zero_pipeline
mod = seq(mod)
File “/home/xq/liupan/tvm/python/tvm/ir/transform.py”, line 167, in call
return _ffi_transform_api.RunPass(self, mod)
File “tvm/ffi/cython/./function.pxi”, line 247, in tvm.ffi.core.Function.call
File “/home/xq/liupan/tvm/src/ir/transform.cc”, line 538, in operator()
TVM_FFI_STATIC_INIT_BLOCK({
File “/home/xq/liupan/tvm/src/ir/transform.cc”, line 294, in tvm::transform::Pass::operator()(tvm::IRModule) const
return this->operator()(std::move(mod), PassContext::Current());
File “/home/xq/liupan/tvm/src/ir/transform.cc”, line 310, in tvm::transform::Pass::operator()(tvm::IRModule, tvm::transform::PassContext const&) const
ret = node->operator()(std::move(mod), pass_ctx);
File “/home/xq/liupan/tvm/src/ir/transform.cc”, line 489, in tvm::transform::SequentialNode::operator()(tvm::IRModule, tvm::transform::PassContext const&) const
mod = pass(std::move(mod), pass_ctx);
File “/home/xq/liupan/tvm/src/ir/transform.cc”, line 310, in tvm::transform::Pass::operator()(tvm::IRModule, tvm::transform::PassContext const&) const
ret = node->operator()(std::move(mod), pass_ctx);
File “/home/xq/liupan/tvm/src/ir/transform.cc”, line 419, in tvm::transform::ModulePassNode::operator()(tvm::IRModule, tvm::transform::PassContext const&) const
mod = pass_func(std::move(mod), pass_ctx);
File “/home/xq/liupan/tvm/src/relax/transform/legalize_ops.cc”, line 398, in operator()
mod = LegalizeMutator(mod, cmap, enable_warning).Transform();
File “/home/xq/liupan/tvm/src/relax/transform/legalize_ops.cc”, line 75, in tvm::relax::LegalizeMutator::Transform()
auto updated_func = Downcast(this->VisitExpr(func));
File “/home/xq/liupan/tvm/src/relax/ir/expr_functor.cc”, line 554, in tvm::relax::ExprMutator::VisitExpr(tvm::RelaxExpr const&)
return builder_->Normalize(ExprFunctor::VisitExpr(expr));
File “/home/xq/liupan/tvm/include/tvm/relax/expr_functor.h”, line 132, in tvm::relax::ExprFunctor<tvm::RelaxExpr (tvm::RelaxExpr const&)>::VisitExpr(tvm::RelaxExpr const&)
return vtable(n, this, std::forward(args)…) ;
File “/home/xq/liupan/tvm/include/tvm/node/functor.h”, line 102, in tvm::NodeFunctor<tvm::RelaxExpr (tvm::ffi::ObjectRef const&, tvm::relax::ExprFunctor<tvm::RelaxExpr (tvm::RelaxExpr const&)>)>::operator()(tvm::ffi::ObjectRef const&, tvm::relax::ExprFunctor<tvm::RelaxExpr (tvm::RelaxExpr const&)>) const
return (*func_[n->type_index() - begin_type_index_])(n, std::forward(args)…) ;
File “/home/xq/liupan/tvm/include/tvm/relax/expr_functor.h”, line 170, in tvm::relax::ExprFunctor<tvm::RelaxExpr (tvm::RelaxExpr const&)>::InitVTable()::{lambda(tvm::ffi::ObjectRef const&, tvm::relax::ExprFunctor<tvm::RelaxExpr (tvm::RelaxExpr const&)>*)#8}::_FUN(tvm::ffi::ObjectRe