# tfio.experimental.IOTensor

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/io/blob/v0.24.0/tensorflow_io/python/experimental/io_tensor.py#L22-L42) |

IOTensor

Inherits From: [`IOTensor`](https://www.tensorflow.org/io/api_docs/python/tfio/IOTensor)

    tfio.experimental.IOTensor(
        spec, internal=False
    )

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `spec` | The `TensorSpec` of values in this tensor. |

<br />

## Methods

### `from_arrow`

[View source](https://github.com/tensorflow/io/blob/v0.24.0/tensorflow_io/python/ops/io_tensor.py#L326-L344)

    @classmethod
    from_arrow(
        table, spec=None, **kwargs
    )

Creates an `IOTensor` from a pyarrow.Table.

<br />

<br />

<br />

| Args ||
|---|---|
| `table` | An instance of a `pyarrow.Table`. |
| `spec` | A dict of `dataset:tf.TensorSpec` or `dataset:dtype` pairs that specify the dataset selected and the tf.TensorSpec or dtype of the dataset. In eager mode the spec is probed automatically. In graph mode `spec` is required and columns in the `pyarrow.Table` can be keyed by column name or index. |
| `name` | A name prefix for the IOTensor (optional). |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| A `IOTensor`. ||

<br />

### `from_audio`

[View source](https://github.com/tensorflow/io/blob/v0.24.0/tensorflow_io/python/ops/io_tensor.py#L239-L258)

    @classmethod
    from_audio(
        filename, **kwargs
    )

Creates an `IOTensor` from an audio file.

The following audio file formats are supported:

- WAV
- Flac
- Vorbis
- MP3

<br />

<br />

<br />

| Args ||
|---|---|
| `filename` | A string, the filename of an audio file. |
| `name` | A name prefix for the IOTensor (optional). |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| A `IOTensor`. ||

<br />

### `from_avro`

[View source](https://github.com/tensorflow/io/blob/v0.24.0/tensorflow_io/python/ops/io_tensor.py#L395-L411)

    @classmethod
    from_avro(
        filename, schema, **kwargs
    )

Creates an `IOTensor` from an avro file.

<br />

<br />

<br />

| Args ||
|---|---|
| `filename` | A string, the filename of an avro file. |
| `schema` | A string, the schema of an avro file. |
| `name` | A name prefix for the IOTensor (optional). |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| A `IOTensor`. ||

<br />

### `from_csv`

[View source](https://github.com/tensorflow/io/blob/v0.24.0/tensorflow_io/python/ops/io_tensor.py#L380-L393)

    @classmethod
    from_csv(
        filename, **kwargs
    )

Creates an `IOTensor` from an csv file.

<br />

<br />

<br />

| Args ||
|---|---|
| `filename` | A string, the filename of an csv file. |
| `name` | A name prefix for the IOTensor (optional). |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| A `IOTensor`. ||

<br />

### `from_exr`

[View source](https://github.com/tensorflow/io/blob/v0.24.0/tensorflow_io/python/experimental/io_tensor.py#L29-L42)

    @classmethod
    from_exr(
        filename, **kwargs
    )

Creates an `IOTensor` from a OpenEXR file.

<br />

<br />

<br />

| Args ||
|---|---|
| `filename` | A string, the filename of a OpenEXR file. |
| `name` | A name prefix for the IOTensor (optional). |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| A `IOTensor`. ||

<br />

### `from_feather`

[View source](https://github.com/tensorflow/io/blob/v0.24.0/tensorflow_io/python/ops/io_tensor.py#L311-L324)

    @classmethod
    from_feather(
        filename, **kwargs
    )

Creates an `IOTensor` from an feather file.

<br />

<br />

<br />

| Args ||
|---|---|
| `filename` | A string, the filename of an feather file. |
| `name` | A name prefix for the IOTensor (optional). |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| A `IOTensor`. ||

<br />

### `from_ffmpeg`

[View source](https://github.com/tensorflow/io/blob/v0.24.0/tensorflow_io/python/ops/io_tensor.py#L413-L426)

    @classmethod
    from_ffmpeg(
        filename, **kwargs
    )

Creates an `IOTensor` from a audio/video file.

<br />

<br />

<br />

| Args ||
|---|---|
| `filename` | A string, the filename of a audio/video file. |
| `name` | A name prefix for the IOTensor (optional). |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| A `IOTensor`. ||

<br />

### `from_hdf5`

[View source](https://github.com/tensorflow/io/blob/v0.24.0/tensorflow_io/python/ops/io_tensor.py#L361-L378)

    @classmethod
    from_hdf5(
        filename, spec=None, **kwargs
    )

Creates an `IOTensor` from an hdf5 file.

<br />

<br />

<br />

| Args ||
|---|---|
| `filename` | A string, the filename of an hdf5 file. |
| `spec` | A dict of `dataset:tf.TensorSpec` or `dataset:dtype` pairs that specify the dataset selected and the tf.TensorSpec or dtype of the dataset. In eager mode the spec is probed automatically. In graph mode spec has to be specified. |
| `name` | A name prefix for the IOTensor (optional). |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| A `IOTensor`. ||

<br />

### `from_json`

[View source](https://github.com/tensorflow/io/blob/v0.24.0/tensorflow_io/python/ops/io_tensor.py#L260-L275)

    @classmethod
    from_json(
        filename, **kwargs
    )

Creates an `IOTensor` from an json file.

<br />

<br />

<br />

| Args ||
|---|---|
| `filename` | A string, the filename of an json file. |
| `name` | A name prefix for the IOTensor (optional). |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| A `IOTensor`. ||

<br />

### `from_kafka`

[View source](https://github.com/tensorflow/io/blob/v0.24.0/tensorflow_io/python/ops/io_tensor.py#L277-L309)

    @classmethod
    from_kafka(
        topic, partition=0, servers=None, configuration=None, **kwargs
    )

Creates an `IOTensor` from a Kafka stream.

<br />

<br />

<br />

| Args ||
|---|---|
| `topic` | A [`tf.string`](https://www.tensorflow.org/api_docs/python/tf#string) tensor containing topic subscription. |
| `partition` | A [`tf.int64`](https://www.tensorflow.org/api_docs/python/tf#int64) tensor containing the partition, by default 0. |
| `servers` | An optional list of bootstrap servers, by default `localhost:9092`. |
| `configuration` | An optional [`tf.string`](https://www.tensorflow.org/api_docs/python/tf#string) tensor containing configurations in \[Key=Value\] format. There are three types of configurations: Global configuration: please refer to 'Global configuration properties' in librdkafka doc. Examples include \["enable.auto.commit=false", "heartbeat.interval.ms=2000"\] Topic configuration: please refer to 'Topic configuration properties' in librdkafka doc. Note all topic configurations should be prefixed with `configuration.topic.`. Examples include \["conf.topic.auto.offset.reset=earliest"\] |
| `name` | A name prefix for the IOTensor (optional). |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| A `IOTensor`. ||

<br />

### `from_lmdb`

[View source](https://github.com/tensorflow/io/blob/v0.24.0/tensorflow_io/python/ops/io_tensor.py#L346-L359)

    @classmethod
    from_lmdb(
        filename, **kwargs
    )

Creates an `IOTensor` from a LMDB key/value store.

<br />

<br />

<br />

| Args ||
|---|---|
| `filename` | A string, the filename of a LMDB file. |
| `name` | A name prefix for the IOTensor (optional). |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| A `IOTensor`. ||

<br />

### `from_parquet`

[View source](https://github.com/tensorflow/io/blob/v0.24.0/tensorflow_io/python/ops/io_tensor.py#L428-L441)

    @classmethod
    from_parquet(
        filename, **kwargs
    )

Creates an `IOTensor` from a parquet file.

<br />

<br />

<br />

| Args ||
|---|---|
| `filename` | A string, the filename of a parquet file. |
| `name` | A name prefix for the IOTensor (optional). |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| A `IOTensor`. ||

<br />

### `from_tensor`

[View source](https://github.com/tensorflow/io/blob/v0.24.0/tensorflow_io/python/ops/io_tensor.py#L218-L237)

    @classmethod
    from_tensor(
        tensor, **kwargs
    )

Converts a [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor) into a `IOTensor`.

#### Examples:

<br />

<br />

<br />

| Args ||
|---|---|
| `tensor` | The `Tensor` to convert. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| A `IOTensor`. ||

<br />

<br />

<br />

<br />

| Raises ||
|---|---|
| `ValueError` | If tensor is not a `Tensor`. |

<br />

### `from_tiff`

[View source](https://github.com/tensorflow/io/blob/v0.24.0/tensorflow_io/python/ops/io_tensor.py#L443-L458)

    @classmethod
    from_tiff(
        filename, **kwargs
    )

Creates an `IOTensor` from a tiff file.

Note tiff file may consists of multiple images with different shapes.

<br />

<br />

<br />

| Args ||
|---|---|
| `filename` | A string, the filename of a tiff file. |
| `name` | A name prefix for the IOTensor (optional). |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| A `IOTensor`. ||

<br />

### `graph`

[View source](https://github.com/tensorflow/io/blob/v0.24.0/tensorflow_io/python/ops/io_tensor.py#L200-L212)

    @classmethod
    graph(
        dtype
    )

Obtain a GraphIOTensor to be used in graph mode.

<br />

<br />

<br />

| Args ||
|---|---|
| `dtype` | Data type of the GraphIOTensor. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| A class of `GraphIOTensor`. ||

<br />