Registering CPU kernel with half dtype for cholesky_op
Also not sure for `BatchCholesky` whether half dtype should have support? At present as per code `BatchCholesky` supports only float and double and complex dtypes which are supported on Cholesky also excluded. I don't think it's as easy as just registering a kernel for the type.  These matrix decomposition ops are sensitive to errors, and using `half` directly in the computation will likely lead to horrible accuracy.  It's probably best to do the decomposition in higher precision then cast the final result back to half. @cantonios ,

Thanks for the explanation.Actually this Op registered with `half` dtype for **XLA** and hence tried adding kernel here. Also when I cross checked with `jit_compile=True` and with `half` dtype its not raising exception but generating few NaNs in output.Refer attached [gist](https://colab.sandbox.google.com/gist/SuryanarayanaY/b4e804b28f1d2119cc123d489c5dea7c/61973_with_jit_compile.ipynb)

Is this behaviour is due to the reason you mentioned ?

As per your suggestion we can do casting to high precision dtype say `float32` then apply cholesky op and convert the output back to `half` dtype. All this pre and post casting  be done at Python level only if I am not wrong. The source code link for [cholesky](https://www.tensorflow.org/api_docs/python/tf/linalg/cholesky) is not available in documentation and I couldn't figure out it exactly. Any help is appreciated. > @cantonios ,
> 
> Thanks for the explanation.Actually this Op registered with `half` dtype for **XLA** and hence tried adding kernel here. Also when I cross checked with `jit_compile=True` and with `half` dtype its not raising exception but generating few NaNs in output.Refer attached [gist](https://colab.sandbox.google.com/gist/SuryanarayanaY/b4e804b28f1d2119cc123d489c5dea7c/61973_with_jit_compile.ipynb)
> 
> Is this behaviour is due to the reason you mentioned ?

Probably.  Personally, I don't think any of these matrix decomposition ops _should_ support `half`, but if they must, then it should definitely do the cast before/after.

> As per your suggestion we can do casting to high precision dtype say `float32` then apply cholesky op and convert the output back to `half` dtype. All this pre and post casting be done at Python level only if I am not wrong.

You need to do the casting in C++ if you're registering a `half` C++ kernel.  To do the casting, you would need to create a higher-precision copy of the matrix [here](https://github.com/tensorflow/tensorflow/blob/dab293abf1b258358660173965bc955c3884e5c0/tensorflow/core/kernels/linalg/cholesky_op.cc#L49), then also cast the output back during assignment [here](https://github.com/tensorflow/tensorflow/blob/dab293abf1b258358660173965bc955c3884e5c0/tensorflow/core/kernels/linalg/cholesky_op.cc#L64).  I don't know about XLA - that probably also needs to be updated.



 Hi @SuryanarayanaY Any update on this PR? Please. Thank you!
  This PR is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you. Hi @SuryanarayanaY Any update on this PR? Please. Thank you! Hi @SuryanarayanaY Any update on this PR? Please. Thank you! This PR is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you. Hi @SuryanarayanaY Any update on this PR? Please. Thank you! Hi @SuryanarayanaY Any update on this PR? Please. Thank you! Hi @SuryanarayanaY Any update on this PR? Please. Thank you! Hi @SuryanarayanaY Any update on this PR? Please. Thank you! Hi @SuryanarayanaY Any update on this PR? Please. Thank you! This PR is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you. Not stale.Will work on it soon. This PR is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you. This PR was closed because it has been inactive for 14 days since being marked as stale. Please reopen if you'd like to work on this further.
The `tf.linalg.cholesky` should support `half` data type  as per documentation. The Op registered for `half` data type also in `REGISTER_OP()`. But There is no CPU kernel for this Op to support half dtype. Hence adding the CPU kernel for same.

Fixes #61907