, fmt, pack=True)

Reads a tensor from a file.

Reads a tensor from the file filename. The extension must be one of the those supported by PyTaco listed in the Tensor I/O section.

filename: string

The name of the file containing the tensor to read.

fmt: pytaco.format

The format that PyTaco should use to store the tensor.

pack: boolean, optional

If true, by taco will immediately pack the tensor in the specified format after reading the file. Otherwise, it will keep the data in a buffer until either the user explicitly calls pack() or the tensor is implicitly packed by taco.


A tensor of type double, with format fmt containing the data read from the file filename.


>>> import pytaco as pt
>>> a = pt.tensor([2, 2], [pt.dense, pt.compressed], dtype=pt.float32)
>>> a.insert([0, 0], 10)
>>> pt.write("simple_test.tns", a)
>>> t ="simple_test.tns", pt.csr)
>>> t[0, 0]