From 42578f79c23c06ae11f35b260ad8f276a9ab2d4c Mon Sep 17 00:00:00 2001 From: Bimal Gaudel Date: Thu, 21 Nov 2024 12:28:32 -0500 Subject: [PATCH] More zero tensor checking. --- src/TiledArray/tensor/kernels.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/TiledArray/tensor/kernels.h b/src/TiledArray/tensor/kernels.h index a2530f2f5d..0b0767ed81 100644 --- a/src/TiledArray/tensor/kernels.h +++ b/src/TiledArray/tensor/kernels.h @@ -417,14 +417,15 @@ inline void inplace_tensor_op(Op&& op, TR& result, const Ts&... tensors) { TA_ASSERT(!empty(result, tensors...)); TA_ASSERT(is_range_set_congruent(result, tensors...)); - const auto volume = result.range().volume(); - - for (decltype(result.range().volume()) ord = 0ul; ord < volume; ++ord) { + auto volume = result.total_size(); + for (decltype(volume) ord = 0; ord < volume; ++ord) { + if constexpr (is_tensor_of_tensor_v) + if (((tensors.data()[ord].range().volume() == 0) || ...)) continue; if constexpr (std::is_invocable_r_v) - op(result.at_ordinal(ord), tensors.at_ordinal(ord)...); + op(result.data()[ord], tensors.data()[ord]...); else - inplace_tensor_op(op, result.at_ordinal(ord), tensors.at_ordinal(ord)...); + inplace_tensor_op(op, result.data()[ord], tensors.data()[ord]...); } }