Skip to content

Commit 960de6c

Browse files
committed
Merge pull request #842 from l-bat:lb/onnx_normalize
2 parents 61ea2e2 + 00d6a27 commit 960de6c

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed
152 Bytes
Binary file not shown.
152 Bytes
Binary file not shown.

testdata/dnn/onnx/generate_onnx_models.py

+13
Original file line numberDiff line numberDiff line change
@@ -1245,3 +1245,16 @@ def forward(self, x):
12451245
x = Variable(torch.randn([1, 1, 3, 4]))
12461246
model = PadCalculation()
12471247
save_data_and_model("calc_pads", x, model, version=11)
1248+
1249+
class NormalizeFusion(nn.Module):
1250+
def forward(self, x):
1251+
mul = x * x
1252+
sum = torch.sum(mul, dim=(1), keepdim=True)
1253+
maximum = torch.clamp(sum, min=1e-8)
1254+
sqrt = torch.sqrt(maximum)
1255+
reciprocal = torch.reciprocal(sqrt)
1256+
return x * reciprocal
1257+
1258+
x = Variable(torch.randn([2, 3]))
1259+
model = NormalizeFusion()
1260+
save_data_and_model("normalize_fusion", x, model)
322 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)