Skip to content
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
30 changes: 30 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ option(SEQUANT_BTAS "Enable BTAS eval backend" ${SEQUANT_EVAL_TESTS})
add_feature_info(SEQUANT_EVAL_BTAS SEQUANT_BTAS "Enable BTAS eval backend")
option(SEQUANT_TILEDARRAY "Enable TiledArray eval backend" ${SEQUANT_EVAL_TESTS})
add_feature_info(SEQUANT_EVAL_TILEDARRAY SEQUANT_TILEDARRAY "Enable TiledArray eval backend")
option(SEQUANT_TAPP "Enable TAPP eval backend" ${SEQUANT_EVAL_TESTS})
add_feature_info(SEQUANT_EVAL_TAPP SEQUANT_TAPP "Enable TAPP eval backend")

option(SEQUANT_IWYU "Whether to use the include-what-you-use tool (if found)" OFF)
option(SEQUANT_WARNINGS_AS_ERRORS "Whether to treat compiler warnings as errors" ${PROJECT_IS_TOP_LEVEL})
Expand Down Expand Up @@ -460,6 +462,14 @@ set(SeQuant_eval_btas_src
SeQuant/core/eval/backends/btas/result.hpp
)

# TAPP backend sources (header-only)
set(SeQuant_eval_tapp_src
SeQuant/core/eval/backends/tapp/tensor.hpp
SeQuant/core/eval/backends/tapp/ops.hpp
SeQuant/core/eval/backends/tapp/eval_expr.hpp
SeQuant/core/eval/backends/tapp/result.hpp
)

# Core sources (just version info)
set(SeQuant_core_src
${PROJECT_BINARY_DIR}/SeQuant/version.hpp
Expand All @@ -486,6 +496,12 @@ if (SEQUANT_BTAS)
endif()
set(SEQUANT_HAS_BTAS ON)
endif ()
if (SEQUANT_TAPP)
if (NOT TARGET tapp::reference)
include(FindOrFetchTAPP)
endif()
set(SEQUANT_HAS_TAPP ON)
endif ()

if (NOT PROJECT_IS_TOP_LEVEL)
set(SEQUANT_SYSTEM "SYSTEM")
Expand Down Expand Up @@ -578,6 +594,17 @@ if (SEQUANT_HAS_BTAS)
target_compile_definitions(SeQuant-eval-btas INTERFACE SEQUANT_HAS_BTAS=1)
endif()

##########################
# SeQuant-eval-tapp: TAPP backend (header-only)
##########################
if (SEQUANT_HAS_TAPP)
add_library(SeQuant-eval-tapp INTERFACE)
set_target_properties(SeQuant-eval-tapp PROPERTIES EXPORT_NAME eval::tapp)
add_library(SeQuant::eval::tapp ALIAS SeQuant-eval-tapp)
target_link_libraries(SeQuant-eval-tapp INTERFACE SeQuant-eval SeQuant-symb tapp::reference)
target_compile_definitions(SeQuant-eval-tapp INTERFACE SEQUANT_HAS_TAPP=1)
endif()

##########################
# SeQuant-export: code generation/export (depends on eval)
##########################
Expand Down Expand Up @@ -616,6 +643,9 @@ endif()
if (SEQUANT_HAS_BTAS)
list(APPEND SEQUANT_MODULES SeQuant-eval-btas)
endif()
if (SEQUANT_HAS_TAPP)
list(APPEND SEQUANT_MODULES SeQuant-eval-tapp)
endif()

##########################
# SeQuant: umbrella INTERFACE target (backwards compatibility)
Expand Down
1 change: 0 additions & 1 deletion SeQuant/core/eval/backends/btas/result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ class ResultTensorBTAS final : public Result {

private:
[[nodiscard]] std::size_t size_in_bytes() const final {
static_assert(std::is_arithmetic_v<typename T::value_type>);
const auto& tensor = get<T>();
// only count data
return tensor.range().volume() * sizeof(T);
Expand Down
64 changes: 64 additions & 0 deletions SeQuant/core/eval/backends/tapp/eval_expr.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#ifndef SEQUANT_EVAL_BACKENDS_TAPP_EVAL_EXPR_HPP
#define SEQUANT_EVAL_BACKENDS_TAPP_EVAL_EXPR_HPP

#ifdef SEQUANT_HAS_TAPP

#include <SeQuant/core/eval/eval_expr.hpp>

#include <SeQuant/core/container.hpp>
#include <SeQuant/core/hash.hpp>
#include <SeQuant/core/index.hpp>

#include <range/v3/view.hpp>

#include <cstdint>

namespace sequant {

///
/// \brief This class extends the EvalExpr class by adding an annot() method so
/// that it can be used to evaluate using TAPP.
///
class EvalExprTAPP final : public EvalExpr {
public:
using annot_t = container::svector<int64_t>;

///
/// \param bk iterable of Index objects.
/// \return vector of int64_t-type hash values
/// of the labels of indices in \c bk
///
template <typename Iterable>
static auto index_hash(Iterable&& bk) {
return ranges::views::transform(
std::forward<Iterable>(bk), [](auto const& idx) {
return static_cast<int64_t>(sequant::hash::value(Index{idx}.label()));
});
}

template <typename... Args, typename = std::enable_if_t<
std::is_constructible_v<EvalExpr, Args...>>>
EvalExprTAPP(Args&&... args) : EvalExpr{std::forward<Args>(args)...} {
annot_ = index_hash(canon_indices()) | ranges::to<annot_t>;
}

///
/// \return Annotation (container::svector<int64_t>) for TAPP tensors.
///
[[nodiscard]] inline annot_t const& annot() const noexcept { return annot_; }

private:
annot_t annot_;
};

/// Type alias for TAPP evaluation nodes
using EvalNodeTAPP = EvalNode<EvalExprTAPP>;

static_assert(meta::eval_node<EvalNodeTAPP>);
static_assert(meta::can_evaluate<EvalNodeTAPP>);

} // namespace sequant

#endif // SEQUANT_HAS_TAPP

#endif // SEQUANT_EVAL_BACKENDS_TAPP_EVAL_EXPR_HPP
Loading