MCPcopy Create free account
hub / github.com/TencentARC/BrushNet / update_mapping_from_spec

Function update_mapping_from_spec

src/diffusers/utils/testing_utils.py:927–937  ·  view source on GitHub ↗
(device_fn_dict: Dict[str, Callable], attribute_name: str)

Source from the content-addressed store, hash-verified

925if is_torch_available():
926 # Update device function dict mapping
927 def update_mapping_from_spec(device_fn_dict: Dict[str, Callable], attribute_name: str):
928 try:
929 # Try to import the function directly
930 spec_fn = getattr(device_spec_module, attribute_name)
931 device_fn_dict[torch_device] = spec_fn
932 except AttributeError as e:
933 # If the function doesn't exist, and there is no default, throw an error
934 if "default" not in device_fn_dict:
935 raise AttributeError(
936 f"`{attribute_name}` not found in '{device_spec_path}' and no default fallback function found."
937 ) from e
938
939 if "DIFFUSERS_TEST_DEVICE_SPEC" in os.environ:
940 device_spec_path = os.environ["DIFFUSERS_TEST_DEVICE_SPEC"]

Callers 1

testing_utils.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected