NOTE: These instructions are currently deprecated. Since OpenVINO™ 2020.4 version, no specific steps are needed to convert ONNX* DLRM models. For general instructions on converting ONNX models, please refer to Converting a ONNX* Model topic.
These instructions are applicable only to the DLRM converted to the ONNX* file format from the facebookresearch/dlrm model.
Step 1. Save trained Pytorch* model to ONNX* format. If you training model using script provided in model repository just add
--save-onnx flag to the command line parameters and you'll get
dlrm_s_pytorch.onnx file containing model serialized in ONNX* format.
Step 2. To generate the Intermediate Representation (IR) of the model, change your current working directory to the Model Optimizer installation directory and run the Model Optimizer with the following parameters:
Note that Pytorch model uses operation
torch.nn.EmbeddingBag. This operation converts to onnx as custom
ATen layer and not directly supported by OpenVINO*, but it is possible to convert this operation to:
Gatherif each "bag" consists of exactly one index. In this case
offsetsinput becomes obsolete and not needed. They will be removed during conversion.
ExperimentalSparseWeightedSumif "bags" contain not just one index. In this case Model Optimizer will print warning that pre-process of offsets is needed, because
torch.nn.EmbeddingBaghave different format of inputs. For example if you have
indicesinput of shape [indices_shape] and
offsetsinput of shape [num_bags] you need to get offsets of shape [indices_shape, 2]. To do that you may use the following code snippet:
torch.nn.EmbeddingBagoperation you'll need to do that for every offset input. If your offsets have same shape they will be merged into one input of shape [num_embedding_bags, indices_shape, 2].