MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT / convert

Method convert

tools/Polygraphy/polygraphy/util/format.py:106–119  ·  view source on GitHub ↗

Permutes a shape from one format to another. Args: shape (Tuple[int]): The shape to convert. new_format (DataFormat): The desired format of the shape. Returns: Tuple[int]: A new shape in the correct format.

(shape, new_format)

Source from the content-addressed store, hash-verified

104
105 @staticmethod
106 def convert(shape, new_format):
107 """
108 Permutes a shape from one format to another.
109
110 Args:
111 shape (Tuple[int]): The shape to convert.
112 new_format (DataFormat): The desired format of the shape.
113
114 Returns:
115 Tuple[int]: A new shape in the correct format.
116 """
117 old_format = FormatManager.determine_format(shape)
118 perm = FormatManager.permutation(old_format, new_format)
119 return [shape[index] if index != -1 else 1 for index in perm]

Callers 1

load_image_npFunction · 0.45

Calls 2

determine_formatMethod · 0.80
permutationMethod · 0.80

Tested by

no test coverage detected