From 73313441f16ff0b849cb6d91c010e5ac4740b783 Mon Sep 17 00:00:00 2001 From: Leonardo Leone Date: Thu, 9 Apr 2026 15:09:02 +0200 Subject: [PATCH] Fix device location --- depth/model/multivariate/CUDA_approximation.py | 4 ++-- depth/model/multivariate/Halfspace.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/depth/model/multivariate/CUDA_approximation.py b/depth/model/multivariate/CUDA_approximation.py index fe54ad9..300bcb7 100644 --- a/depth/model/multivariate/CUDA_approximation.py +++ b/depth/model/multivariate/CUDA_approximation.py @@ -13,7 +13,7 @@ # device = torch.device("cpu") def cudaApprox(data:torch.Tensor,x:torch.Tensor,notion:str, solver:str,option:int,NRandom:int,n_refinements:int,sphcap_shrink:float, - step:int=10000,device=None)->torch.Tensor: + step:int=10000,device="cpu")->torch.Tensor: """Main function to compute approximated depth based on chosen notion """ torch.manual_seed(2801) @@ -52,7 +52,7 @@ def RS(data:torch.Tensor,z:torch.Tensor,notion:str, """Compute (refined) Random search """ eps=torch.tensor([torch.pi/2],dtype=torch.float32,device=device) # initial cap size - pole=normalize(torch.normal(0,1,z.shape)).reshape(z.shape) # first pole + pole=normalize(torch.normal(0,1,z.shape,device=device)).reshape(z.shape) # first pole dMin=torch.ones((1,1),dtype=torch.float32,device=device) for ref in range(n_refinements): dirs=poleCuda(dirs,num_dir=dirRef, pole=pole,eps=eps,device=device) diff --git a/depth/model/multivariate/Halfspace.py b/depth/model/multivariate/Halfspace.py index a92babc..55946ac 100644 --- a/depth/model/multivariate/Halfspace.py +++ b/depth/model/multivariate/Halfspace.py @@ -58,8 +58,8 @@ def halfspace(x, data, exact=True, method="recursive", if CUDA==False:return depth_approximation(x, data, "halfspace", solver, NRandom ,option, n_refinements, sphcap_shrink, alpha_Dirichlet, cooling_factor, cap_size, start, space, line_solver, bound_gc) if CUDA==True: - return cudaApprox(data,x, "halfspace", solver, option,NRandom, n_refinements, - sphcap_shrink,device) + return cudaApprox(data,x, "halfspace", solver=solver, option=option,NRandom=NRandom, n_refinements=n_refinements, + sphcap_shrink=sphcap_shrink,device=device) halfspace.__doc__="""