Skip to content

Commit

Permalink
Use .data() method to access elements by ordinal in tensor_reduce fun…
Browse files Browse the repository at this point in the history
…ction.
  • Loading branch information
bimalgaudel committed Dec 17, 2023
1 parent 6e18686 commit 2520fe5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/TiledArray/tensor/kernels.h
Original file line number Diff line number Diff line change
Expand Up @@ -787,8 +787,8 @@ auto tensor_reduce(ReduceOp&& reduce_op, JoinOp&& join_op,
auto result = identity;
for (decltype(tensor1.range().volume()) ord = 0ul; ord < volume; ++ord) {
auto temp =
tensor_reduce(reduce_op, join_op, identity, tensor1.at_ordinal(ord),
tensors.at_ordinal(ord)...);
tensor_reduce(reduce_op, join_op, identity, tensor1.data()[ord],

This comment has been minimized.

Copy link
@evaleev

evaleev Dec 18, 2023

Member

I think the "correct" way to deal with the issue of at_ordinal not working when batch_size()>1 is to implement alternative to norm() when batch_size()>1 to custom function (like norm_batch(batch_reducer) ... this does not really do the right thing for the case where batch_size() > 1 (recall, as we discussed, norm() needs to return norm maximum over the batches, i.e. you would invoke Tensor<T>::norm_batch(std::max<T>{})

This comment has been minimized.

Copy link
@evaleev

evaleev Dec 18, 2023

Member

this should be reverted as this worked exactly as intended, i.e. correctly detected the logic error in what you were trying to do

tensors.data()[ord]...);
join_op(result, temp);
}

Expand Down

0 comments on commit 2520fe5

Please sign in to comment.