Skip to content

Commit

Permalink
add cleaned name and elemntwise layers
Browse files Browse the repository at this point in the history
  • Loading branch information
ranhomri committed Dec 5, 2024
1 parent 614874f commit 87a26a0
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions onnx2kerastl/elementwise_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ def convert_elementwise_add(node, params, layers, lambda_func, node_name, keras_
const_val = constant_value.flat[0]
layers[node_name] = keras.layers.Lambda(
lambda x: x + const_val,
name=keras_name
name=params['cleaned_name']
)(variable_input)
else:
# Embedding the constant tensor
layers[node_name] = keras.layers.Lambda(
lambda x: x + constant_value,
name=keras_name
name=params['cleaned_name']
)(variable_input)

elif not input_0_is_constant and input_1_is_constant:
Expand All @@ -123,13 +123,13 @@ def convert_elementwise_add(node, params, layers, lambda_func, node_name, keras_
const_val = constant_value.flat[0]
layers[node_name] = keras.layers.Lambda(
lambda x: x + const_val,
name=keras_name
name=params['cleaned_name']
)(variable_input)
else:
# Embedding the constant tensor
layers[node_name] = keras.layers.Lambda(
lambda x: x + constant_value,
name=keras_name
name=params['cleaned_name']
)(variable_input)
else:
# Both inputs are constants; compute the result now
Expand Down Expand Up @@ -179,13 +179,13 @@ def convert_elementwise_mul(node, params, layers, lambda_func, node_name, keras_
const_val = constant_value.flat[0]
layers[node_name] = keras.layers.Lambda(
lambda x: x * const_val,
name=keras_name
name=params['cleaned_name']
)(variable_input)
else:
# Cannot avoid embedding the constant tensor
layers[node_name] = keras.layers.Lambda(
lambda x: x * constant_value,
name=keras_name
name=params['cleaned_name']
)(variable_input)

elif not input_0_is_constant and input_1_is_constant:
Expand All @@ -198,13 +198,13 @@ def convert_elementwise_mul(node, params, layers, lambda_func, node_name, keras_
const_val = constant_value.flat[0]
layers[node_name] = keras.layers.Lambda(
lambda x: x * const_val,
name=keras_name
name=params['cleaned_name']
)(variable_input)
else:
# Cannot avoid embedding the constant tensor
layers[node_name] = keras.layers.Lambda(
lambda x: x * constant_value,
name=keras_name
name=params['cleaned_name']
)(variable_input)
else:
# Both inputs are constants; compute the result now
Expand Down Expand Up @@ -253,13 +253,13 @@ def convert_elementwise_sub(node, params, layers, lambda_func, node_name, keras_
const_val = constant_value.flat[0]
layers[node_name] = keras.layers.Lambda(
lambda x: const_val - x,
name=keras_name
name=params['cleaned_name']
)(variable_input)
else:
# Cannot avoid embedding the constant tensor
layers[node_name] = keras.layers.Lambda(
lambda x: constant_value - x,
name=keras_name
name=params['cleaned_name']
)(variable_input)

elif not input_0_is_constant and input_1_is_constant:
Expand All @@ -272,13 +272,13 @@ def convert_elementwise_sub(node, params, layers, lambda_func, node_name, keras_
const_val = constant_value.flat[0]
layers[node_name] = keras.layers.Lambda(
lambda x: x - const_val,
name=keras_name
name=params['cleaned_name']
)(variable_input)
else:
# Cannot avoid embedding the constant tensor
layers[node_name] = keras.layers.Lambda(
lambda x: x - constant_value,
name=keras_name
name=params['cleaned_name']
)(variable_input)
else:
# Both inputs are constants; compute the result now
Expand Down

0 comments on commit 87a26a0

Please sign in to comment.