@@ -1021,32 +1021,51 @@ def log2(x):
1021
1021
1022
1022
1023
1023
def logaddexp (x1 , x2 ):
1024
- x1 = get_ov_output (x1 )
1025
- x2 = get_ov_output (x2 )
1026
-
1027
- x1_type = x1 .get_element_type ()
1028
- x2_type = x2 .get_element_type ()
1024
+ element_type = None
1025
+ if isinstance (x1 , OpenVINOKerasTensor ):
1026
+ element_type = x1 .output .get_element_type ()
1027
+ if isinstance (x2 , OpenVINOKerasTensor ):
1028
+ element_type = x2 .output .get_element_type ()
1029
+ x1 = get_ov_output (x1 , element_type )
1030
+ x2 = get_ov_output (x2 , element_type )
1031
+ x1 , x2 = _align_operand_types (x1 , x2 , "logaddexp()" )
1029
1032
1030
- if x1_type . is_integral () or x2_type .is_integral ():
1033
+ if x1 . element_type . is_integral () or x2 . element_type .is_integral ():
1031
1034
float_dtype = OPENVINO_DTYPES [config .floatx ()]
1032
- if x1_type .is_integral ():
1035
+ if x1 . element_type .is_integral ():
1033
1036
x1 = ov_opset .convert (x1 , float_dtype )
1034
- if x2_type .is_integral ():
1037
+ if x2 . element_type .is_integral ():
1035
1038
x2 = ov_opset .convert (x2 , float_dtype )
1036
1039
1037
- x1 , x2 = _align_operand_types (x1 , x2 , "logaddexp()" )
1038
-
1039
- max_val = ov_opset .maximum (x1 , x2 ).output (0 )
1040
-
1041
- abs_diff = ov_opset .abs (ov_opset .subtract (x1 , x2 ).output (0 )).output (0 )
1042
- neg_abs_diff = ov_opset .negative (abs_diff ).output (0 )
1043
- exp_neg_abs = ov_opset .exp (neg_abs_diff ).output (0 )
1044
-
1045
- one = ov_opset .constant (1 , exp_neg_abs .get_element_type ()).output (0 )
1046
- one_plus_exp = ov_opset .add (one , exp_neg_abs ).output (0 )
1047
- log_term = ov_opset .log (one_plus_exp ).output (0 )
1048
-
1049
- result = ov_opset .add (max_val , log_term ).output (0 )
1040
+ # Get the output nodes properly
1041
+ max_val_node = ov_opset .maximum (x1 , x2 )
1042
+ max_val = max_val_node .output (0 )
1043
+
1044
+ # Compute absolute difference
1045
+ sub_node = ov_opset .subtract (x1 , x2 )
1046
+ abs_diff_node = ov_opset .abs (sub_node .output (0 ))
1047
+ abs_diff = abs_diff_node .output (0 )
1048
+
1049
+ # Compute negative absolute difference and its exponential
1050
+ neg_abs_diff_node = ov_opset .negative (abs_diff )
1051
+ neg_abs_diff = neg_abs_diff_node .output (0 )
1052
+ exp_neg_abs_node = ov_opset .exp (neg_abs_diff )
1053
+ exp_neg_abs = exp_neg_abs_node .output (0 )
1054
+
1055
+ # Get the element type from the node, not the output
1056
+ element_type = exp_neg_abs_node .get_element_type ()
1057
+ one_node = ov_opset .constant (1 , element_type )
1058
+ one = one_node .output (0 )
1059
+
1060
+ # Compute log term
1061
+ one_plus_exp_node = ov_opset .add (one , exp_neg_abs )
1062
+ one_plus_exp = one_plus_exp_node .output (0 )
1063
+ log_term_node = ov_opset .log (one_plus_exp )
1064
+ log_term = log_term_node .output (0 )
1065
+
1066
+ # Final result
1067
+ result_node = ov_opset .add (max_val , log_term )
1068
+ result = result_node .output (0 )
1050
1069
1051
1070
return OpenVINOKerasTensor (result )
1052
1071
0 commit comments