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_bindings/src/PyFunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ void define_func(py::module &m) {
})
.def("defined", &Func::defined)
.def("outputs", &Func::outputs)
.def("output_type", &Func::output_type)
.def("output_types", &Func::output_types)

.def("bound", &Func::bound, py::arg("var"), py::arg("min"), py::arg("extent"))
Expand Down
11 changes: 11 additions & 0 deletions src/Func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,18 @@ void Func::define_extern(const std::string &function_name,
}

/** Get the types of the buffers returned by an extern definition. */
const Type &Func::output_type() const {
user_assert(defined())
<< "Can't access output buffer of undefined Func.\n";
user_assert(func.output_types().size() == 1)
<< "Can't call Func::output_type on Func \"" << name()
<< "\" because it returns a Tuple.\n";
return func.output_types()[0];
}

const std::vector<Type> &Func::output_types() const {
user_assert(defined())
<< "Can't access output buffer of undefined Func.\n";
return func.output_types();
}

Expand Down
3 changes: 3 additions & 0 deletions src/Func.h
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,10 @@ class Func {
// @}

/** Get the types of the outputs of this Func. */
// @{
const Type &output_type() const;
const std::vector<Type> &output_types() const;
// @}

/** Get the number of outputs of this Func. Corresponds to the
* size of the Tuple this Func was defined to return. */
Expand Down