class_docstr: Specifies to prune only 1x1 Conv2D layers in the model.
  
  PruneForLatencyOnXNNPack checks that the model contains a subgraph that can
  leverage XNNPACK's sparse inference and applies pruning wrapper only to
  Conv2D with `kernel_size = (1, 1)`.
  
  Reference:
    - [Fast Sparse ConvNets](https://arxiv.org/abs/1911.09723)
    - [XNNPACK Sparse Inference](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/delegates/xnnpack/README.md#sparse-inference) # pylint: disable=line-too-long
class_docstr_tok: ["Specifies","to","prune","only","1x1","Conv2D","layers","in","the","model",".","PruneForLatencyOnXNNPack","checks","that","the","model","contains","a","subgraph","that","can","leverage","XNNPACK","'s","sparse","inference","and","applies","pruning","wrapper","only","to","Conv2D","with","`","kernel_size","=","(","1",",","1",")","`",".","Reference",":","-","[","Fast","Sparse","ConvNets","]","(","https",":","\/\/arxiv.org\/abs\/1911.09723",")","-","[","XNNPACK","Sparse","Inference","]","(","https",":","\/\/github.com\/tensorflow\/tensorflow\/blob\/master\/tensorflow\/lite\/delegates\/xnnpack\/README.md","#","sparse-inference",")","#","pylint",":","disable=line-too-long"]
docstr: Traverses the model and returns layers satisfying `stop_fn` criteria.
docstr_tok: ["Traverses","the","model","and","returns","layers","satisfying","`","stop_fn","`","criteria","."]
code: def _lookup_layers(self, source_layers, stop_fn, next_fn):
      """Traverses the model and returns layers satisfying `stop_fn` criteria."""
      to_visit = set(source_layers)
      used_layers = set(source_layers)
      found_layers = set()
      while to_visit:
          layer = to_visit.pop()
          if stop_fn(layer):
              found_layers.add(layer)
          else:
              next_layers = next_fn(layer)
              if not next_layers:
                  return set()
              for next_layer in next_layers:
                  if next_layer not in used_layers:
                      used_layers.add(next_layer)
                      to_visit.add(next_layer)
  
      return found_layers
  
file_path: model-optimization/tensorflow_model_optimization/python/core/sparsity/keras/pruning_policy.py
imports: import abc
  import tensorflow
  from tensorflow_model_optimization.python.core.quantization.keras import utils
  from tensorflow_model_optimization.python.core.sparsity.keras import pruning_wrapper
label_desc: Use image node_id 4 for calling the PruneForLatencyOnXNNPack obj's underlying member method code with example usage: obj._lookup_layers(source_layers, stop_fn, next_fn) and returns: found_layers, set