Module Dtype.Image

type kind = image_kind =
  1. | Imageh
  2. | Imagef
    (*

    Image storage kind. Imageh stores half-precision image elements; Imagef stores single-precision image elements. Both have Val.float32 as their loaded base dtype.

    *)
type t = Ptr.t

Image dtype. Images are specialized Ptr.t values, matching tinygrad's ImageDType as a subclass of pointer dtype.

val create : kind -> int list -> t

create kind shape is an image pointer dtype in Global address space with base Val.float32, size equal to the product of shape, pointer vector width 1, and image storage kind kind.

val imageh : int list -> t

imageh shape is create Imageh shape. It has priority 100, bitsize 16, base Val.float32, address space Global, and size = List.fold_left ( * ) 1 shape.

val imagef : int list -> t

imagef shape is create Imagef shape. It has priority 100, bitsize 32, base Val.float32, address space Global, and size = List.fold_left ( * ) 1 shape.

val kind : t -> kind

kind image is the image storage kind.

Raises Invalid_argument if image is not an image pointer dtype.

val shape : t -> int list

shape image is the image shape.

Raises Invalid_argument if image is not an image pointer dtype.

val base : t -> Val.t

base image is Val.float32.

Raises Invalid_argument if image is not an image pointer dtype.

val size : t -> int

size image is the product of shape.

Raises Invalid_argument if image is not an image pointer dtype.

val pitch : t -> int

pitch image is the tinygrad row pitch in bytes, shape[1] * 4 * Ptr.itemsize image, with shape[1] rounded up to 256 pixels on macOS.

Raises Invalid_argument if image is not an image pointer dtype or has fewer than two dimensions.

val addrspace : t -> addr_space

addrspace image is Global.

Raises Invalid_argument if image is not an image pointer dtype.

val vec : int -> t -> t

vec n image is image with pointer vector width n. The image shape and storage kind are preserved.

Raises Invalid_argument if n < 1, if image is already vectorized, or if image is not an image pointer dtype.