auto_decomposition
Description
Generates a decomposed model file and its weight files from a given original TensorFlow model and its weight file.
Restrictions
- The input model file (.meta) must match the weight files (.data-0000X-of-0000X and .index). The .data-0000X-of-0000X weight file must match the .index weight index file.
- Pass the directory of the original model and an output directory to the call to the tensor decomposition API. The API automatically decomposes any Convolution layer that meets the decomposition conditions. For details about the decomposition conditions, see Tensor Decomposition.
Prototype
add_ops = auto_decomposition(meta_path,ckpt_path,save_path)
Parameters
Parameter |
Input/Return |
Description |
Restrictions |
---|---|---|---|
meta_path |
Input |
TensorFlow model definition file (.meta). Ensure that the .meta file can be properly loaded by tf.compat.v1.train.import_meta_graph. For example, for a .meta file obtained through Horovod training, you must run the import hovorod.tensorflow command for the file to be successfully invoked by auto_decomposition. |
A string. |
ckpt_path |
Input |
Weight files of the already-trained TensorFlow model (.data-0000X-of-0000X and .index). You only need to specify the common prefix of the .data-0000X-of-0000X file and .index file. |
A string. |
save_path |
Input |
Directory of the result files. |
A string. |
add_ops |
Return |
List of newly added convolutional layers after model decomposition. |
A list. |
Returns
Returns a list of newly added convolutional layers after model decomposition.
Outputs
- Checkpoint file when saving the TensorFlow model.
- .meta model file after tensor decomposition.
- .data-00000-of-00001 weight file after tensor decomposition.
- .index weight file index after tensor decomposition.
- .pkl file that records the graph structure changes during tensor decomposition, which will be passed to the decompose_graph call.
Example
from amct_caffe.tensor_decompose import auto_decomposition auto_decomposition(meta_path='model.ckpt-2000.meta', ckpt_path='model.ckpt-200', save_path='model_decomposed' )