(device_fn_dict: dict[str, Callable], attribute_name: str)
| 1385 | if is_torch_available(): |
| 1386 | # Update device function dict mapping |
| 1387 | def update_mapping_from_spec(device_fn_dict: dict[str, Callable], attribute_name: str): |
| 1388 | try: |
| 1389 | # Try to import the function directly |
| 1390 | spec_fn = getattr(device_spec_module, attribute_name) |
| 1391 | device_fn_dict[torch_device] = spec_fn |
| 1392 | except AttributeError as e: |
| 1393 | # If the function doesn't exist, and there is no default, throw an error |
| 1394 | if "default" not in device_fn_dict: |
| 1395 | raise AttributeError( |
| 1396 | f"`{attribute_name}` not found in '{device_spec_path}' and no default fallback function found." |
| 1397 | ) from e |
| 1398 | |
| 1399 | if "DIFFUSERS_TEST_DEVICE_SPEC" in os.environ: |
| 1400 | device_spec_path = os.environ["DIFFUSERS_TEST_DEVICE_SPEC"] |
no outgoing calls
no test coverage detected
searching dependent graphs…