Skip to content

Commit

Permalink
code style
Browse files Browse the repository at this point in the history
  • Loading branch information
yangulei committed Feb 17, 2022
1 parent 1c7ef99 commit d023ec1
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/tir/ir/data_layout.cc
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,10 @@ inline bool GetStoreRule(Array<PrimExpr>* index_rule, Array<PrimExpr>* shape_rul

std::stringstream ss;
ss << "index rule for " << src_layout.name() << "-->" << dst_layout.name() << ": [ ";
for (const auto& r : *index_rule) { ss << r << ", "; }; ss << "]" << std::endl;
for (const auto& r : *index_rule) { ss << r << ", "; } ss << "]" << std::endl;

ss << "shape rule for " << src_layout.name() << "-->" << dst_layout.name() << ": [ ";
for (const auto& r : *shape_rule) { ss << r << ", "; }; ss << "]" << std::endl;
for (const auto& r : *shape_rule) { ss << r << ", "; } ss << "]" << std::endl;
VLOG(1) << std::endl << ss.str();

return true;
Expand Down Expand Up @@ -366,12 +366,13 @@ inline Array<PrimExpr> TransformShape(const Array<PrimExpr>& src_shape,
}

std::stringstream ss;
ss << "shape rule for " << Layout(src_axis).name() << "-->" << Layout(target_axis).name() << ": [ ";
for (const auto& r : transform_rule) { ss << r << ", "; }; ss << "]" << std::endl;
ss << "shape rule for " << Layout(src_axis).name() << "-->"
<< Layout(target_axis).name() << ": [ ";
for (const auto& r : transform_rule) { ss << r << ", "; } ss << "]" << std::endl;

ss << "shape transform: [ ";
for (const auto& s : src_shape) { ss << s << ", "; }; ss << "] --> [ ";
for (const auto& r : result) { ss << r << ", "; }; ss << "]" << std::endl;
for (const auto& s : src_shape) { ss << s << ", "; } ss << "] --> [ ";
for (const auto& r : result) { ss << r << ", "; } ss << "]" << std::endl;
VLOG(1) << std::endl << ss.str();

return result;
Expand All @@ -380,13 +381,15 @@ inline Array<PrimExpr> TransformShape(const Array<PrimExpr>& src_shape,
Array<PrimExpr> BijectiveLayout::ForwardShape(const Array<PrimExpr>& shape) const {
ICHECK(defined()) << "Cannot operate on an undefined bijective layout.";
const BijectiveLayoutNode* self = operator->();
return TransformShape(shape, self->src_layout->axes, self->dst_layout->axes, self->shape_forward_rule);
return TransformShape(shape,
self->src_layout->axes, self->dst_layout->axes, self->shape_forward_rule);
}

Array<PrimExpr> BijectiveLayout::BackwardShape(const Array<PrimExpr>& shape) const {
ICHECK(defined()) << "Cannot operate on an undefined bijective layout.";
const BijectiveLayoutNode* self = operator->();
return TransformShape(shape, self->dst_layout->axes, self->src_layout->axes, self->shape_backward_rule);
return TransformShape(shape,
self->dst_layout->axes, self->src_layout->axes, self->shape_backward_rule);
}

BijectiveLayout::BijectiveLayout(Layout src_layout, Layout dst_layout) {
Expand All @@ -398,7 +401,8 @@ BijectiveLayout::BijectiveLayout(Layout src_layout, Layout dst_layout) {
// To be consistent with previous behavior, a nullptr layout is created
// when argument is invalid.
if (GetStoreRule(&n->index_forward_rule, &n->shape_forward_rule, n->src_layout, n->dst_layout)) {
ICHECK(GetStoreRule(&n->index_backward_rule, &n->shape_backward_rule, n->dst_layout, n->src_layout));
ICHECK(GetStoreRule(&n->index_backward_rule, &n->shape_backward_rule,
n->dst_layout, n->src_layout));
data_ = std::move(n);
}
}
Expand Down

0 comments on commit d023ec1

Please sign in to comment.