How to use GPU functions?

In the file memref.cpp, I used the function ‘_mlir_ciface_main_graph’ which was defined in lenet-2.noentry.so. When I complied with the instruction"g++ --std=c++11 -O3 memref.cpp ./lenet-2.noentry.so -o lenet-2.noentry -I $ONNX_MLIR_INCLUDE", the following errors occured :
“./lenet-2.noentry.so: undefined reference to mgpuModuleLoad' ./lenet-2.noentry.so: undefined reference to mgpuStreamSynchronize’
./lenet-2.noentry.so: undefined reference to mgpuLaunchKernel' ./lenet-2.noentry.so: undefined reference to mgpuStreamCreate’
./lenet-2.noentry.so: undefined reference to mgpuModuleUnload' ./lenet-2.noentry.so: undefined reference to mgpuStreamDestroy’
./lenet-2.noentry.so: undefined reference to mgpuMemAlloc' ./lenet-2.noentry.so: undefined reference to mgpuModuleGetFunction’
collect2: error: ld returned 1 exit status”
I checked the file lenet-2.llvmnoentry.mlir, which generated lenet-2.noentry.so, and found several GPU functions (like llvm.func @mgpuStreamCreate() → !llvm.ptr) in it. They were not defined in lenet-2.llvmnoentry.mlir, so how can I use them?

We don’t know what memref.cpp or lenet-2.noentry.so contain, so it is hard to tell. The missing functions are provided by MLIR’s platform-agnostic GPU runtime, implemented by mlir/lib/ExecutionEngine/[Cuda,Rocm]RuntimeWrappers.cpp that are typically built as libmlir_cuda_runtime.so or libmlir_rocm_runtime.so, respectively, when the corresponding backend is enabled. If you don’t already link those into some library and don’t provide your own implementation, I suppose you can link the libraries built by MLIR.

Thank you for your help!