CoinCheung commented on pull request #8069:
URL: https://github.com/apache/tvm/pull/8069#issuecomment-878677560
HI,
I tried this:
```python
def compile_model(mod, params, target, logfile, save_path):
tvm.relay.backend.compile_engine.get().clear()
mod = tvm.relay.transform.ToMixedPrecision(
mixed_precision_type='float16')(mod)
with tvm.autotvm.apply_history_best(logfile):
with tvm.transform.PassContext(opt_level=3):
lib = tvm.relay.build(mod, target=target, params=params)
lib.export_library(save_path) # 保存编译好的模型, 必须so结尾,不然c++不识别
```
But I got the error:
```
Traceback (most recent call last):
File "main.py", line 207, in <module>
args.save_path)
File "main.py", line 122, in compile_model
mixed_precision_type='float16')(mod)
File "/root/build/tvm/python/tvm/ir/transform.py", line 161, in __call__
return _ffi_transform_api.RunPass(self, mod)
File "/root/build/tvm/python/tvm/_ffi/_ctypes/packed_func.py", line 237,
in __call__
raise get_last_ffi_error()
tvm._ffi.base.TVMError: Traceback (most recent call last):
23: TVMFuncCall
22: std::_Function_handler<void (tvm::runtime::TVMArgs,
tvm::runtime::TVMRetValue*), tvm::runtime::TypedPackedFunc<tvm::IRModule
(tvm::transform::Pass,
tvm::IRModule)>::AssignTypedLambda<tvm::transform::{lambda(tvm::transform::Pass,
tvm::IRModule)#7}>(tvm::transform::{lambda(tvm::transform::Pass,
tvm::IRModule)#7}, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >)::{lambda(tvm::runtime::TVMArgs const&,
tvm::runtime::TVMRetValue*)#1}>::_M_invoke(std::_Any_data const&,
tvm::runtime::TVMArgs&&, tvm::runtime::TVMRetValue*&&)
21: tvm::transform::Pass::operator()(tvm::IRModule) const
20: tvm::transform::Pass::operator()(tvm::IRModule,
tvm::transform::PassContext const&) const
19: tvm::relay::transform::FunctionPassNode::operator()(tvm::IRModule,
tvm::transform::PassContext const&) const
18: std::_Function_handler<void (tvm::runtime::TVMArgs,
tvm::runtime::TVMRetValue*), tvm::runtime::TypedPackedFunc<tvm::relay::Function
(tvm::relay::Function, tvm::IRModule,
tvm::transform::PassContext)>::AssignTypedLambda<tvm::relay::transform::ToMixedPrecision(tvm::runtime::DataType,
int)::{lambda(tvm::relay::Function, tvm::IRModule,
tvm::transform::PassContext)#1}>(tvm::relay::transform::ToMixedPrecision(tvm::runtime::DataType,
int)::{lambda(tvm::relay::Function, tvm::IRModule,
tvm::transform::PassContext)#1})::{lambda(tvm::runtime::TVMArgs const&,
tvm::runtime::TVMRetValue*)#1}>::_M_invoke(std::_Any_data const&,
tvm::runtime::TVMArgs&&, tvm::runtime::TVMRetValue*&&)
17: tvm::relay::ToMixedPrecision(tvm::RelayExpr const&,
tvm::runtime::DataType const&, int)
16: tvm::relay::MixedModeMutator::VisitExpr(tvm::RelayExpr const&)
15: tvm::relay::MixedModeMutator::VisitLeaf(tvm::RelayExpr const&)
14: _ZN3tvm5relay16MixedModeMutator17DispatchVisitExprERKNS_9Re
13: tvm::relay::ExprMutator::VisitExpr(tvm::RelayExpr const&)
12: tvm::relay::ExprFunctor<tvm::RelayExpr (tvm::RelayExpr
const&)>::VisitExpr(tvm::RelayExpr const&)
11: _ZZN3tvm5relay11ExprFunctorIFNS_9RelayExprERKS2_EE10InitVTableEvENUlR
10: tvm::relay::MixedPrecisionPass::VisitExpr_(tvm::relay::FunctionNode
const*)
9: tvm::relay::ExprMutator::VisitExpr_(tvm::relay::FunctionNode const*)
8: tvm::relay::MixedModeMutator::VisitExpr(tvm::RelayExpr const&)
7: tvm::relay::MixedModeMutator::VisitLeaf(tvm::RelayExpr const&)
6: _ZN3tvm5relay16MixedModeMutator17DispatchVisitExprERKNS_9Re
5: tvm::relay::ExprMutator::VisitExpr(tvm::RelayExpr const&)
4: tvm::relay::ExprFunctor<tvm::RelayExpr (tvm::RelayExpr
const&)>::VisitExpr(tvm::RelayExpr const&)
3: _ZZN3tvm5relay11ExprFunctorIFNS_9RelayExprERKS2_EE10InitVTableEvENUlR
2: tvm::relay::MixedModeMutator::VisitExpr_(tvm::relay::CallNode const*)
1: tvm::relay::MixedPrecisionPass::Rewrite_(tvm::relay::CallNode const*,
tvm::RelayExpr const&)
0: tvm::Op::GetAttrMapContainer(tvm::runtime::String const&)
File "/root/build/tvm/src/ir/../node/attr_registry.h", line 146
TVMError: Attribute 'FTVMMixedPrecisionConversionType' is not registered
```
Did I miss any key point of using this feature ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]