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

allow direct method setting to support custom layers #460

Merged
merged 1 commit into from
Dec 2, 2020

Conversation

jaybdub
Copy link
Contributor

@jaybdub jaybdub commented Dec 2, 2020

Currently, converters may only be written for methods with modules visible by torch2trt.py. In addition, converter methods must be specified by full string path, like @tensorrt_converter('torch.relu').

This PR allows the user to specify converters for custom methods.

  1. @tensorrt_converter will now automatically determine and import the needed module. For example, @tensorrt_converter("my_package.my_module.my_activation") now works, assuming my_package is installed.

  2. @tensorrt_converter will now accept non-builtin methods directly. This helps for locally defined functions, or if it is difficult to determine the full function string name. For example, a local function my_activation can now be converted

    def my_activation(x):
        return 10 * x
    
    @tensorrt_converter(my_activation) 
    def convert_my_activation(ctx):
        # ...

@jaybdub jaybdub merged commit 81024cc into NVIDIA-AI-IOT:master Dec 2, 2020
@jaybdub jaybdub deleted the import branch December 2, 2020 00:19
jaybdub added a commit that referenced this pull request Dec 2, 2020
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.

1 participant