salad-demo / salad /utils /thutil.py
DveloperY0115's picture
init repo
801501a
raw
history blame contribute delete
199 Bytes
import numpy as np
import torch
def th2np(tensor):
if isinstance(tensor, np.ndarray):
return tensor
if isinstance(tensor, torch.Tensor):
return tensor.detach().cpu().numpy()