Support attributes when emitting function calls (#18156)
authorDavid Riazati <davidriazati@fb.com>
Tue, 19 Mar 2019 20:51:25 +0000 (13:51 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 19 Mar 2019 20:56:40 +0000 (13:56 -0700)
Summary:
The type of each `initial_ivalue` is completely known at some point but that information is discarded by the time a call to it is emitted. This PR is kind of a hack, as a better (longer) solution, the method should know about the type of each initial value.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18156

Differential Revision: D14525768

Pulled By: driazati

fbshipit-source-id: 52d53e9711a07a4551c988bd95fe997e654aa465

torch/csrc/jit/script/module.cpp

index 91de02e..94b1068 100644 (file)
@@ -55,7 +55,10 @@ Value* try_emit_call_to(
           << " attempting to call a method with parameters/attributes"
              " from a raw graph. File a bug report";
     }
-    matched_schema->inputs.push_back(caller->get_or_add_parameter(member));
+    // TODO: preserve the type information so we don't have to infer it here
+    auto type = incompleteInferTypeFrom(*member);
+    matched_schema->inputs.push_back(
+        caller->get_or_add_attribute(type, member));
   }
   callee.check_single_output();
   return inlineCallTo(graph, *callee.graph(), matched_schema->inputs).at(0);