The documentation for torch.clip mentions that it is an alias of torch.clamp but there is no decomposition defined for torch.clip in torch/_decomp/
In the exported IR, thus a torch.clip gets exported as torch.ops.aten.clip.default(...)
I’m wondering if a decomposition should be added so backends only have to support clamp.
Currently, we’re seeing failures when importing a Module with torch.clip in it via Torch-MLIR. Lowering it to StableHLO fails as there isn’t suppport for clip
Hi!
torch/_decomp does not contain decompositions between aliases (clip/clamp, abs/absolute, div/divide, acos/arccos, …). Same thing for torch._refs. So this problem is broader than just clip.
From what I understand, the mapping from a function to its alias is either in the function’s code, or in torch/csrc/jit/passes/normalize_ops.cpp in:
const std::unordered_map<Symbol, Symbol>& getOperatorAliasMap() {
// map from op alias -> normalized op
static const std::unordered_map<Symbol, Symbol> alias_map = {
{aten::absolute, aten::abs},
{aten::absolute_, aten::abs_},
{aten::clip, aten::clamp},
...
But this is only used by jit and probably your export didn’t use this mapping at all. There’s a recent issue about standardizing how aliases are handled, which I think is very related to your problem. Maybe you could post a reproducer there for your exact problem.
Hi,
Thanks for the prompt response, I’ll take a look at your link.