Skip to content

Commit 117ebff

Browse files
committed
add
1 parent 69494f7 commit 117ebff

File tree

2 files changed

+36
-16
lines changed

2 files changed

+36
-16
lines changed

_unittests/ut_reference/test_torch_onnx_evaluator.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,42 @@ def test_conv_autopad_valid(self):
11931193
B = torch.tensor([[[[0]]]], dtype=torch.float32)
11941194
self._finalize_test(model, X, W, B, use_ort=True)
11951195

1196+
def test_conv_autopad_upper(self):
1197+
model = oh.make_model(
1198+
oh.make_graph(
1199+
[
1200+
oh.make_node(
1201+
"Conv",
1202+
["X", "W", "B"],
1203+
["Y"],
1204+
dilations=[1, 1],
1205+
strides=[2, 2],
1206+
auto_pad="SAME_UPPER",
1207+
)
1208+
],
1209+
"g",
1210+
[
1211+
oh.make_tensor_value_info("X", TFLOAT, [None, None, None, None]),
1212+
oh.make_tensor_value_info("W", TFLOAT, [None, None, None, None]),
1213+
oh.make_tensor_value_info("B", TFLOAT, [None, None, None, None]),
1214+
],
1215+
[oh.make_tensor_value_info("Y", TFLOAT, [None, None, None, None])],
1216+
),
1217+
opset_imports=[oh.make_opsetid("", 18)],
1218+
ir_version=10,
1219+
)
1220+
sH, sW = 5, 5
1221+
i = sH // 2
1222+
j = sW // 2
1223+
X = torch.zeros((1, 1, sH, sW), dtype=torch.float32)
1224+
X[0, 0, i, j] = 1.0
1225+
W = torch.zeros((1, 1, 3, 3), dtype=torch.float32)
1226+
W[0, 0, :, :] = torch.minimum(
1227+
2 ** torch.arange(9).reshape((3, -1)), torch.tensor([256])
1228+
)
1229+
B = torch.tensor([[[[0]]]], dtype=torch.float32)
1230+
self._finalize_test(model, X, W, B, use_ort=True)
1231+
11961232
def test_nonzero(self):
11971233
model = oh.make_model(
11981234
oh.make_graph(

onnx_diagnostic/reference/torch_ops/access_ops.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from typing import Optional
22
import onnx
3-
import numpy as np
43
import torch
54
from . import OpRun, OpRunTensor
65

@@ -29,21 +28,6 @@ def __init__(self, node: onnx.NodeProto, version: Optional[int] = None):
2928
super().__init__(node, version)
3029
self.reduction = self.get_attribute_string(node, "reduction", "none")
3130

32-
def _scatter_nd_impl(data, indices, updates, reduction=None): # type: ignore
33-
output = np.copy(data)
34-
for i in np.ndindex(indices.shape[:-1]):
35-
if reduction == "add":
36-
output[tuple(indices[i])] += updates[i]
37-
elif reduction == "mul":
38-
output[tuple(indices[i])] *= updates[i]
39-
elif reduction == "max":
40-
output[tuple(indices[i])] = np.maximum(output[indices[i]], updates[i])
41-
elif reduction == "min":
42-
output[tuple(indices[i])] = np.minimum(output[indices[i]], updates[i])
43-
else:
44-
output[tuple(indices[i])] = updates[i]
45-
return output
46-
4731
def run(
4832
self, data: OpRunTensor, indices: OpRunTensor, updates: OpRunTensor
4933
) -> OpRunTensor:

0 commit comments

Comments
 (0)