From f13da939f82e0af5b7f0644079e1685319c66e64 Mon Sep 17 00:00:00 2001
From: Stephan Seitz <stephan.seitz@fau.de>
Date: Fri, 9 Aug 2019 15:54:39 +0200
Subject: [PATCH] Attach code to operation generated by torch_native

---
 docs/conf.py                                      | 2 +-
 src/pystencils_autodiff/backends/_torch_native.py | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/docs/conf.py b/docs/conf.py
index 5bc0c3b..5a2a0cf 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -141,7 +141,7 @@ pygments_style = 'sphinx'
 # The theme to use for HTML and HTML Help pages.  See the documentation for
 # a list of builtin themes.
 html_theme = 'alabaster'
-# html_theme = 'sphinx_rtd_theme'  # official readthedocs theme used also by Martin
+# html_theme = 'sphinx_rtd_theme' #official readthedocs theme used also by Martin
 
 # Theme options are theme-specific and customize the look and feel of a theme
 # further.  For a list of options available for each theme, see the
diff --git a/src/pystencils_autodiff/backends/_torch_native.py b/src/pystencils_autodiff/backends/_torch_native.py
index 1fab51c..1276e73 100644
--- a/src/pystencils_autodiff/backends/_torch_native.py
+++ b/src/pystencils_autodiff/backends/_torch_native.py
@@ -122,6 +122,7 @@ def generate_torch(destination_folder,
     from torch.utils.cpp_extension import load
     compiled_operation = load(operation_string, required_files, verbose=True,
                               extra_cuda_cflags=[] if is_cuda else [])
+    compiled_operation.code = output
     return compiled_operation
 
 
@@ -163,6 +164,7 @@ def create_autograd_function(autodiff_obj, inputfield_to_tensor_dict, forward_lo
         cls.saved = None
         cls.forward = forward
         cls.backward = backward
+        cls.code = compiled_operation.code
         return cls()
     else:
         op = pystencils_autodiff.backends._pytorch.create_autograd_function(autodiff_obj,
-- 
GitLab