Skip to content

Failed assertion for serializing sparse tensors #225

@keceli

Description

@keceli

I got an assertion failure and core dump when I was testing serialization with LibChemist. It turns out that the problem is due to an assert at this line.

Here is a minimal example that demonstrates this problem. Note that, the code runs if we comment out this line: St("i,j") = S("j,i");.

#include <tiledarray.h>
#include <madness/world/text_fstream_archive.h>

int main(int argc, char *argv[]) {
  using namespace std;

  TA::World &world = TA::initialize(argc, argv);
  using namespace TA;
  TiledRange1 TR0{0, 3, 8, 10};
  TiledRange1 TR1{0, 4, 7, 10};
  TiledRange TR{TR0, TR1};
  Tensor<float> shape_tensor(TR.tiles_range(), 0.0);
  shape_tensor(0, 0) = 1.0;
  shape_tensor(0, 1) = 1.0;
  shape_tensor(1, 1) = 1.0;
  shape_tensor(2, 2) = 1.0;
  SparseShape<float> shape(shape_tensor, TR);
  TSpArrayD S(world, TR, shape);
  TSpArrayD St;
  S.fill(1.0);
  
  const char *file = "archive.dat";
  madness::archive::TextFstreamOutputArchive archive( file );
  St("i,j") = S("j,i");
  archive & S;
  return 0;
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions