the current ONNX export for relu6 generates a min/max pair (
|
@torch_op("aten::relu6", trace_only=True) |
|
def aten_relu6(self: TReal) -> TReal: |
|
"""relu6(Tensor self) -> Tensor""" |
|
|
|
six = op.CastLike(op.Constant(value_int=6), self) |
|
return op.Min(op.Relu(self), six) |
)
given that ONNX has a Clip layer, Why not use
zero = op.CastLike(op.Constant(value_int=0), self)
six = op.CastLike(op.Constant(value_int=6), self)
return op.Clip(self, zero, six)
instead?
Sure, the sequence is easy to optimize downstream, but generating the Clip layer here makes a lot of sense.
the current ONNX export for relu6 generates a min/max pair (
onnxscript/onnxscript/function_libs/torch_lib/ops/nn.py
Lines 1594 to 1599 in 4cd022b
given that ONNX has a Clip layer, Why not use
instead?
Sure, the sequence is easy to optimize downstream, but generating the Clip layer here makes a lot of sense.