Shortcuts

ts.utils package

Submodules

ts.utils.timeit_decorator module

timeit decorator

ts.utils.timeit_decorator.timeit(func)[source]

Use this decorator on a method to find it’s execution time. :param func: :return:

ts.utils.util module

Utility functions for TorchServe

class ts.utils.util.PT2Backend(value)[source]

Bases: str, Enum

An enumeration.

AOT_CUDAGRAPHS = 'aot_cudagraphs'
AOT_EAGER = 'aot_eager'
AOT_NVFUSER = 'aot_nvfuser'
EAGER = 'eager'
FX2TRT = 'fx2trt'
INDUCTOR = 'inductor'
IPEX = 'ipex'
NVFUSER = 'nvfuser'
OFI = 'ofi'
ONNXRT = 'onnxrt'
TORCHXLA_TRACE_ONCE = 'torchxla_trace_once'
exception ts.utils.util.PredictionException(message, error_code=500)[source]

Bases: Exception

ts.utils.util.check_valid_pt2_backend(backend: str) bool[source]
ts.utils.util.get_yaml_config(yaml_file_path)[source]
ts.utils.util.list_classes_from_module(module, parent_class=None)[source]

Parse user defined module to get all model service classes in it.

Parameters:
  • module

  • parent_class

Returns:

List of model service class definitions

ts.utils.util.load_label_mapping(mapping_file_path)[source]

Load a JSON mapping { class ID -> friendly class name }. Used in BaseHandler.

ts.utils.util.map_class_to_label(probs, mapping=None, lbl_classes=None)[source]

Given a list of classes & probabilities, return a dictionary of { friendly class name -> probability }

Module contents

Util files for TorchServe

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources