From 1bc4eb93c7b4aa055deeb46f495f89713aab3e3f Mon Sep 17 00:00:00 2001 From: David Riazati Date: Tue, 19 Mar 2019 13:51:25 -0700 Subject: [PATCH] Support attributes when emitting function calls (#18156) 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 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/torch/csrc/jit/script/module.cpp b/torch/csrc/jit/script/module.cpp index 91de02e..94b1068 100644 --- a/torch/csrc/jit/script/module.cpp +++ b/torch/csrc/jit/script/module.cpp @@ -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); -- 2.7.4