auto_decomposition
Function Usage
Call auto_decomposition to perform tensor decomposition on the source TensorFlow model, generating a new model file.
Constraints
- The model definition file (.meta), model weight file (.data-XXXXX-of-XXXXX), and weight index file (.index) must match the original TensorFlow model provided by the user for decomposition.
- Pass the directory of the source model and the output directory to the API 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 Restrictions.
Prototype
add_ops = auto_decomposition(meta_path, ckpt_path, save_path)
Parameters
Option |
Input/Return |
Description |
Restriction |
|---|---|---|---|
meta_path |
Input |
Path of the TensorFlow model definition file (.meta). NOTE:
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 called by auto_decomposition. |
A string |
ckpt_path |
Input |
Path of the TensorFlow model weight file to be decomposed. This parameter is the common prefix path of the .data-XXXXX-of-XXXXX file and the .index file. For example, the preceding two files are path/model-200.data-00000-of-00001 and path/model-200.index, The value of ckpt_path is path/model-200. |
A string |
save_path |
Input |
Path for storing the files obtained after tensor decomposition. Files such as .data-XXXXX-of-XXXXX with the prefix of this path are generated. For example, if this parameter is set to path/model, the generated .data-XXXXX-of-XXXXX and .index files are as follows: path/model.data-XXXXX-of-XXXXX and path/model.index. |
A string |
add_ops |
Returns |
List of names of newly added convolutional layers after tensor decomposition. |
A list. |
Returns
List of names of newly added convolutional layers after tensor decomposition.
Outputs
- checkpoint: checkpoint list file.
- .meta: model definition file after tensor decomposition.
- .data-00000-of-00001: weight file after tensor decomposition.
- .index: index of the weight file after tensor decomposition.
- A graph change history file (.pkl) file, which is used by the decompose_graph API to modify the graph defined by the source training code.
Example
1 2 3 4 5 | from amct_tensorflow.tensor_decompose import auto_decomposition auto_decomposition(meta_path='src_path/model.meta', ckpt_path='src_path/model', save_path='decomposed_path/model' ) |