[Bugfix] Fix auto dtype casting for BatchFeature (#19316)
Signed-off-by: Isotr0py <2037008807@qq.com> Signed-off-by: Isotr0py <mozf@mail2.sysu.edu.cn>
This commit is contained in:
@@ -190,6 +190,16 @@ TORCH_DTYPE_TO_NUMPY_DTYPE = {
|
||||
torch.int64: np.int64,
|
||||
}
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def set_default_torch_num_threads(num_threads: int):
|
||||
"""Sets the default number of threads for PyTorch to the given value."""
|
||||
old_num_threads = torch.get_num_threads()
|
||||
torch.set_num_threads(num_threads)
|
||||
yield
|
||||
torch.set_num_threads(old_num_threads)
|
||||
|
||||
|
||||
P = ParamSpec('P')
|
||||
T = TypeVar("T")
|
||||
U = TypeVar("U")
|
||||
|
||||
Reference in New Issue
Block a user