[Relay] clip operator with dynamic min/max fails

I tried to compile Pytorch model which uses clamp(min, max) operator (Relay.clip) with max parameter equal to input image width. relay.frontend.from_pytorch fails to convert such model.

To reproduce the issue:

import torch
import tvm
from tvm import relay

class Net(torch.nn.Module):
    def __init__(self):
        super(Net, self).__init__()
    def forward(self, a):
        amax = a.shape[1] / 10.0
        b = a.clamp(min=0, max=amax)
        return b

a = torch.tensor([[9,8,7,1],[7,2,5,4]]) / 10.0
net = Net()
net(a)

traced_net = torch.jit.trace(net, (a))

shape_list = [("input0", [2,4])]
mod, params = relay.frontend.from_pytorch(traced_net, shape_list)

Error:

>>> mod, params = relay.frontend.from_pytorch(traced_net, shape_list)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/pivovaa/workspace/tvm/python/tvm/relay/frontend/pytorch.py", line 3253, in from_pytorch
    ret = converter.convert_operators(_get_operator_nodes(graph.nodes()), outputs, ret_name)[0]
  File "/Users/pivovaa/workspace/tvm/python/tvm/relay/frontend/pytorch.py", line 2674, in convert_operators
    relay_out = relay_op(
  File "/Users/pivovaa/workspace/tvm/python/tvm/relay/frontend/pytorch.py", line 1693, in clamp
    return _op.clip(data, amin, amax)
  File "/Users/pivovaa/workspace/tvm/python/tvm/relay/op/tensor.py", line 1059, in clip
    return _make.clip(a, a_min, a_max)
  File "/Users/pivovaa/workspace/tvm/python/tvm/_ffi/_ctypes/packed_func.py", line 237, in __call__
    raise get_last_ffi_error()
tvm._ffi.base.TVMError: Traceback (most recent call last):
  File "/Users/pivovaa/workspace/tvm/include/tvm/runtime/packed_func.h", line 721
TVMError: In function relay.op._make.clip: error while converting argument 2: [13:26:04] /Users/pivovaa/workspace/tvm/include/tvm/runtime/packed_func.h:501: ---------------------------------------------------------------
An internal invariant was violated during the execution of TVM.
Please read TVM's error reporting guidelines.
More details can be found here: https://discuss.tvm.ai/t/error-reporting/7793.
---------------------------------------------------------------

  Check failed: type_code_ == kDLFloat: expected float but got Object

What should be done to support dynamic max parameter in Relay.clip operator?

Current clamp() impl in relay/frontend/pytorch.py

The fix for the issue [torch] Use try_infer_value for clamp min/max by apivovarov · Pull Request #7712 · apache/tvm · GitHub