From: Bram Wasti Date: Wed, 17 Apr 2019 21:17:01 +0000 (-0700) Subject: Only require python print on certain namespaces (#18846) X-Git-Tag: accepted/tizen/6.5/unified/20211028.231830~194 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3e0b46b6d132c22af84769a6df1ef8d1f785dbe2;p=platform%2Fupstream%2Fpytorch.git Only require python print on certain namespaces (#18846) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/18846 ghimport-source-id: b211e15d24c88fdc32d79222d9fce2fa9c291541 Differential Revision: D14901485 Pulled By: bwasti fbshipit-source-id: 4b02a66d325ba5391d1f838055aea13b5e4f6485 --- diff --git a/torch/csrc/jit/passes/python_print.cpp b/torch/csrc/jit/passes/python_print.cpp index f7bfd99..40dc2d3 100644 --- a/torch/csrc/jit/passes/python_print.cpp +++ b/torch/csrc/jit/passes/python_print.cpp @@ -1263,7 +1263,16 @@ TORCH_API bool printerHasSpecialCaseFor(Symbol sym) { }; - return handled.count(sym) || unneeded.count(sym); + // These namespaces are required to have Python printers unless + // otherwise noted in unneeded. + const static std::unordered_set required_namespaces = { + c10::namespaces::prim, + c10::namespaces::aten, + c10::namespaces::onnx, + }; + + return handled.count(sym) || unneeded.count(sym) || + !required_namespaces.count(sym.ns()); } } // namespace jit