Skip to content

Commit

Permalink
fix to_static and amp of petrv2 (#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyber-pioneer authored May 11, 2023
1 parent 285c693 commit 5250935
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
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

0 comments on commit 5250935

Please sign in to comment.