Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions python/tvm/script/ir_builder/tir/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
"""Package tvm.script.ir_builder.tir"""
from .ir import * # pylint: disable=wildcard-import,redefined-builtin
from .ir import boolean as bool # pylint: disable=redefined-builtin
from .ir import buffer_decl as Buffer
4 changes: 1 addition & 3 deletions python/tvm/script/parser/tir/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class BufferProxy:
def __call__(
self,
shape,
dtype=None,
dtype="float32",
data=None,
strides=None,
elem_offset=None,
Expand All @@ -65,8 +65,6 @@ def __call__(
buffer_type="",
axis_separators=None,
) -> Buffer:
if dtype is None:
raise ValueError("Data type must be specified when constructing buffer")
return buffer_decl(
shape,
dtype=dtype,
Expand Down
3 changes: 1 addition & 2 deletions src/script/printer/tir/buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,7 @@ TVM_STATIC_IR_FUNCTOR(IRDocsifier, vtable) //
if (!d->IsVarDefined(buffer)) {
if (Optional<Frame> opt_f = FindLowestVarDef(buffer, d)) {
ExprDoc lhs = DefineBuffer(buffer, opt_f.value(), d);
ExprDoc rhs = BufferDecl(buffer, "buffer_decl", // TODO(@junrushao): name confusing
{}, p, opt_f.value(), d);
ExprDoc rhs = BufferDecl(buffer, "Buffer", {}, p, opt_f.value(), d);
opt_f.value()->stmts.push_back(AssignDoc(lhs, rhs, NullOpt));
}
}
Expand Down
8 changes: 3 additions & 5 deletions src/script/printer/tir/ir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ TVM_STATIC_IR_FUNCTOR(IRDocsifier, vtable)
} else if (dtype == DataType::Bool()) {
return LiteralDoc::Boolean(imm->value, imm_p->Attr("value"));
} else {
return TIR(d, runtime::DLDataType2String(dtype)) //
->Call({LiteralDoc::Int(imm->value, imm_p->Attr("value"))});
return TIR(d, DType2Str(dtype))->Call({LiteralDoc::Int(imm->value, imm_p->Attr("value"))});
}
});

Expand All @@ -45,7 +44,7 @@ TVM_STATIC_IR_FUNCTOR(IRDocsifier, vtable)
if (dtype == d->cfg->float_dtype) {
return LiteralDoc::Float(imm->value, imm_p->Attr("value"));
} else {
return TIR(d, runtime::DLDataType2String(dtype)) //
return TIR(d, DType2Str(dtype))
->Call({LiteralDoc::Float(imm->value, imm_p->Attr("value"))});
}
});
Expand All @@ -61,8 +60,7 @@ TVM_STATIC_IR_FUNCTOR(IRDocsifier, vtable)

TVM_STATIC_IR_FUNCTOR(IRDocsifier, vtable)
.set_dispatch<PrimType>("", [](PrimType ty, ObjectPath p, IRDocsifier d) -> Doc {
std::string dtype = ty->dtype.is_void() ? "void" : runtime::DLDataType2String(ty->dtype);
return TIR(d, dtype);
return TIR(d, DType2Str(ty->dtype));
});

TVM_STATIC_IR_FUNCTOR(IRDocsifier, vtable)
Expand Down
4 changes: 4 additions & 0 deletions src/script/printer/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ inline std::string Docsify(const ObjectRef& obj, const IRDocsifier& d, const Fra
return DocToPythonScript(StmtBlockDoc(f->stmts), cfg);
}

