1#pragma once
2
3#include <torch/csrc/jit/ir/ir.h>
4
5namespace torch {
6namespace jit {
7
8// Considering prim::RaiseException nodes unreachable, simplify prim::If nodes
9// when one of the branches contains prim::RaiseException.
10//
11// This pass is illegal in general case as the modified graph might not throw
12// an exception that the original graph would throw. The purpose of the pass is
13// to cleanup the graph in a "risky" way by removing pathways leading to
14// RaiseExceptions nodes. In some sense, this pass could be considered as a
15// "Release" mode, while the original graph was in a "Debug" mode.
16// The pass should only be used when such transformation is guaranteed to be
17// safe by some other mechanisms. For instance, when we know exact shapes of
18// tensors flowing throuth the graph and tensors with such shapes never cause
19// exceptions.
20TORCH_API void EliminateExceptions(std::shared_ptr<Graph>& graph);
21
22} // namespace jit
23} // namespace torch
24