forked from microsoft/onnxscript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextra_opinfo.py
More file actions
727 lines (653 loc) · 23.7 KB
/
extra_opinfo.py
File metadata and controls
727 lines (653 loc) · 23.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
"""
Test data for aten operators which don't exist in PyTorch file:
pytorch/torch/testing/_internal/common_methods_invocations.py.
"""
import functools
import itertools
from typing import Any, List
import torch
from torch import testing as torch_testing
from torch.testing._internal import (
common_dtype,
common_methods_invocations,
common_utils,
)
from torch.testing._internal.opinfo import core as opinfo_core
def sample_inputs__local_scalar_dense(op_info, device, dtype, requires_grad, **kwargs):
del op_info
shapes = (
(),
(1,),
(3,),
(1, 1),
(1, 2),
(2, 1),
(1, 1, 1),
(2, 2, 2),
)
for shape in shapes:
t = torch_testing.make_tensor(
shape,
low=0,
high=1,
device=device,
dtype=dtype,
requires_grad=requires_grad,
**kwargs,
)
yield opinfo_core.SampleInput(t)
def sample_inputs_conv3d(op_info, device, dtype, requires_grad, **kwargs):
del op_info
make_arg = functools.partial(
torch_testing.make_tensor, device=device, dtype=dtype, requires_grad=requires_grad
)
# Ordered as shapes for input, weight, bias,
# and a dict of values of (stride, padding, dilation, groups)
cases: tuple[tuple[int, ...], tuple[int, ...], tuple[int, ...], dict[str, Any]] = ( # type: ignore[assignment]
(
(1, 3, 3, 224, 224),
(32, 3, 3, 3, 3),
None,
{
"stride": (2, 2, 2),
"padding": (1, 1, 1),
"dilation": (1, 1, 1),
"groups": 1,
},
),
(
(2, 4, 3, 56, 56),
(32, 4, 3, 3, 3),
(32,),
{
"stride": (3, 3, 3),
"padding": 2,
"dilation": (1, 1, 1),
"groups": 1,
},
),
)
for input_shape, weight, bias, kwargs in cases: # type: ignore[assignment]
# Batched
yield opinfo_core.SampleInput(
make_arg(input_shape),
args=(make_arg(weight), make_arg(bias) if bias is not None else bias),
kwargs=kwargs,
)
# Unbatched
yield opinfo_core.SampleInput(
make_arg(input_shape[1:]), # type: ignore[index]
args=(make_arg(weight), make_arg(bias) if bias is not None else bias),
kwargs=kwargs,
)
def sample_inputs_convolution(op_info, device, dtype, requires_grad, **kwargs):
del op_info
make_arg = functools.partial(
torch_testing.make_tensor, device=device, dtype=dtype, requires_grad=requires_grad
)
# Ordered as shapes for input, weight, bias,
# and a dict of values of (stride, padding, dilation, groups)
cases: tuple[tuple[int, ...], tuple[int, ...], tuple[int, ...], dict[str, Any]] = ( # type: ignore[assignment]
(
(1, 3, 4),
(3, 3, 3),
(3,),
{
"stride": (2,),
"padding": (2,),
"dilation": (1,),
"transposed": False,
"output_padding": (0,),
"groups": 1,
},
),
(
(1, 3, 4),
(3, 3, 3),
None,
{
"stride": (2,),
"padding": (2,),
"dilation": (1,),
"transposed": True,
"output_padding": (0,),
"groups": 1,
},
),
(
(1, 3, 224, 224),
(32, 3, 3, 3),
None,
{
"stride": (2, 2),
"padding": (1, 1),
"dilation": (1, 1),
"transposed": False,
"output_padding": (0, 0),
"groups": 1,
},
),
(
(1, 3, 3, 224, 224),
(32, 3, 3, 3, 3),
(32,),
{
"stride": (2, 2, 2),
"padding": (1, 1, 1),
"dilation": (1, 1, 1),
"transposed": False,
"output_padding": (0, 0, 0),
"groups": 1,
},
),
# FIXME(jiz): Uncomment out these test data once
# torch 2.0 is released.
# (
# (1, 3, 224, 224, 224),
# (32, 3, 3, 3, 3),
# (32,),
# {
# "stride": (2, 2, 2),
# "padding": (1, 1, 1),
# "dilation": (1, 1, 1),
# "transposed": False,
# "output_padding": (0, 0, 0),
# "groups": 1,
# },
# ),
(
(2, 4, 6, 6),
(4, 1, 3, 3),
(4,),
{
"stride": (3, 2),
"padding": (1, 1),
"dilation": (1, 1),
"transposed": True,
"output_padding": (0, 0),
"groups": 4,
},
),
)
for input_shape, weight, bias, kwargs in cases: # type: ignore[assignment]
yield opinfo_core.SampleInput(
make_arg(input_shape),
args=(make_arg(weight), make_arg(bias) if bias is not None else bias),
kwargs=kwargs,
)
def sample_inputs_layer_norm(op_info, device, dtype, requires_grad, **kwargs):
del op_info # unused
del kwargs
make_arg = functools.partial(
torch_testing.make_tensor, device=device, dtype=dtype, requires_grad=requires_grad
)
# Ordered as input shape, normalized_shape, eps
cases: tuple[tuple[int], tuple[int], float] = ( # type: ignore[assignment]
((1, 2, 3), (1, 2, 3), 0.5),
((2, 2, 3), (2, 3), -0.5),
((1,), (1,), 1e-5),
((1, 2), (2,), 1e-5),
((0, 1), (1,), 1e-5),
)
for input_shape, normalized_shape, eps in cases: # type: ignore[misc]
# Shape of weight and bias should be the same as normalized_shape
weight = make_arg(normalized_shape) # type: ignore[has-type]
bias = make_arg(normalized_shape) # type: ignore[has-type]
yield opinfo_core.SampleInput(
make_arg(input_shape), # type: ignore[has-type]
args=(normalized_shape, weight, bias, eps), # type: ignore[has-type]
)
yield opinfo_core.SampleInput(
make_arg(input_shape), # type: ignore[has-type]
args=(normalized_shape, None, bias, eps), # type: ignore[has-type]
)
yield opinfo_core.SampleInput(
make_arg(input_shape), # type: ignore[has-type]
args=(normalized_shape, weight, None, eps), # type: ignore[has-type]
)
yield opinfo_core.SampleInput(
make_arg(input_shape), # type: ignore[has-type]
args=(normalized_shape, None, None, eps), # type: ignore[has-type]
)
class _TestParamsMaxPoolEmptyStrideBase:
# Adapted from https://github.com/pytorch/pytorch/blob/d6d55f8590eab05d2536756fb4efcfb2d07eb81a/torch/testing/_internal/common_methods_invocations.py#L3203
def __init__(self):
self.kwargs = {
"kernel_size": [3],
"stride": [()],
"ceil_mode": [True, False],
"padding": [0, 1],
"dilation": [1],
}
# fmt: off
self.shapes = [
[1, 2, None], # batch
[2], # channels
[3, 6] # signal
]
# fmt: on
def _gen_shape(self):
for shape in itertools.product(*self.shapes):
# shape[0] is None indicates missing batch dimension
if shape[0] is None:
shape = shape[1:]
yield shape, torch.contiguous_format
# only 2d (N, C, H, W) rank 4 tensors support channels_last memory format
if len(self.shapes) == 4 and len(shape) == 4:
yield shape, torch.channels_last
def _gen_kwargs(self):
keys = self.kwargs.keys()
for values in itertools.product(*self.kwargs.values()):
yield dict(zip(keys, values))
def gen_input_params(self):
yield from itertools.product(self._gen_shape(), self._gen_kwargs())
class _TestParamsMaxPool1dEmptyStride(_TestParamsMaxPoolEmptyStrideBase):
def __init__(self):
super().__init__()
self.kwargs["kernel_size"] += [(3,)]
self.kwargs["stride"] += [(2,)]
self.kwargs["padding"] += [(1,)]
self.kwargs["dilation"] += [(1,)]
class _TestParamsMaxPool2dEmptyStride(_TestParamsMaxPoolEmptyStrideBase):
def __init__(self):
super().__init__()
self.kwargs["kernel_size"] += [(3, 2)]
self.kwargs["stride"] += [(2, 1)]
self.kwargs["padding"] += [(1, 1)]
self.kwargs["dilation"] += [(1, 2)]
self.shapes.append([6])
class _TestParamsMaxPool3dEmptyStride(_TestParamsMaxPoolEmptyStrideBase):
def __init__(self):
super().__init__()
self.kwargs["kernel_size"] += [(3, 2, 3)]
self.kwargs["stride"] += [(2, 1, 2)]
self.kwargs["dilation"] += [(1, 2, 1)]
self.shapes.append([6])
self.shapes.append([5])
def sample_inputs_max_pool_empty_strides(op_info, device, dtype, requires_grad, **kwargs):
make_arg = functools.partial(
torch_testing.make_tensor, device=device, dtype=dtype, requires_grad=False
)
# FIXME: (RuntimeError: non-empty 3D or 4D (batch mode) tensor expected for input)
params_generator_type_dict = {
"max_pool1d": _TestParamsMaxPool1dEmptyStride,
"max_pool2d": _TestParamsMaxPool2dEmptyStride,
"max_pool3d": _TestParamsMaxPool3dEmptyStride,
}
params_generator = params_generator_type_dict[op_info.name]()
for (shape, memory_format), kwargs in params_generator.gen_input_params():
arg = make_arg(shape).to(memory_format=memory_format).requires_grad_(requires_grad)
yield opinfo_core.SampleInput(arg, kwargs=kwargs)
def sample_inputs_max_pool1d_with_indices(op_info, device, dtype, requires_grad, **kwargs):
del op_info
make_arg = functools.partial(
torch_testing.make_tensor, device=device, dtype=dtype, requires_grad=False
)
params_generator = (
common_methods_invocations._TestParamsMaxPool1d() # pylint: disable=protected-access
)
for (shape, memory_format), kwargs in params_generator.gen_input_params():
arg = make_arg(shape).to(memory_format=memory_format).requires_grad_(requires_grad)
yield opinfo_core.SampleInput(arg, kwargs=kwargs)
def sample_inputs_max_pool2d_with_indices(op_info, device, dtype, requires_grad, **kwargs):
del op_info
make_arg = functools.partial(
torch_testing.make_tensor, device=device, dtype=dtype, requires_grad=False
)
params_generator = (
common_methods_invocations._TestParamsMaxPool2d() # pylint: disable=protected-access
)
for (shape, memory_format), kwargs in params_generator.gen_input_params():
arg = make_arg(shape).to(memory_format=memory_format).requires_grad_(requires_grad)
yield opinfo_core.SampleInput(arg, kwargs=kwargs)
def sample_inputs_max_pool3d_with_indices(op_info, device, dtype, requires_grad, **kwargs):
del op_info
make_arg = functools.partial(
torch_testing.make_tensor, device=device, dtype=dtype, requires_grad=False
)
params_generator = (
common_methods_invocations._TestParamsMaxPool3d() # pylint: disable=protected-access
)
for (shape, memory_format), kwargs in params_generator.gen_input_params():
arg = make_arg(shape).to(memory_format=memory_format).requires_grad_(requires_grad)
yield opinfo_core.SampleInput(arg, kwargs=kwargs)
def sample_inputs_native_group_norm(op_info, device, dtype, requires_grad, **kwargs):
del op_info
make_arg = functools.partial(
torch_testing.make_tensor, device=device, dtype=dtype, requires_grad=requires_grad
)
# Ordered as input shape, C,N,HxW, and kwargs for group and eps
cases = (
((1, 6, 3), (6,), (6,), 1, 6, 3, {"group": 2, "eps": 0.5}),
((2, 6, 3), (6,), (6,), 2, 6, 3, {"group": 3, "eps": -0.5}),
((5, 5, 5), (5,), (5,), 5, 5, 5, {"group": 1, "eps": 1e-5}),
((5, 8, 10), (8,), (8,), 5, 8, 10, {"group": 4, "eps": 1e-5}),
)
for input_shape, weight, bias, N, C, HxW, kwargs in cases:
# args: running mean, running var, weight and bias should necessarily be of shape: (channels,)
channels = input_shape[1] if len(input_shape) > 1 else 0
weight = make_arg(channels) if channels > 0 else None
bias = make_arg(channels) if channels > 0 else None
yield opinfo_core.SampleInput(
make_arg(input_shape),
args=(
weight,
bias,
N,
C,
HxW,
),
kwargs=kwargs,
)
def sample_inputs_col2im(op_info, device, dtype, requires_grad, **kwargs):
del op_info
# input_shape, output_size, kernal, dilation, padding, stride
cases = (
(
(1, 12, 12),
(4, 5),
(2, 2),
{"dilation": (1, 1), "padding": (0, 0), "stride": (1, 1)},
),
(
(1, 8, 30),
(4, 5),
(2, 2),
{"dilation": (1, 1), "padding": (1, 1), "stride": (1, 1)},
),
(
(1, 8, 9),
(4, 4),
(2, 2),
{"dilation": (1, 1), "padding": (0, 0), "stride": (1, 1)},
),
(
(1, 8, 25),
(4, 4),
(2, 2),
{"dilation": (1, 1), "padding": (1, 1), "stride": (1, 1)},
),
(
(1, 8, 9),
(4, 4),
(2, 2),
{"dilation": (1, 1), "padding": (1, 1), "stride": (2, 2)},
),
(
(1, 9, 4),
(4, 4),
(3, 3),
{"dilation": (1, 1), "padding": (1, 1), "stride": (2, 2)},
),
(
(1, 18, 16),
(2, 2),
(1, 1),
{"dilation": (2, 2), "padding": (3, 3), "stride": (2, 2)},
),
)
make_arg = functools.partial(
torch_testing.make_tensor, device=device, dtype=dtype, requires_grad=requires_grad
)
for shape, output_size, kernel_size, kwargs in cases:
tensor = make_arg(shape)
yield opinfo_core.SampleInput(tensor, args=(output_size, kernel_size), kwargs=kwargs)
def sample_inputs_stft(op_info, device, dtype, requires_grad, **kwargs):
del op_info
del kwargs
def mt(shape, **kwargs):
return torch_testing.make_tensor(
shape, device=device, dtype=dtype, requires_grad=requires_grad, **kwargs
)
yield opinfo_core.SampleInput(mt(100), n_fft=10, return_complex=True)
yield opinfo_core.SampleInput(mt(100), n_fft=10, return_complex=False)
if dtype.is_complex:
yield opinfo_core.SampleInput(mt(100), n_fft=10)
yield opinfo_core.SampleInput(mt(10), n_fft=7, return_complex=True)
yield opinfo_core.SampleInput(mt((10, 100)), n_fft=16, hop_length=4, return_complex=True)
window = mt(16, low=0.5, high=2.0)
yield opinfo_core.SampleInput(
mt((2, 100)), kwargs=dict(n_fft=16, window=window, return_complex=True)
)
yield opinfo_core.SampleInput(
mt((3, 100)), kwargs=dict(n_fft=16, window=window, return_complex=True)
)
if not dtype.is_complex:
yield opinfo_core.SampleInput(
mt((10, 100)), n_fft=16, window=window, onesided=False, return_complex=True
)
def sample_inputs_tensor_bool(op_info, device, dtype, requires_grad, **kwargs):
del op_info
del device
del requires_grad
del kwargs
yield opinfo_core.SampleInput(True, dtype=dtype)
yield opinfo_core.SampleInput(False, dtype=dtype)
def sample_inputs_tensor_float(op_info, device, dtype, requires_grad, **kwargs):
del op_info
del device
del requires_grad
del kwargs
yield opinfo_core.SampleInput(3.0, dtype=dtype)
yield opinfo_core.SampleInput(-1.0, dtype=dtype)
def sample_inputs_tensor_int(op_info, device, dtype, requires_grad, **kwargs):
del op_info
del device
del requires_grad
del kwargs
yield opinfo_core.SampleInput(2, dtype=dtype)
yield opinfo_core.SampleInput(-5, dtype=dtype)
def sample_inputs_bernoulli_p(op_info, device, dtype, requires_grad, **kwargs):
del op_info
shapes = [
[3],
[],
[3, 2],
[2, 3, 2],
]
for shape in shapes:
for p in (0, 0.5, 1):
t = torch_testing.make_tensor(
shape,
low=0,
high=1,
device=device,
dtype=dtype,
requires_grad=requires_grad,
**kwargs,
)
yield opinfo_core.SampleInput(t, args=(p,))
yield opinfo_core.SampleInput(t, kwargs={"p": p})
def sample_inputs_bernoulli_p_deterministic(op_info, device, dtype, requires_grad, **kwargs):
del op_info
shapes = [
[3],
[],
[3, 2],
[2, 3, 2],
]
for shape in shapes:
for p in (0, 1):
t = torch_testing.make_tensor(
shape,
low=0,
high=1,
device=device,
dtype=dtype,
requires_grad=requires_grad,
**kwargs,
)
yield opinfo_core.SampleInput(t, args=(p,))
yield opinfo_core.SampleInput(t, kwargs={"p": p})
OP_DB: List[opinfo_core.OpInfo] = [
opinfo_core.OpInfo(
"aten._local_scalar_dense",
# pylint: disable=protected-access
op=torch.ops.aten._local_scalar_dense,
aten_name="_local_scalar_dense",
dtypes=common_dtype.all_types(),
sample_inputs_func=sample_inputs__local_scalar_dense,
),
opinfo_core.OpInfo(
"col2im",
op=torch.ops.aten.col2im,
aten_name="col2im",
dtypes=common_dtype.floating_and_complex_types_and(torch.half, torch.bfloat16),
sample_inputs_func=sample_inputs_col2im,
supports_out=False,
),
opinfo_core.OpInfo(
"convolution",
aliases=("convolution",),
aten_name="convolution",
dtypes=common_dtype.floating_and_complex_types_and(torch.int64, torch.bfloat16),
sample_inputs_func=sample_inputs_convolution,
supports_forward_ad=True,
supports_fwgrad_bwgrad=True,
gradcheck_nondet_tol=common_utils.GRADCHECK_NONDET_TOL,
skips=(),
supports_out=False,
),
opinfo_core.OpInfo(
"layer_norm",
aliases=("layer_norm",),
aten_name="layer_norm",
dtypes=common_dtype.floating_and_complex_types_and(torch.int64, torch.bfloat16),
sample_inputs_func=sample_inputs_layer_norm,
supports_forward_ad=True,
supports_fwgrad_bwgrad=True,
gradcheck_nondet_tol=common_utils.GRADCHECK_NONDET_TOL,
skips=(),
supports_out=False,
),
opinfo_core.OpInfo(
"native_group_norm",
op=torch.ops.aten.native_group_norm,
aten_name="native_group_norm",
dtypes=common_dtype.floating_and_complex_types_and(torch.half, torch.bfloat16),
sample_inputs_func=sample_inputs_native_group_norm,
supports_out=False,
),
opinfo_core.OpInfo(
"max_pool1d",
variant_test_name="empty_strides",
op=torch.ops.aten.max_pool1d,
aten_name="max_pool1d",
dtypes=common_dtype.floating_types_and(torch.bfloat16),
sample_inputs_func=sample_inputs_max_pool_empty_strides,
),
opinfo_core.OpInfo(
"max_pool2d",
variant_test_name="empty_strides",
op=torch.ops.aten.max_pool2d,
aten_name="max_pool2d",
dtypes=common_dtype.floating_types_and(torch.bfloat16),
sample_inputs_func=sample_inputs_max_pool_empty_strides,
),
opinfo_core.OpInfo(
"max_pool3d",
variant_test_name="empty_strides",
op=torch.ops.aten.max_pool3d,
aten_name="max_pool3d",
dtypes=common_dtype.floating_types_and(torch.bfloat16),
sample_inputs_func=sample_inputs_max_pool_empty_strides,
),
opinfo_core.OpInfo(
"nn.functional.conv3d",
aliases=("conv3d",),
aten_name="conv3d",
dtypes=common_dtype.floating_and_complex_types_and(torch.int64, torch.bfloat16),
sample_inputs_func=sample_inputs_conv3d,
supports_forward_ad=True,
supports_fwgrad_bwgrad=True,
gradcheck_nondet_tol=common_utils.GRADCHECK_NONDET_TOL,
skips=(),
supports_out=False,
),
opinfo_core.OpInfo(
"nn.functional.max_pool1d_with_indices",
aten_name="max_pool1d_with_indices",
supports_forward_ad=True,
supports_fwgrad_bwgrad=True,
dtypes=common_dtype.floating_types_and(torch.bfloat16),
skips=(),
sample_inputs_func=sample_inputs_max_pool1d_with_indices,
),
opinfo_core.OpInfo(
"nn.functional.max_pool2d_with_indices",
aten_name="max_pool2d_with_indices",
supports_forward_ad=True,
supports_fwgrad_bwgrad=True,
dtypes=common_dtype.floating_types_and(torch.bfloat16),
skips=(),
sample_inputs_func=sample_inputs_max_pool2d_with_indices,
),
opinfo_core.OpInfo(
"nn.functional.max_pool3d_with_indices",
aten_name="max_pool3d_with_indices",
supports_forward_ad=True,
supports_fwgrad_bwgrad=True,
dtypes=common_dtype.floating_types_and(torch.bfloat16),
skips=(),
sample_inputs_func=sample_inputs_max_pool3d_with_indices,
),
# NOTE: torch.STFT has pre-padding and it's not supported by aten::stft
# This custom OpInfo uses aten::stft directly.
opinfo_core.OpInfo(
"aten.stft",
aten_name="stft",
op=torch.ops.aten.stft,
dtypes=common_dtype.floating_and_complex_types_and(torch.half, torch.bfloat16),
sample_inputs_func=sample_inputs_stft,
# Runs very slowly on slow gradcheck - alternatively reduce input sizes
gradcheck_fast_mode=True,
supports_forward_ad=True,
supports_fwgrad_bwgrad=True,
check_batched_forward_grad=False,
check_batched_grad=False,
check_batched_gradgrad=False,
supports_out=False,
gradcheck_nondet_tol=common_utils.GRADCHECK_NONDET_TOL,
),
opinfo_core.OpInfo(
"aten.tensor.bool",
aten_name="tensor.bool",
op=torch.ops.aten.tensor.bool,
dtypes=common_dtype.all_types_and(torch.half, torch.bfloat16),
sample_inputs_func=sample_inputs_tensor_bool,
),
opinfo_core.OpInfo(
"aten.tensor.float",
aten_name="tensor.float",
op=torch.ops.aten.tensor.float,
dtypes=common_dtype.all_types_and(torch.half, torch.bfloat16),
sample_inputs_func=sample_inputs_tensor_float,
),
opinfo_core.OpInfo(
"aten.tensor.int",
aten_name="tensor.int",
op=torch.ops.aten.tensor.int,
dtypes=common_dtype.all_types_and(torch.half, torch.bfloat16),
sample_inputs_func=sample_inputs_tensor_int,
),
opinfo_core.OpInfo(
# Unique ID used to connect
# TorchLibOpInfo("aten.bernoulli.p", ...)
# and
# opinfo_core.OpInfo("aten.bernoulli.p", ...)
"aten.bernoulli.p",
aten_name="bernoulli.p",
op=torch.ops.aten.bernoulli.p,
# dtypes can be a tuple of (torch.float, torch.double).
dtypes=common_dtype.all_types(),
sample_inputs_func=sample_inputs_bernoulli_p,
),
opinfo_core.OpInfo(
# Deterministic bernoulli sampling where p is either 0 or 1
"aten.bernoulli.p_deterministic",
aten_name="bernoulli.p",
op=torch.ops.aten.bernoulli.p,
dtypes=common_dtype.all_types(),
sample_inputs_func=sample_inputs_bernoulli_p_deterministic,
),
]