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

Reorg for converters leaky_relu (FX Converter Refactor [6/N]) <Target: converter_reorg_proto> #1902

Merged
merged 1 commit into from
May 30, 2023

Conversation

apbose
Copy link
Collaborator

@apbose apbose commented May 10, 2023

No description provided.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some changes that do not conform to Python style guidelines:

--- py/torch_tensorrt/fx/converters/aten_ops_converters.py	2023-05-10 05:50:01.758314 +0000
+++ py/torch_tensorrt/fx/converters/aten_ops_converters.py	2023-05-10 05:50:17.483655 +0000
@@ -214,28 +214,20 @@
        "other": args[1],
    }
    return acc_ops_converters.acc_ops_fmod(network, target, None, kwargs_new, name)


-
@tensorrt_converter(torch.ops.aten.leaky_relu.default)
def aten_ops_leaky_relu(
    network: TRTNetwork,
    target: Target,
    args: Tuple[Argument, ...],
    kwargs: Dict[str, Argument],
    name: str,
) -> Union[TRTTensor, Sequence[TRTTensor]]:

-    return activation.leaky_relu(
-        network,
-        target,
-        SourceIR.ATEN,
-        name,
-        args[0],
-        args[1]
-    ) 
+    return activation.leaky_relu(network, target, SourceIR.ATEN, name, args[0], args[1])


@tensorrt_converter(torch.ops.aten.linear)
def aten_ops_linear(
    network: TRTNetwork,
--- py/torch_tensorrt/fx/converters/impl/activation.py	2023-05-10 05:50:01.758314 +0000
+++ py/torch_tensorrt/fx/converters/impl/activation.py	2023-05-10 05:50:17.702542 +0000
@@ -96,16 +96,18 @@
    network: TRTNetwork,
    target: Target,
    source_ir: Optional[SourceIR],
    name: str,
    input_val: TRTTensor,
-    alpha: Optional[Any]
+    alpha: Optional[Any],
):
    operation_type = trt.ActivationType.LEAKY_RELU

    def leaky_relu_dyn_range_fn(dyn_range):
-        return (max(0, dyn_range[0]) + alpha * min(0, dyn_range[0])), (max(0, dyn_range[1]) + alpha * min(0, dyn_range[1]))
+        return (max(0, dyn_range[0]) + alpha * min(0, dyn_range[0])), (
+            max(0, dyn_range[1]) + alpha * min(0, dyn_range[1])
+        )

    return convert_activation(
        network,
        target,
        source_ir,
--- py/torch_tensorrt/fx/converters/nn_ops_converters.py	2023-05-10 05:50:01.758314 +0000
+++ py/torch_tensorrt/fx/converters/nn_ops_converters.py	2023-05-10 05:50:17.768262 +0000
@@ -34,7 +34,7 @@
        network=network,
        target="torch.nn.functional.leaky_relu",
        source_ir=SourceIR.NN,
        name=layer_name,
        input_val=kwargs["input"],
-        alpha=kwargs["negative_slope"]
-    )
\ No newline at end of file
+        alpha=kwargs["negative_slope"],
+    )
--- py/torch_tensorrt/fx/converters/acc_ops_converters.py	2023-05-10 05:50:01.758314 +0000
+++ py/torch_tensorrt/fx/converters/acc_ops_converters.py	2023-05-10 05:50:19.367247 +0000
@@ -1023,16 +1023,11 @@
    kwargs: Dict[str, Argument],
    name: str,
) -> Union[TRTTensor, Sequence[TRTTensor]]:

    return activation.leaky_relu(
-        network,
-        target,
-        SourceIR.ACC,
-        name,
-        kwargs["input"],
-        kwargs["negative_slope"]
+        network, target, SourceIR.ACC, name, kwargs["input"], kwargs["negative_slope"]
    )


@tensorrt_converter(acc_ops.elu)
def acc_ops_elu(
--- py/torch_tensorrt/fx/test/converters/aten_op/test_leaky_relu_aten.py	2023-05-10 05:50:01.762314 +0000
+++ py/torch_tensorrt/fx/test/converters/aten_op/test_leaky_relu_aten.py	2023-05-10 05:50:19.646364 +0000
@@ -48,6 +48,6 @@
            TestModule(), input_specs, expected_ops={torch.ops.aten.leaky_relu.default}
        )


if __name__ == "__main__":
-    run_tests()
\ No newline at end of file
+    run_tests()

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code conforms to C++ style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code conforms to C++ style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code conforms to Python style guidelines

@apbose apbose requested review from narendasan, frank-wei and wushirong and removed request for yinghai May 12, 2023 16:58
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code conforms to C++ style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code conforms to C++ style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code conforms to C++ style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code conforms to Python style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code conforms to Python style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code conforms to Python style guidelines

@narendasan narendasan changed the title Reorg for converters leaky_relu (FX Converter Refactor [2/N]) Reorg for converters leaky_relu (FX Converter Refactor [6/N]) May 12, 2023
@apbose apbose changed the title Reorg for converters leaky_relu (FX Converter Refactor [6/N]) Reorg for converters leaky_relu (FX Converter Refactor [6/N]) <Target: converter_reorg_proto> May 15, 2023
@gs-olive gs-olive force-pushed the converter_reorg_activation_leaky_relu branch from 24e1d32 to a335af8 Compare May 15, 2023 21:44
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code conforms to Python style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code conforms to C++ style guidelines

@narendasan narendasan force-pushed the converter_reorg_activation_leaky_relu branch from a335af8 to e77d993 Compare May 30, 2023 22:04
@github-actions github-actions bot added component: build system Issues re: Build system component: conversion Issues re: Conversion stage labels May 30, 2023
@github-actions github-actions bot added component: converters Issues re: Specific op converters component: core Issues re: The core compiler component: lowering Issues re: The lowering / preprocessing passes component: partitioning component: tests Issues re: Tests labels May 30, 2023
@narendasan narendasan changed the base branch from converter_reorg_proto to main May 30, 2023 22:04
correcting nn_ops for leaky_relu and correcting linting error
@narendasan narendasan force-pushed the converter_reorg_activation_leaky_relu branch from e77d993 to 13ecfa6 Compare May 30, 2023 23:59
@narendasan narendasan merged commit de8faa2 into main May 30, 2023
@narendasan narendasan deleted the converter_reorg_activation_leaky_relu branch May 30, 2023 23:59
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code conforms to Python style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code conforms to C++ style guidelines

narendasan pushed a commit that referenced this pull request Jun 2, 2023
narendasan pushed a commit that referenced this pull request Jun 2, 2023
narendasan pushed a commit that referenced this pull request Jun 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed component: api [Python] Issues re: Python API component: build system Issues re: Build system component: conversion Issues re: Conversion stage component: converters Issues re: Specific op converters component: core Issues re: The core compiler component: fx component: lowering Issues re: The lowering / preprocessing passes component: partitioning component: tests Issues re: Tests fx Story: ATen Op Support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants