(gm)
| 132 | |
| 133 | |
| 134 | def _get_updated_range_constraints(gm): |
| 135 | def get_shape_env(gm): |
| 136 | vals = [ |
| 137 | node.meta["val"] |
| 138 | for node in gm.graph.nodes |
| 139 | if node.meta.get("val", None) is not None |
| 140 | ] |
| 141 | from torch._guards import detect_fake_mode # type: ignore[21] |
| 142 | |
| 143 | fake_mode = detect_fake_mode(vals) |
| 144 | if fake_mode is not None: |
| 145 | return fake_mode.shape_env |
| 146 | for v in vals: |
| 147 | if isinstance(v, torch.SymInt): |
| 148 | return v.node.shape_env |
| 149 | |
| 150 | shape_env = get_shape_env(gm) |
| 151 | if shape_env is None: |
| 152 | return {} |
| 153 | range_constraints = { |
| 154 | shape_env.replacements.get(k, k): v for k, v in shape_env.var_to_range.items() |
| 155 | } |
| 156 | # Only when we have an unbacked symint, and it's used as constructor inputs, |
| 157 | # runtime_var_to_range will make a difference compated to var_to_range. |
| 158 | # e.g. [2, oo) -> [0, oo) |
| 159 | for k, v in shape_env.var_to_range.items(): |
| 160 | if k not in shape_env.replacements: |
| 161 | range_constraints[k] = v |
| 162 | return range_constraints |
| 163 | |
| 164 | |
| 165 | def _get_updated_graph_signature( |
no test coverage detected