mlx.data.Buffer.rename_key

mlx.data.Buffer.rename_key#

Buffer.rename_key(self: mlx.data._c.Buffer, key: str, output_key: str) mlx.data._c.Buffer#

Rename a sample key.

This is equivalent to

def rename_key(s):
  s[output_key] = s[key]
  del s[key]
  return s

dset = dset.sample_transform(rename_key)

but more efficient and with better error reporting.

Parameters:
  • key (str) – The key to rename.

  • output_key (str) – The value to set key to.