Convert tf.Tensor into tensorflow::Tensor
Hey @SuryanarayanaY . you working on this ?
 Hi @zhumakhan ,

Tensorflow provides C_API that can be used to build [bindings for other languages](https://github.com/tensorflow/docs/tree/master/site/en/r1/guide/extend/bindings.md) which is defined in [c_api.h](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/c/c_api.h).

Please refer the above sources and let us know if it helps. Thanks!
 Thanks for your suggestion, will check that and let you know! @SuryanarayanaY as I understood, c_api.h is to create extension for other languages. But my problem was that current python api of tensorflow does not allow to get raw data pointer of tf.Tensor (e.g. torch.Tensor.data_ptr(), jax.Array.unsafe_data_pointer()). Hence I decided to make a C++ extension which returns tensorflow::Tensor::data() and bind it to python with pybind11. So, currently I can pass tf.Tensor (python api's tensor) into that C++ extension and take it as PyObject* argument inside the C++ extension. Further I should convert PyObject* into tensorflow::Tensor, call data() method and return its result. I stuck at the last step at the moment. Would really appreciate your suggestions on that.
Thanks! Hi @zhumakhan ,

Could you please try converting a tf.tensor into serialized TensorProto prototype by using [tf.io.serialize_tensor](https://www.tensorflow.org/api_docs/python/tf/io/serialize_tensor) API, and then using tensorflow::ops::[ParseTensor](https://www.tensorflow.org/api_docs/cc/class/tensorflow/ops/parse-tensor) parse the serialized TensorProto back to tf:Tensor.

Please try this and let us know if this doesn't work. Thanks! This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you. This issue was closed because it has been inactive for 7 days since being marked as stale. Please reopen if you'd like to work on this further. Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/61214">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/61214">No</a>

### Issue type

Bug

### Have you reproduced the bug with TensorFlow Nightly?

Yes

### Source

source

### TensorFlow version

2.13

### Custom code

Yes

### OS platform and distribution

Ubuntu 20

### Mobile device

_No response_

### Python version

3.8

### Bazel version

_No response_

### GCC/compiler version

_No response_

### CUDA/cuDNN version

11.2

### GPU model and memory

_No response_

### Current behavior?

Is there any way to convert tf.Tensor from python into tensorflow::Tensor C++?

### Standalone code to reproduce the issue

```shell
Actually using pybind11. I can get PyObject* from tf.Tensor and have no idea how to get tensorflow::Tensor* from PyObject*
```


### Relevant log output

_No response_