<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/model-optimization/blob/v0.8.1/tensorflow_model_optimization/python/core/sparsity/keras/pruning_policy.py#L86-L302) |

Specifies to prune only 1x1 Conv2D layers in the model.

Inherits From: [`PruningPolicy`](https://www.tensorflow.org/model_optimization/api_docs/python/tfmot/sparsity/keras/PruningPolicy)

### Used in the notebooks

| Used in the guide |
|---|
| - [Pruning for on-device inference w/ XNNPACK](https://www.tensorflow.org/model_optimization/guide/pruning/pruning_for_on_device_inference) |

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)`.

<br />

<br />

| ## Reference ||
|---|---|
| <br /> - [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) ||

<br />

## Methods

### `allow_pruning`

[View source](https://github.com/tensorflow/model-optimization/blob/v0.8.1/tensorflow_model_optimization/python/core/sparsity/keras/pruning_policy.py#L98-L100)

    allow_pruning(
        layer
    )

Allows to prune only 1x1 Conv2D layers.

### `ensure_model_supports_pruning`

[View source](https://github.com/tensorflow/model-optimization/blob/v0.8.1/tensorflow_model_optimization/python/core/sparsity/keras/pruning_policy.py#L248-L302)

    ensure_model_supports_pruning(
        model
    )

Ensures that the model contains only supported layers.