sparseml.tensorflow_v1 package

Subpackages

Submodules

sparseml.tensorflow_v1.base module

sparseml.tensorflow_v1.base.check_tensorflow_install(min_version: Optional[str] = '1.8.0', max_version: Optional[str] = '1.16.0', raise_on_error: bool = True, allow_env_ignore_flag: bool = True)bool[source]

Check that the tensorflow package is installed. If raise_on_error, will raise an ImportError if it is not installed or the required version range, if set, is not installed. If not raise_on_error, will return True if installed with required version and False otherwise.

Parameters
  • min_version (str) – The minimum version for tensorflow that it must be greater than or equal to, if unset will require no minimum version

  • max_version (str) – The maximum version for tensorflow that it must be less than or equal to, if unset will require no maximum version.

  • raise_on_error (bool) – True to raise any issues such as not installed, minimum version, or maximum version as ImportError. False to return the result.

  • allow_env_ignore_flag (bool) – True to allow the env variable SPARSEML_IGNORE_TFV1 to ignore the tensorflow install and version checks. False to ignore the ignore flag.

Returns

If raise_on_error, will return False if tensorflow is not installed or the version is outside the accepted bounds and True if everything is correct.

Return type

bool

sparseml.tensorflow_v1.base.check_tf2onnx_install(min_version: Optional[str] = '1.0.0', max_version: Optional[str] = None, raise_on_error: bool = True)bool[source]

Check that the tf2onnx package is installed. If raise_on_error, will raise an ImportError if it is not installed or the required version range, if set, is not installed. If not raise_on_error, will return True if installed with required version and False otherwise.

Parameters
  • min_version (str) – The minimum version for tf2onnx that it must be greater than or equal to, if unset will require no minimum version

  • max_version (str) – The maximum version for tf2onnx that it must be less than or equal to, if unset will require no maximum version.

  • raise_on_error (bool) – True to raise any issues such as not installed, minimum version, or maximum version as ImportError. False to return the result.

Returns

If raise_on_error, will return False if tf2onnx is not installed or the version is outside the accepted bounds and True if everything is correct.

Return type

bool

sparseml.tensorflow_v1.base.require_tensorflow(min_version: Optional[str] = '1.8.0', max_version: Optional[str] = '1.16.0', allow_env_ignore_flag: bool = True)[source]

Decorator function to require use of tensorflow. Will check that tensorflow package is installed and within the bounding ranges of min_version and max_version if they are set before calling the wrapped function. See check_tensorflow_install() for more info.

Parameters
  • min_version (str) – The minimum version for tensorflow that it must be greater than or equal to, if unset will require no minimum version

  • max_version (str) – The maximum version for tensorflow that it must be less than or equal to, if unset will require no maximum version.

  • allow_env_ignore_flag (bool) – True to allow the env variable SPARSEML_IGNORE_TFV1 to ignore the tensorflow install and version checks. False to ignore the ignore flag.

sparseml.tensorflow_v1.base.require_tf2onnx(min_version: Optional[str] = '1.0.0', max_version: Optional[str] = None)[source]

Decorator function to require use of tf2onnx. Will check that tf2onnx package is installed and within the bounding ranges of min_version and max_version if they are set before calling the wrapped function. See check_tf2onnx_install() for more info.

Parameters
  • min_version (str) – The minimum version for tf2onnx that it must be greater than or equal to, if unset will require no minimum version

  • max_version (str) – The maximum version for tf2onnx that it must be less than or equal to, if unset will require no maximum version.

Module contents

Functionality for working with and sparsifying Models in the TensorFlow 1.x framework