TensorRT  7.2.1.6
NVIDIA TensorRT
Looking for a C++ dev who knows TensorRT?
I'm looking for work. Hire me!
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
polygraphy.util.misc Namespace Reference

Classes

class  Compressed
 Compression and Serialization. More...
 
class  FreeOnException
 

Functions

def version (version_str)
 
def find_in_dict (name, mapping, index=None)
 
def unique_list (sequence)
 
def default_value (value, default)
 
def unpack_args (args, num)
 
def is_dimension_dynamic (dim)
 Shapes. More...
 
def num_dynamic_dimensions (shape)
 
def is_shape_dynamic (shape)
 
def is_valid_shape_override (new_shape, original_shape)
 
def override_dynamic_shape (shape)
 
def shapes_match (shape0, shape1)
 
def volume (obj)
 
def is_empty_shape (shape)
 
def is_compressed (obj)
 
def compress (obj)
 
def decompress (compressed)
 
def pickle_load (path)
 
def pickle_save (path, obj)
 
def send_on_queue (queue, obj)
 
def try_send_on_queue (queue, obj)
 
def receive_on_queue (queue, timeout=None)
 
def try_receive_on_queue (queue, timeout=None)
 
def try_call (func, *args, **kwargs)
 
def insert_suffix (path, suffix)
 File creation. More...
 
def lazy_write (contents, path, mode="wb")
 
def try_match_shape (arr, shape)
 
def str_from_module_info (module, name=None)
 
def log_module_info (module, name=None, severity=G_LOGGER.VERBOSE)
 
def str_from_layer (prefix, index, name, op, input_info, output_info)
 
def indent_block (block, level=1)
 

Variables

dictionary NP_TYPE_FROM_STR = {np.dtype(dtype).name: np.dtype(dtype) for dtype in np.sctypeDict.values()}
 
dictionary STR_FROM_NP_TYPE = {dtype: name for name, dtype in NP_TYPE_FROM_STR.items()}
 
int PIPE_MAX_SEND_BYTES = 1 << 31
 

Function Documentation

◆ version()

def polygraphy.util.misc.version (   version_str)

◆ find_in_dict()

def polygraphy.util.misc.find_in_dict (   name,
  mapping,
  index = None 
)
Attempts to partially match keys in a dictionary. Checks for exact matches and
substring matches, falling back to index based matching.

Args:
    name (str): The key to search for.
    mapping (dict): The dictionary to search in.
    index (int): An index to fall back to if the key could not be found by name.

Returns:
    str: The key found in the dict, or None if it could not be found.

◆ unique_list()

def polygraphy.util.misc.unique_list (   sequence)
Creates a list without duplicate elements, preserving order.

Args:
    sequence (Sequence): The sequence to make unique

Returns:
    list: A list containing the same elements as sequence, in the same order, but without duplicates.

◆ default_value()

def polygraphy.util.misc.default_value (   value,
  default 
)
Returns a specified default value if the provided value is None.

Args:
    value (object): The value.
    default (object): The default value to use if value is None.

Returns:
    object: Either value, or the default.
Here is the caller graph for this function:

◆ unpack_args()

def polygraphy.util.misc.unpack_args (   args,
  num 
)
Extracts the specified number of arguments from a tuple, padding with
`None` if the tuple length is insufficient.

Args:
    args (Tuple[object]): The tuple of arguments
    num (int): The number of elements desired.

Returns:
    Tuple[object]: A tuple containing `num` arguments, padded with `None` if `len(args) < num`

◆ is_dimension_dynamic()

def polygraphy.util.misc.is_dimension_dynamic (   dim)

Shapes.

Here is the caller graph for this function:

◆ num_dynamic_dimensions()

def polygraphy.util.misc.num_dynamic_dimensions (   shape)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_shape_dynamic()

def polygraphy.util.misc.is_shape_dynamic (   shape)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_valid_shape_override()

def polygraphy.util.misc.is_valid_shape_override (   new_shape,
  original_shape 
)
Here is the call graph for this function:

◆ override_dynamic_shape()

def polygraphy.util.misc.override_dynamic_shape (   shape)
Here is the call graph for this function:

◆ shapes_match()

