Does MetalPerformanceShader supports int8 computation?

I saw that MPSImage have int8 as a channel format(https://developer.apple.com/documentation/metalperformanceshaders/mpsimagefeaturechannelformat/mpsimagefeaturechannelformatunorm8?language=objc), but seems that textures doesn't support int8 as the data type. Can anyone confirm about whether we can have int8 computation in MPSCNN, e.g. for MPSCNNConvolution, can we use an input image with int8 type? Thanks!


From Metal-Shading-Language-Specification:


2.8 Textures

The texture data type is a handle to one-, two-, or three-dimensional texture data that corresponds to all or a portion of a single mipmap level of a texture. The following templates define specific texture data types:

...


T specifies the color type returned when reading from a texture or the color type specified when writing to the texture. For texture types (except depth texture types), T can be half, float, short, ushort, int, or uint. For depth texture types, T must be float.


Accepted Reply

I think that you're confusing actual texture data (as in: what is in texture memory) and type of values returned by/used by shaders when reading/sampling/writing to a texture. These are often different. And indeed, you can't use int8 values directly when reading from/writing to a texture. But texture itself can have byte-sized components (see also https://forums.developer.apple.com/thread/91339).

Replies

I think that you're confusing actual texture data (as in: what is in texture memory) and type of values returned by/used by shaders when reading/sampling/writing to a texture. These are often different. And indeed, you can't use int8 values directly when reading from/writing to a texture. But texture itself can have byte-sized components (see also https://forums.developer.apple.com/thread/91339).

Thanks very much!