Open cchan-lm opened 2 years ago
Any news on this? I also have a split
node in my ONNX graph, and it's breaking the network when I use a dynamic batch size
I have not yet found a workaround due to other efforts but do have to revisit this... @fatcat-z do you know of anything?
I have not yet found a workaround due to other efforts but do have to revisit this... @fatcat-z Jay Zhang FTE do you know of anything?
I just noticed the saved model generated after calling dlrm_model.save() method has already change the inputs as you provided, so I believe it's not changed by tf2onnx. When we load the saved model in tf2onnx, the inputs have been there already.
Describe the bug When
tf.unstack
ortf.split
is used on an input, dynamic batch dimension is lost.This was found while trying to export NodLabs's DLRM. An example script is provided to generate the model's architecture for saving. Inputs are
[dense_features, sparse_features]
. The inputs are split up in the model'scall
method. The resulting ONNX model shows thatdense_features
kept its dynamic batch dimension, butspare_features
has been rolled out explicitly and its dynamic batch dimension is lost.Urgency Supporting external customers with guidance on how to export TF to ONNX, so we would like to know very soon. Understandably, it's the holiday season, so if there's resolution/workaround by mid-January, that would be great :) Thank you for any assistence!
System information
To Reproduce
dlrm_example.py
:import sys import numpy as np import tensorflow as tf from tensorflow.keras import Model from tensorflow.keras import Sequential from tensorflow.keras.layers import Dense, Layer, Embedding
class LatentFactor(Embedding):
def MLP(units_list, use_bias=True, activation='relu', out_activation=None):
class SecondOrderFeatureInteraction(Layer):
Method 4
class SparseProcessorLayer(tf.keras.layers.Layer):
def init(self, latent_factors):
super().init()
self._latent_factors = latent_factors
def call(self, sparse_features):
sparse_emb_vecs = list(map(lambda pair: pair1,
zip(tf.unstack(sparse_features, axis=1),
self._latent_factors)))
return sparse_emb_vecs
class DLRM(Model):
def test_dlrm(): dim_embed = 4 bottom_mlp_size = [8, 4] top_mlp_size = [128, 64, 1]
if name == "main": test_dlrm()
2021-12-16 17:46:44,643 - INFO - Model inputs: ['input_1', 'input_2_1_1', 'input_2_1_10', 'input_2_1_11', 'input_2_1_12', 'input_2_1_13', 'input_2_1_14', 'input_2_1_15', 'input_2_1_16', 'input_2_1_17', 'input_2_1_18', 'input_2_1_19', 'input_2_1_2', 'input_2_1_20', 'input_2_1_21', 'input_2_1_22', 'input_2_1_23', 'input_2_1_24', 'input_2_1_25', 'input_2_1_26', 'input_2_1_3', 'input_2_1_4', 'input_2_1_5', 'input_2_1_6', 'input_2_1_7', 'input_2_1_8', 'input_2_1_9', 'input_2_2_1', 'input_2_2_10', 'input_2_2_11', 'input_2_2_12', 'input_2_2_13', 'input_2_2_14', 'input_2_2_15', 'input_2_2_16', 'input_2_2_17', 'input_2_2_18', 'input_2_2_19', 'input_2_2_2', 'input_2_2_20', 'input_2_2_21', 'input_2_2_22', 'input_2_2_23', 'input_2_2_24', 'input_2_2_25', 'input_2_2_26', 'input_2_2_3', 'input_2_2_4', 'input_2_2_5', 'input_2_2_6', 'input_2_2_7', 'input_2_2_8', 'input_2_2_9', 'input_2_3_1', 'input_2_3_10', 'input_2_3_11', 'input_2_3_12', 'input_2_3_13', 'input_2_3_14', 'input_2_3_15', 'input_2_3_16', 'input_2_3_17', 'input_2_3_18', 'input_2_3_19', 'input_2_3_2', 'input_2_3_20', 'input_2_3_21', 'input_2_3_22', 'input_2_3_23', 'input_2_3_24', 'input_2_3_25', 'input_2_3_26', 'input_2_3_3', 'input_2_3_4', 'input_2_3_5', 'input_2_3_6', 'input_2_3_7', 'input_2_3_8', 'input_2_3_9', 'input_2_4_1', 'input_2_4_10', 'input_2_4_11', 'input_2_4_12', 'input_2_4_13', 'input_2_4_14', 'input_2_4_15', 'input_2_4_16', 'input_2_4_17', 'input_2_4_18', 'input_2_4_19', 'input_2_4_2', 'input_2_4_20', 'input_2_4_21', 'input_2_4_22', 'input_2_4_23', 'input_2_4_24', 'input_2_4_25', 'input_2_4_26', 'input_2_4_3', 'input_2_4_4', 'input_2_4_5', 'input_2_4_6', 'input_2_4_7', 'input_2_4_8', 'input_2_4_9']