Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zero inner tensors in ToT times T to give ToT checked. #497

Merged
merged 2 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/TiledArray/einsum/tiledarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,8 @@ auto einsum(expressions::TsrExpr<ArrayA_> A, expressions::TsrExpr<ArrayB_> B,
using ResultTensor = typename ArrayC::value_type;
using ResultShape = typename ArrayC::shape_type;

auto const& tnsrExprA = A;
auto const& tnsrExprB = B;
auto const &tnsrExprA = A;
auto const &tnsrExprB = B;

auto a = std::get<0>(Einsum::idx(A));
auto b = std::get<0>(Einsum::idx(B));
Expand Down Expand Up @@ -489,12 +489,12 @@ auto einsum(expressions::TsrExpr<ArrayA_> A, expressions::TsrExpr<ArrayB_> B,

auto sum_tot_2_tos = [](auto const &tot) {
using tot_t = std::remove_reference_t<decltype(tot)>;
typename tot_t::value_type result(
tot.range(), [tot](auto &&ix) {
if (!tot(ix).empty())
return tot(ix).sum();
else return typename tot_t::numeric_type{};
});
typename tot_t::value_type result(tot.range(), [tot](auto &&ix) {
if (!tot(ix).empty())
return tot(ix).sum();
else
return typename tot_t::numeric_type{};
});
return result;
};

Expand Down
9 changes: 6 additions & 3 deletions src/TiledArray/tensor/kernels.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<TR, Ts...>)
if constexpr (is_tensor_of_tensor_v<TR>)
if (result.data()[ord].range().volume() == 0) continue;
if constexpr (is_tensor_of_tensor_v<Ts...>)
if (((tensors.data()[ord].range().volume() == 0) || ...)) continue;
if constexpr (std::is_invocable_r_v<void, Op, typename TR::value_type&,
typename Ts::value_type...>)
Expand Down Expand Up @@ -997,8 +999,9 @@ auto tensor_reduce(ReduceOp&& reduce_op, JoinOp&& join_op,

auto result = identity;
for (std::remove_cv_t<decltype(volume)> 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);
Expand Down