Pytorch to tensorrt conversion using torch2trt on jetson nano

I want to convert a pytorch model to tensorrt using the library torch2trt on the jetson nano. But I am getting an error. The complete log is below:

Warning: Encountered known unsupported method torch.is_grad_enabled

Warning: Encountered known unsupported method torch.zeros

Warning: Encountered known unsupported method torch.Tensor.transpose


TypeError Traceback (most recent call last)
in
----> 1 model_trt = torch2trt(model, )

/usr/local/lib/python3.6/dist-packages/torch2trt-0.1.0-py3.6-linux-aarch64.egg/torch2trt/torch2trt.py in torch2trt(module, inputs, input_names, output_names, log_level, max_batch_size, fp16_mode, max_workspace_size, strict_type_constraints, keep_network, int8_mode, int8_calib_dataset, int8_calib_algorithm, int8_calib_batch_size, use_onnx)
500 ctx.add_inputs(inputs, input_names)
501
→ 502 outputs = module(*inputs)
503
504 if not isinstance(outputs, tuple) and not isinstance(outputs, list):

/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py in call(self, *input, **kwargs)
530 result = self._slow_forward(*input, **kwargs)
531 else:
→ 532 result = self.forward(*input, **kwargs)
533 for hook in self._forward_hooks.values():
534 hook_result = hook(self, input, result)

~/FaceDetection-DSFD/face_ssd_infer.py in forward(self, x)
128 self.last_feature_maps = featuremap_size
129 with torch.no_grad():
→ 130 output = self.detect(face_loc, face_conf, self.priors)
131 else:
132 output = torch.cat((face_loc, face_conf), 2)

/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py in call(self, *input, **kwargs)
530 result = self._slow_forward(*input, **kwargs)
531 else:
→ 532 result = self.forward(*input, **kwargs)
533 for hook in self._forward_hooks.values():
534 hook_result = hook(self, input, result)

~/FaceDetection-DSFD/layers/detection.py in forward(self, loc_data, conf_data, prior_data)
42 for i in range(num):
43 default = prior_data
—> 44 decoded_boxes = decode(loc_data[i], default, self.variance)
45 # For each class, perform nms
46 conf_scores = conf_preds[i].clone()

/usr/local/lib/python3.6/dist-packages/torch2trt-0.1.0-py3.6-linux-aarch64.egg/torch2trt/torch2trt.py in wrapper(*args, **kwargs)
281
282 # print(‘%s’ % (converter.name,))
→ 283 converter"converter"
284
285 # convert to None so conversion will fail for unsupported layers

/usr/local/lib/python3.6/dist-packages/torch2trt-0.1.0-py3.6-linux-aarch64.egg/torch2trt/converters/getitem.py in convert_tensor_getitem(ctx)
32 # Step 1 - Replace ellipsis with expanded slices
33
—> 34 num_ellipsis = len(input.shape) - num_slice_types(slices)
35
36 new_slices =

/usr/local/lib/python3.6/dist-packages/torch2trt-0.1.0-py3.6-linux-aarch64.egg/torch2trt/converters/getitem.py in num_slice_types(slices)
16 def num_slice_types(slices):
17 num_slice = 0
—> 18 for s in slices:
19 if isinstance(s, slice) or isinstance(s, int):
20 num_slice += 1

TypeError: ‘int’ object is not iterable

For reference, the model can be found at GitHub - vlad3996/FaceDetection-DSFD

Hey @bhavikkumar.sanghvi managed to optimize DSFS using tensorrt? I have kind of having the same issue.