Problem in slice layer with dynamic shape input
hi , we were trying to build a network with a dynamic input, and the network have some slice layers. Then we got a failure: slice size must be positive.
Do you have any suggestions for this problem?Thx~
Hi @yux94 ,
Please share:
- full error traceback
- the code that reproduces the error
- all environment info requested in issue template
@rmccorm4 Thank you for your reply. In my case, the slice layer throws an error if shape with dim -1:
slicelayer = network. add_slice(input, start, shape, stride)
the input dims : (-1,768,1,1) while the network has a dynamic input(1,3,32,-1) and 3 dense block before this. What we want is to split&concat, and get the output with (-1*h, 768/h,1,1) first, h=8 then we set
slicenum=input. get_output(0).shape[1]/8 for i in range(8): ……start_index = slice_num*i ……slicelayer = network. add_slice(input, (0,start_index,0,0), (input. get_output(0).shape[0],slice_num,1,1) ,(1,1,0,0))
The error traceback is: [Slice] slice size must be positive, size =[-1,96,1,1]
###environment tensorRT version 7.0.0.11 CUDA version 9.0. 176 CUDNN version 7.5.0 GPU Type Tesla M60
@rmccorm4 Thank you for your reply. In my case, the slice layer throws an error if shape with dim -1:
slicelayer = network. add_slice(input, start, shape, stride)
the input dims : (-1,768,1,1) while the network has a dynamic input(1,3,32,-1) and 3 dense block before this. What we want is to split&concat, and get the output with (-1*h, 768/h,1,1) first, h=8 then we set
slicenum=input. get_output(0).shape[1]/8 for i in range(8): ……start_index = slice_num*i ……slicelayer = network. add_slice(input, (0,start_index,0,0), (input. get_output(0).shape[0],slice_num,1,1) ,(1,1,0,0))
The error traceback is: [Slice] slice size must be positive, size =[-1,96,1,1]
###environment tensorRT version 7.0.0.11 CUDA version 9.0. 176 CUDNN version 7.5.0 GPU Type Tesla M60
I have the same error, have you solved this problem?
meet same error with a dynamic input model, how to solve it?
Hello @yux94 @jiuzhuanzhuan @wnzhyee Have you tried 7.2? If you still see the failure in 7.2, could you share your model or code? thanks!
I will close this since no response for more than 3 weeks, please reopen if you still have question, thanks!
i think you have to extract the shapes at runtime with a shape layer, and use the setInput method in slice layers as describe in the 7.3 section of this doc : https://docs.nvidia.com/deeplearning/tensorrt/developer-guide/index.html#work_dynamic_shapes