@@ -100,16 +100,7 @@ def test_backward(input_shape, input_dim, dtype, indices_dtype, combiner, graph_
100
100
expected_grads = tape .gradient (expected , [params , weights ])
101
101
# Gather returns sparse IndexedSlices so we have to sum them together.
102
102
test_utils .assert_allclose_according_to_type (
103
- tf .math .unsorted_segment_sum (
104
- expected_grads [0 ].values ,
105
- expected_grads [0 ].indices ,
106
- expected_grads [0 ].dense_shape [0 ],
107
- ),
108
- tf .math .unsorted_segment_sum (
109
- grads [0 ].values ,
110
- grads [0 ].indices ,
111
- grads [0 ].dense_shape [0 ],
112
- ),
103
+ tf .convert_to_tensor (expected_grads [0 ]), tf .convert_to_tensor (grads [0 ]),
113
104
)
114
105
test_utils .assert_allclose_according_to_type (
115
106
expected_grads [1 ],
@@ -125,14 +116,4 @@ def test_backward(input_shape, input_dim, dtype, indices_dtype, combiner, graph_
125
116
expected_grads = tape .gradient (expected , [params ])
126
117
# Gather returns sparse IndexedSlices so we have to sum them together.
127
118
test_utils .assert_allclose_according_to_type (
128
- tf .math .unsorted_segment_sum (
129
- expected_grads [0 ].values ,
130
- expected_grads [0 ].indices ,
131
- expected_grads [0 ].dense_shape [0 ],
132
- ),
133
- tf .math .unsorted_segment_sum (
134
- grads [0 ].values ,
135
- grads [0 ].indices ,
136
- grads [0 ].dense_shape [0 ],
137
- ),
138
- )
119
+ tf .convert_to_tensor (expected_grads [0 ]), tf .convert_to_tensor (grads [0 ]))
0 commit comments