TorchScript allows defining custom C++ or CUDA operators using ATen and registering them for use in scripted models, while ONNX Runtime enables custom operators through a registration API, supporting both C++ and Python function implementations. Exporting TorchScript custom ops to ONNX requires additional steps to map them to existing or new custom ONNX ops.