-
Notifications
You must be signed in to change notification settings - Fork 34
/
pytorch-v2.5.0-fix-mobile-build.patch
51 lines (46 loc) · 2.21 KB
/
pytorch-v2.5.0-fix-mobile-build.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
diff -Nuarp pytorch-v2.5.0.orig/torch/csrc/jit/serialization/pickle.cpp pytorch-v2.5.0/torch/csrc/jit/serialization/pickle.cpp
--- pytorch-v2.5.0.orig/torch/csrc/jit/serialization/pickle.cpp 2024-10-18 00:29:49.000000000 +0800
+++ pytorch-v2.5.0/torch/csrc/jit/serialization/pickle.cpp 2024-10-18 15:33:48.593233652 +0800
@@ -66,7 +66,7 @@ std::vector<char> pickle(
// This has to live here instead of the C++ API to mirror torch.save since the
// mobile build excludes the C++ API
std::vector<char> pickle_save(const at::IValue& ivalue) {
-#ifndef C10_MOBILE
+#if 0//ndef C10_MOBILE
// Pickle the IValue into an array of bytes
std::vector<char> pickle_data;
Pickler pickler([&](const char* buf, size_t size) {
@@ -102,7 +102,7 @@ std::vector<char> pickle_save(const at::
#endif
}
-#ifndef C10_MOBILE
+#if 0//ndef C10_MOBILE
size_t VectorReader::read(uint64_t pos, void* buf, size_t n, const char* what)
const {
std::copy(
@@ -123,7 +123,7 @@ size_t StringViewReader::read(
IValue pickle_load(const std::vector<char>& data) {
// Read in the pickle data
-#ifndef C10_MOBILE
+#if 0//ndef C10_MOBILE
caffe2::serialize::PyTorchStreamReader reader(
std::make_unique<VectorReader>(data));
@@ -144,7 +144,7 @@ IValue pickle_load(const std::vector<cha
// A specialized version of pickle_load that can load custom objects.
c10::IValue pickle_load_obj(std::string_view data) {
-#ifndef C10_MOBILE
+#if 0//ndef C10_MOBILE
caffe2::serialize::PyTorchStreamReader reader(
std::make_unique<torch::jit::StringViewReader>(data));
return torch::jit::readArchiveAndTensors(
diff -Nuarp pytorch-v2.5.0.orig/torch/csrc/jit/serialization/pickle.h pytorch-v2.5.0/torch/csrc/jit/serialization/pickle.h
--- pytorch-v2.5.0.orig/torch/csrc/jit/serialization/pickle.h 2024-10-18 00:29:49.000000000 +0800
+++ pytorch-v2.5.0/torch/csrc/jit/serialization/pickle.h 2024-10-18 15:34:01.544234269 +0800
@@ -106,7 +106,7 @@ TORCH_API IValue unpickle(
c10::TypePtr (*type_parser)(const std::string&) =
Unpickler::defaultTypeParser);
-#ifndef C10_MOBILE
+#if 0//ndef C10_MOBILE
class VectorReader : public caffe2::serialize::ReadAdapterInterface {
public:
VectorReader(std::vector<char> data) : data_(std::move(data)) {}