Trying to serialize tensors or modules to something else than files using OutputArchive.save_to(WriteFunction)
causes a segmentation fault.
import org.bytedeco.javacpp.annotation.*;
import org.bytedeco.pytorch.presets.torch.*;
import org.bytedeco.pytorch.*;
import org.bytedeco.javacpp.*;
class T {
static WriteFunction wf = new WriteFunction() {
@Override
@Virtual
public long call(Pointer buf, long nbytes) {
System.err.println("writing "+nbytes);
return nbytes;
}
};
public static void main(String[] a) {
OutputArchive oa = new OutputArchive();
Tensor t = AbstractTensor.create(1F, 2F);
oa.write("test", t);
oa.save_to(wf);
}
}
The equivalent following C++ code does work:
#include <torch/torch.h>
#include <iostream>
size_t wf(const void *p, size_t l) {
std::cerr << "writing " << l << std::endl;
return l;
}
int main() {
torch::Tensor t = torch::rand({2, 3});
torch::serialize::OutputArchive oa;
oa.write("test", t);
oa.save_to(wf);
}
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4