mlx.data.Buffer.sample_transform

mlx.data.Buffer.sample_transform#

Buffer.sample_transform(self: mlx.data._c.Buffer, func: Callable[[dict], dict]) mlx.data._c.Buffer#

Apply the python function func on whole samples.

The function should return a dictionary of arrays or values that can be cast to arrays (buffers, scalars etc). When used with Stream it can also be used to skip samples by returning an empty dictionary.

This transformation is very powerful but it should be used with caution given that python is slightly plagued by the global interpreter lock. See the Quick Start for more.

Parameters:

func (callable) – The function to apply.