From bea7b7419d454c5bc513583554405f6cb1d3de9a Mon Sep 17 00:00:00 2001 From: Bimal Gaudel Date: Wed, 18 Dec 2024 14:20:57 -0500 Subject: [PATCH] fix: zero tensor check when ToT time T occurs --- src/TiledArray/tensor/kernels.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/TiledArray/tensor/kernels.h b/src/TiledArray/tensor/kernels.h index 0b0767ed81..1fa12552bc 100644 --- a/src/TiledArray/tensor/kernels.h +++ b/src/TiledArray/tensor/kernels.h @@ -419,7 +419,9 @@ inline void inplace_tensor_op(Op&& op, TR& result, const Ts&... tensors) { auto volume = result.total_size(); for (decltype(volume) ord = 0; ord < volume; ++ord) { - if constexpr (is_tensor_of_tensor_v) + if constexpr (is_tensor_of_tensor_v) + if (result.data()[ord].range().volume() == 0) continue; + if constexpr (is_tensor_of_tensor_v) if (((tensors.data()[ord].range().volume() == 0) || ...)) continue; if constexpr (std::is_invocable_r_v) @@ -997,8 +999,9 @@ auto tensor_reduce(ReduceOp&& reduce_op, JoinOp&& join_op, auto result = identity; for (std::remove_cv_t ord = 0ul; ord < volume; ++ord) { - if (tensor1.data()[ord].range().volume() == 0 - || ((tensors.data()[ord].range().volume() == 0) || ...)) continue; + if (tensor1.data()[ord].range().volume() == 0 || + ((tensors.data()[ord].range().volume() == 0) || ...)) + continue; auto temp = tensor_reduce(reduce_op, join_op, identity, tensor1.data()[ord], tensors.data()[ord]...); join_op(result, temp);