Skip to main content
Muna supports a fixed set of input and output value types for compiled models. Below are supported type annotations:
Floating-point input and return values should be annotated with the float built-in type.
Unlike Python which defaults to 64-bit floats, Muna will always lower a Python float to 32 bits.
For control over the binary width of the number, use the numpy.float[16,32,64] types:
Integer input and return values should be annotated with the int built-in type.
Unlike Python which supports arbitrary-precision integers, Muna will always lower a Python int to 32 bits.
For control over the binary width of the integer, use the numpy.int[8,16,32,64] types:
Boolean input and return values must be annotated with the bool built-in type.
Tensor input and return values must be annotated with the NumPy numpy.typing.NDArray[T] type, where T is the tensor element type.
You can also annotate with the np.ndarray type, but doing so will always assume a float32 element type (following PyTorch semantics).
Below are the supported element types:
Muna does not yet support complex numbers or tensors.
Muna only supports, and will always assume, little-endian ordering for multi-byte element types.
String input and return values must be annotated with the str built-in type.
List input and return values must be annotated with the list[T] built-in type, where T is the element type.
When the list element type T is a Pydantic BaseModel, a full JSON schema will be generated.
Providing an element type T is optional but strongly recommended because it is used to generate a schema for the parameter or return value.
Dictionary input and return values can be annotated in one of two ways:
  1. Using a Pydantic BaseModel subclass.
  2. Using the dict[str, T] built-in type.
We strongly recommend the Pydantic BaseModel annotation, as it allows us to generate a full JSON schema.
When using the dict annotation, they key type must be str. The value type T can be any arbitrary type.
Image input and return values must be annotated with the Pillow PIL.Image.Image type.
Binary input and return values can be annotated in one of three ways:
  1. Using the bytes built-in type.
  2. Using the bytearray built-in type.
  3. Using the io.BytesIO type.