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

Added converter for torch.Tensor.expand_as() method #614

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

maronuu
Copy link

@maronuu maronuu commented Aug 22, 2021

Description

This PR is related to Issue #565, but this issue cannot be closed yet even when this PR is merged.

A converter for torch.Tensor.expand(size) already exists, but one for torch.Tensor.expand_as(other) did not.
Users can convert expand_as by replacing all expand_as(other) with expand(other.size()), but it should not be a favorable way.

I made a converter torch2trt/converters/expand_as.py similar to torch2trt/converters/expand.py, with some new test cases.

The result of testing in my environment is as follows:

Environment

Ubuntu 20.04
Python 3.8.8
torch 1.8.1
torch2trt 0.3.0
cuda 11.1
cudnn 8.1.1
TensorRT 7.2.2

Test Result

| torch2trt.converters.expand_as.test_tensor_expand_as_scalar | float32 | [1] | {} | 0.00E+00 | nan | 0.00E+00 | 3.4e+05 | 1.88e+04 | 0.014 | 0.0646 |
| torch2trt.converters.expand_as.test_tensor_expand_as_singledim | float32 | [(1, 1, 3, 3)] | {} | 0.00E+00 | nan | 0.00E+00 | 3.3e+05 | 1.97e+04 | 0.0129 | 0.0631 |
| torch2trt.converters.expand_as.test_tensor_expand_as_multidim | float32 | [(1, 1, 1, 3)] | {} | 0.00E+00 | nan | 0.00E+00 | 3.2e+05 | 1.78e+04 | 0.0138 | 0.0635 |
| torch2trt.converters.expand_as.test_tensor_expand_as_singledim_half | float16 | [(1, 1, 3, 3)] | {} | 0.00E+00 | nan | 0.00E+00 | 3.17e+05 | 1.52e+04 | 0.0167 | 0.0877 |
| torch2trt.converters.expand_as.test_tensor_expand_as_multidim_half | float16 | [(1, 1, 1, 3)] | {} | 0.00E+00 | nan | 0.00E+00 | 3.25e+05 | 1.53e+04 | 0.0134 | 0.0784 |
NUM_TESTS: 5
NUM_SUCCESSFUL_CONVERSION: 5
NUM_FAILED_CONVERSION: 0
NUM_ABOVE_TOLERANCE: 0
NUM_pSNR_TOLERANCE: 0

@maronuu maronuu changed the title add converter for torch.Tensor.expand_as() method Added converter for torch.Tensor.expand_as() method Aug 22, 2021
@github2016-yuan
Copy link

@maronuu Have you converted yolov5s.pt to yolov5s_trt.pt yet?

@maronuu
Copy link
Author

maronuu commented Sep 7, 2021

@github2016-yuan
No, I don't work on YOLOv5.
If you are looking for the YOLOv5 implementation in TensorRT, this repository might be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants