@@ -1041,13 +1041,12 @@ def access_term_cache(node):
1041
1041
# list of bools indicating if each input is connected to the cost
1042
1042
inputs_connected = [
1043
1043
(
1044
- True
1045
- in [
1044
+ any (
1046
1045
input_to_output and output_to_cost
1047
1046
for input_to_output , output_to_cost in zip (
1048
1047
input_to_outputs , outputs_connected
1049
1048
)
1050
- ]
1049
+ )
1051
1050
)
1052
1051
for input_to_outputs in connection_pattern
1053
1052
]
@@ -1067,25 +1066,24 @@ def access_term_cache(node):
1067
1066
# List of bools indicating if each input only has NullType outputs
1068
1067
only_connected_to_nan = [
1069
1068
(
1070
- True
1071
- not in [
1069
+ not any (
1072
1070
in_to_out and out_to_cost and not out_nan
1073
1071
for in_to_out , out_to_cost , out_nan in zip (
1074
1072
in_to_outs , outputs_connected , ograd_is_nan
1075
1073
)
1076
- ]
1074
+ )
1077
1075
)
1078
1076
for in_to_outs in connection_pattern
1079
1077
]
1080
1078
1081
- if True not in inputs_connected :
1079
+ if not any ( inputs_connected ) :
1082
1080
# All outputs of this op are disconnected so we can skip
1083
1081
# Calling the op's grad method and report that the inputs
1084
1082
# are disconnected
1085
1083
# (The op's grad method could do this too, but this saves the
1086
1084
# implementer the trouble of worrying about this case)
1087
1085
input_grads = [disconnected_type () for ipt in inputs ]
1088
- elif False not in only_connected_to_nan :
1086
+ elif all ( only_connected_to_nan ) :
1089
1087
# All inputs are only connected to nan gradients, so we don't
1090
1088
# need to bother calling the grad method. We know the gradient
1091
1089
# with respect to all connected inputs is nan.
0 commit comments