[binaries] fix dump_operator_name binary (#71246)

Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/71246

Test Plan: Imported from OSS

Reviewed By: malfet

Differential Revision: D33555962

Pulled By: IvanKobzarev

fbshipit-source-id: 2b386e52fa8e76c877fec5b6b15d99f7d280801f
(cherry picked from commit f6d60fdff68964f77aa46ca2c51327cb66566194)
This commit is contained in:
Ivan Kobzarev
2022-01-20 09:22:21 -08:00
committed by PyTorch MergeBot
parent 89c844db9b
commit 4868907cf3

View File

@ -29,7 +29,8 @@ void dump_opnames(const Module& m, std::unordered_set<std::string>& opnames) {
for (const auto& method : methods) { for (const auto& method : methods) {
const auto& func = method.function(); const auto& func = method.function();
std::cout << "function name: " << func.name() << std::endl; std::cout << "function name: " << func.name() << std::endl;
torch::jit::Code code(func.graph(), ""); auto graph = toGraphFunction(func).graph()->copy();
torch::jit::Code code(graph, "");
for (size_t i = 0; i < code.instructions().size(); ++i) { for (size_t i = 0; i < code.instructions().size(); ++i) {
auto ins = code.instructions()[i]; auto ins = code.instructions()[i];
auto node = code.instructions_source()[i]; auto node = code.instructions_source()[i];