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

TRT Error #821

Closed
elohimarthur opened this issue Nov 24, 2022 · 2 comments
Closed

TRT Error #821

elohimarthur opened this issue Nov 24, 2022 · 2 comments

Comments

@elohimarthur
Copy link

elohimarthur commented Nov 24, 2022

Hi! dear professor!
I want to try to convert my model into TensorRT with torch2trt, I have fixed some Warning like unsupport op torch.zeros and torch.flip(I am not sure I'm right). However, I meet error below and how can I fix it?

[11/24/2022-14:44:24] [TRT] [E] 4: [graphShapeAnalyzer.cpp::analyzeShapes::1294] Error Code 4: Miscellaneous (IShuffleLayer encoder.2:1:SHUFFLE:GPU: reshape wildcard -1 has infinite number of solutions or no solution. Reshaping [4,10000] to [0,-1,0,1].)
[11/24/2022-14:44:24] [TRT] [E] 4: [graphShapeAnalyzer.cpp::analyzeShapes::1294] Error Code 4: Miscellaneous (IShuffleLayer encoder.2:1:SHUFFLE:GPU: reshape wildcard -1 has infinite number of solutions or no solution. Reshaping [4,10000] to [0,-1,0,1].)
[11/24/2022-14:44:24] [TRT] [E] 4: [graphShapeAnalyzer.cpp::analyzeShapes::1294] Error Code 4: Miscellaneous (IShuffleLayer encoder.2:1:SHUFFLE:GPU: reshape wildcard -1 has infinite number of solutions or no solution. Reshaping [4,10000] to [0,-1,0,1].)
[11/24/2022-14:44:24] [TRT] [E] 4: [graphShapeAnalyzer.cpp::analyzeShapes::1294] Error Code 4: Miscellaneous (IShuffleLayer encoder.2:1:SHUFFLE:GPU: reshape wildcard -1 has infinite number of solutions or no solution. Reshaping [4,10000] to [0,-1,0,1].)
[11/24/2022-14:44:24] [TRT] [E] 4: [graphShapeAnalyzer.cpp::analyzeShapes::1294] Error Code 4: Miscellaneous (IShuffleLayer encoder.2:1:SHUFFLE:GPU: reshape wildcard -1 has infinite number of solutions or no solution. Reshaping [4,10000] to [0,-1,0,1].)
[11/24/2022-14:44:24] [TRT] [E] 4: [graphShapeAnalyzer.cpp::analyzeShapes::1294] Error Code 4: Miscellaneous (IShuffleLayer encoder.2:1:SHUFFLE:GPU: reshape wildcard -1 has infinite number of solutions or no solution. Reshaping [4,10000] to [0,-1,0,1].)
[11/24/2022-14:44:24] [TRT] [E] 4: [graphShapeAnalyzer.cpp::analyzeShapes::1294] Error Code 4: Miscellaneous (IShuffleLayer encoder.2:1:SHUFFLE:GPU: reshape wildcard -1 has infinite number of solutions or no solution. Reshaping [4,10000] to [0,-1,0,1].)
[11/24/2022-14:44:24] [TRT] [E] 4: [graphShapeAnalyzer.cpp::analyzeShapes::1294] Error Code 4: Miscellaneous (IShuffleLayer encoder.2:1:SHUFFLE:GPU: reshape wildcard -1 has infinite number of solutions or no solution. Reshaping [4,10000] to [0,-1,0,1].)
[11/24/2022-14:44:24] [TRT] [E] 4: [graphShapeAnalyzer.cpp::analyzeShapes::1294] Error Code 4: Miscellaneous (IShuffleLayer encoder.2:1:SHUFFLE:GPU: reshape wildcard -1 has infinite number of solutions or no solution. Reshaping [4,10000] to [0,-1,0,1].)
[11/24/2022-14:44:24] [TRT] [E] 3: encoder.2:1:SHUFFLE:GPU: has zero placeholder that refers to invalid axis 2.
[11/24/2022-14:44:24] [TRT] [E] 4: [network.cpp::validate::2917] Error Code 4: Internal Error (Layer encoder.2:1:SHUFFLE:GPU failed validation)
@elohimarthur
Copy link
Author

elohimarthur commented Nov 24, 2022

My op of Torch.flip like below:
Do I make it right?

from torch2trt.torch2trt import *
from torch2trt.module_test import add_module_test


@tensorrt_converter('torch.flip')
@tensorrt_converter('torch.Tensor.flip')

def convert_flip(ctx):
    input = ctx.method_args[0]
    input_trt = add_missing_trt_tensors(ctx.network, [input])[0]
    output = ctx.method_return

    permutation = ctx.method_args[1]

    layer = ctx.network.add_shuffle(input_trt)
    layer.second_transpose = tuple(permutation)

    output._trt = layer.get_output(0)

class TorchFlip(torch.nn.Module):

    def __init__(self, *args):
        super(TorchFlip, self).__init__()
        self.args = args
        
    def forward(self, x):
        return torch.flip(x, *self.args)

class TorchFlip(torch.nn.Module):
    
    def __init__(self, *args):
        super(TorchFlip, self).__init__()
        self.args = args
        
    def forward(self, x):
        return x.flip(*self.args)

@add_module_test(torch.float32, torch.device('cuda'), [(1, 3, 3)])
@add_module_test(torch.float32, torch.device('cuda'), [(1, 3, 3, 3)])
@add_module_test(torch.float32, torch.device('cuda'), [(2, 3, 3, 3)], max_batch_size=2)

def test_torch_flip_0_0():
    return TorchFlip(1)

test_torch_flip_0_0()

@jaybdub
Copy link
Contributor

jaybdub commented Nov 29, 2022

Hi @elohimarthur ,

Thanks for reaching out!

I believe to use torch.flip, the slice method needs to be used instead shuffle.

I've added a PR to enable torch.flip and torch.Tensor.flip here

#822

Please let me know if this works for your use case or you have any issues.

Best,
John

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

No branches or pull requests

2 participants