Skip to content

Commit 24d9c9d

Browse files
committed
Fix transform_tensor for non-default allocator float_vec
fplus::transform with rvalue relies on type deduction that fails when float_vec uses Eigen::aligned_allocator. Replace with an explicit copy and in-place std::transform, which achieves the same effect: the copy uses memcpy rather than zero-initialization, and the plain iterator allows the compiler to vectorize the loop.
1 parent a0fdb7d commit 24d9c9d

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

include/fdeep/tensor.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,9 @@ namespace internal {
190190
template <typename F>
191191
tensor transform_tensor(F f, const tensor& m)
192192
{
193-
return tensor(m.shape(), fplus::transform(f, float_vec(*m.as_vector())));
193+
float_vec result(*m.as_vector());
194+
std::transform(result.begin(), result.end(), result.begin(), f);
195+
return tensor(m.shape(), std::move(result));
194196
}
195197

196198
inline std::vector<tensor> tensor_to_depth_slices(const tensor& m)

0 commit comments

Comments
 (0)