I am trying to build a custom layer for my neural network that can perform its computation on the GPU. The function is to be written in C and loaded in Mathematica via the LibraryLink. Is it possible to use this function directly with CompiledLayer?
The last line in the documentation says "CompiledLayer does not yet compile to GPU architectures. When setting TargetDevice -> 'GPU', both training and inference will happen on the CPU." However, in my case since the function will already be compiled, technically, it should be possible run it with compiled layer. I have not yet tried this, but if anyone has tried, please let me know how this works.
Edit: I tried building a CompiledLayer with an external function:
myFuncc =
FunctionCompile@
Function[{Typed[a1, TypeSpecifier["NumericArray"]["Real32", 3]],
Typed[a2, TypeSpecifier["NumericArray"]["Real32", 3]]},
libraryAdd[a1, a2]]
Context: Symbol or string expected at position 1 in \
Context[LibraryFunction[/Users/som/Developer/MyLinkLib/libMyLink.dylib,addArrays,{{NumericArray,\
Shared},{NumericArray,Shared}},NumericArray]].
Compile: TypeError. Cannot find a definition for LibraryFunction[Function name: addArrays
Argument count: 2
]
So, can anyone suggest ideas to get around this?