inline std::string DType2Str(const runtime::DataType& dtype) {
return dtype.is_void() ? "void" : runtime::DLDataType2String(dtype);
}

} // namespace printer
} // namespace script
} // namespace tvm
Expand Down
146 changes: 73 additions & 73 deletions tests/python/contrib/test_ethosu/test_copy_compute_reordering.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ class AllOperatorsWithWeights:
def main() -> None:
# function attr dict
T.func_attr({"from_legacy_te_schedule": True, "global_symbol": "main", "tir.noalias": True})
buffer1 = T.buffer_decl([8192], "int8")
buffer2 = T.buffer_decl([128], "uint8")
buffer3 = T.buffer_decl([32], "uint8")
buffer4 = T.buffer_decl([112], "uint8")
buffer5 = T.buffer_decl([32], "uint8")
buffer6 = T.buffer_decl([112], "uint8")
buffer7 = T.buffer_decl([32], "uint8")
buffer8 = T.buffer_decl([112], "uint8")
buffer9 = T.buffer_decl([32], "uint8")
buffer10 = T.buffer_decl([2048], "int8")
buffer1 = T.Buffer([8192], "int8")
buffer2 = T.Buffer([128], "uint8")
buffer3 = T.Buffer([32], "uint8")
buffer4 = T.Buffer([112], "uint8")
buffer5 = T.Buffer([32], "uint8")
buffer6 = T.Buffer([112], "uint8")
buffer7 = T.Buffer([32], "uint8")
buffer8 = T.Buffer([112], "uint8")
buffer9 = T.Buffer([32], "uint8")
buffer10 = T.Buffer([2048], "int8")
# body
p1 = T.decl_buffer([128], "uint8")
p2 = T.decl_buffer([112], "uint8")
Expand Down Expand Up @@ -77,16 +77,16 @@ class ReferenceModule:
def main() -> None:
# function attr dict
T.func_attr({"from_legacy_te_schedule": True, "global_symbol": "main", "tir.noalias": True})
buffer1 = T.buffer_decl([8192], "int8")
buffer2 = T.buffer_decl([128], "uint8")
buffer3 = T.buffer_decl([32], "uint8")
buffer4 = T.buffer_decl([112], "uint8")
buffer5 = T.buffer_decl([32], "uint8")
buffer6 = T.buffer_decl([112], "uint8")
buffer7 = T.buffer_decl([32], "uint8")
buffer8 = T.buffer_decl([112], "uint8")
buffer9 = T.buffer_decl([32], "uint8")
buffer10 = T.buffer_decl([2048], "int8")
buffer1 = T.Buffer([8192], "int8")
buffer2 = T.Buffer([128], "uint8")
buffer3 = T.Buffer([32], "uint8")
buffer4 = T.Buffer([112], "uint8")
buffer5 = T.Buffer([32], "uint8")
buffer6 = T.Buffer([112], "uint8")
buffer7 = T.Buffer([32], "uint8")
buffer8 = T.Buffer([112], "uint8")
buffer9 = T.Buffer([32], "uint8")
buffer10 = T.Buffer([2048], "int8")
# body
p1 = T.decl_buffer([128], "uint8")
p2 = T.decl_buffer([112], "uint8")
Expand Down Expand Up @@ -123,16 +123,16 @@ class ReferenceModule:
def main() -> None:
# function attr dict
T.func_attr({"from_legacy_te_schedule": True, "global_symbol": "main", "tir.noalias": True})
buffer1 = T.buffer_decl([8192], "int8")
buffer2 = T.buffer_decl([128], "uint8")
buffer3 = T.buffer_decl([32], "uint8")
buffer4 = T.buffer_decl([112], "uint8")
buffer5 = T.buffer_decl([32], "uint8")
buffer6 = T.buffer_decl([112], "uint8")
buffer7 = T.buffer_decl([32], "uint8")
buffer8 = T.buffer_decl([112], "uint8")
buffer9 = T.buffer_decl([32], "uint8")
buffer10 = T.buffer_decl([2048], "int8")
buffer1 = T.Buffer([8192], "int8")
buffer2 = T.Buffer([128], "uint8")
buffer3 = T.Buffer([32], "uint8")
buffer4 = T.Buffer([112], "uint8")
buffer5 = T.Buffer([32], "uint8")
buffer6 = T.Buffer([112], "uint8")
buffer7 = T.Buffer([32], "uint8")
buffer8 = T.Buffer([112], "uint8")
buffer9 = T.Buffer([32], "uint8")
buffer10 = T.Buffer([2048], "int8")
# body
p1 = T.decl_buffer([128], "uint8")
p2 = T.decl_buffer([112], "uint8")
Expand Down Expand Up @@ -167,8 +167,8 @@ class AllOperatorsWithoutWeights:
@T.prim_func
def main() -> None:
T.func_attr({"from_legacy_te_schedule": True, "global_symbol": "main", "tir.noalias": True})
buffer1 = T.buffer_decl([36], "int8")
buffer2 = T.buffer_decl([9], "int8")
buffer1 = T.Buffer([36], "int8")
buffer2 = T.Buffer([9], "int8")
# body
p1 = T.decl_buffer([96], "int8")
T.evaluate(T.call_extern("ethosu_pooling", "int8", 3, 4, 3, 3, 0, 4, buffer1[0], 0, 0, 0, T.float32(1), 0, "NHWC", 12, 3, 1, "int8", 3, 2, 3, 3, 0, 2, p1[0], 0, 0, 0, T.float32(1), 0, "NHCWB16", 32, 16, 1, "MAX", 2, 1, 2, 1, 1, 1, 0, 0, 0, 0, "NONE", 0, 0, "TFL", "NONE", 0, 0, 0, dtype="handle"))
Expand All @@ -189,11 +189,11 @@ class OperatorsWithAndWithoutWeights:
@T.prim_func
def main() -> None:
T.func_attr({"from_legacy_te_schedule": True, "global_symbol": "main", "tir.noalias": True})
buffer1 = T.buffer_decl([97156], "int8")
buffer2 = T.buffer_decl([80], "uint8")
buffer3 = T.buffer_decl([64], "uint8")
buffer4 = T.buffer_decl([96], "uint8")
buffer5 = T.buffer_decl([32], "uint8")
buffer1 = T.Buffer([97156], "int8")
buffer2 = T.Buffer([80], "uint8")
buffer3 = T.Buffer([64], "uint8")
buffer4 = T.Buffer([96], "uint8")
buffer5 = T.Buffer([32], "uint8")
# body
p1 = T.decl_buffer([390336], "int8")
p2 = T.decl_buffer([80], "uint8")
Expand Down Expand Up @@ -224,11 +224,11 @@ class ReferenceModule:
@T.prim_func
def main() -> None:
T.func_attr({"from_legacy_te_schedule": True, "global_symbol": "main", "tir.noalias": True})
buffer1 = T.buffer_decl([97156], "int8")
buffer2 = T.buffer_decl([80], "uint8")
buffer3 = T.buffer_decl([64], "uint8")
buffer4 = T.buffer_decl([96], "uint8")
buffer5 = T.buffer_decl([32], "uint8")
buffer1 = T.Buffer([97156], "int8")
buffer2 = T.Buffer([80], "uint8")
buffer3 = T.Buffer([64], "uint8")
buffer4 = T.Buffer([96], "uint8")
buffer5 = T.Buffer([32], "uint8")
# body
p1 = T.decl_buffer([390336], "int8")
p2 = T.decl_buffer([80], "uint8")
Expand Down Expand Up @@ -257,11 +257,11 @@ class ReferenceModule:
@T.prim_func
def main() -> None:
T.func_attr({"from_legacy_te_schedule": True, "global_symbol": "main", "tir.noalias": True})
buffer1 = T.buffer_decl([97156], "int8")
buffer2 = T.buffer_decl([80], "uint8")
buffer3 = T.buffer_decl([64], "uint8")
buffer4 = T.buffer_decl([96], "uint8")
buffer5 = T.buffer_decl([32], "uint8")
buffer1 = T.Buffer([97156], "int8")
buffer2 = T.Buffer([80], "uint8")
buffer3 = T.Buffer([64], "uint8")
buffer4 = T.Buffer([96], "uint8")
buffer5 = T.Buffer([32], "uint8")
# body
p1 = T.decl_buffer([390336], "int8")
p2 = T.decl_buffer([80], "uint8")
Expand Down Expand Up @@ -289,14 +289,14 @@ class CopyToBufferWithLocalScope:
@T.prim_func
def main() -> None:
T.func_attr({"from_legacy_te_schedule": True, "global_symbol": "main", "tir.noalias": True})
buffer1 = T.buffer_decl([64], "uint8")
buffer2 = T.buffer_decl([48], "uint8")
buffer3 = T.buffer_decl([48], "uint8")
buffer4 = T.buffer_decl([256], "uint8")
buffer5 = T.buffer_decl([16], "uint8")
buffer6 = T.buffer_decl([48], "uint8")
buffer7 = T.buffer_decl([256], "uint8")
buffer8 = T.buffer_decl([64], "uint8")
buffer1 = T.Buffer([64], "uint8")
buffer2 = T.Buffer([48], "uint8")
buffer3 = T.Buffer([48], "uint8")
buffer4 = T.Buffer([256], "uint8")
buffer5 = T.Buffer([16], "uint8")
buffer6 = T.Buffer([48], "uint8")
buffer7 = T.Buffer([256], "uint8")
buffer8 = T.Buffer([64], "uint8")
# body
p1 = T.decl_buffer([48], "uint8")
p2 = T.decl_buffer([48], "uint8")
Expand Down Expand Up @@ -330,14 +330,14 @@ class ReferenceModule:
@T.prim_func
def main() -> None:
T.func_attr({"from_legacy_te_schedule": True, "global_symbol": "main", "tir.noalias": True})
buffer1 = T.buffer_decl([64], "uint8")
buffer2 = T.buffer_decl([48], "uint8")
buffer3 = T.buffer_decl([48], "uint8")
buffer4 = T.buffer_decl([256], "uint8")
buffer5 = T.buffer_decl([16], "uint8")
buffer6 = T.buffer_decl([48], "uint8")
buffer7 = T.buffer_decl([256], "uint8")
buffer8 = T.buffer_decl([64], "uint8")
buffer1 = T.Buffer([64], "uint8")
buffer2 = T.Buffer([48], "uint8")
buffer3 = T.Buffer([48], "uint8")
buffer4 = T.Buffer([256], "uint8")
buffer5 = T.Buffer([16], "uint8")
buffer6 = T.Buffer([48], "uint8")
buffer7 = T.Buffer([256], "uint8")
buffer8 = T.Buffer([64], "uint8")
# body
p1 = T.decl_buffer([48], "uint8")
p2 = T.decl_buffer([48], "uint8")
Expand Down Expand Up @@ -406,11 +406,11 @@ class ReferenceModule:
@T.prim_func
def main() -> None:
T.func_attr({"from_legacy_te_schedule": True, "global_symbol": "main", "tir.noalias": True})
buffer1 = T.buffer_decl([97156], "int8")
buffer2 = T.buffer_decl([80], "uint8")
buffer3 = T.buffer_decl([64], "uint8")
buffer4 = T.buffer_decl([96], "uint8")
buffer5 = T.buffer_decl([32], "uint8")
buffer1 = T.Buffer([97156], "int8")
buffer2 = T.Buffer([80], "uint8")
buffer3 = T.Buffer([64], "uint8")
buffer4 = T.Buffer([96], "uint8")
buffer5 = T.Buffer([32], "uint8")
# body
p1 = T.decl_buffer([390336], "int8")
p2 = T.decl_buffer([80], "uint8")
Expand Down Expand Up @@ -439,11 +439,11 @@ class ReferenceModule:
@T.prim_func
def main() -> None:
T.func_attr({"from_legacy_te_schedule": True, "global_symbol": "main", "tir.noalias": True})
buffer1 = T.buffer_decl([97156], "int8")
buffer2 = T.buffer_decl([80], "uint8")
buffer3 = T.buffer_decl([64], "uint8")
buffer4 = T.buffer_decl([96], "uint8")
buffer5 = T.buffer_decl([32], "uint8")
buffer1 = T.Buffer([97156], "int8")
buffer2 = T.Buffer([80], "uint8")
buffer3 = T.Buffer([64], "uint8")
buffer4 = T.Buffer([96], "uint8")
buffer5 = T.Buffer([32], "uint8")
# body
p1 = T.decl_buffer([390336], "int8")
p2 = T.decl_buffer([80], "uint8")
Expand Down
Loading