Skip to content

Commit 86528d5

Browse files
committed
style
1 parent edd3582 commit 86528d5

5 files changed

Lines changed: 15 additions & 16 deletions

File tree

ml3d/torch/models/point_transformer.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,9 @@ def knn_batch(points,
730730
return_distances=True)
731731
if return_distances:
732732
return ans.neighbors_index.reshape(
733-
-1, k).long().to(device), ans.neighbors_distance.reshape(-1, k).to(
734-
device)
733+
-1,
734+
k).long().to(device), ans.neighbors_distance.reshape(-1,
735+
k).to(device)
735736
else:
736737
return ans.neighbors_index.reshape(-1, k).long().to(device)
737738

ml3d/torch/pipelines/base_pipeline.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ def __init__(self,
7272
if distributed:
7373
raise NotImplementedError(
7474
"Distributed training for XPU is not supported yet.")
75-
self.device = torch.device(
76-
device if ':' in str(device) else 'xpu')
75+
self.device = torch.device(device if ':' in str(device) else 'xpu')
7776
elif not torch.cuda.is_available():
7877
if distributed:
7978
raise NotImplementedError(
@@ -83,8 +82,8 @@ def __init__(self,
8382
if distributed:
8483
self.device = torch.device(device)
8584
print(f"Rank : {self.rank} using device : {self.device}")
86-
device_index = (self.device.index if self.device.index is not None
87-
else 0)
85+
device_index = (self.device.index
86+
if self.device.index is not None else 0)
8887
if hasattr(torch, 'accelerator'):
8988
torch.accelerator.set_device_index(device_index)
9089
elif self.device.type == 'cuda':

ml3d/torch/pipelines/object_detection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,8 @@ def run_train(self):
336336
# wrap model for multiple GPU
337337
if self.distributed:
338338
model.to(self.device)
339-
device_index = (self.device.index if self.device.index is not None
340-
else 0)
339+
device_index = (self.device.index
340+
if self.device.index is not None else 0)
341341
model = torch.nn.parallel.DistributedDataParallel(
342342
model, device_ids=[device_index])
343343
model.get_loss = model.module.get_loss

tests/test_models_torch.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@
4747
import pytest
4848
import torch
4949

50-
from torch_backend_parity import (assert_cpu_accelerator_parity,
51-
move_to_device)
50+
from torch_backend_parity import (assert_cpu_accelerator_parity, move_to_device)
5251

5352
if 'PATH_TO_OPEN3D_ML' in os.environ.keys():
5453
base = os.environ['PATH_TO_OPEN3D_ML']
@@ -92,8 +91,8 @@
9291

9392
def _bev_box3d():
9493
"""BEVBox3D lives in Open3D-ML (ml3d), not in open3d.ml.datasets."""
95-
ml_root = (os.environ.get('OPEN3D_ML_ROOT')
96-
or os.environ.get('PATH_TO_OPEN3D_ML') or base)
94+
ml_root = (os.environ.get('OPEN3D_ML_ROOT') or
95+
os.environ.get('PATH_TO_OPEN3D_ML') or base)
9796
if ml_root not in sys.path:
9897
sys.path.insert(0, ml_root)
9998
from ml3d.datasets.utils import BEVBox3D
@@ -115,8 +114,7 @@ def _pointrcnn_ctor_kwargs(mode):
115114
npoints=[256, 64, 16, 4],
116115
radius=[[0.1, 0.5], [0.5, 1.0], [1.0, 2.0], [2.0, 4.0]],
117116
nsample=[[4, 8], [4, 8], [4, 8], [4, 8]],
118-
mlps=[[[8, 8, 16], [16, 16, 32]],
119-
[[32, 32, 64], [32, 48, 64]],
117+
mlps=[[[8, 8, 16], [16, 16, 32]], [[32, 32, 64], [32, 48, 64]],
120118
[[64, 98, 128], [64, 98, 128]],
121119
[[128, 128, 256], [128, 192, 256]]],
122120
),
@@ -500,8 +498,8 @@ def make_net(device=torch.device('cpu')):
500498
def run(device):
501499
model = make_net(device)
502500
model.load_state_dict(state)
503-
batcher = ml3d.dataloaders.ConcatBatcher(
504-
str(device), model='PointTransformer')
501+
batcher = ml3d.dataloaders.ConcatBatcher(str(device),
502+
model='PointTransformer')
505503
batch = batcher.collate_fn([sample])
506504
batch['data'].to(device)
507505
out = model(batch['data'])

tests/torch_backend_parity.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
RTOL = {"cuda": 1e-4, "xpu": 1e-3}
88
ATOL = {"cuda": 1e-5, "xpu": 1e-4}
99

10+
1011
def move_to_device(obj, device):
1112
"""Recursively move tensors in nested batch structures to ``device``."""
1213
if torch.is_tensor(obj):

0 commit comments

Comments
 (0)