Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
18 changes: 10 additions & 8 deletions python_bindings/src/halide/halide_/PyImageParam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ void define_image_param(py::module &m) {

.def("__repr__", [](const OutputImageParam &im) -> std::string {
std::ostringstream o;
o << "<halide.OutputImageParam '" << im.name() << "'";
o << "<halide.OutputImageParam ";
if (!im.defined()) {
o << " (undefined)";
o << "OutputImageParam()";
} else {
// TODO: add dimensions to this
o << " type " << halide_type_to_string(im.type());
o << "'" << im.name() << "'"
<< ", dims: " << im.dimensions()
<< ", type: " << halide_type_to_string(im.type());
}
o << ">";
return o.str();
Expand Down Expand Up @@ -79,12 +80,13 @@ void define_image_param(py::module &m) {

.def("__repr__", [](const ImageParam &im) -> std::string {
std::ostringstream o;
o << "<halide.ImageParam '" << im.name() << "'";
o << "<halide.ImageParam ";
if (!im.defined()) {
o << " (undefined)";
o << "ImageParam()";
} else {
// TODO: add dimensions to this
o << " type " << halide_type_to_string(im.type());
o << "'" << im.name() << "'"
<< ", dims: " << im.dimensions()
<< ", type: " << halide_type_to_string(im.type());
}
o << ">";
return o.str();
Expand Down
16 changes: 15 additions & 1 deletion python_bindings/test/correctness/basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,6 @@ def test_unevaluated_funcref():
g = hl.Func("g")
g[x] = 2

print("------------------------")
f = hl.Func("f")
f[hl._] += g[hl._]
assert list(f.realize([1])) == [2]
Expand Down Expand Up @@ -582,6 +581,20 @@ def test_implicit_update_by_float():
assert f.realize([1])[0] == 0.5


def test_print_ir():
im = hl.ImageParam()
assert str(im) == "<halide.ImageParam ImageParam()>"

im = hl.OutputImageParam()
assert str(im) == "<halide.OutputImageParam OutputImageParam()>"

im = hl.ImageParam(hl.UInt(16), 2, "input")
assert str(im) == "<halide.ImageParam 'input', dims: 2, type: uint16>"

r = hl.RDom()
assert str(r) == "<halide.RDom RDom()>"


if __name__ == "__main__":
test_compiletime_error()
test_runtime_error()
Expand All @@ -605,3 +618,4 @@ def test_implicit_update_by_float():
test_unevaluated_funcref()
test_implicit_update_by_int()
test_implicit_update_by_float()
test_print_ir()
Loading