def polygraphy.util.misc.shapes_match (   shape0,
  shape1 
)

◆ volume()

def polygraphy.util.misc.volume (   obj)
Here is the caller graph for this function:

◆ is_empty_shape()

def polygraphy.util.misc.is_empty_shape (   shape)
Here is the call graph for this function:

◆ is_compressed()

def polygraphy.util.misc.is_compressed (   obj)
Here is the caller graph for this function:

◆ compress()

def polygraphy.util.misc.compress (   obj)
Here is the caller graph for this function:

◆ decompress()

def polygraphy.util.misc.decompress (   compressed)
Here is the caller graph for this function:

◆ pickle_load()

def polygraphy.util.misc.pickle_load (   path)

◆ pickle_save()

def polygraphy.util.misc.pickle_save (   path,
  obj 
)

◆ send_on_queue()

def polygraphy.util.misc.send_on_queue (   queue,
  obj 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ try_send_on_queue()

def polygraphy.util.misc.try_send_on_queue (   queue,
  obj 
)
Attempts to send an object over the queue, compressing it if needed.
In the event the object cannot be sent, sends `None` instead.

Args:
    queue (queue.Queue): The queue to send the object over.
    obj (object): The object to send.
Here is the call graph for this function:

◆ receive_on_queue()

def polygraphy.util.misc.receive_on_queue (   queue,
  timeout = None 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ try_receive_on_queue()

def polygraphy.util.misc.try_receive_on_queue (   queue,
  timeout = None 
)
Here is the call graph for this function:

◆ try_call()

def polygraphy.util.misc.try_call (   func,
args,
**  kwargs 
)
Attempts to invoke a function with arguments. If `func` is not callable, then returns `func`
The second return value of this function indicates whether the argument was a callable.
Here is the caller graph for this function:

◆ insert_suffix()

def polygraphy.util.misc.insert_suffix (   path,
  suffix 
)

File creation.

Inserts the provided suffix into the given path, before any file extensions.

Returns:
    str: The path, with suffix inserted, or None if no path was provided.

◆ lazy_write()

def polygraphy.util.misc.lazy_write (   contents,
  path,
  mode = "wb" 
)
Writes a file to the specified path.

Args:
    contents (Callable() -> bytes):
            Either a bytes-like object that can be written to disk, or a callable which will return such an object.
    path (str): The path to write to.


    mode(str): The mode to use when writing. Defaults to "wb".

Returns:
    str: The complete file path, or `None` if nothing was written.
Here is the call graph for this function:

◆ try_match_shape()

def polygraphy.util.misc.try_match_shape (   arr,
  shape 
)
Attempts to permute or reshape the array so its shape matches the specified shape.
This is a no-op if the array is already the correct shape.

Args:
    arr (numpy.ndarray): The array to reshape.
    shape (Tuple[int]): The shape to use. May contain at most 1 dynamic dimension.

Returns:
    numpy.ndarray: The reshaped array.
Here is the call graph for this function:

◆ str_from_module_info()

def polygraphy.util.misc.str_from_module_info (   module,
  name = None 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ log_module_info()

def polygraphy.util.misc.log_module_info (   module,
  name = None,
  severity = G_LOGGER.VERBOSE 
)
Here is the call graph for this function:

◆ str_from_layer()

def polygraphy.util.misc.str_from_layer (   prefix,
  index,
  name,
  op,
  input_info,
  output_info 
)

◆ indent_block()

def polygraphy.util.misc.indent_block (   block,
  level = 1 
)
Indents the provided block of text.

Args:
    block (str): The text to indent.
    level (int): The number of tabs to indent with.

Returns:
    str: The indented block.

Variable Documentation

◆ NP_TYPE_FROM_STR

dictionary polygraphy.util.misc.NP_TYPE_FROM_STR = {np.dtype(dtype).name: np.dtype(dtype) for dtype in np.sctypeDict.values()}

◆ STR_FROM_NP_TYPE

dictionary polygraphy.util.misc.STR_FROM_NP_TYPE = {dtype: name for name, dtype in NP_TYPE_FROM_STR.items()}

◆ PIPE_MAX_SEND_BYTES

int polygraphy.util.misc.PIPE_MAX_SEND_BYTES = 1 << 31