MCPcopy
hub / github.com/huggingface/transformers / device

Method device

src/transformers/models/bark/modeling_bark.py:1283–1298  ·  view source on GitHub ↗

`torch.device`: The device on which the module is (assuming that all the module parameters are on the same device).

(self)

Source from the content-addressed store, hash-verified

1281
1282 @property
1283 def device(self) -> torch.device:
1284 """
1285 `torch.device`: The device on which the module is (assuming that all the module parameters are on the same
1286 device).
1287 """
1288 # for bark_model, device must be verified on its sub-models
1289 # if has _hf_hook, has been offloaded so the device has to be found in the hook
1290 if not hasattr(self.semantic, "_hf_hook"):
1291 return super().device
1292 for module in self.semantic.modules():
1293 if (
1294 hasattr(module, "_hf_hook")
1295 and hasattr(module._hf_hook, "execution_device")
1296 and module._hf_hook.execution_device is not None
1297 ):
1298 return torch.device(module._hf_hook.execution_device)
1299
1300 def enable_cpu_offload(
1301 self,

Callers 15

__init__Method · 0.45
__init__Method · 0.45
device_placementMethod · 0.45
forwardMethod · 0.45
_msa_sparse_atten_opFunction · 0.45
replace_with_eetq_linearFunction · 0.45
replace_with_spqr_linearFunction · 0.45
replace_with_bnb_linearFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected