(obj, target_type)
| 1433 | |
| 1434 | |
| 1435 | def _isinstance(obj, target_type) -> bool: |
| 1436 | if isinstance(target_type, collections.abc.Container): |
| 1437 | if not isinstance(target_type, tuple): |
| 1438 | raise RuntimeError( |
| 1439 | "The second argument to " |
| 1440 | "`torch.jit.isinstance` must be a type " |
| 1441 | "or a tuple of types" |
| 1442 | ) |
| 1443 | for t_type in target_type: |
| 1444 | if _isinstance(obj, t_type): |
| 1445 | return True |
| 1446 | return False |
| 1447 | |
| 1448 | origin_type = get_origin(target_type) |
| 1449 | if origin_type: |
| 1450 | return container_checker(obj, target_type) |
| 1451 | |
| 1452 | # Check to handle non-typed optional origin returns as none instead |
| 1453 | # of as optional in 3.7-3.8 |
| 1454 | check_args_exist(target_type) |
| 1455 | |
| 1456 | # handle non-containers |
| 1457 | return isinstance(obj, target_type) |
| 1458 | |
| 1459 | |
| 1460 | class _TensorExtractor(pickle.Pickler): |
no test coverage detected
searching dependent graphs…