xref: /aosp_15_r20/external/pytorch/torch/_functorch/top_operators_github_usage.py (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1# mypy: ignore-errors
2
3"""
4From https://docs.google.com/spreadsheets/d/12R3nCOLskxPYjjiNkdqy4OdQ65eQp_htebXGODsjSeA/edit#gid=0
5Try to keep this list in sync with that.
6"""
7import operator
8
9
10top_torch = [
11    ("t", 6837449),
12    ("tensor", 585786),
13    ("mode", 462182),
14    ("cat", 394818),
15    ("max", 368038),
16    ("zeros", 329495),
17    ("load", 327756),
18    ("no_grad", 294694),
19    ("save", 265130),
20    ("from_numpy", 243063),
21    ("manual_seed", 165044),
22    ("ones", 153696),
23    ("randn", 150796),
24    ("stack", 133358),
25    ("sum", 130772),
26    ("arange", 98087),
27    ("rand", 94715),
28    ("mean", 88546),
29    ("exp", 73883),
30    ("zeros_like", 72831),
31    ("min", 72248),
32    ("sigmoid", 66798),
33    ("log", 62135),
34    ("matmul", 47811),
35    ("clamp", 45304),
36    ("sqrt", 44911),
37    ("abs", 43535),
38    ("tanh", 42793),
39    ("empty", 40311),
40    ("argmax", 38435),
41    ("bmm", 33984),
42    ("pow", 33571),
43    ("norm", 31125),
44    ("mm", 30995),
45    ("is_tensor", 29546),
46    ("ones_like", 29512),
47    ("nonzero", 28681),
48    ("full", 28373),
49    ("unsqueeze", 27911),
50    ("where", 26585),
51    ("randperm", 26450),
52    ("eye", 24342),
53    ("mul", 23236),
54    ("topk", 22537),
55    ("as_tensor", 21967),
56    ("sort", 21412),
57    ("squeeze", 20863),
58    ("randint", 20771),
59    ("linspace", 20041),
60    ("add", 19201),
61    ("transpose", 18663),
62    ("split", 18325),
63    ("gather", 17904),
64    ("set_grad_enabled", 16013),
65    ("sin", 15669),
66    ("cos", 15562),
67    ("div", 15513),
68    ("index_select", 14866),
69    ("multinomial", 14331),
70    ("flatten", 14267),
71    ("isnan", 14170),
72    ("randn_like", 13096),
73    ("eq", 12680),
74    ("einsum", 12480),
75    ("round", 12367),
76    ("floor", 11628),
77    ("allclose", 11000),
78    ("reshape", 10605),
79    ("diag", 10167),
80    ("chunk", 9581),
81    ("std", 9379),
82    ("set_default_tensor_type", 9281),
83    ("triu", 8559),
84    ("meshgrid", 8292),
85    ("set_num_threads", 8126),
86    ("unique", 7964),
87    ("full_like", 7780),
88    ("tril", 7538),
89    ("dot", 7275),
90    ("sign", 6943),
91    ("equal", 6916),
92    ("normal", 6750),
93    ("cumsum", 6556),
94    ("dist", 6058),
95    ("isfinite", 6030),
96    ("gt", 5935),
97    ("set_printoptions", 5888),
98    ("range", 5491),
99    ("empty_like", 5351),
100    ("flip", 5342),
101    ("masked_select", 5341),
102    ("bernoulli", 5262),
103    ("atan", 5253),
104    ("var", 5247),
105    ("prod", 5200),
106    ("erf", 5088),
107    ("inverse", 5072),
108    ("addmm", 4854),
109    ("logsumexp", 4582),
110    ("fft", 4436),
111    ("lt", 4421),
112    ("log2", 4316),
113    ("enable_grad", 4238),
114    ("rand_like", 4187),
115    ("argsort", 3972),
116    ("seed", 3932),
117    ("mv", 3547),
118    ("ger", 3309),
119    ("ge", 3248),
120    ("atan2", 3210),
121    ("ceil", 3202),
122    ("ne", 3075),
123    ("bincount", 3063),
124    ("acos", 3055),
125    ("rsqrt", 3031),
126    ("svd", 3029),
127    ("numel", 3003),
128    ("log1p", 2840),
129    ("unbind", 2808),
130    ("le", 2714),
131    ("isinf", 2707),
132    ("cross", 2646),
133    ("set_default_dtype", 2536),
134    ("argmin", 2535),
135    ("sparse_coo_tensor", 2489),
136    ("log10", 2304),
137    ("kthvalue", 2192),
138    ("set_rng_state", 2158),
139    ("get_rng_state", 1996),
140    ("get_default_dtype", 1879),
141    ("det", 1868),
142    ("qr", 1864),
143    ("histc", 1852),
144    ("symeig", 1832),
145    ("trace", 1801),
146    ("median", 1795),
147    ("addcmul", 1751),
148    ("remainder", 1717),
149    ("baddbmm", 1693),
150    ("lgamma", 1665),
151    ("repeat_interleave", 1598),
152    ("fmod", 1576),
153    ("reciprocal", 1575),
154    ("tan", 1560),
155    ("initial_seed", 1532),
156    ("take", 1529),
157    ("stft", 1487),
158    ("get_num_threads", 1477),
159    ("real", 1459),
160    ("cholesky", 1406),
161    ("quantize_per_tensor", 1392),
162    ("diag_embed", 1364),
163    ("lerp", 1363),
164    ("asin", 1345),
165    ("eig", 1333),
166    ("trunc", 1290),
167    ("diagonal", 1287),
168    ("cosh", 1279),
169    ("rfft", 1269),
170    ("cumprod", 1260),
171    ("addr", 1211),
172    ("roll", 1198),
173    ("narrow", 1188),
174    ("digamma", 1172),
175    ("square", 1163),
176    ("sinh", 1131),
177    ("logspace", 1084),
178    ("broadcast_tensors", 1070),
179    ("irfft", 1013),
180    ("frac", 997),
181    ("hann_window", 994),
182    ("solve", 989),
183    ("logdet", 977),
184    ("expm1", 968),
185    ("cdist", 946),
186    ("addmv", 903),
187    ("randint_like", 888),
188    ("tensordot", 888),
189    ("ifft", 877),
190    ("true_divide", 854),
191    ("erfinv", 830),
192    ("addcdiv", 819),
193    ("addbmm", 813),
194    ("renorm", 781),
195    ("pinverse", 753),
196    ("isclose", 740),
197    ("erfc", 729),
198    ("is_storage", 725),
199    ("triangular_solve", 723),
200    ("rot90", 709),
201    ("logical_not", 686),
202    ("geqrf", 681),
203    ("slogdet", 677),
204    ("lu", 665),
205    ("hamming_window", 659),
206    ("orgqr", 651),
207    ("ormqr", 622),
208    ("is_floating_point", 602),
209    ("diagflat", 562),
210    ("cholesky_solve", 559),
211    ("tril_indices", 552),
212    ("chain_matmul", 551),
213    ("triu_indices", 548),
214    ("angle", 522),
215    ("poisson", 505),
216    ("matrix_power", 485),
217    ("unique_consecutive", 471),
218    ("quantize_per_channel", 465),
219    ("std_mean", 458),
220    ("bartlett_window", 447),
221    ("var_mean", 428),
222    ("lstsq", 421),
223    ("logical_and", 419),
224    ("mvlgamma", 411),
225    ("blackman_window", 400),
226    ("bitwise_not", 395),
227    ("cholesky_inverse", 388),
228    ("as_strided", 384),
229    ("floor_divide", 353),
230    ("cartesian_prod", 321),
231    ("lu_solve", 317),
232    ("set_flush_denormal", 310),
233    ("empty_strided", 283),
234    ("logical_xor", 282),
235    ("polygamma", 282),
236    ("logical_or", 280),
237    ("set_num_interop_threads", 278),
238    ("combinations", 274),
239    ("trapz", 270),
240    ("matrix_rank", 260),
241    ("lu_unpack", 255),
242    ("result_type", 244),
243    ("conj", 231),
244    ("cummax", 230),
245    ("lobpcg", 229),
246    ("bitwise_xor", 217),
247    ("promote_types", 213),
248    ("get_num_interop_threads", 211),
249    ("cummin", 205),
250    ("bitwise_and", 198),
251    ("dequantize", 192),
252    ("bitwise_or", 191),
253    ("imag", 191),
254    ("can_cast", 184),
255    ("istft", 180),
256    ("compiled_with_cxx11_abi", 159),
257    ("is_complex", 151),
258    ("block_diag", 136),
259    ("pca_lowrank", 124),
260    ("absolute", 122),
261    ("svd_lowrank", 108),
262    ("neg", 2),
263]
264
265top_nn_functional = [
266    ("nn.functional.softmax", 10522),
267    ("nn.functional.relu", 8572),
268    ("nn.functional.interpolate", 7277),
269    ("nn.functional.pad", 5207),
270    ("nn.functional.log_softmax", 4699),
271    ("nn.functional.normalize", 2338),
272    ("nn.functional.cross_entropy", 2083),
273    ("nn.functional.grid_sample", 1970),
274    ("nn.functional.one_hot", 1967),
275    ("nn.functional.mse_loss", 1920),
276    ("nn.functional.conv2d", 1593),
277    ("nn.functional.dropout", 1516),
278    ("nn.functional.softplus", 1385),
279    ("nn.functional.sigmoid", 1128),
280    ("nn.functional.linear", 1036),
281    ("nn.functional.gelu", 930),
282    ("nn.functional.avg_pool2d", 899),
283    ("nn.functional.max_pool2d", 876),
284    ("nn.functional.nll_loss", 863),
285    ("nn.functional.embedding", 737),
286    ("nn.functional.tanh", 664),
287    ("nn.functional.leaky_relu", 640),
288    ("nn.functional.adaptive_avg_pool2d", 633),
289    ("nn.functional.cosine_similarity", 627),
290    ("nn.functional.unfold", 609),
291    ("nn.functional.conv1d", 596),
292    ("nn.functional.binary_cross_entropy_with_logits", 591),
293    ("nn.functional.l1_loss", 571),
294    ("nn.functional.binary_cross_entropy", 492),
295    ("nn.functional.elu", 416),
296    ("nn.functional.batch_norm", 413),
297    ("nn.functional.upsample", 413),
298    ("nn.functional.fold", 305),
299    ("nn.functional.affine_grid", 298),
300    ("nn.functional.max_pool1d", 297),
301    ("nn.functional.torch", 294),
302    ("nn.functional.threshold", 263),
303    ("nn.functional.smooth_l1_loss", 262),
304    ("nn.functional.pairwise_distance", 253),
305    ("nn.functional.logsigmoid", 243),
306    ("nn.functional.adaptive_max_pool2d", 235),
307    ("nn.functional.relu6", 213),
308    ("nn.functional.pixel_shuffle", 209),
309    ("nn.functional.avg_pool3d", 203),
310    ("nn.functional.bilinear", 203),
311    ("nn.functional.conv_transpose2d", 201),
312    ("nn.functional.gumbel_softmax", 197),
313    ("nn.functional.max_unpool2d", 196),
314    ("nn.functional.kl_div", 191),
315    ("nn.functional.hardtanh", 189),
316    ("nn.functional.ctc_loss", 185),
317    ("nn.functional.layer_norm", 178),
318    ("nn.functional.conv3d", 172),
319    ("nn.functional.max_unpool3d", 167),
320    ("nn.functional.hardshrink", 165),
321    ("nn.functional.hardswish", 156),
322    ("nn.functional.selu", 156),
323    ("nn.functional.glu", 155),
324    ("nn.functional.assert_int_or_pair", 150),
325    ("nn.functional.hardsigmoid", 146),
326    ("nn.functional.upsample_bilinear", 146),
327    ("nn.functional.max_pool3d", 140),
328    ("nn.functional.adaptive_avg_pool3d", 139),
329    ("nn.functional.instance_norm", 124),
330    ("nn.functional.embedding_bag", 122),
331    ("nn.functional.upsample_nearest", 110),
332    ("nn.functional.avg_pool1d", 105),
333    ("nn.functional.prelu", 102),
334    ("nn.functional.celu", 92),
335    ("nn.functional.dropout2d", 86),
336    ("nn.functional.hinge_embedding_loss", 82),
337    ("nn.functional.softsign", 81),
338    ("nn.functional.max_unpool1d", 74),
339    ("nn.functional.silu", 74),
340    ("nn.functional.softshrink", 70),
341    ("nn.functional.leaky_relu_", 68),
342    ("nn.functional.softmin", 67),
343    ("nn.functional.channel_shuffle", 66),
344    ("nn.functional.multilabel_margin_loss", 66),
345    ("nn.functional.dropout3d", 65),
346    ("nn.functional.multi_margin_loss", 65),
347    ("nn.functional.lp_pool2d", 64),
348    ("nn.functional.conv_transpose1d", 62),
349    ("nn.functional.triplet_margin_loss", 62),
350    ("nn.functional.tanhshrink", 61),
351    ("nn.functional.adaptive_max_pool1d", 59),
352    ("nn.functional.cosine_embedding_loss", 58),
353    ("nn.functional.multi_head_attention_forward", 58),
354    ("nn.functional.max_pool1d_with_indices", 53),
355    ("nn.functional.poisson_nll_loss", 53),
356    ("nn.functional.margin_ranking_loss", 52),
357    ("nn.functional.soft_margin_loss", 52),
358    ("nn.functional.adaptive_max_pool3d", 51),
359    ("nn.functional.group_norm", 51),
360    ("nn.functional.local_response_norm", 51),
361    ("nn.functional.multilabel_soft_margin_loss", 51),
362    ("nn.functional.relu_", 50),
363    ("nn.functional.alpha_dropout", 49),
364    ("nn.functional.feature_alpha_dropout", 49),
365    ("nn.functional.lp_pool1d", 49),
366    ("nn.functional.adaptive_max_pool1d_with_indices", 48),
367    ("nn.functional.adaptive_max_pool2d_with_indices", 48),
368    ("nn.functional.adaptive_max_pool3d_with_indices", 48),
369    ("nn.functional.fractional_max_pool2d", 48),
370    ("nn.functional.fractional_max_pool2d_with_indices", 48),
371    ("nn.functional.fractional_max_pool3d", 48),
372    ("nn.functional.fractional_max_pool3d_with_indices", 48),
373    ("nn.functional.max_pool2d_with_indices", 48),
374    ("nn.functional.max_pool3d_with_indices", 48),
375    ("nn.functional.handle_torch_function", 47),
376    ("nn.functional.has_torch_function", 47),
377    ("nn.functional.adaptive_avg_pool1d", 43),
378    ("nn.functional.pdist", 43),
379    ("nn.functional.rrelu_", 37),
380    ("nn.functional.elu_", 34),
381    ("nn.functional.boolean_dispatch", 33),
382    ("nn.functional.hardtanh_", 26),
383    ("nn.functional.triplet_margin_with_distance_loss", 23),
384    ("nn.functional.selu_", 20),
385    ("nn.functional.pixel_unshuffle", 19),
386    ("nn.functional.conv_transpose3d", 18),
387    ("nn.functional.gaussian_nll_loss", 15),
388    ("nn.functional.has_torch_function_unary", 15),
389    ("nn.functional.has_torch_function_variadic", 15),
390    ("nn.functional.celu_", 13),
391    ("nn.functional.huber_loss", 7),
392    ("nn.functional.mish", 4),
393    ("nn.functional.threshold_", 3),
394    ("nn.functional.grad", 2),
395    ("nn.functional.conv_tbc", 1),
396    ("nn.functional.math", 1),
397]
398
399top_nn_module = [
400    ("nn.Module", 927129, None),
401    ("nn.Linear", 530688, "nn.functional.linear"),
402    ("nn.Sequential", 384968, None),
403    ("nn.Conv2d", 383320, "nn.functional.conv2d"),
404    ("nn.ReLU", 318877, "nn.functional.relu"),
405    ("nn.BatchNorm2d", 233265, "nn.functional.batch_norm"),
406    ("nn.Dropout", 179268, "nn.functional.dropout"),
407    ("nn.ModuleList", 171225, None),
408    ("nn.Parameter", 153291, None),
409    ("nn.CrossEntropyLoss", 152696, "nn.functional.cross_entropy"),
410    ("nn.MaxPool2d", 138619, "nn.functional.max_pool2d"),
411    ("nn.Embedding", 111844, "nn.functional.embedding"),
412    ("nn.DataParallel", 104238, None),
413    ("nn.MSELoss", 82954, "nn.functional.mse_loss"),
414    ("nn.Sigmoid", 75810, "nn.functional.sigmoid"),
415    ("nn.LeakyReLU", 65632, "nn.functional.leaky_relu"),
416    ("nn.BatchNorm1d", 65374, "nn.functional.batch_norm"),
417    ("nn.Softmax", 65114, "nn.functional.softmax"),
418    ("nn.Tanh", 59445, "nn.functional.tanh"),
419    ("nn.AdaptiveAvgPool2d", 59071, "nn.functional.adaptive_avg_pool2d"),
420    ("nn.AvgPool2d", 58377, "nn.functional.avg_pool2d"),
421    ("nn.ConvTranspose2d", 57524, "nn.functional.conv_transpose2d"),
422    ("nn.LSTM", 57411, None),
423    ("nn.Conv1d", 41108, "nn.functional.conv1d"),
424    ("nn.LayerNorm", 36089, "nn.functional.layer_norm"),
425    ("nn.BCELoss", 34005, "nn.functional.binary_cross_entropy"),
426    ("nn.Upsample", 32527, "nn.functional.interpolate"),
427    ("nn.BCEWithLogitsLoss", 29944, "nn.functional.binary_cross_entropy_with_logits"),
428    ("nn.GRU", 25421, None),
429    ("nn.Dropout2d", 23512, "nn.functional.dropout2d"),
430    ("nn.LogSoftmax", 22897, "nn.functional.log_softmax"),
431    ("nn.L1Loss", 22778, "nn.functional.l1_loss"),
432    ("nn.GroupNorm", 22183, "nn.functional.group_norm"),
433    ("nn.NLLLoss", 21751, "nn.functional.nll_loss"),
434    ("nn.Conv3d", 20874, "nn.functional.conv3d"),
435    ("nn.Identity", 17911, None),
436    ("nn.InstanceNorm2d", 16426, "nn.functional.instance_norm"),
437    ("nn.BatchNorm3d", 16378, "nn.functional.batch_norm"),
438    ("nn.PReLU", 13472, "nn.functional.prelu"),
439    ("nn.ReLU6", 12622, "nn.functional.relu6"),
440    ("nn.ELU", 12508, "nn.functional.elu"),
441    ("nn.LSTMCell", 10885, None),
442    ("nn.Flatten", 10384, "torch.flatten"),
443    ("nn.ModuleDict", 10255, None),
444    ("nn.ReflectionPad2d", 9954, "nn.functional.pad"),
445    ("nn.MaxPool3d", 9526, "nn.functional.max_pool3d"),
446    ("nn.MaxPool1d", 9154, "nn.functional.max_pool1d"),
447    ("nn.RNN", 9154, None),
448    ("nn.ZeroPad2d", 8847, "nn.functional.pad"),
449    ("nn.ParameterList", 7702, None),
450    ("nn.SyncBatchNorm", 6814, None),
451    ("nn.PixelShuffle", 6571, "nn.functional.pixel_shuffle"),
452    ("nn.SmoothL1Loss", 6517, "nn.functional.smooth_l1_loss"),
453    ("nn.Hardswish", 6458, "nn.functional.hardswish"),
454    ("nn.AdaptiveMaxPool2d", 6071, "nn.functional.adaptive_max_pool2d"),
455    ("nn.SELU", 6043, "nn.functional.selu"),
456    ("nn.ConvTranspose3d", 6039, "nn.functional.conv_transpose3d"),
457    ("nn.GRUCell", 5840, None),
458    ("nn.ReplicationPad2d", 5600, "nn.functional.pad"),
459    ("nn.KLDivLoss", 5541, "nn.functional.kl_div"),
460    ("nn.ConvTranspose1d", 5183, "nn.functional.conv_transpose1d"),
461    ("nn.Softplus", 5120, "nn.functional.softplus"),
462    ("nn.SiLU", 4895, "nn.functional.silu"),
463    ("nn.AvgPool3d", 4523, "nn.functional.avg_pool3d"),
464    ("nn.CosineSimilarity", 4058, "nn.functional.cosine_similarity"),
465    ("nn.GELU", 3932, "nn.functional.gelu"),
466    ("nn.UpsamplingBilinear2d", 3673, "nn.functional.interpolate"),
467    ("nn.InstanceNorm1d", 3658, "nn.functional.instance_norm"),
468    ("nn.Transformer", 3604, None),
469    ("nn.MultiheadAttention", 3435, "nn.functional.multi_head_attention_forward"),
470    ("nn.AvgPool1d", 3195, "nn.functional.avg_pool1d"),
471    ("nn.Dropout3d", 2964, "nn.functional.dropout3d"),
472    ("nn.AdaptiveAvgPool3d", 2915, "nn.functional.adaptive_avg_pool3d"),
473    ("nn.InstanceNorm3d", 2893, "nn.functional.instance_norm"),
474    ("nn.Hardtanh", 2613, "nn.functional.hardtanh"),
475    ("nn.MarginRankingLoss", 2568, "nn.functional.margin_ranking_loss"),
476    ("nn.GLU", 2526, "nn.functional.glu"),
477    ("nn.AdaptiveAvgPool1d", 2481, "nn.functional.adaptive_avg_pool1d"),
478    ("nn.EmbeddingBag", 2344, "nn.functional.embedding_bag"),
479    ("nn.TransformerEncoderLayer", 2292, None),
480    ("nn.TransformerEncoder", 2091, None),
481    ("nn.MaxUnpool2d", 2031, "nn.functional.max_unpool2d"),
482    ("nn.UpsamplingNearest2d", 2004, "nn.functional.interpolate"),
483    ("nn.ConstantPad1d", 1904, "nn.functional.pad"),
484    ("nn.ConstantPad2d", 1791, "nn.functional.pad"),
485    ("nn.CTCLoss", 1789, "nn.functional.ctc_loss"),
486    ("nn.AdaptiveMaxPool1d", 1713, "nn.functional.adaptive_max_pool1d"),
487    ("nn.AdaptiveLogSoftmaxWithLoss", 1665, None),
488    ("nn.Bilinear", 1664, "nn.functional.bilinear"),
489    ("nn.RNNCell", 1653, None),
490    ("nn.MultiLabelSoftMarginLoss", 1624, "nn.functional.multilabel_soft_margin_loss"),
491    ("nn.Unfold", 1452, "nn.functional.unfold"),
492    ("nn.RReLU", 1431, "nn.functional.rrelu"),
493    ("nn.CosineEmbeddingLoss", 1357, "nn.functional.cosine_embedding_loss"),
494    ("nn.LocalResponseNorm", 1331, "nn.functional.local_response_norm"),
495    ("nn.Softmax2d", 1300, "nn.functional.softmax"),
496    ("nn.PairwiseDistance", 1241, "nn.functional.pairwise_distance"),
497    ("nn.LogSigmoid", 1235, "nn.functional.logsigmoid"),
498    ("nn.TripletMarginLoss", 1230, "nn.functional.triplet_margin_loss"),
499    ("nn.RNNBase", 1133, None),
500    ("nn.Threshold", 1043, "nn.functional.threshold"),
501    ("nn.AdaptiveMaxPool3d", 1025, "nn.functional.adaptive_max_pool3d"),
502    ("nn.CELU", 1018, "nn.functional.celu"),
503    ("nn.NLLLoss2d", 966, "nn.functional.nll_loss"),
504    ("nn.Softsign", 877, "nn.functional.softsign"),
505    ("nn.ReplicationPad1d", 862, "nn.functional.pad"),
506    ("nn.SoftMarginLoss", 856, "nn.functional.soft_margin_loss"),
507    ("nn.ParameterDict", 742, None),
508    ("nn.ReflectionPad1d", 731, "nn.functional.pad"),
509    ("nn.Softshrink", 713, "nn.functional.softshrink"),
510    ("nn.AlphaDropout", 710, "nn.functional.alpha_dropout"),
511    ("nn.Tanhshrink", 681, "nn.functional.tanhshrink"),
512    ("nn.PoissonNLLLoss", 676, "nn.functional.poisson_nll_loss"),
513    ("nn.MaxUnpool3d", 660, "nn.functional.max_unpool3d"),
514    ("nn.Fold", 630, "nn.functional.fold"),
515    ("nn.MultiMarginLoss", 622, "nn.functional.multi_margin_loss"),
516    ("nn.TransformerDecoderLayer", 614, None),
517    ("nn.TransformerDecoder", 607, None),
518    ("nn.Hardshrink", 592, "nn.functional.hardshrink"),
519    ("nn.ConstantPad3d", 582, "nn.functional.pad"),
520    ("nn.MultiLabelMarginLoss", 580, "nn.functional.multilabel_margin_loss"),
521    ("nn.LPPool2d", 550, "nn.functional.lp_pool2d"),
522    ("nn.Softmin", 537, "nn.functional.softmin"),
523    ("nn.MaxUnpool1d", 518, "nn.functional.max_unpool1d"),
524    ("nn.FractionalMaxPool2d", 484, "nn.functional.fractional_max_pool2d"),
525    ("nn.Hardsigmoid", 477, "nn.functional.hardsigmoid"),
526    ("nn.ReplicationPad3d", 470, "nn.functional.pad"),
527    ("nn.HingeEmbeddingLoss", 442, "nn.functional.hinge_embedding_loss"),
528    ("nn.LPPool1d", 386, "nn.functional.lp_pool1d"),
529    ("nn.FractionalMaxPool3d", 252, "nn.functional.fractional_max_pool3d"),
530    ("nn.Container", 217, None),
531    ("nn.Unflatten", 206, "nn.functional.unflatten"),
532    ("nn.FeatureAlphaDropout", 136, "nn.functional.feature_alpha_dropout"),
533    (
534        "nn.TripletMarginWithDistanceLoss",
535        107,
536        "nn.functional.triplet_margin_with_distance_loss",
537    ),
538    ("nn.ChannelShuffle", 90, "nn.functional.channel_shuffle"),
539    ("nn.RNNCellBase", 88, None),
540    ("nn.LazyLinear", 81, "nn.functional.linear"),
541    ("nn.UninitializedParameter", 60, None),
542    ("nn.CrossMapLRN2d", 59, None),
543    ("nn.GaussianNLLLoss", 55, "nn.functional.gaussian_nll_loss"),
544    ("nn.PixelUnshuffle", 45, "nn.functional.pixel_unshuffle"),
545    ("nn.Mish", 31, "nn.functional.mish"),
546    ("nn.ReflectionPad3d", 22, "nn.functional.pad"),
547    ("nn.HuberLoss", 18, "nn.functional.huber_loss"),
548    ("nn.LazyConv2d", 15, None),
549    ("nn.LazyConv1d", 9, None),
550    ("nn.LazyConv3d", 8, None),
551    ("nn.LazyConvTranspose1d", 8, None),
552    ("nn.LazyConvTranspose2d", 8, None),
553    ("nn.LazyConvTranspose3d", 8, None),
554    ("nn.LazyBatchNorm1d", 3, None),
555    ("nn.LazyBatchNorm2d", 3, None),
556    ("nn.LazyBatchNorm3d", 3, None),
557    ("nn.UninitializedBuffer", 3, None),
558]
559
560# No rankings because these are a little hard to get rankings for
561method_only_ops = [
562    "bfloat16",
563    "bool",
564    "byte",
565    "char",
566    "contiguous",
567    "cpu",
568    "cuda",
569    "detach",
570    "double",
571    "expand",
572    "expand_as",
573    "float",
574    "get_device",
575    "half",
576    "hardshrink",
577    "index_add",
578    "index_copy",
579    "index_fill",
580    "index_put",
581    "int",
582    "is_contiguous",
583    "is_pinned",
584    "is_set_to",
585    "is_shared",
586    "is_signed",
587    "item",
588    "long",
589    "masked_scatter",
590    "masked_fill",
591    "narrow_copy",
592    "numpy",
593    "pin_memory",
594    "repeat",
595    "reshape_as",
596    "select",
597    "short",
598    "storage_offset",
599    "sum_to_size",
600    "to",
601    "to_mkldnn",
602    "tolist",
603    "type",
604    "type_as",
605    "unfold",
606    "view",
607    "view_as",
608]
609
610
611def get_nn_functional_top_list():
612    top_nn_functional_ = dict(top_nn_functional)
613    for _, count, functional_name in top_nn_module:
614        if functional_name is None:
615            continue
616        if functional_name == "torch.flatten":
617            continue
618        if functional_name not in top_nn_functional_:
619            top_nn_functional_[functional_name] = count
620        else:
621            top_nn_functional_[functional_name] += count
622
623    top_nn_functional_ = list(top_nn_functional_.items())
624    top_nn_functional_.sort(key=operator.itemgetter(1), reverse=True)
625    return top_nn_functional_
626
627
628usage_count = {}
629for k, v in get_nn_functional_top_list():
630    usage_count[k] = v
631for k, v in top_torch:
632    usage_count[k] = v
633