[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[UNIKRAFT/PYTORCH PATCH 5/5] Add patches



In this patch we add several patches for:
disabling some features such as backtracking,
remove calls to functions from cpuinfo, remove
calls for other missing symbols.

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxx>
---
 ...ds-to-suppress-redefinition-warnings.patch | 37 +++++++++++++++++
 .../0002-Comment-out-calls-to-enable_if.patch | 40 +++++++++++++++++++
 patches/0003-Comment-out-waitpid-call.patch   | 27 +++++++++++++
 ...variable-to-avoid-compilation-errors.patch | 28 +++++++++++++
 patches/0005-Disable-backtrace-support.patch  | 34 ++++++++++++++++
 patches/0006-Disable-demangle.patch           | 25 ++++++++++++
 .../0007-Comment-out-nexttoward-call.patch    | 26 ++++++++++++
 ...8-Remove-cpuinfo_get_processor-calls.patch | 34 ++++++++++++++++
 patches/0009-Comment-out-runJITCPPTests.patch | 29 ++++++++++++++
 ...emove-calls-to-cpuinfo_get_processor.patch | 25 ++++++++++++
 10 files changed, 305 insertions(+)
 create mode 100644 
patches/0001-Add-guards-to-suppress-redefinition-warnings.patch
 create mode 100644 patches/0002-Comment-out-calls-to-enable_if.patch
 create mode 100644 patches/0003-Comment-out-waitpid-call.patch
 create mode 100644 
patches/0004-Rename-variable-to-avoid-compilation-errors.patch
 create mode 100644 patches/0005-Disable-backtrace-support.patch
 create mode 100644 patches/0006-Disable-demangle.patch
 create mode 100644 patches/0007-Comment-out-nexttoward-call.patch
 create mode 100644 patches/0008-Remove-cpuinfo_get_processor-calls.patch
 create mode 100644 patches/0009-Comment-out-runJITCPPTests.patch
 create mode 100644 patches/0010-Remove-calls-to-cpuinfo_get_processor.patch

diff --git a/patches/0001-Add-guards-to-suppress-redefinition-warnings.patch 
b/patches/0001-Add-guards-to-suppress-redefinition-warnings.patch
new file mode 100644
index 0000000..b8fd7b1
--- /dev/null
+++ b/patches/0001-Add-guards-to-suppress-redefinition-warnings.patch
@@ -0,0 +1,37 @@
+From d4645e726ef513d1a22eb0d6be1d610cd2a01b62 Mon Sep 17 00:00:00 2001
+From: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxx>
+Date: Tue, 7 Apr 2020 22:07:49 +0000
+Subject: [PATCH 1/8] Add guards to suppress redefinition warnings
+
+Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxx>
+---
+ c10/macros/Export.h | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/c10/macros/Export.h b/c10/macros/Export.h
+index 0a213ed..7fce4f4 100644
+--- a/c10/macros/Export.h
++++ b/c10/macros/Export.h
+@@ -86,7 +86,9 @@
+ 
+ // This one is being used by libc10.so
+ #ifdef C10_BUILD_MAIN_LIB
++#ifndef C10_API
+ #define C10_API C10_EXPORT
++#endif
+ #else
+ #define C10_API C10_IMPORT
+ #endif
+@@ -94,7 +96,9 @@
+ // This one is being used by libtorch.so
+ // TODO: rename this to TORCH_API
+ #ifdef CAFFE2_BUILD_MAIN_LIB
++#ifndef CAFFE2_API
+ #define CAFFE2_API C10_EXPORT
++#endif
+ #else
+ #define CAFFE2_API C10_IMPORT
+ #endif
+-- 
+2.11.0
+
diff --git a/patches/0002-Comment-out-calls-to-enable_if.patch 
b/patches/0002-Comment-out-calls-to-enable_if.patch
new file mode 100644
index 0000000..0195485
--- /dev/null
+++ b/patches/0002-Comment-out-calls-to-enable_if.patch
@@ -0,0 +1,40 @@
+From f844c7363c909ffa3d1bc8c692ce24e38be6c988 Mon Sep 17 00:00:00 2001
+From: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxx>
+Date: Tue, 7 Apr 2020 22:22:37 +0000
+Subject: [PATCH 2/8] Comment out calls to enable_if
+
+Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxx>
+---
+ aten/src/ATen/native/cpu/MultinomialKernel.cpp | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/aten/src/ATen/native/cpu/MultinomialKernel.cpp 
b/aten/src/ATen/native/cpu/MultinomialKernel.cpp
+index c00c4c0..352cbc4 100644
+--- a/aten/src/ATen/native/cpu/MultinomialKernel.cpp
++++ b/aten/src/ATen/native/cpu/MultinomialKernel.cpp
+@@ -48,8 +48,8 @@ void multinomial_apply(Tensor& result, const Tensor& self, 
const int64_t n_sampl
+       TORCH_CHECK(std::isfinite(static_cast<double>(val)),
+                   "invalid multinomial distribution (encountering probability 
entry = infinity or NaN)");
+ #else
+-      TORCH_CHECK(std::isfinite(val),
+-                  "invalid multinomial distribution (encountering probability 
entry = infinity or NaN)");
++      //TORCH_CHECK(std::isfinite(val),
++      //            "invalid multinomial distribution (encountering 
probability entry = infinity or NaN)");
+ #endif
+ 
+       sum += val;
+@@ -130,9 +130,11 @@ void multinomial_apply(Tensor& result, const Tensor& 
self, const int64_t n_sampl
+ }
+ 
+ static void multinomial_kernel_impl(Tensor& result, const Tensor& self, const 
int64_t n_sample, const bool with_replacement, Generator *gen) {
++  /*
+   AT_DISPATCH_FLOATING_TYPES_AND_HALF(self.scalar_type(), "multinomial", [&] {
+     multinomial_apply<scalar_t>(result, self, n_sample, with_replacement, 
gen);
+   });
++  */
+ }
+ 
+ }
+-- 
+2.11.0
+
diff --git a/patches/0003-Comment-out-waitpid-call.patch 
b/patches/0003-Comment-out-waitpid-call.patch
new file mode 100644
index 0000000..1c09da7
--- /dev/null
+++ b/patches/0003-Comment-out-waitpid-call.patch
@@ -0,0 +1,27 @@
+From 972caf96f8ad327d281e7287c48c14e0e8fa2dc9 Mon Sep 17 00:00:00 2001
+From: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxx>
+Date: Tue, 7 Apr 2020 22:27:39 +0000
+Subject: [PATCH 3/8] Comment out waitpid call
+
+Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxx>
+---
+ torch/csrc/DataLoader.cpp | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/torch/csrc/DataLoader.cpp b/torch/csrc/DataLoader.cpp
+index 164a7ce..5f438ea 100644
+--- a/torch/csrc/DataLoader.cpp
++++ b/torch/csrc/DataLoader.cpp
+@@ -113,7 +113,8 @@ static PyObject *THPModule_errorIfAnyWorkerFails(PyObject 
*module, PyObject *noa
+       // Use waitid rather than waitpid so that we can set NOWAIT, and that 
Python
+       // and other handlers can get whatever info they want about the child.
+       infop.si_pid = 0;
+-      error = waitid(P_PID, worker_pid, &infop, WEXITED|WNOHANG|WNOWAIT);
++      // error = waitid(P_PID, worker_pid, &infop, WEXITED|WNOHANG|WNOWAIT);
++      error = 0;
+       // ignore errors and case with no waitable child
+       if (error < 0 || infop.si_pid == 0)
+         continue;
+-- 
+2.11.0
+
diff --git a/patches/0004-Rename-variable-to-avoid-compilation-errors.patch 
b/patches/0004-Rename-variable-to-avoid-compilation-errors.patch
new file mode 100644
index 0000000..89ce0bb
--- /dev/null
+++ b/patches/0004-Rename-variable-to-avoid-compilation-errors.patch
@@ -0,0 +1,28 @@
+From 22f0829c951dc358b7fa6b40c67dbed8c36cc6e1 Mon Sep 17 00:00:00 2001
+From: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxx>
+Date: Tue, 7 Apr 2020 22:34:46 +0000
+Subject: [PATCH 4/8] Rename variable to avoid compilation errors
+
+Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxx>
+---
+ torch/csrc/jit/script/python_tree_views.cpp | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/torch/csrc/jit/script/python_tree_views.cpp 
b/torch/csrc/jit/script/python_tree_views.cpp
+index b7726d6..4d89ea3 100644
+--- a/torch/csrc/jit/script/python_tree_views.cpp
++++ b/torch/csrc/jit/script/python_tree_views.cpp
+@@ -74,8 +74,8 @@ Maybe<T> wrap_maybe(const SourceRange& fallback_pos, T* val) 
{
+ }
+ 
+ void initTreeViewBindings(PyObject* module) {
+-  auto _C = py::handle(module).cast<py::module>();
+-  auto m = _C.def_submodule("_jit_tree_views");
++  auto C = py::handle(module).cast<py::module>();
++  auto m = C.def_submodule("_jit_tree_views");
+ 
+   py::class_<SourceRange>(m, "SourceRange")
+       .def(
+-- 
+2.11.0
+
diff --git a/patches/0005-Disable-backtrace-support.patch 
b/patches/0005-Disable-backtrace-support.patch
new file mode 100644
index 0000000..6551681
--- /dev/null
+++ b/patches/0005-Disable-backtrace-support.patch
@@ -0,0 +1,34 @@
+From 290fb52ee2cecba86f3585ef9e500dc168063934 Mon Sep 17 00:00:00 2001
+From: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxx>
+Date: Tue, 7 Apr 2020 22:37:49 +0000
+Subject: [PATCH 5/8] Disable backtrace support
+
+Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxx>
+---
+ c10/util/Backtrace.cpp | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/c10/util/Backtrace.cpp b/c10/util/Backtrace.cpp
+index 3abfc08..6e09abc 100644
+--- a/c10/util/Backtrace.cpp
++++ b/c10/util/Backtrace.cpp
+@@ -15,11 +15,13 @@
+ // No backtrace on mobile, windows and emscripten platforms.
+ #define SUPPORTS_BACKTRACE 0
+ #else
+-#define SUPPORTS_BACKTRACE 1
+-#include <cxxabi.h>
+-#include <execinfo.h>
++//#define SUPPORTS_BACKTRACE 1
++//#include <cxxabi.h>
++//#include <execinfo.h>
+ #endif
+ 
++#define SUPPORTS_BACKTRACE 0
++
+ namespace c10 {
+ 
+ // TODO: This backtrace retrieval can be implemented on Windows via the 
Windows
+-- 
+2.11.0
+
diff --git a/patches/0006-Disable-demangle.patch 
b/patches/0006-Disable-demangle.patch
new file mode 100644
index 0000000..2f4c59d
--- /dev/null
+++ b/patches/0006-Disable-demangle.patch
@@ -0,0 +1,25 @@
+From 0a32adf17fcd86ef28a51b3f68e4130f7db26ee2 Mon Sep 17 00:00:00 2001
+From: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxx>
+Date: Tue, 7 Apr 2020 22:39:52 +0000
+Subject: [PATCH 6/8] Disable demangle
+
+Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxx>
+---
+ c10/util/Type.cpp | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/c10/util/Type.cpp b/c10/util/Type.cpp
+index 3e00055..dc18ab2 100644
+--- a/c10/util/Type.cpp
++++ b/c10/util/Type.cpp
+@@ -13,6 +13,7 @@
+ #define HAS_DEMANGLE 1
+ #endif
+ 
++#define HAS_DEMANGLE 0
+ #if HAS_DEMANGLE
+ 
+ #include <cxxabi.h>
+-- 
+2.11.0
+
diff --git a/patches/0007-Comment-out-nexttoward-call.patch 
b/patches/0007-Comment-out-nexttoward-call.patch
new file mode 100644
index 0000000..369ce10
--- /dev/null
+++ b/patches/0007-Comment-out-nexttoward-call.patch
@@ -0,0 +1,26 @@
+From 511ccc836b30d8eb303b151c3b47e79d0c4c4097 Mon Sep 17 00:00:00 2001
+From: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxx>
+Date: Tue, 7 Apr 2020 22:49:24 +0000
+Subject: [PATCH 7/8] Comment out nexttoward call
+
+Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxx>
+---
+ aten/src/ATen/native/Distributions.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/aten/src/ATen/native/Distributions.cpp 
b/aten/src/ATen/native/Distributions.cpp
+index 644888a..0accb3b 100644
+--- a/aten/src/ATen/native/Distributions.cpp
++++ b/aten/src/ATen/native/Distributions.cpp
+@@ -289,7 +289,7 @@ Tensor _s_dirichlet_cpu(const Tensor& alpha, Generator 
*gen) {
+       [](scalar_t& ret_val, const double& gamma, const double& gamma_sum){
+         ret_val = gamma / gamma_sum;
+         auto min_val = std::numeric_limits<scalar_t>::min();
+-        auto max_val = std::nexttoward(static_cast<scalar_t>(1.0f), 0.0f);
++        auto max_val = 
static_cast<scalar_t>(1.0f);//std::nexttoward(static_cast<scalar_t>(1.0f), 
0.0f);
+         ret_val = std::min(max_val, std::max(min_val, ret_val));
+         ret_val = static_cast<scalar_t>(ret_val);
+       }
+-- 
+2.11.0
+
diff --git a/patches/0008-Remove-cpuinfo_get_processor-calls.patch 
b/patches/0008-Remove-cpuinfo_get_processor-calls.patch
new file mode 100644
index 0000000..ffdf274
--- /dev/null
+++ b/patches/0008-Remove-cpuinfo_get_processor-calls.patch
@@ -0,0 +1,34 @@
+From ffa7d398d11a2f8a93b69feb9dc1d147801da943 Mon Sep 17 00:00:00 2001
+From: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxx>
+Date: Tue, 7 Apr 2020 22:54:06 +0000
+Subject: [PATCH 8/8] Remove cpuinfo_get_processor calls
+
+Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxx>
+---
+ caffe2/utils/bench_utils.cc | 10 +---------
+ 1 file changed, 1 insertion(+), 9 deletions(-)
+
+diff --git a/caffe2/utils/bench_utils.cc b/caffe2/utils/bench_utils.cc
+index df77512..93384cc 100644
+--- a/caffe2/utils/bench_utils.cc
++++ b/caffe2/utils/bench_utils.cc
+@@ -14,15 +14,7 @@ uint32_t wipe_cache() {
+   if (wipe_buffer == nullptr) {
+     CAFFE_ENFORCE(cpuinfo_initialize(), "failed to initialize cpuinfo");
+     const cpuinfo_processor* processor = cpuinfo_get_processor(0);
+-    if (processor->cache.l4 != nullptr) {
+-      wipe_size = processor->cache.l4->size;
+-    } else if (processor->cache.l3 != nullptr) {
+-      wipe_size = processor->cache.l3->size;
+-    } else if (processor->cache.l2 != nullptr) {
+-      wipe_size = processor->cache.l2->size;
+-    } else {
+-      wipe_size = processor->cache.l1d->size;
+-    }
++    wipe_size = 64 * 1024;
+ #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64
+     /*
+      * On ARM precise cache size is not available, and cpuinfo may
+-- 
+2.11.0
+
diff --git a/patches/0009-Comment-out-runJITCPPTests.patch 
b/patches/0009-Comment-out-runJITCPPTests.patch
new file mode 100644
index 0000000..cc49951
--- /dev/null
+++ b/patches/0009-Comment-out-runJITCPPTests.patch
@@ -0,0 +1,29 @@
+From 2f2f760fac6b14f7ce63ee1858262b4c3bbae4a7 Mon Sep 17 00:00:00 2001
+From: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxx>
+Date: Tue, 7 Apr 2020 23:52:29 +0000
+Subject: [PATCH 1/1] Comment out runJITCPPTests
+
+We comment out runJITCPPTests calls because we
+are not running the unit tests.
+
+Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxx>
+---
+ torch/csrc/jit/init.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/torch/csrc/jit/init.cpp b/torch/csrc/jit/init.cpp
+index 9745464..cf99b95 100644
+--- a/torch/csrc/jit/init.cpp
++++ b/torch/csrc/jit/init.cpp
+@@ -286,7 +286,7 @@ void initJITBindings(PyObject* module) {
+             // newly spawned worker threads will try to initialize their
+             // PyThreadState*, and they need the GIL for this.
+             AutoNoGIL _no_gil;
+-            return runJITCPPTests(runCuda);
++            //return runJITCPPTests(runCuda);
+           },
+           py::arg("run_cuda"))
+       .def(
+-- 
+2.11.0
+
diff --git a/patches/0010-Remove-calls-to-cpuinfo_get_processor.patch 
b/patches/0010-Remove-calls-to-cpuinfo_get_processor.patch
new file mode 100644
index 0000000..b9582b9
--- /dev/null
+++ b/patches/0010-Remove-calls-to-cpuinfo_get_processor.patch
@@ -0,0 +1,25 @@
+iFrom d8d7f7b02d983bb3e00728648dceb462f0f2155f Mon Sep 17 00:00:00 2001
+From: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxx>
+Date: Tue, 7 Apr 2020 23:57:21 +0000
+Subject: [PATCH 1/1] Remove calls to cpuinfo_get_processor
+
+Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxx>
+---
+ caffe2/utils/bench_utils.cc | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/caffe2/utils/bench_utils.cc b/caffe2/utils/bench_utils.cc
+index 93384cc..facf095 100644
+--- a/caffe2/utils/bench_utils.cc
++++ b/caffe2/utils/bench_utils.cc
+@@ -13,7 +13,7 @@ uint32_t wipe_cache() {
+ 
+   if (wipe_buffer == nullptr) {
+     CAFFE_ENFORCE(cpuinfo_initialize(), "failed to initialize cpuinfo");
+-    const cpuinfo_processor* processor = cpuinfo_get_processor(0);
++    const cpuinfo_processor* processor;// = cpuinfo_get_processor(0);
+     wipe_size = 64 * 1024;
+ #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64
+     /*
+-- 
+2.11.0
-- 
2.20.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.