@zh217 Just to further debug, does the example in https://pytorch.org/tutorials/advanced/torch_script_custom_ops.html 5 starting from "The second flavor of JIT compilation allows you to pass the source code for your custom TorchScript operator as a string. For this, use  torch.utils.cpp_extension.load_inline" work for you?
Also the following minimal Python script should work using PyTorch 1.2.0:
import torch
import torch.utils.cpp_extension

op_source = """
#include <torch/script.h>

torch::Tensor warp_perspective() {
  torch::Tensor output = torch::randn({3, 4});
  return output.clone();
}

static auto registry =
  torch::jit::RegisterOperators("my_ops::warp_perspective", &warp_perspective);
"""

torch.utils.cpp_extension.load_inline(
    name="warp_perspective",
    cpp_sources=op_source,
    is_python_module=False,
    verbose=True,
)

print(torch.ops.my_ops.warp_perspective())