-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
123 additions
and
448 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
[settings] | ||
known_third_party = distutils,graphviz,numpy,packaging,setuptools,tensorrt,termcolor,torch,torchvision | ||
known_third_party = distutils,graphviz,mmdeploy,numpy,packaging,setuptools,tensorrt,torch,torchvision |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import torch | ||
from torch2trt_dynamic import TRTModule, module2trt | ||
from torchvision.models import resnet18 | ||
|
||
|
||
def test_convert(tmp_path): | ||
model = resnet18().cuda().eval() | ||
|
||
trt_model = module2trt( | ||
model, | ||
args=[torch.rand(1, 3, 224, 224).cuda()], | ||
) | ||
|
||
model_path = tmp_path / 'tmp.pth' | ||
torch.save(trt_model.state_dict(), model_path) | ||
assert model_path.exists() | ||
|
||
trt_model = TRTModule() | ||
trt_model.load_state_dict(torch.load(model_path)) | ||
|
||
x = torch.rand(1, 3, 224, 224).cuda() | ||
with torch.no_grad(): | ||
y = model(x) | ||
y_trt = trt_model(x) | ||
|
||
torch.testing.assert_close(y, y_trt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Empty file.
Oops, something went wrong.