nncf/experimental/tensorflow/patch_tf.py
def patch_tf_operations() -> None:
        """
        Applies patches to the TensorFlow code.
        """
        op_type_name_to_op_info_map = TFPatcher._get_ops_info()
        for op_type_name, (fn, fn_name, module) in op_type_name_to_op_info_map.items():
            tf_op_wrapper = TensorFlowOpWrapper(fn, op_type_name)
            setattr(module, fn_name, tf_op_wrapper)

            if hasattr(module, op_type_name):
                setattr(module, op_type_name, tf_op_wrapper)

            # Wraps `fn` from the public API
            if hasattr(fn, '_tf_api_names'):
                tf_api_names = getattr(fn, '_tf_api_names')
                for api_name in tf_api_names:
                    items = api_name.split('.')
                    module_names = items[:-1]
                    name = items[-1]

                    curr_module = tf
                    for curr_name in module_names:
                        curr_module = getattr(curr_module, curr_name)
                    setattr(curr_module, name, tf_op_wrapper)

            # TODO(andrey-churkin): Changes references from the `tensorflow.python.ops.nn`
            # module because the Keras uses it (Only for TF versions: 2.4.x, 2.5.x). Need
            # to remove this for new versions.
            if getattr(nn, fn_name, None) is fn:
                setattr(nn, fn_name, tf_op_wrapper)

            # TODO(andrey-churkin): This is required because `tensorflow.python.ops.math_ops` module
            # contains following import `from tensorflow.python.ops.gen_math_ops import *`
            if getattr(math_ops, fn_name, None) is fn:
                setattr(math_ops, fn_name, tf_op_wrapper)

        ops.name_scope = TFPatcher._wrap_name_scope_internal_fn(ops.name_scope)
        ops.name_scope_v2.__enter__ = TFPatcher._wrap_name_scope_v2_enter_fn(ops.name_scope_v2.__enter__)
        tf.name_scope.__enter__ = TFPatcher._wrap_name_scope_v2_enter_fn(tf.name_scope.__enter__)

        Applies patches to the TensorFlow code.
        
Applies patches to the TensorFlow code.
Applies patches to the TensorFlow code .
def patch_tf_operations() -> None:
        op_type_name_to_op_info_map = TFPatcher._get_ops_info()
        for op_type_name, (fn, fn_name, module) in op_type_name_to_op_info_map.items():
            tf_op_wrapper = TensorFlowOpWrapper(fn, op_type_name)
            setattr(module, fn_name, tf_op_wrapper)
            if hasattr(module, op_type_name):
                setattr(module, op_type_name, tf_op_wrapper)
            if hasattr(fn, '_tf_api_names'):
                tf_api_names = getattr(fn, '_tf_api_names')
                for api_name in tf_api_names:
                    items = api_name.split('.')
                    module_names = items[:-1]
                    name = items[-1]
                    curr_module = tf
                    for curr_name in module_names:
                        curr_module = getattr(curr_module, curr_name)
                    setattr(curr_module, name, tf_op_wrapper)
            if getattr(nn, fn_name, None) is fn:
                setattr(nn, fn_name, tf_op_wrapper)
            if getattr(math_ops, fn_name, None) is fn:
                setattr(math_ops, fn_name, tf_op_wrapper)
        ops.name_scope = TFPatcher._wrap_name_scope_internal_fn(ops.name_scope)
        ops.name_scope_v2.__enter__ = TFPatcher._wrap_name_scope_v2_enter_fn(ops.name_scope_v2.__enter__)
        tf.name_scope.__enter__ = TFPatcher._wrap_name_scope_v2_enter_fn(tf.name_scope.__enter__)
def patch_tf_operations ( ) -> None : op_type_name_to_op_info_map = TFPatcher . _get_ops_info ( ) for op_type_name , ( fn , fn_name , module ) in op_type_name_to_op_info_map . items ( ) : tf_op_wrapper = TensorFlowOpWrapper ( fn , op_type_name ) setattr ( module , fn_name , tf_op_wrapper ) if hasattr ( module , op_type_name ) : setattr ( module , op_type_name , tf_op_wrapper ) if hasattr ( fn , '_tf_api_names' ) : tf_api_names = getattr ( fn , '_tf_api_names' ) for api_name in tf_api_names : items = api_name . split ( '.' ) module_names = items [ : - 1 ] name = items [ - 1 ] curr_module = tf for curr_name in module_names : curr_module = getattr ( curr_module , curr_name ) setattr ( curr_module , name , tf_op_wrapper ) if getattr ( nn , fn_name , None ) is fn : setattr ( nn , fn_name , tf_op_wrapper ) if getattr ( math_ops , fn_name , None ) is fn : setattr ( math_ops , fn_name , tf_op_wrapper ) ops . name_scope = TFPatcher . _wrap_name_scope_internal_fn ( ops . name_scope ) ops . name_scope_v2 . __enter__ = TFPatcher . _wrap_name_scope_v2_enter_fn ( ops . name_scope_v2 . __enter__ ) tf . name_scope . __enter__ = TFPatcher . _wrap_name_scope_v2_enter_fn ( tf . name_scope . __enter__ )
Applies patches to the TensorFlow code.
Applies patches to the TensorFlow code .
"""
        Applies patches to the TensorFlow code.
        """ # Wraps `fn` from the public API # TODO(andrey-churkin): Changes references from the `tensorflow.python.ops.nn` # module because the Keras uses it (Only for TF versions: 2.4.x, 2.5.x). Need # to remove this for new versions. # TODO(andrey-churkin): This is required because `tensorflow.python.ops.math_ops` module # contains following import `from tensorflow.python.ops.gen_math_ops import *`