Skip to content

Commit a3dba66

Browse files
committed
device in name
1 parent 0527037 commit a3dba66

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

torch2trt/torch2trt.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ def _configure_layer(self, layer):
357357
# set layer device type
358358
device_type = self._ctx.current_device_type()
359359
self._ctx.builder_config.set_device_type(layer, device_type)
360+
orig_device_type = device_type
360361
if not self._ctx.builder_config.can_run_on_DLA(layer) and device_type == trt.DeviceType.DLA:
361362
if self._ctx.torch2trt_kwargs['gpu_fallback']:
362363
device_type = trt.DeviceType.GPU # layer will fall back to GPU
@@ -366,13 +367,14 @@ def arg_str(arg):
366367
if isinstance(arg, torch.Tensor):
367368
return "tensor(shape=%s, dtype=%s)" % (str(list(arg.shape)), str(arg.dtype))
368369
return str(arg)
369-
scope_name = self._ctx.current_module_name() + ':' + layer.type.name
370+
scope_name = self._ctx.current_module_name()# + ':' + layer.type.name
370371
self._layer_counts[scope_name] += 1
371372
args = [arg_str(arg) for arg in self._ctx.method_args]
372373
kwargs = ["%s=%s" % (key, arg_str(arg)) for key, arg in self._ctx.method_kwargs.items()]
373-
layer.name = scope_name
374-
if self._layer_counts[scope_name] > 1:
375-
layer.name = layer.name + '(' + str(self._layer_counts[scope_name] - 1) + ')'
374+
layer.name = scope_name + ':' + str(self._layer_counts[scope_name] - 1) + ':' + layer.type.name + ':' + device_type_str(device_type)
375+
376+
if orig_device_type != device_type:
377+
layer.name = layer.name + '(' + device_type_str(orig_device_type) + ')'
376378
# "%s [%s #%d, %s] %s(%s)" % (self._ctx.current_module_name(), layer.type.name, self._layer_counts[layer.type.name], device_type_str(device_type),
377379
# self._ctx.method_str, ", ".join(args + kwargs))
378380

0 commit comments

Comments
 (0)