TorchScript custom ops with dynamic size() param

I want to write a custom op like Upsample.
y = nn.Upsample(size=x0.size()[2:], mode='bilinear', align_corners=True)(x1)
When I trace it, the TorchScript will record the size as a dynamic size of x0, how can I implement it?
I tried to use IntArrayRef in my custom c++ code, but got some static size number in traced TorchScript.