MichaelJKlaiber opened a new issue, #15853:
URL: https://github.com/apache/tvm/issues/15853
When including a dict in a TensorIR (block) attribute, printing with
`.script()` throws an error.
See attr `attr1": {1: 2, 3: 4}` below:
```
import tvm
from tvm.ir.module import IRModule
from tvm.script import tir as T
import numpy as np
@tvm.script.ir_module
class MyModule:
@T.prim_func
def main(a: T.handle, b: T.handle):
# We exchange data between function by handles, which are similar to
pointer.
T.func_attr({"global_symbol": "main", "tir.noalias": True})
# Create buffer from handles.
A = T.match_buffer(a, (8,), dtype="float32")
B = T.match_buffer(b, (8,), dtype="float32")
for i in range(8):
# A block is an abstraction for computation.
with T.block("B"):
T.block_attr({"attr0": [0.1, 0.2], "attr1": {1: 2, 3: 4}})
# Define a spatial block iterator and bind it to value i.
vi = T.axis.spatial(8, i)
B[vi] = A[vi] + 1.0
print(MyModule.script())
```
### Expected behavior
What you were expecting
### Actual behavior
```
getting this error:
File "tvm/_ffi/_cython/./packed_func.pxi", line 331, in
tvm._ffi._cy3.core.PackedFuncBase.__call__
File "tvm/_ffi/_cython/./packed_func.pxi", line 262, in
tvm._ffi._cy3.core.FuncCall
File "tvm/_ffi/_cython/./packed_func.pxi", line 251, in
tvm._ffi._cy3.core.FuncCall3
File "tvm/_ffi/_cython/./base.pxi", line 181, in
tvm._ffi._cy3.core.CHECK_CALL
tvm._ffi.base.TVMError: Traceback (most recent call last):
21: TVMFuncCall
20: _ZN3tvm7runtime13PackedF
19: tvm::runtime::TypedPackedFunc<tvm::runtime::String
(tvm::runtime::ObjectRef const&, tvm::runtime::String const&,
bool)>::AssignTypedLambda<tvm::runtime::String (*)(tvm::runtime::ObjectRef
const&, tvm::runtime::String const&, bool)>(tvm::runtime::String
(*)(tvm::runtime::ObjectRef const&, tvm::runtime::String const&, bool),
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>
>)::{lambda(tvm::runtime::TVMArgs const&,
tvm::runtime::TVMRetValue*)#1}::operator()(tvm::runtime::TVMArgs const&,
tvm::runtime::TVMRetValue*) const
18: tvm::tir::AsTVMScript(tvm::runtime::ObjectRef const&,
tvm::runtime::String const&, bool)
17: tvm::tir::TVMScriptPrinter::Print(tvm::runtime::ObjectRef const&)
16: tvm::tir::TVMScriptPrinter::PrintIRModule(tvm::IRModule const&)
15: tvm::tir::TVMScriptPrinter::Print(tvm::runtime::ObjectRef const&)
14: tvm::tir::TVMScriptPrinter::PrintPrimFunc(tvm::tir::PrimFunc const&)
13: tvm::tir::TVMScriptPrinter::PrintBlockBody(tvm::tir::BlockNode const*)
12: tvm::tir::TVMScriptPrinter::PrintBody(tvm::tir::Stmt const&)
11: tvm::tir::TVMScriptPrinter::Print(tvm::runtime::ObjectRef const&)
10: tvm::tir::StmtFunctor<tvm::Doc (tvm::tir::Stmt
const&)>::VisitStmt(tvm::tir::Stmt const&)
9:
_ZZN3tvm3tir11StmtFunctorIFNS_3DocERKNS0_4StmtEEE10InitVTableEvENUlRKNS_7runtime9ObjectRefEPS7_E2_4_FUNESB_S
8: tvm::tir::TVMScriptPrinter::VisitStmt_(tvm::tir::ForNode const*)
7: tvm::tir::TVMScriptPrinter::PrintBody(tvm::tir::Stmt const&)
6: tvm::tir::TVMScriptPrinter::Print(tvm::runtime::ObjectRef const&)
5: tvm::tir::StmtFunctor<tvm::Doc (tvm::tir::Stmt
const&)>::VisitStmt(tvm::tir::Stmt const&)
4: tvm::tir::StmtFunctor<tvm::Doc (tvm::tir::Stmt
const&)>::InitVTable()::{lambda(tvm::runtime::ObjectRef const&,
tvm::tir::StmtFunctor<tvm::Doc (tvm::tir::Stmt
const&)>*)#19}::_FUN(tvm::runtime::ObjectRef const&)
3: tvm::tir::TVMScriptPrinter::VisitStmt_(tvm::tir::BlockRealizeNode
const*)
2: tvm::tir::TVMScriptPrinter::PrintBlockAttr(tvm::tir::BlockRealizeNode
const*)
1:
tvm::tir::TVMScriptPrinter::PrintAnnotations(tvm::runtime::Map<tvm::runtime::String,
tvm::runtime::ObjectRef, void, void> const&)
0: tvm::tir::TVMScriptPrinter::Print(tvm::runtime::ObjectRef const&)
File "tvm/src/printer/tvmscript_printer.cc", line 758
TVMError: Do not know how to print Map
```
### Environment
Ubuntu 22.04
### Steps to reproduce
See above
### Triage
* tir:printer
--
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]