Revert D13498974: [pytorch][PR] [jit] Add self to Python printer reserved words
authorEdward Yang <ezyang@fb.com>
Thu, 20 Dec 2018 18:00:09 +0000 (10:00 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 20 Dec 2018 18:02:37 +0000 (10:02 -0800)
Differential Revision:
D13498974

Original commit changeset: 488efb661476

fbshipit-source-id: 3b991bccf4cf2ffdafe70f145aff0ae2837e31f8

test/onnx/expect/TestOperators.test_norm.expect
torch/csrc/jit/passes/python_print.cpp
torch/jit/__init__.py

index 56e57e3..ec9a7e6 100644 (file)
@@ -3,7 +3,7 @@ producer_name: "pytorch"
 producer_version: "0.4"
 graph {
   node {
-    input: "0"
+    input: "self"
     output: "1"
     op_type: "ReduceL2"
     attribute {
@@ -19,7 +19,7 @@ graph {
   }
   name: "torch-jit-export"
   input {
-    name: "0"
+    name: "self"
     type {
       tensor_type {
         elem_type: 1
index cdb8752..27e7594 100644 (file)
@@ -142,22 +142,22 @@ void createTensorToParameterNameMap(
   // they are keywords or namespaces used in the output
   const static std::unordered_set<std::string> reserved_names = {
     // identifiers in the environment while parsing
-    "_", // avoid the confusing unnamed _
     "aten",
-    "attribute",
+    "ops",
     "CONSTANTS",
     "fork",
+    "attribute",
     "getattr",
+    "_", // avoid the confusing unnamed _
     "inf",
     "nan",
-    "ops",
-    "self",
     // the python keywords
+    "False",
+    "None",
+    "True",
     "and",
     "as",
     "assert",
-    "async",
-    "await",
     "break",
     "class",
     "continue",
@@ -166,7 +166,6 @@ void createTensorToParameterNameMap(
     "elif",
     "else",
     "except",
-    "False",
     "finally",
     "for",
     "from",
@@ -176,14 +175,12 @@ void createTensorToParameterNameMap(
     "in",
     "is",
     "lambda",
-    "None",
     "nonlocal",
     "not",
     "or",
     "pass",
     "raise",
     "return",
-    "True",
     "try",
     "while",
     "with",
index a59c980..fe90ab1 100644 (file)
@@ -223,10 +223,10 @@ def _create_interpreter_name_lookup_fn(frames_up=1):
 
         for k, v in f_locals.items():
             if isinstance(v, torch.Tensor) and var is v:
-                return k if k != 'self' else ''
+                return k
         for k, v in f_globals.items():
             if isinstance(v, torch.Tensor) and var is v:
-                return k if k != 'self' else ''
+                return k
         return ''
     return _get_interpreter_name_for_var