mirror of
https://github.com/iperov/DeepFaceLive
synced 2025-08-20 05:23:23 -07:00
add xlib.avecl
This commit is contained in:
parent
932edfe875
commit
0058474da7
56 changed files with 5569 additions and 0 deletions
22
xlib/avecl/_internal/HTensor.py
Normal file
22
xlib/avecl/_internal/HTensor.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
from typing import List, Union
|
||||
|
||||
from .Tensor import *
|
||||
|
||||
|
||||
class HTensor:
|
||||
"""
|
||||
Helper functions for Tensor
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def all_same_device( tensor_or_list : Union[Tensor, List[Tensor] ] ) -> bool:
|
||||
"""
|
||||
check if all tensors in a list use the same device
|
||||
"""
|
||||
if not isinstance(tensor_or_list, (list,tuple)):
|
||||
tensor_or_list = (tensor_or_list,)
|
||||
|
||||
device = tensor_or_list[0].get_device()
|
||||
return all( device == tensor.get_device() for tensor in tensor_or_list )
|
||||
|
||||
__all__ = ['HTensor']
|
Loading…
Add table
Add a link
Reference in a new issue