Skip to content

Commit

Permalink
Fix #8534 (#8535)
Browse files Browse the repository at this point in the history
* Fix #8534

This needs to take src by value, because the helper function mutates
ones of its members in-place.

* Add comment
  • Loading branch information
abadams authored Dec 23, 2024
1 parent c11d977 commit 9c3e6de
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/runtime/HalideBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -1991,9 +1991,11 @@ class Buffer {
/** Make a buffer with the same shape and memory nesting order as
* another buffer. It may have a different type. */
template<typename T2, int D2, int S2>
static Buffer<T, Dims, InClassDimStorage> make_with_shape_of(const Buffer<T2, D2, S2> &src,
static Buffer<T, Dims, InClassDimStorage> make_with_shape_of(Buffer<T2, D2, S2> src,
void *(*allocate_fn)(size_t) = nullptr,
void (*deallocate_fn)(void *) = nullptr) {
// Note that src is taken by value because its dims are mutated
// in-place by the helper. Do not change to taking it by reference.
static_assert(Dims == D2 || Dims == AnyDims);
const halide_type_t dst_type = T_is_void ? src.type() : halide_type_of<typename std::remove_cv<not_void_T>::type>();
return Buffer<>::make_with_shape_of_helper(dst_type, src.dimensions(), src.buf.dim,
Expand Down

0 comments on commit 9c3e6de

Please sign in to comment.