<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.21.0/tensorflow/python/framework/tensor_conversion_registry.py#L80-L131) |

Registers a function for converting objects of `base_type` to `Tensor`.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.register_tensor_conversion_function`](https://www.tensorflow.org/api_docs/python/tf/register_tensor_conversion_function)

<br />

    tf.register_tensor_conversion_function(
        base_type, conversion_func, priority=100
    )

The conversion function must have the following signature:

        def conversion_func(value, dtype=None, name=None, as_ref=False):
          # ...

It must return a `Tensor` with the given `dtype` if specified. If the
conversion function creates a new `Tensor`, it should use the given
`name` if specified. All exceptions will be propagated to the caller.

The conversion function may return `NotImplemented` for some
inputs. In this case, the conversion process will continue to try
subsequent conversion functions.

If `as_ref` is true, the function must return a `Tensor` reference,
such as a `Variable`.

> [!NOTE]
> **Note:** The conversion functions will execute in order of priority, followed by order of registration. To ensure that a conversion function `F` runs before another conversion function `G`, ensure that `F` is registered with a smaller priority than `G`.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `base_type` | The base type or tuple of base types for all objects that `conversion_func` accepts. |
| `conversion_func` | A function that converts instances of `base_type` to `Tensor`. |
| `priority` | Optional integer that indicates the priority for applying this conversion function. Conversion functions with smaller priority values run earlier than conversion functions with larger priority values. Defaults to 100. |

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `TypeError` | If the arguments do not have the appropriate type. |

<br />