File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -185,7 +185,14 @@ class Tensor {
185185 : range_(range), nbatch_(nbatch) {
186186 size_t size = range_.volume () * nbatch;
187187 allocator_type allocator;
188+ #if EIGEN_HAS_MAJOR_VERSION_5
189+ // Eigen 3.5.x returns nullptr if size=0
190+ auto * ptr = (!size && range_.rank ())
191+ ? static_cast <allocator_type::pointer>(std::malloc (size))
192+ : allocator.allocate (size);
193+ #else
188194 auto * ptr = allocator.allocate (size);
195+ #endif
189196 // default construct elements of data only if can have any effect ...
190197 if constexpr (!std::is_trivially_default_constructible_v<T>) {
191198 // .. and requested
@@ -1186,10 +1193,10 @@ class Tensor {
11861193 bool empty = this ->empty ();
11871194 auto range = this ->range_ ;
11881195 auto nbatch = this ->nbatch_ ;
1189- ar & empty;
1196+ ar& empty;
11901197 if (!empty) {
1191- ar & range;
1192- ar & nbatch;
1198+ ar& range;
1199+ ar& nbatch;
11931200 if constexpr (madness::is_input_archive_v<Archive>) {
11941201 *this = Tensor (std::move (range), nbatch, default_construct{true });
11951202 }
You can’t perform that action at this time.
0 commit comments