Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slightly improve error message for non-integer RDom min/extent #7151

Merged
merged 2 commits into from
Nov 16, 2022
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
4 changes: 2 additions & 2 deletions src/Expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ bool is_parallel(ForType for_type) {
Range::Range(const Expr &min_in, const Expr &extent_in)
: min(lossless_cast(Int(32), min_in)), extent(lossless_cast(Int(32), extent_in)) {
if (min_in.defined() && !min.defined()) {
user_error << "Min cannot be losslessly cast to an int32: " << min_in;
user_error << "Range min is not representable as an int32: " << min_in;
}
if (extent_in.defined() && !extent.defined()) {
user_error << "Extent cannot be losslessly cast to an int32: " << extent_in;
user_error << "Range extent is not representable as an int32: " << extent_in;
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/RDom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ class CheckRDomBounds : public IRGraphVisitor {
};
} // namespace

void RDom::validate_min_extent(const Expr &min, const Expr &extent) {
user_assert(lossless_cast(Int(32), min).defined())
<< "RDom min cannot be represented as an int32: " << min;
user_assert(lossless_cast(Int(32), extent).defined())
<< "RDom extent cannot be represented as an int32: " << extent;
}

void RDom::initialize_from_region(const Region &region, string name) {
if (name.empty()) {
name = make_entity_name(this, "Halide:.*:RDom", 'r');
Expand Down
2 changes: 2 additions & 0 deletions src/RDom.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,12 @@ class RDom {

void init_vars(const std::string &name);

void validate_min_extent(const Expr &min, const Expr &extent);
void initialize_from_region(const Region &region, std::string name = "");

template<typename... Args>
HALIDE_NO_USER_CODE_INLINE void initialize_from_region(Region &region, const Expr &min, const Expr &extent, Args &&...args) {
validate_min_extent(min, extent);
region.push_back({min, extent});
initialize_from_region(region, std::forward<Args>(args)...);
}
Expand Down