Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix model replication issue when using PointNet2SetAbstraction with nn.DataParallel #305

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions kaolin/models/PointNet2.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,8 +559,10 @@ def __init__(self,

self.num_points_out = num_points_out
self.pointnet_layer_dims_list = pointnet_layer_dims_list
self.sub_modules = nn.ModuleList()
self.layers = []
self.grouper_modules = nn.ModuleList()
self.pointnet_modules = nn.ModuleList()
self.num_samples_list = []

self.pointnet_in_channels = pointnet_in_features + \
(3 if use_xyz_feature else 0)

Expand Down Expand Up @@ -590,10 +592,9 @@ def __init__(self,
)

# Register sub-modules
self.sub_modules.append(grouper)
self.sub_modules.append(pointnet)

self.layers.append((grouper, pointnet, num_samples))
self.grouper_modules.append(grouper)
self.pointnet_modules.append(pointnet)
self.num_samples_list.append(num_samples)

def forward(self, xyz, features=None):
"""
Expand Down Expand Up @@ -625,7 +626,7 @@ def forward(self, xyz, features=None):
new_xyz = new_xyz.transpose(1, 2).contiguous()

new_features_list = []
for grouper, pointnet, num_samples in self.layers:
for grouper, pointnet, num_samples in zip(self.grouper_modules, self.pointnet_modules, self.num_samples_list):
new_features = grouper(xyz, new_xyz, features)
# shape = (batch_size, num_points_out, self.pointnet_in_channels, num_samples)
# if num_points_out is None:
Expand Down