Skip to content

Commit 5659a35

Browse files
committed
address PR #562 review: include hygiene, K_ re-init, gemm_batched congruence checks
- einsum/tiledarray.h, tile_op/batched_contract_reduce.h, pmap/slabbed_pmap.h: include what is used (<cstdlib>, <string_view>, util/vector.h, <memory>, <utility>) instead of relying on transitive includes - cont_engine.h: re-initialize K_ in init_distribution_general() (defensive; engines are single-use, but mirrors the n_slabs_ reset) - sparse_shape.h: gemm_batched() now TA_ASSERTs that the argument ranks match the folded gemm ranks plus the fused modes and that the fused and contracted mode extents of the two shapes are congruent (the batched analogue of the checks GemmHelper::compute_matrix_sizes performs for plain gemm)
1 parent ef0066c commit 5659a35

5 files changed

Lines changed: 21 additions & 0 deletions

File tree

src/TiledArray/einsum/tiledarray.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414

1515
#include <madness/world/thread.h>
1616

17+
#include <cstdlib>
1718
#include <optional>
19+
#include <string_view>
1820

1921
namespace TiledArray {
2022
enum struct DeNest { True, False };

src/TiledArray/expressions/cont_engine.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,7 @@ class ContEngine : public BinaryEngine<Derived> {
793793
// Compute the slab count and the fused sizes of the per-slab contraction
794794
size_type M = 1ul, m = 1ul, N = 1ul, n = 1ul;
795795
n_slabs_ = 1ul;
796+
K_ = 1ul;
796797
for (unsigned int i = 0u; i < nh; ++i) n_slabs_ *= left_tiles_size[i];
797798
for (unsigned int i = nh; i < nh + neA; ++i) {
798799
M *= left_tiles_size[i];

src/TiledArray/pmap/slabbed_pmap.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525

2626
#include <TiledArray/pmap/pmap.h>
2727

28+
#include <memory>
29+
#include <utility>
30+
2831
namespace TiledArray {
2932
namespace detail {
3033

src/TiledArray/sparse_shape.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,6 +1719,20 @@ class SparseShape {
17191719
using integer = TiledArray::math::blas::integer;
17201720
const auto* left_extent = tile_norms_.range().extent_data();
17211721
const auto* right_extent = other.tile_norms_.range().extent_data();
1722+
1723+
// check that the ranks match the folded gemm ranks plus the fused modes,
1724+
// and that the fused and contracted mode extents of the two shapes are
1725+
// congruent
1726+
TA_ASSERT(tile_norms_.range().rank() == nfused + gemm_helper.left_rank());
1727+
TA_ASSERT(other.tile_norms_.range().rank() ==
1728+
nfused + gemm_helper.right_rank());
1729+
for (unsigned int d = 0u; d < nfused; ++d)
1730+
TA_ASSERT(left_extent[d] == right_extent[d]);
1731+
for (unsigned int i = gemm_helper.left_inner_begin(),
1732+
j = gemm_helper.right_inner_begin();
1733+
i < gemm_helper.left_inner_end(); ++i, ++j)
1734+
TA_ASSERT(left_extent[nfused + i] == right_extent[nfused + j]);
1735+
17221736
integer H = 1, M = 1, N = 1, K = 1;
17231737
for (unsigned int d = 0u; d < nfused; ++d) H *= left_extent[d];
17241738
for (unsigned int i = gemm_helper.left_outer_begin();

src/TiledArray/tile_op/batched_contract_reduce.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#define TILEDARRAY_TILE_OP_BATCHED_CONTRACT_REDUCE_H__INCLUDED
2525

2626
#include <TiledArray/tile_op/contract_reduce.h>
27+
#include <TiledArray/util/vector.h>
2728

2829
namespace TiledArray {
2930
namespace detail {

0 commit comments

Comments
 (0)