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 to_static and amp of petrv2 #327

Merged
merged 1 commit into from
May 11, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion paddle3d/apis/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def parse_losses(losses):
total_loss = losses
elif isinstance(losses, dict):
for loss_name, loss_value in losses.items():
log_loss[loss_name] = sum(loss_value)
log_loss[loss_name] = paddle.sum(loss_value)
total_loss = sum(
_loss_value for _loss_name, _loss_value in log_loss.items())

Expand Down
9 changes: 5 additions & 4 deletions paddle3d/models/detection/petr/petr3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ def __init__(self,
self.neck = neck
self.to_static = to_static
if self.to_static:
self.pts_bbox_head.to_static = True
for transformerlayer in self.pts_bbox_head.transformer.decoder.layers:
transformerlayer.use_recompute = False
for backbonelayer in self.backbone.sublayers():
Expand All @@ -159,8 +158,10 @@ def __init__(self,
InputSpec([12, 1024, 10, 25])
]]
specs_backbone = [InputSpec([12, 3, 320, 800])]
apply_to_static(
to_static, self.pts_bbox_head, image_shape=specs_head)
if not self.pts_bbox_head.with_denoise:
self.pts_bbox_head.to_static = True
apply_to_static(
to_static, self.pts_bbox_head, image_shape=specs_head)
apply_to_static(
to_static, self.backbone, image_shape=specs_backbone)
apply_to_static(to_static, self.neck, image_shape=specs_neck)
Expand Down Expand Up @@ -295,7 +296,7 @@ def forward_pts_train(self,
gt_bboxes_ignore=None):
"""
"""
if self.to_static:
if self.to_static and not self.pts_bbox_head.with_denoise:
timestamp = paddle.to_tensor(np.asarray(img_metas[0]['timestamp']))
outs = self.pts_bbox_head(
pts_feats,
Expand Down