@@ -696,37 +696,27 @@ namespace madness {
696696namespace archive {
697697
698698template <class Archive , typename T>
699- struct ArchiveSerializeImpl <Archive, TiledArray::UMTensor<T>> {
700- // / \tparam Archive A MADNESS archive type
701- // / \param[out] ar An input/output archive
702- // / \param[in,out] t The UMTensor to serialize/deserialize
703- static inline void serialize (const Archive &ar, TiledArray::UMTensor<T> &t) {
704- bool empty = t.empty ();
705- auto range = t.range ();
706-
707- ar & empty;
708- if (!empty) {
709- ar & range;
710-
711- if constexpr (madness::is_input_archive_v<Archive>) { // input
712- t = TiledArray::UMTensor<T>(std::move (range));
713- auto stream = TiledArray::device::stream_for (t.range ());
714- TiledArray::to_execution_space<TiledArray::ExecutionSpace::Host>(
715- t, stream);
716- TiledArray::device::sync_madness_task_with (stream);
717- } else { // output
718- auto stream = TiledArray::device::stream_for (t.range ());
719- TiledArray::to_execution_space<TiledArray::ExecutionSpace::Host>(
720- t, stream);
721- TiledArray::device::sync_madness_task_with (stream);
722- }
699+ struct ArchiveLoadImpl <Archive, TiledArray::UMTensor<T>> {
700+ static inline void load (const Archive &ar, TiledArray::UMTensor<T> &t) {
701+ TiledArray::Range range{};
702+ ar & range;
723703
704+ if (range.volume () > 0 ) {
705+ t = TiledArray::UMTensor<T>(std::move (range));
724706 ar &madness::archive::wrap (t.data (), t.size ());
725-
726707 } else {
727- if constexpr (madness::is_input_archive_v<Archive>) {
728- t = TiledArray::UMTensor<T>{};
729- }
708+ t = TiledArray::UMTensor<T>{};
709+ }
710+ }
711+ };
712+
713+ template <class Archive , typename T>
714+ struct ArchiveStoreImpl <Archive, TiledArray::UMTensor<T>> {
715+ static inline void store (const Archive &ar,
716+ const TiledArray::UMTensor<T> &t) {
717+ ar & t.range ();
718+ if (t.range ().volume () > 0 ) {
719+ ar &madness::archive::wrap (t.data (), t.size ());
730720 }
731721 }
732722};
0 commit comments