Annex v0.2.1 Annex.Data behaviour View Source

Annex.Data defines the callbacks and helpers for data structures used by Annex.

An implementer of the Annex.Layer behaviour must return an Annex.Data implementer from the c:data_type/0 callback.

Link to this section Summary

Types

A module that implements the Annex.Data Behaviour.

Functions

Annex.Data.cast/4 calls cast/3 for an Annex.Data behaviour implementing module.

Given a type, data, and a target_shape converts the data to the type and target_shape

Given a type (Data implementing module) and some data returns true or false if the data is of the correct type.

Given an Annex.Data type and the data returns the shape of the data.

Flattens an Annex.Data into a list of floats via Enum.into/2.

Flattens an Annex.Data into a list of floats via the type's callback.

Link to this section Types

Link to this type

flat_data() View Source
flat_data() :: [float(), ...]

A module that implements the Annex.Data Behaviour.

Link to this section Functions

Link to this function

apply_op(data, name, args) View Source
apply_op(data(), any(), [any()]) :: data()

Link to this function

apply_op(type, data, name, args) View Source
apply_op(module(), data(), any(), [any()]) :: data()

Annex.Data.cast/4 calls cast/3 for an Annex.Data behaviour implementing module.

Valid shapes are a non-empty tuple of positive integers or any the atom :any. e.g. {2, 3} or {3, :any}

Link to this function

convert(type, data, target_shape) View Source

Given a type, data, and a target_shape converts the data to the type and target_shape

If the data matches the type and the data_shape matches the target_shape the data is returned unaltered.

If either the type or target_shape do not match the data the data is casted using Data.cast/3.

Link to this function

flat_data_to_tensor(flat_data, shape) View Source

Link to this function

infer_type(item) View Source
infer_type(data()) :: any()

Link to this macro

is_flat_data(data) View Source (macro)

Given a type (Data implementing module) and some data returns true or false if the data is of the correct type.

Calls is_type?/1 of the type.

Given an Annex.Data type and the data returns the shape of the data.

The shape of data is used to cast between the expected shapes from one Annex.Layer to the next or from one Annex.Sequence to the next.

Flattens an Annex.Data into a list of floats via Enum.into/2.

Link to this function

to_flat_list(type, data) View Source
to_flat_list(type(), data()) :: Annex.Data.flat_data()

Flattens an Annex.Data into a list of floats via the type's callback.

Link to this section Callbacks

Link to this callback

apply_op(data, op, args) View Source
apply_op(data(), op(), args()) :: data()

Link to this callback

is_type?(any) View Source
is_type?(any()) :: boolean()

Link to this callback

to_flat_list(data) View Source
to_flat_list(data()) :: [float()]