summaryrefslogtreecommitdiff
path: root/lib/core/c++/memory.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/core/c++/memory.hpp')
-rw-r--r--lib/core/c++/memory.hpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/core/c++/memory.hpp b/lib/core/c++/memory.hpp
index b6a089e..e97c7fc 100644
--- a/lib/core/c++/memory.hpp
+++ b/lib/core/c++/memory.hpp
@@ -21,11 +21,31 @@ struct memory_size_helper<sch::FixedArray<Sch,N...>> {
static constexpr uint64_t bytes = saw::ct_multiply<uint64_t,N...>::value * memory_size_helper<Sch>::bytes;
};
+template<typename Sch, uint64_t... N>
+struct memory_size_helper<sch::Tensor<Sch,N...>> {
+ static constexpr uint64_t bytes = saw::ct_multiply<uint64_t,N...>::value * memory_size_helper<Sch>::bytes;
+};
+
template<typename Sch, uint64_t Ghost, uint64_t... N>
struct memory_size_helper<sch::Chunk<Sch,Ghost,N...>> {
static constexpr uint64_t bytes = memory_size_helper<typename sch::Chunk<Sch,Ghost,N...>::InnerSchema>::bytes;
};
+template<typename... Members>
+struct memory_size_helper<sch::Struct<Members...>> {
+
+ template<uint64_t i>
+ static constexpr uint64_t apply_i() {
+ if constexpr ( i < sizeof...(Members) ){
+ using M_I = typename saw::parameter_pack_type<i,Members...>::type;
+ return apply_i<i+1u>() + memory_size_helper<typename M_I::ValueType>::bytes;
+ }
+ return 0u;
+ }
+
+ static constexpr uint64_t bytes = apply_i<0u>();
+};
+
template<typename... T>
class memory_estimate_helper final {
private: