@test_util.run_deprecated_v1
def testSparseDevicePlacement(self):
    for index_dtype in [dtypes.int32, dtypes.int64]:
        with self.cached_session(force_gpu=test.is_gpu_available()):
            var = variables.Variable([[1.0], [2.0]])
            indices = constant_op.constant([0, 1], dtype=index_dtype)
            g_sum = (lambda : math_ops.reduce_sum(array_ops.gather(var, indices)))
            optimizer = adam.Adam(3.0)
            minimize_op = optimizer.minimize(g_sum, var_list=[var])
            variables.global_variables_initializer().run()
            minimize_op.run()
@test_util.run_deprecated_v1
def testSparseDevicePlacement(self):
    for index_dtype in [dtypes.int32, dtypes.int64]:
        with self.cached_session(force_gpu=test.is_gpu_available()):
            var = variables.Variable([[1.0], [2.0]])
            indices = constant_op.constant([0, 1], dtype=index_dtype)
            g_sum = (lambda : math_ops.reduce_sum(array_ops.gather(var, indices)))
            optimizer = adam.Adam(3.0)
            minimize_op = optimizer.minimize(g_sum, var_list=[var])
            variables.global_variables_initializer().run()
            minimize_op.run()