Return True if input is a large scalar value. Large scalars are skipped because ``torch.histc`` supports values only up to a certain upper bound.
(node: Node, gm: torch.fx.GraphModule)
| 275 | |
| 276 | |
| 277 | def _is_large_scalar(node: Node, gm: torch.fx.GraphModule): |
| 278 | """Return True if input is a large scalar value. |
| 279 | |
| 280 | Large scalars are skipped because ``torch.histc`` supports values only up |
| 281 | to a certain upper bound. |
| 282 | |
| 283 | """ |
| 284 | HISTC_UPPER_BOUND = 3.4028235e15 |
| 285 | if node.op == "get_attr" and isinstance(node.target, str): |
| 286 | tensor = _get_node_target(gm, node.target) |
| 287 | # torch.histc works until this upper bound |
| 288 | return tensor.numel() == 1 and abs(tensor.item()) > HISTC_UPPER_BOUND |
| 289 | if node.op == "call_function" and node.target in ( |
| 290 | torch.ops.aten.full.default, |
| 291 | torch.ops.aten.full, |
| 292 | torch.ops.aten.fill_.Scalar, |
| 293 | ): |
| 294 | fill_value = cast(float, node.args[1]) |
| 295 | return abs(fill_value) > HISTC_UPPER_BOUND |
| 296 | return False |
| 297 | |
| 298 | |
| 299 | def _is_non_float_tensor(node: Node) -> bool: |
no test coverage detected