Skip to content

Commit

Permalink
btas::Tensor can be copied into from Tensor and TensorInterface ... t…
Browse files Browse the repository at this point in the history
…his allows TA::retile on DistArrays of btas::Tensors
  • Loading branch information
evaleev committed Sep 24, 2024
1 parent 81a3af5 commit 87b024b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/TiledArray/external/btas.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ class boxrange_iteration_order<TiledArray::Range> {
static constexpr int value = row_major;
};

template <typename T, typename A>
class is_tensor<TiledArray::Tensor<T, A>> : public std::true_type {};

template <typename T, typename R, typename O>
class is_tensor<TiledArray::detail::TensorInterface<T, R, O>>
: public std::true_type {};

} // namespace btas

namespace TiledArray {
Expand Down
15 changes: 15 additions & 0 deletions tests/btas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,21 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(tensor_ctor, Tensor, tensor_types) {
BOOST_REQUIRE_NO_THROW(Tensor t1 = t0);
Tensor t1 = t0;
BOOST_CHECK(t1.empty());

// can copy TA::Tensor to btas::Tensor
TA::Tensor<typename Tensor::value_type> ta_tensor(r);
BOOST_REQUIRE_NO_THROW(Tensor(ta_tensor));
Tensor t2(ta_tensor);
for (auto i : r) {
BOOST_CHECK_EQUAL(ta_tensor(i), t2(i));
}

// can copy TA::TensorInterface to btas::Tensor
BOOST_REQUIRE_NO_THROW(Tensor(ta_tensor.block(r.lobound(), r.upbound())));
Tensor t3(ta_tensor.block(r.lobound(), r.upbound()));
for (auto i : r) {
BOOST_CHECK_EQUAL(ta_tensor(i), t3(i));
}
}

BOOST_AUTO_TEST_CASE_TEMPLATE(copy, Array, array_types) {
Expand Down
2 changes: 2 additions & 0 deletions tests/expressions_btas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
*
*/

#include <TiledArray/config.h>

#ifdef TILEDARRAY_HAS_BTAS
#include "expressions_fixture.h"

Expand Down

0 comments on commit 87b024b

Please sign in to comment.