pytaco.read
- pytaco.read(filename, 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.
- Parameters
- 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.
- Returns
Examples
>>> 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 = pt.read("simple_test.tns", pt.csr) >>> t[0, 0] 10.0