Metal Inline Functions

Hi! How to define and call an inline function in Metal? Or simple function that will return some value.

Case:

inline uint index4D(constant _4D& shape,
                    constant uint& n,
                    constant uint& c,
                    constant uint& h,
                    constant uint& w) {
    return n * shape.C * shape.H * shape.W + c * shape.H * shape.W + h * shape.W + w;
}

When I call it in my kernel function I get No matching function for call error.

Thx in advance.

Can you post how you're using this is in a kernel function as well how you're building the library?

@Graphics and Games Engineer

For example:

kernel void test(constant _4D& insh) {
    uint shape = index4D(&insh, 2, 2, 2, 2);
    ...
}

Can you post how you would use it?
Metal Inline Functions
 
 
Q