add Model Compression and Conversion

This commit is contained in:
laiweijian 2023-06-26 14:09:17 +08:00
parent 3b672beb23
commit ec02e19e97
10 changed files with 720 additions and 377 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -8,7 +8,12 @@
</th> </th>
</tr> </tr>
</thead> </thead>
<tbody><tr id="modelarts_04_0099__row562392115411"><td class="cellrowborder" valign="top" width="18.970000000000002%" headers="mcps1.3.1.1.3.1.1 "><p id="modelarts_04_0099__p162319216418">2022-10-28</p> <tbody><tr id="modelarts_04_0099__row6135175817"><td class="cellrowborder" valign="top" width="18.970000000000002%" headers="mcps1.3.1.1.3.1.1 "><p id="modelarts_04_0099__p4148112587">203-06-19</p>
</td>
<td class="cellrowborder" valign="top" width="81.03%" headers="mcps1.3.1.1.3.1.2 "><p id="modelarts_04_0099__p9599191420582">Added: <a href="modelarts_23_0106.html">Model Compression and Conversion</a></p>
</td>
</tr>
<tr id="modelarts_04_0099__row562392115411"><td class="cellrowborder" valign="top" width="18.970000000000002%" headers="mcps1.3.1.1.3.1.1 "><p id="modelarts_04_0099__p162319216418">2022-10-28</p>
</td> </td>
<td class="cellrowborder" valign="top" width="81.03%" headers="mcps1.3.1.1.3.1.2 "><div class="p" id="modelarts_04_0099__p63942524335">Added:<ul id="modelarts_04_0099__ul12233201016142"><li id="modelarts_04_0099__li1181012143145"><a href="modelarts_23_0282.html">Video Labeling</a></li><li id="modelarts_04_0099__li1179811912142"><a href="modelarts_23_0337.html">Setting the Initialization Script</a></li><li id="modelarts_04_0099__li84391349343"><a href="modelarts_23_0068.html">Edge Services</a></li></ul> <td class="cellrowborder" valign="top" width="81.03%" headers="mcps1.3.1.1.3.1.2 "><div class="p" id="modelarts_04_0099__p63942524335">Added:<ul id="modelarts_04_0099__ul12233201016142"><li id="modelarts_04_0099__li1181012143145"><a href="modelarts_23_0282.html">Video Labeling</a></li><li id="modelarts_04_0099__li1179811912142"><a href="modelarts_23_0337.html">Setting the Initialization Script</a></li><li id="modelarts_04_0099__li84391349343"><a href="modelarts_23_0068.html">Edge Services</a></li></ul>
</div> </div>

View File

@ -10,6 +10,8 @@
</li> </li>
<li class="ulchildlink"><strong><a href="modelarts_23_0055.html">Managing Model Versions</a></strong><br> <li class="ulchildlink"><strong><a href="modelarts_23_0055.html">Managing Model Versions</a></strong><br>
</li> </li>
<li class="ulchildlink"><strong><a href="modelarts_23_0106.html">Model Compression and Conversion</a></strong><br>
</li>
</ul> </ul>
</div> </div>

View File

@ -0,0 +1,21 @@
<a name="modelarts_23_0106"></a><a name="modelarts_23_0106"></a>
<h1 class="topictitle1">Model Compression and Conversion</h1>
<div id="body8662426"></div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="modelarts_23_0107.html">Compressing and Converting Models</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="modelarts_23_0108.html">Model Input Path Specifications</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="modelarts_23_0109.html">Model Output Path Description</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="modelarts_23_0110.html">Conversion Templates</a></strong><br>
</li>
</ul>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="modelarts_23_0051.html">Model Management</a></div>
</div>
</div>

View File

