Equivalent of "torch.cuda.LongTensor" in tensorflow

Hello,

I try to convert an existing code in pytorch to tensorflow. In the original code, they use “dtype=torch.cuda.LongTensor” to specify using GPU. Is there any alternative in tensorflow ? I have tried to use classical types of tensorflow such as “dtype =tf.dtypes.int64” but the code is very slow.

Thank you for your help.

1 Like

Hello,
the device placement can be specified using tf.device in this way:

with tf.device("/gpu:0"):
    x = tf.Variable(shape, dtpe=tf.int64) # shape is a variable defined somewhere, with the shape

In this case the x variable is placed in the first GPU, and the type is 64 bit integer

2 Likes

Thank you for your answer.

I have converted my list into tf.Variable and then I changed my list values within a loop, but I got the following error:
“TypeError: ‘ResourceVariable’ object does not support item assignment”

Any idea ?

1 Like