Thanks for your kind reminder and here are my double checks.
First, the setup file is
from setuptools import setup
from torch.utils.cpp_extension import CppExtension, BuildExtension

setup(name='lr_batch_c',
      ext_modules=[CppExtension('lr_batch_c', ['lr_batch.cpp'])],
      cmdclass={'build_ext': BuildExtension})

and I saw flags -DNDEBUG -O3 when using python setup.py build_ext --inplace to compile the cpp file.
Second, except the explicit transferring of x, y to cuda, all other operations are using standard pytorch api’s and those operations should runs on CUDA, right?