mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-23 14:59:34 +08:00
Expose _export_data from C++ to Python (#79207)
Summary: https://www.internalfb.com/code/fbsource/[477a5768452957f87e56044169de47f051197567]/fbcode/caffe2/torch/csrc/jit/mobile/train/export_data.cpp export_data is used to serialize data. I binded this method to Python with PyBind11 Test Plan: Wrote a file pybind_check.py which checks if the binding works. Then, tried to read the produced data file from C++ with "torch::jit::_load_parameters" and checked that content matched. Differential Revision: D37029253 Pull Request resolved: https://github.com/pytorch/pytorch/pull/79207 Approved by: https://github.com/qihqi
This commit is contained in:
committed by
PyTorch MergeBot
parent
338bfe6315
commit
c0a7c1d02e
@ -59,6 +59,7 @@
|
||||
#include <pybind11/pybind11.h>
|
||||
#include <pybind11/stl.h>
|
||||
#include <pybind11/stl_bind.h>
|
||||
#include <torch/csrc/jit/mobile/train/export_data.h>
|
||||
#include <chrono>
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
@ -2294,6 +2295,14 @@ void initJitScriptBindings(PyObject* module) {
|
||||
}
|
||||
});
|
||||
|
||||
m.def(
|
||||
"_save_parameters",
|
||||
[](const std::map<std::string, at::Tensor>& map,
|
||||
const std::string& filename,
|
||||
bool use_flatbuffer = false) {
|
||||
_save_parameters(map, filename, use_flatbuffer);
|
||||
});
|
||||
|
||||
initScriptDictBindings(module);
|
||||
initScriptListBindings(module);
|
||||
}
|
||||
|
Reference in New Issue
Block a user