@ -0,0 +1,71 @@
<a name="modelarts_23_0107"></a><a name="modelarts_23_0107"></a>
<h1 class="topictitle1">Compressing and Converting Models</h1>
<div id="body8662426"><p id="modelarts_23_0107__en-us_topic_0177490741_p13752153615816">To obtain higher computing power, you can deploy the models created on ModelArts or a local PC on the Ascend chip. In this case, you need to compress or convert the models to the required formats before deploying them.</p>
<p id="modelarts_23_0107__en-us_topic_0177490741_p199872381116">ModelArts supports model conversion, allowing you to convert a model to a required format before deploying the model on a chip with higher computing power and performance.</p>
<p id="modelarts_23_0107__en-us_topic_0177490741_p054014571465">Model conversion applies to the following scenarios:</p>
<ul id="modelarts_23_0107__en-us_topic_0177490741_ul1359518018917"><li id="modelarts_23_0107__en-us_topic_0177490741_li149591250125519">If you use the TensorFlow framework (in <strong id="modelarts_23_0107__en-us_topic_0177490741_b2693151832716">frozen_graph</strong> or <span class="filepath" id="modelarts_23_0107__en-us_topic_0177490741_filepath166944182271"><b>saved_model</b></span> format) to train a model, you can convert the model to the <strong id="modelarts_23_0107__en-us_topic_0177490741_b269419185273">.om</strong> format. The converted model can be deployed and run on Ascend chips.</li></ul>
<div class="section" id="modelarts_23_0107__en-us_topic_0177490741_section16868162912128"><h4 class="sectiontitle">Constraints</h4><ul id="modelarts_23_0107__en-us_topic_0177490741_ul929217463126"><li id="modelarts_23_0107__en-us_topic_0177490741_li513210479577">Only Ascend chips are supported for model conversion.</li><li id="modelarts_23_0107__en-us_topic_0177490741_li11166131551319">Only TensorFlow models can be converted. For a TensorFlow model, the input data type is of the INT32, BOOL, UINT8, or FLOAT type.</li><li id="modelarts_23_0107__en-us_topic_0177490741_li18339193717134">ModelArts provides conversion templates for you to choose. For details about the supported templates, see <a href="modelarts_23_0110.html">Conversion Templates</a>.</li><li id="modelarts_23_0107__en-us_topic_0177490741_li3414174215110">The <strong id="modelarts_23_0107__en-us_topic_0177490741_b046725663916">.tflite</strong> and TensorRT formats support fewer operators and quantization operators. Therefore, some models may fail to be converted. If the conversion fails, view the log dialog box or check error logs in the conversion output directory.</li><li id="modelarts_23_0107__en-us_topic_0177490741_li93151422175320">An OBS directory must be specified in compression/conversion tasks. Ensure that the OBS directory you use and ModelArts are in the same region.</li><li id="modelarts_23_0107__en-us_topic_0177490741_li216613356321">When importing the converted model to ModelArts, you need to use the <a href="modelarts_23_0205.html">model template</a>.</li><li id="modelarts_23_0107__en-us_topic_0177490741_li11683197165715">For a TensorFlow model, the FrozenGraphDef and SavedModel formats are supported. If a model is in the SavedModel format, the model is converted to the FrozenGraphDef format and then to the OM format.</li><li id="modelarts_23_0107__en-us_topic_0177490741_li86831472575">Inputs with dynamic shapes are not supported, for example, NHWC = [?,?,?,3]. A fixed value needs to be specified during model conversion.</li><li id="modelarts_23_0107__en-us_topic_0177490741_li1968312717571">The input can be up to 4-dimensional. Operators involving dimension changes (such as reshape and expanddim) cannot output five dimensions.</li><li id="modelarts_23_0107__en-us_topic_0177490741_li76831976573">Except the const operator, the input and output at all layers in a model must meet the condition <span class="parmvalue" id="modelarts_23_0107__en-us_topic_0177490741_parmvalue1368320720573"><b>dim!=0</b></span>.</li><li id="modelarts_23_0107__en-us_topic_0177490741_li168316765718">Model conversion does not support models that contain training operators.</li><li id="modelarts_23_0107__en-us_topic_0177490741_li17683579571">A UINT8 quantized model cannot be converted.</li><li id="modelarts_23_0107__en-us_topic_0177490741_li126831577578">Model operators support only 2D convolution but do not support 3D convolution. The batch_normalization_1 and FusedBatchNorm operators cannot be converted in batches.</li></ul>
</div>
<div class="section" id="modelarts_23_0107__en-us_topic_0177490741_section3596205519426"><h4 class="sectiontitle">Creating a Model Compression/Conversion Task</h4><ol id="modelarts_23_0107__en-us_topic_0177490741_ol46961657104315"><li id="modelarts_23_0107__en-us_topic_0177490741_li1580718447312">Log in to the ModelArts management console, and choose <strong id="modelarts_23_0107__en-us_topic_0177490741_b1929364977">Model Management</strong> &gt; <strong id="modelarts_23_0107__en-us_topic_0177490741_b1407018547">Compression/Conversion</strong> in the left navigation pane. The <strong id="modelarts_23_0107__en-us_topic_0177490741_b879409168">Compression/Conversion</strong> page is displayed.</li><li id="modelarts_23_0107__en-us_topic_0177490741_li861952913360">Click <span class="uicontrol" id="modelarts_23_0107__en-us_topic_0177490741_uicontrol2078887502"><b>Create Task</b></span> in the upper left corner to create a task.</li><li id="modelarts_23_0107__en-us_topic_0177490741_li7917421155412">On the <span class="wintitle" id="modelarts_23_0107__en-us_topic_0177490741_wintitle5429153919216"><b>Create Task</b></span> page that is displayed, set the required parameters based on <a href="#modelarts_23_0107__en-us_topic_0177490741_table1796410181761">Table 1</a>.
<div class="tablenoborder"><a name="modelarts_23_0107__en-us_topic_0177490741_table1796410181761"></a><a name="en-us_topic_0177490741_table1796410181761"></a><table cellpadding="4" cellspacing="0" summary="" id="modelarts_23_0107__en-us_topic_0177490741_table1796410181761" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Parameters</caption><thead align="left"><tr id="modelarts_23_0107__en-us_topic_0177490741_row1096417181165"><th align="left" class="cellrowborder" valign="top" width="30.79%" id="mcps1.3.6.2.3.3.2.3.1.1"><p id="modelarts_23_0107__en-us_topic_0177490741_p496411185612">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="69.21000000000001%" id="mcps1.3.6.2.3.3.2.3.1.2"><p id="modelarts_23_0107__en-us_topic_0177490741_p29641188617">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="modelarts_23_0107__en-us_topic_0177490741_row159640181065"><td class="cellrowborder" valign="top" width="30.79%" headers="mcps1.3.6.2.3.3.2.3.1.1 "><p id="modelarts_23_0107__en-us_topic_0177490741_p1964151818614">Name</p>
</td>
<td class="cellrowborder" valign="top" width="69.21000000000001%" headers="mcps1.3.6.2.3.3.2.3.1.2 "><p id="modelarts_23_0107__en-us_topic_0177490741_p12964118365">Name of a model conversion task</p>
</td>
</tr>
<tr id="modelarts_23_0107__en-us_topic_0177490741_row59644181565"><td class="cellrowborder" valign="top" width="30.79%" headers="mcps1.3.6.2.3.3.2.3.1.1 "><p id="modelarts_23_0107__en-us_topic_0177490741_p14964918767">Description</p>
</td>
<td class="cellrowborder" valign="top" width="69.21000000000001%" headers="mcps1.3.6.2.3.3.2.3.1.2 "><p id="modelarts_23_0107__en-us_topic_0177490741_p2964191810613">Description of a model conversion task</p>
</td>
</tr>
<tr id="modelarts_23_0107__en-us_topic_0177490741_row8964418860"><td class="cellrowborder" valign="top" width="30.79%" headers="mcps1.3.6.2.3.3.2.3.1.1 "><p id="modelarts_23_0107__en-us_topic_0177490741_p1396401818613">Conversion Template</p>
</td>
<td class="cellrowborder" valign="top" width="69.21000000000001%" headers="mcps1.3.6.2.3.3.2.3.1.2 "><p id="modelarts_23_0107__en-us_topic_0177490741_p789911954313">ModelArts provides various templates to define model conversion and the parameters required during the conversion.</p>
<p id="modelarts_23_0107__en-us_topic_0177490741_p168451741155418"><a href="modelarts_23_0110.html">Conversion Templates</a> details the supported model conversion templates. You can select a template from the template list. Alternatively, you can enter a keyword in the search box to search for a template, or select a template based on the chip type, framework type, or model file format.</p>
<ul id="modelarts_23_0107__en-us_topic_0177490741_ul54226551112"><li id="modelarts_23_0107__en-us_topic_0177490741_li174231655719">Chip type: ModelArts conversion templates support Ascend chips.</li><li id="modelarts_23_0107__en-us_topic_0177490741_li34239551518">Framework type: The conversion templates generate models in different formats based on different frameworks. The TensorFlow framework is supported.</li><li id="modelarts_23_0107__en-us_topic_0177490741_li54231551611">Model file format: The supported model file formats are listed in the drop-down list. Select a format from the drop-down list. The <span class="parmname" id="modelarts_23_0107__en-us_topic_0177490741_parmname11171161014519"><b>frozen_graph</b></span> and <span class="parmname" id="modelarts_23_0107__en-us_topic_0177490741_parmname1347125519452"><b>tf_serving</b></span> formats are supported.</li></ul>
</td>
</tr>
<tr id="modelarts_23_0107__en-us_topic_0177490741_row1496441810611"><td class="cellrowborder" valign="top" width="30.79%" headers="mcps1.3.6.2.3.3.2.3.1.1 "><p id="modelarts_23_0107__en-us_topic_0177490741_p1796410180619">Conversion Input Path</p>
</td>
<td class="cellrowborder" valign="top" width="69.21000000000001%" headers="mcps1.3.6.2.3.3.2.3.1.2 "><p id="modelarts_23_0107__en-us_topic_0177490741_p59641318568">Path to the model to be converted. The path must be an OBS path and comply with the ModelArts specifications. For details about the specifications, see <a href="modelarts_23_0108.html">Model Input Path Specifications</a>.</p>
</td>
</tr>
<tr id="modelarts_23_0107__en-us_topic_0177490741_row199641718466"><td class="cellrowborder" valign="top" width="30.79%" headers="mcps1.3.6.2.3.3.2.3.1.1 "><p id="modelarts_23_0107__en-us_topic_0177490741_p2964418660">Conversion Output Path</p>
</td>
<td class="cellrowborder" valign="top" width="69.21000000000001%" headers="mcps1.3.6.2.3.3.2.3.1.2 "><p id="modelarts_23_0107__en-us_topic_0177490741_p1096418181662">Path to the converted model. The path must comply with the ModelArts specifications. For details about the specifications, see <a href="modelarts_23_0109.html">Model Output Path Description</a>.</p>
</td>
</tr>
<tr id="modelarts_23_0107__en-us_topic_0177490741_row7964161815614"><td class="cellrowborder" valign="top" width="30.79%" headers="mcps1.3.6.2.3.3.2.3.1.1 "><p id="modelarts_23_0107__en-us_topic_0177490741_p996471815614">Advanced Settings</p>
</td>
<td class="cellrowborder" valign="top" width="69.21000000000001%" headers="mcps1.3.6.2.3.3.2.3.1.2 "><p id="modelarts_23_0107__en-us_topic_0177490741_p29650182062">ModelArts allows you to configure advanced settings for different conversion templates, for example, the precision.</p>
<p id="modelarts_23_0107__en-us_topic_0177490741_p149841991216">Different conversion templates support different advanced settings. For details about the parameters supported by each template, see <a href="modelarts_23_0110.html">Conversion Templates</a>.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="fignone" id="modelarts_23_0107__en-us_topic_0177490741_fig19290162924015"><span class="figcap"><b>Figure 1 </b>Creating a model compression/conversion task</span><br><span><img id="modelarts_23_0107__en-us_topic_0177490741_image19387194612355" src="en-us_image_0000001454866081.png"></span></div>
</li><li id="modelarts_23_0107__en-us_topic_0177490741_li196715271141">After entering the task information, click <span class="uicontrol" id="modelarts_23_0107__en-us_topic_0177490741_uicontrol2108594434"><b>Create Now</b></span> in the lower right corner.<p id="modelarts_23_0107__en-us_topic_0177490741_p204831817184">After the task is created, the system automatically switches to the <span class="wintitle" id="modelarts_23_0107__en-us_topic_0177490741_wintitle1765402109"><b>Compression/Conversion</b></span> page. The created conversion task is displayed on the page and is in the <span class="parmname" id="modelarts_23_0107__en-us_topic_0177490741_parmname724524273"><b>Initializing</b></span> status. The conversion task takes several minutes to complete. When the task status changes to <span class="parmname" id="modelarts_23_0107__en-us_topic_0177490741_parmname2093852447"><b>Successful</b></span>, the task is complete and the model has been converted.</p>
<p id="modelarts_23_0107__en-us_topic_0177490741_p1742612316154">If the task status changes to <span class="parmname" id="modelarts_23_0107__en-us_topic_0177490741_parmname1829004689"><b>Failed</b></span>, click the task name to go to the task details page, view the log information, adjust task parameters based on the log information, and create another conversion task.</p>
</li></ol>
</div>
<div class="section" id="modelarts_23_0107__en-us_topic_0177490741_section1242118461436"><h4 class="sectiontitle">Deleting a Model Compression/Conversion Task</h4><p id="modelarts_23_0107__en-us_topic_0177490741_p1918785094320">You can delete unnecessary conversion tasks. However, tasks in the <span class="parmname" id="modelarts_23_0107__en-us_topic_0177490741_parmname197981910183810"><b>Running</b></span> or <span class="parmname" id="modelarts_23_0107__en-us_topic_0177490741_parmname15138121933819"><b>Initializing</b></span> status cannot be deleted.</p>
<div class="note" id="modelarts_23_0107__en-us_topic_0177490741_note1847672484817"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="modelarts_23_0107__en-us_topic_0177490741_p747682454814">Deleted tasks cannot be recovered. Exercise caution when performing this operation.</p>
</div></div>
<ul id="modelarts_23_0107__en-us_topic_0177490741_ul34761756114514"><li id="modelarts_23_0107__en-us_topic_0177490741_li847675614520">Deleting a single task:<p id="modelarts_23_0107__en-us_topic_0177490741_p17664290460"><a name="modelarts_23_0107__en-us_topic_0177490741_li847675614520"></a><a name="en-us_topic_0177490741_li847675614520"></a>On the <span class="wintitle" id="modelarts_23_0107__en-us_topic_0177490741_wintitle299973217396"><b>Compression/Conversion</b></span> page, click <span class="uicontrol" id="modelarts_23_0107__en-us_topic_0177490741_uicontrol1268175020391"><b>Delete</b></span> in the <strong id="modelarts_23_0107__en-us_topic_0177490741_b184822541391">Operation</strong> column of the target task.</p>
</li><li id="modelarts_23_0107__en-us_topic_0177490741_li15520512464">Deleting a batch of tasks:<p id="modelarts_23_0107__en-us_topic_0177490741_p103537276476"><a name="modelarts_23_0107__en-us_topic_0177490741_li15520512464"></a><a name="en-us_topic_0177490741_li15520512464"></a>On the <span class="wintitle" id="modelarts_23_0107__en-us_topic_0177490741_wintitle6917020134012"><b>Compression/Conversion</b></span> page, select multiple tasks to be deleted and click <span class="uicontrol" id="modelarts_23_0107__en-us_topic_0177490741_uicontrol8817173317407"><b>Delete</b></span> in the upper left corner.</p>
</li></ul>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="modelarts_23_0106.html">Model Compression and Conversion</a></div>
</div>
</div>

