tfmot.sparsity.keras.PruneForLatencyOnXNNPack
Stay organized with collections
Save and categorize content based on your preferences.
Specifies to prune only 1x1 Conv2D layers in the model.
Inherits From: PruningPolicy
Used in the notebooks
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)
.
Methods
allow_pruning
View source
allow_pruning(
layer
)
Allows to prune only 1x1 Conv2D layers.
ensure_model_supports_pruning
View source
ensure_model_supports_pruning(
model
)
Ensures that the model contains only supported layers.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-05-26 UTC.
[null,null,["Last updated 2023-05-26 UTC."],[],[],null,["# tfmot.sparsity.keras.PruneForLatencyOnXNNPack\n\n\u003cbr /\u003e\n\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/model-optimization/blob/v0.7.5/tensorflow_model_optimization/python/core/sparsity/keras/pruning_policy.py#L83-L283) |\n\nSpecifies to prune only 1x1 Conv2D layers in the model.\n\nInherits From: [`PruningPolicy`](../../../tfmot/sparsity/keras/PruningPolicy)\n\n### Used in the notebooks\n\n| Used in the guide |\n|---------------------------------------------------------------------------------------------------------------------------------------------|\n| - [Pruning for on-device inference w/ XNNPACK](https://www.tensorflow.org/model_optimization/guide/pruning/pruning_for_on_device_inference) |\n\nPruneForLatencyOnXNNPack checks that the model contains a subgraph that can\nleverage XNNPACK's sparse inference and applies pruning wrapper only to\nConv2D with `kernel_size = (1, 1)`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Reference --------- ||\n|---|---|\n| \u003cbr /\u003e - [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) ||\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `allow_pruning`\n\n[View source](https://github.com/tensorflow/model-optimization/blob/v0.7.5/tensorflow_model_optimization/python/core/sparsity/keras/pruning_policy.py#L95-L97) \n\n allow_pruning(\n layer\n )\n\nAllows to prune only 1x1 Conv2D layers.\n\n### `ensure_model_supports_pruning`\n\n[View source](https://github.com/tensorflow/model-optimization/blob/v0.7.5/tensorflow_model_optimization/python/core/sparsity/keras/pruning_policy.py#L230-L283) \n\n ensure_model_supports_pruning(\n model\n )\n\nEnsures that the model contains only supported layers."]]