Get a tensors memory address

Hi there!

Is there a possibility to get a tensors memory address? Like an equivalent to torch’s .data_ptr()?

Thanks in advance!

@anon25443,

You can access the memory address of a tensor using the id() function.

import tensorflow as tf
a = tf.constant([1, 2, 3])
memory_address=hex(id(a))

Thank you!

1 Like