Skip to content

Commit a0fdb7d

Browse files
committed
Use fplus::transform with rvalue in transform_tensor
Passes a copy of the source vector as an rvalue, triggering fplus's in-place transform path which uses std::begin() instead of back_insert_iterator, allowing the compiler to vectorize the loop.
1 parent 5686c8c commit a0fdb7d

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

include/fdeep/tensor.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,7 @@ namespace internal {
190190
template <typename F>
191191
tensor transform_tensor(F f, const tensor& m)
192192
{
193-
const auto& src = *m.as_vector();
194-
float_vec result(src.size());
195-
std::transform(src.begin(), src.end(), result.begin(), f);
196-
return tensor(m.shape(), std::move(result));
193+
return tensor(m.shape(), fplus::transform(f, float_vec(*m.as_vector())));
197194
}
198195

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

0 commit comments

Comments
 (0)