-
Notifications
You must be signed in to change notification settings - Fork 680
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Koenvandesande remove duplicate filenames (#448)
* Remove duplicate filenames which do not work on Windows by merging files * Fix * relu tests Co-authored-by: Koen van de Sande <koen@keplervision.eu>
- Loading branch information
1 parent
d1fa6f9
commit adccbf1
Showing
7 changed files
with
73 additions
and
55 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,35 @@ | ||
from torch2trt.torch2trt import * | ||
from .ReLU import * | ||
from torch2trt.module_test import add_module_test | ||
|
||
|
||
@tensorrt_converter('torch.relu') | ||
@tensorrt_converter('torch.relu_') | ||
@tensorrt_converter('torch.nn.functional.relu') | ||
@tensorrt_converter('torch.nn.functional.relu_') | ||
def convert_relu(ctx): | ||
def convert_functional_relu(ctx): | ||
ctx.method_args = (torch.nn.ReLU(),) + ctx.method_args | ||
convert_ReLU(ctx) | ||
convert_relu(ctx) | ||
|
||
|
||
@tensorrt_converter('torch.nn.ReLU.forward') | ||
def convert_relu(ctx): | ||
input = ctx.method_args[1] | ||
input_trt = add_missing_trt_tensors(ctx.network, [input])[0] | ||
output = ctx.method_return | ||
layer = ctx.network.add_activation( | ||
input=input_trt, type=trt.ActivationType.RELU) | ||
output._trt = layer.get_output(0) | ||
|
||
@add_module_test(torch.float32, torch.device('cuda'), [(1, 3, 4, 5)]) | ||
def test_relu_basic(): | ||
return torch.nn.ReLU() | ||
|
||
|
||
class FunctionalRelu(torch.nn.Module): | ||
def forward(self, x): | ||
return torch.nn.functional.relu(x) | ||
|
||
|
||
@add_module_test(torch.float32, torch.device('cuda'), [(1, 3, 4, 5)]) | ||
def test_functional_relu_basic(): | ||
return FunctionalRelu() |
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,8 +1,40 @@ | ||
from torch2trt.torch2trt import * | ||
from .ReLU6 import * | ||
from torch2trt.module_test import add_module_test | ||
|
||
|
||
@tensorrt_converter('torch.nn.functional.relu6') | ||
def convert_relu6(ctx): | ||
def convert_functional_relu6(ctx): | ||
ctx.method_args = (torch.nn.ReLU6(),) + ctx.method_args | ||
convert_ReLU6(ctx) | ||
convert_relu6(ctx) | ||
|
||
|
||
@tensorrt_converter('torch.nn.ReLU6.forward') | ||
def convert_relu6(ctx): | ||
input = ctx.method_args[1] | ||
output = ctx.method_return | ||
|
||
input_a_trt, input_b_trt = add_missing_trt_tensors(ctx.network, [input, 6]) | ||
input_a_trt, input_b_trt = broadcast_trt_tensors(ctx.network, [input_a_trt, input_b_trt], len(output.shape) - 1) | ||
|
||
layer = ctx.network.add_activation( | ||
input=input_a_trt, type=trt.ActivationType.RELU) | ||
layer = ctx.network.add_elementwise( | ||
layer.get_output(0), input_b_trt, trt.ElementWiseOperation.MIN) | ||
|
||
output._trt = layer.get_output(0) | ||
|
||
|
||
@add_module_test(torch.float32, torch.device('cuda'), [(1, 3, 4, 5)]) | ||
def test_relu6_basic(): | ||
return torch.nn.ReLU6() | ||
|
||
|
||
class FunctionalRelu6(torch.nn.Module): | ||
def forward(self, x): | ||
return torch.nn.functional.relu6(x) | ||
|
||
|
||
@add_module_test(torch.float32, torch.device('cuda'), [(1, 3, 4, 5)]) | ||
def test_functional_relu6_basic(): | ||
return FunctionalRelu6() | ||
|