mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 12:21:27 +01:00
Summary: This changes our compiler so it first emits Loads & Stores, and then transforms the graph to SSA in a follow up pass. When a variable is set, we emit a prim::Store, and when a variable is referenced, we emit a prim::Load. ``` a = 1 print(a) ``` becomes: ``` %a.1 : int = prim::Constant[value=1]() prim::Store[name="a"](%a.1) %a : int = prim::Load[name="a"]() prim::Print(%a) ``` In the follow up pass, convertToSSA, the values are turned into SSA form with the Loads & Stores removed. This change will enable breaks and continues because you can transform the graph with the variable naming information still intact. There are still some remaining jitter and edge cases issues that I have to look through, but I think is still ready for eview. Pull Request resolved: https://github.com/pytorch/pytorch/pull/21101 Differential Revision: D15723353 Pulled By: eellison fbshipit-source-id: 3269934d4bc24ddaf3a87fdd20620b0f954d83d0
27 lines
656 B
C++
27 lines
656 B
C++
#pragma once
|
|
#include <functional>
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
#include <torch/csrc/jit/ir.h>
|
|
#include <torch/csrc/jit/script/error_report.h>
|
|
#include <torch/csrc/jit/script/module.h>
|
|
#include <torch/csrc/jit/script/resolver.h>
|
|
#include <torch/csrc/jit/script/sugared_value.h>
|
|
#include <torch/csrc/jit/script/tree_views.h>
|
|
|
|
namespace torch {
|
|
namespace jit {
|
|
namespace script {
|
|
|
|
TORCH_API void runCleanupPasses(
|
|
std::shared_ptr<Graph>& to_clean,
|
|
bool convert_ssa = true);
|
|
|
|
TORCH_API bool meaningfulName(const std::string& name);
|
|
TORCH_API void lambdaLiftFork(Node* fork_node);
|
|
|
|
} // namespace script
|
|
} // namespace jit
|
|
} // namespace torch
|