Skip to content

Commit

Permalink
Add printer for Layout/BijectiveLayout (apache#3582)
Browse files Browse the repository at this point in the history
  • Loading branch information
yzhliu authored and wweic committed Sep 6, 2019
1 parent 168f1bb commit 4b7d9f1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 0 additions & 6 deletions python/tvm/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,6 @@ class Layout(NodeBase):
--------
layout : Declare a layout
"""
def __str__(self):
return self.name

def __repr__(self):
return "Layout(" + self.name + ")"

def __len__(self):
return _api_internal._LayoutNdim(self)

Expand Down
11 changes: 11 additions & 0 deletions src/lang/data_layout.cc
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ int32_t Layout::FactorOf(const LayoutAxis& axis) const {
return -1;
}

TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
.set_dispatch<LayoutNode>([](const LayoutNode* l, IRPrinter* p) {
p->stream << "Layout(" << l->name << ")";
});

inline bool GetStoreRule(Array<Expr>* rule,
const Layout& src_layout,
const Layout& dst_layout) {
Expand Down Expand Up @@ -346,4 +351,10 @@ BijectiveLayout BijectiveLayoutNode::make(const Layout& src_layout,
return BijectiveLayout(n);
}

TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
.set_dispatch<BijectiveLayoutNode>([](const BijectiveLayoutNode* b, IRPrinter* p) {
p->stream << "BijectiveLayout(" << b->src_layout.name()
<< "->" << b->dst_layout.name() << ")";
});

} // namespace tvm

0 comments on commit 4b7d9f1

Please sign in to comment.