Thank you very much for you reply!
Firstly, according to step 4 in the guide, the Swift implementation must provide the API endpoints specified in the MLCustomLayer interface. So i guess MPS graph can't be used here? Meanwhile, there is no Declaration introduction in MPS graph. It seems little hard to figure out how to use it.
Secondly, id<MTLTexture> in encodeToCommandBuffer is pre-defined. Although Metal supports 3D and 2D array textures, i think we can only use 2D array here, whose pixelFormat = MTLPixelFormatRGBA16Float and depth = 1. I do some tests, the results show that encodeToCommandBuffer can convert the 5-D input to 4-D data automatically. For instance a 5D input data of 16x8x8x32 x32, the converted 4-D data inside the function is width = 32, height = 32, arrayLength=256. However, i'm not fully understand how the convert process happens except the arrayLength seems be calculated by 16x8x8/4. Besides, the grid_sampler function calculation process needs the 5-D input dimension information according to the [official implementation] (https://github.com/pytorch/pytorch/blob/master/aten/src/ATen/native/cuda/GridSampler.cu). I'm not sure how to used the converted 4-D data inside my kernel since the i don't know the relationship before and after tensor conversion.
Topic:
Graphics & Games
SubTopic:
General
Tags: