Skip to content

Commit

Permalink
Optimize strided loop assignment for runtime-contiguous layout types …
Browse files Browse the repository at this point in the history
…with contiguous assignment
  • Loading branch information
Ivorforce authored Oct 10, 2024
1 parent 8c0a484 commit 9719f99
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions include/xtensor/xassign.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,8 @@ namespace xt
std::size_t simd_size = inner_loop_size / simd_type::size;
std::size_t simd_rest = inner_loop_size % simd_type::size;

bool e1_is_contiguous = E1::contiguous_layout || e1.is_contiguous();

auto fct_stepper = e2.stepper_begin(e1.shape());
auto res_stepper = e1.stepper_begin(e1.shape());

Expand Down Expand Up @@ -1191,7 +1193,7 @@ namespace xt
fct_stepper.to_begin();

// need to step E1 as well if not contigous assign (e.g. view)
if (!E1::contiguous_layout)
if (!e1_is_contiguous)
{
res_stepper.to_begin();
for (std::size_t i = 0; i < idx.size(); ++i)
Expand Down Expand Up @@ -1266,7 +1268,7 @@ namespace xt
fct_stepper.to_begin();

// need to step E1 as well if not contigous assign (e.g. view)
if (!E1::contiguous_layout)
if (!e1_is_contiguous)
{
res_stepper.to_begin();
for (std::size_t i = 0; i < idx.size(); ++i)
Expand Down Expand Up @@ -1311,7 +1313,7 @@ namespace xt
fct_stepper.to_begin();

// need to step E1 as well if not contigous assign (e.g. view)
if (!E1::contiguous_layout)
if (!e1_is_contiguous)
{
res_stepper.to_begin();
for (std::size_t i = 0; i < idx.size(); ++i)
Expand Down

0 comments on commit 9719f99

Please sign in to comment.