Skip to content

Commit

Permalink
[Fix]: fix pplnn empty output error (open-mmlab#320)
Browse files Browse the repository at this point in the history
* fix ppl problems

* fix roialign
  • Loading branch information
VVsssssk committed Dec 21, 2021
1 parent 33bde90 commit ce2b778
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
8 changes: 7 additions & 1 deletion mmdeploy/backend/pplnn/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,13 @@ def forward(self, inputs: Dict[str,
for i in range(self.runtime.GetOutputCount()):
out_tensor = self.runtime.GetOutputTensor(i).ConvertToHost()
name = self.output_names[i]
outputs[name] = torch.from_numpy(np.array(out_tensor, copy=False))
if out_tensor:
outputs[name] = np.array(out_tensor, copy=False)
else:
out_shape = self.runtime.GetOutputTensor(
i).GetShape().GetDims()
outputs[name] = np.random.rand(*out_shape)
outputs[name] = torch.from_numpy(outputs[name])
return outputs

@TimeCounter.count_time()
Expand Down
9 changes: 7 additions & 2 deletions mmdeploy/mmcv/ops/roi_align.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from torch import Tensor

from mmdeploy.core import SYMBOLIC_REWRITER
from mmdeploy.utils import Backend, get_backend


# Here using mmcv.ops.roi_align.__self__ to find
Expand Down Expand Up @@ -36,9 +37,13 @@ def roi_align_default(ctx, g, input: Tensor, rois: Tensor,
Returns:
MMCVRoiAlign op for onnx.
"""

backend = get_backend(ctx.cfg)
if backend == Backend.PPLNN:
domain = 'mmcv'
else:
domain = 'mmdeploy'
return g.op(
'mmdeploy::MMCVRoiAlign',
f'{domain}::MMCVRoiAlign',
input,
rois,
output_height_i=output_size[0],
Expand Down

0 comments on commit ce2b778

Please sign in to comment.