You can take out the data pointers from the arguments of your FFI function (using THCudaTensor_data(state, tensor)), inspect it’s size (assuming it’s contiguous - THCudaTensor_numel(state, tensor)), and pass both these things into your custom kernel. Does that help?