# mypy: allow-untyped-defsfromcontextlibimportcontextmanagertry:fromtorch._Cimport_ittexceptImportError:class_ITTStub:@staticmethoddef_fail(*args,**kwargs):raiseRuntimeError("ITT functions not installed. Are you sure you have a ITT build?")@staticmethoddefis_available():returnFalserangePush=_failrangePop=_failmark=_fail_itt=_ITTStub()# type: ignore[assignment]__all__=["is_available","range_push","range_pop","mark","range"]
[docs]defis_available():""" Check if ITT feature is available or not """return_itt.is_available()
[docs]defrange_push(msg):""" Pushes a range onto a stack of nested range span. Returns zero-based depth of the range that is started. Arguments: msg (str): ASCII message to associate with range """return_itt.rangePush(msg)
[docs]defrange_pop():""" Pops a range off of a stack of nested range spans. Returns the zero-based depth of the range that is ended. """return_itt.rangePop()
[docs]defmark(msg):""" Describe an instantaneous event that occurred at some point. Arguments: msg (str): ASCII message to associate with the event. """return_itt.mark(msg)
@contextmanagerdefrange(msg,*args,**kwargs):""" Context manager / decorator that pushes an ITT range at the beginning of its scope, and pops it at the end. If extra arguments are given, they are passed as arguments to msg.format(). Args: msg (str): message to associate with the range """range_push(msg.format(*args,**kwargs))try:yieldfinally:range_pop()
Docs
Access comprehensive developer documentation for PyTorch
To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.