diff --git a/include/tvm/tir/usmp/utils.h b/include/tvm/tir/usmp/utils.h index 59430eee839f..f49e9ceef794 100644 --- a/include/tvm/tir/usmp/utils.h +++ b/include/tvm/tir/usmp/utils.h @@ -224,7 +224,7 @@ struct AllocatedPoolInfoNode : public Object { hash_reduce(pool_var_idx); } - static constexpr const char* _type_key = "tir.usmp.AllocatedPoolInfo"; + static constexpr const char* _type_key = "ir.AllocatedPoolInfo"; TVM_DECLARE_FINAL_OBJECT_INFO(AllocatedPoolInfoNode, Object); }; diff --git a/python/tvm/ir/memory_pools.py b/python/tvm/ir/memory_pools.py index cd9a75a5c711..37b903c7bb00 100644 --- a/python/tvm/ir/memory_pools.py +++ b/python/tvm/ir/memory_pools.py @@ -245,7 +245,7 @@ def __init__( ) -@register_object("ir.ConstantMemoryPools") +@register_object("ir.AllocatedPoolInfo") class AllocatedPoolInfo(Object): """Allocate memory in a given pool. diff --git a/src/script/printer/tir/usmp.cc b/src/script/printer/tir/usmp.cc new file mode 100644 index 000000000000..5695c2a8076b --- /dev/null +++ b/src/script/printer/tir/usmp.cc @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +#include +#include +#include + +#include "./utils.h" + +namespace tvm { +namespace script { +namespace printer { + +TVM_STATIC_IR_FUNCTOR(IRDocsifier, vtable) + .set_dispatch( + "", [](tir::usmp::AllocatedPoolInfo node, ObjectPath p, IRDocsifier d) -> Doc { + return IR(d, "AllocatedPoolInfo") + ->Call({}, {"pool_info", "allocated_size"}, + {d->AsDoc(node->pool_info, p->Attr("pool_info")), + d->AsDoc(node->allocated_size, p->Attr("allocated_size"))}); + }); + +TVM_STATIC_IR_FUNCTOR(IRDocsifier, vtable) + .set_dispatch("", + [](ConstantPoolInfo node, ObjectPath p, IRDocsifier d) -> Doc { + return IR(d, "ConstantPoolInfo") + ->Call( + {d->AsDoc(node->constant_info_array, + p->Attr("constant_info_array"))}); + }); + +TVM_STATIC_IR_FUNCTOR(IRDocsifier, vtable) + .set_dispatch("", [](ConstantInfo node, ObjectPath p, IRDocsifier d) -> Doc { + return IR(d, "ConstantInfo") + ->Call({d->AsDoc(node->name_hint, p->Attr("name_hint"))}, + {"byte_offset", "data"}, + {d->AsDoc(node->byte_offset, p->Attr("byte_offset")), + d->AddMetadata(node->data)}); + }); + +} // namespace printer +} // namespace script +} // namespace tvm