View File

@ -0,0 +1,27 @@
<a name="modelarts_23_0108"></a><a name="modelarts_23_0108"></a>
<h1 class="topictitle1">Model Input Path Specifications</h1>
<div id="body8662426"><p id="modelarts_23_0108__en-us_topic_0177490742_p084519511556">During model conversion, the model input directory must comply with certain specifications. This section describes how to upload your model package to OBS.</p>
<div class="section" id="modelarts_23_0108__en-us_topic_0177490742_section1723565716500"><h4 class="sectiontitle">Ascend Chip</h4><p id="modelarts_23_0108__en-us_topic_0177490742_p1812022275617">The requirements for converting the models run on the Ascend chip are as follows:</p>
<ul id="modelarts_23_0108__en-us_topic_0177490742_ul81576571513"><li id="modelarts_23_0108__en-us_topic_0177490742_li677039105219">For TensorFlow-based models (in <span class="parmname" id="modelarts_23_0108__en-us_topic_0177490742_parmname19494961016"><b>frozen_graph</b></span> or <span class="parmname" id="modelarts_23_0108__en-us_topic_0177490742_parmname323065212108"><b>saved_model</b></span> format), the input path must comply with the following specifications during model conversion:<div class="p" id="modelarts_23_0108__en-us_topic_0177490742_p53658579133"><span class="parmname" id="modelarts_23_0108__en-us_topic_0177490742_parmname34513557100"><b>frozen_graph</b></span> format<pre class="screen" id="modelarts_23_0108__screen51432417219">|
|---xxxx.pb (Mandatory) Model network file. Only one model network file can exist in the input path. The model must be in <strong id="modelarts_23_0108__b11241154613213">frozen_graph</strong> or <strong id="modelarts_23_0108__b924117468219">saved_model</strong> format.
|---insert_op_conf.cfg (Optional) Insertion operator configuration file. Only one insertion operator configuration file can exist in the input path.
|---plugin (Optional) Custom operator directory. The input directory can contain only one plugin folder. Only custom operators developed based on Tensor Engine (TE) are supported.</pre>
</div>
<p id="modelarts_23_0108__en-us_topic_0177490742_p149761829101216"><span class="parmname" id="modelarts_23_0108__en-us_topic_0177490742_parmname1631815584106"><b>saved_model</b></span> format</p>
<pre class="screen" id="modelarts_23_0108__screen20661155242113">|
|---saved_model.pb (Mandatory) Model network file. Only one model network file can exist in the input path. The model must be in <strong id="modelarts_23_0108__b1436035812217">frozen_graph</strong> or <strong id="modelarts_23_0108__b8360258182115">saved_model</strong> format.
|---variables (Mandatory) Fixed subdirectory name, including the model weight deviation.
|---variables.index Mandatory
|---variables.data-00000-of-00001 Mandatory
|---insert_op_conf.cfg (Optional) Insertion operator configuration file. Only one insertion operator configuration file can exist in the input path.
|---plugin (Optional) Custom operator directory. The input directory can contain only one plugin folder. Only custom operators developed based on Tensor Engine (TE) are supported.</pre>
</li></ul>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="modelarts_23_0106.html">Model Compression and Conversion</a></div>
</div>
</div>

View File

@ -0,0 +1,16 @@
<a name="modelarts_23_0109"></a><a name="modelarts_23_0109"></a>
<h1 class="topictitle1">Model Output Path Description</h1>
<div id="body8662426"><div class="section" id="modelarts_23_0109__en-us_topic_0177612413_section225512310011"><h4 class="sectiontitle">Ascend Chip</h4><p id="modelarts_23_0109__en-us_topic_0177612413_p1812022275617">The following describes the output path of the model run on the Ascend chip after conversion:</p>
</div>
<ul id="modelarts_23_0109__en-us_topic_0177612413_ul1325511311207"><li id="modelarts_23_0109__en-us_topic_0177612413_li677039105219">For TensorFlow-based models, the output path must comply with the following specifications during model conversion:<pre class="screen" id="modelarts_23_0109__screen172616498222">|
|---xxxx.om Converted model to run on the Ascend chip. The model file name extension is <strong id="modelarts_23_0109__b1261375417220">.om</strong>.
|---job_log.txt Conversion log file</pre>
</li></ul>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="modelarts_23_0106.html">Model Compression and Conversion</a></div>
</div>
</div>

File diff suppressed because it is too large Load Diff