From 43f2500c26e026ed9c6e4e529f101e7f092f89de Mon Sep 17 00:00:00 2001 From: tigertang Date: Wed, 18 Nov 2020 14:36:12 +0800 Subject: [PATCH 1/3] Add symbolic for SwishJitAutoFn to support onnx --- timm/models/layers/activations_me.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/timm/models/layers/activations_me.py b/timm/models/layers/activations_me.py index 0441f7c4..d1b9de5a 100644 --- a/timm/models/layers/activations_me.py +++ b/timm/models/layers/activations_me.py @@ -30,6 +30,9 @@ class SwishJitAutoFn(torch.autograd.Function): Inspired by conversation btw Jeremy Howard & Adam Pazske https://twitter.com/jeremyphoward/status/1188251041835315200 """ + @staticmethod + def symbolic(g, x): + return g.op("Mul", x, g.op("Sigmoid", x)) @staticmethod def forward(ctx, x): From 7a4be5c035166e0d0fd037c4f834a3fb39433b7a Mon Sep 17 00:00:00 2001 From: hwangdeyu Date: Tue, 2 Feb 2021 18:02:41 +0800 Subject: [PATCH 2/3] add operator HardSwishJitAutoFn export to onnx --- timm/models/layers/activations_me.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/timm/models/layers/activations_me.py b/timm/models/layers/activations_me.py index 0441f7c4..29bc0863 100644 --- a/timm/models/layers/activations_me.py +++ b/timm/models/layers/activations_me.py @@ -152,6 +152,13 @@ class HardSwishJitAutoFn(torch.autograd.Function): x = ctx.saved_tensors[0] return hard_swish_jit_bwd(x, grad_output) + @staticmethod + def symbolic(g, self): + input = g.op("Add", self, g.op('Constant', value_t=torch.tensor(3, dtype=torch.float))) + hardtanh_ = g.op("Clip", input, g.op('Constant', value_t=torch.tensor(0, dtype=torch.float)), g.op('Constant', value_t=torch.tensor(6, dtype=torch.float))) + hardtanh_ = g.op("Div", hardtanh_, g.op('Constant', value_t=torch.tensor(6, dtype=torch.float))) + return g.op("Mul", self, hardtanh_) + def hard_swish_me(x, inplace=False): return HardSwishJitAutoFn.apply(x) From 3a7aa95f7e5fc90a6a2683c756e854e26201d82e Mon Sep 17 00:00:00 2001 From: Ross Wightman Date: Fri, 5 Feb 2021 07:39:21 -0800 Subject: [PATCH 3/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1cb5182f..1b34d7cf 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## What's New -### Jan 30, 2012 +### Jan 30, 2021 * Add initial "Normalization Free" NF-RegNet-B* and NF-ResNet model definitions based on [paper](https://arxiv.org/abs/2101.08692) ### Jan 25, 2021