trace_rules.py 136 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599
  1. # mypy: allow-untyped-defs
  2. import _collections_abc
  3. import _weakrefset
  4. import abc
  5. import builtins
  6. import collections
  7. import contextlib
  8. import copy
  9. import copyreg
  10. import dataclasses
  11. import enum
  12. import functools
  13. import importlib
  14. import inspect
  15. import itertools
  16. import linecache
  17. import logging
  18. import multiprocessing
  19. import operator
  20. import os
  21. import posixpath
  22. import random
  23. import re
  24. import selectors
  25. import signal
  26. import sys
  27. import tempfile
  28. import threading
  29. import tokenize
  30. import traceback
  31. import types
  32. import typing
  33. import unittest
  34. import weakref
  35. from collections import defaultdict
  36. from typing import Any, Callable, cast, Dict, List, Optional, Set, Union
  37. np: Optional[types.ModuleType] = None
  38. try:
  39. import numpy as np
  40. except ModuleNotFoundError:
  41. pass
  42. import torch
  43. import torch._inductor.test_operators
  44. import torch.distributed
  45. import torch.utils._content_store
  46. from ..utils import _config_module
  47. from .resume_execution import TORCH_DYNAMO_RESUME_IN_PREFIX
  48. from .utils import getfile, hashable, NP_SUPPORTED_MODULES, unwrap_if_wrapper
  49. from .variables import (
  50. BuiltinVariable,
  51. FunctorchHigherOrderVariable,
  52. NestedUserFunctionVariable,
  53. SkipFunctionVariable,
  54. TorchInGraphFunctionVariable,
  55. UserFunctionVariable,
  56. UserMethodVariable,
  57. )
  58. if typing.TYPE_CHECKING:
  59. from .variables.base import VariableTracker
  60. """
  61. A note on skip/inline rules:
  62. Dynamo consults this file to determine whether function should be inlined or skipped.
  63. A skip applies at the frame boundary, meaning dynamo either triggers a graph break
  64. at the beginning of the frame or attempts to trace/inline the whole frame. When skipping
  65. a frame, recursively called frames are still traced by dynamo unless also skipped.
  66. Skipfiles (skipped at the file level instead of function level) still apply on a
  67. frame-by-frame boundary as dynamo traces, but apply to all functions in that file.
  68. @skip is a helper decorator that can be applied to your function to cause it to be
  69. included here.
  70. Dynamo skip/inline rules & priorities are defined as follows:
  71. * Inline is the default behavior and will be used unless explicitly skipped.
  72. * Dynamo has two SKIPLIST: BUILTIN_SKIPLIST and THIRDPARTY_SKIPLIST.
  73. * BUILTIN_SKIPLIST contains builtin python modules, such as abc, collections, etc.
  74. * THIRDPARTY_SKIPLIST contains common third party libraries, such as numpy, pandas, etc.
  75. * Functions in these two SKIPLISTs are always skipped, except:
  76. * They have explicitly defined rule in `manual_torch_name_rule_map`;
  77. * The corresponding python module has been put into MOD_INLINELIST.
  78. * PyTorch(torch) is in the BUILTIN_SKIPLIST by default, but there are many cases
  79. where we want inline the functions under torch namespace.
  80. We should specify inline for the functions in `manual_torch_name_rule_map` or
  81. put the corresponding python module into MOD_INLINELIST to make dynamo inline them.
  82. * If you call functions under skipped modules/files, Dynamo will wrap these functions
  83. as SkipFunctionVariable. There are a few functions(e.g, collections.OrderedDict) that
  84. we have special handling at SkipFunctionVariable.call_function.
  85. Overall: *_INLINELIST has precedence over *_SKIPLIST has precedence over DEFAULT (inline)
  86. To figure out what the behavior is, check the following list in order:
  87. * `manual_torch_name_rule_map` (Inline if YES)
  88. * MOD_INLINELIST (Inline if YES)
  89. * BUILTIN_SKIPLIST & THIRDPARTY_SKIPLIST (Skip if YES)
  90. * Inline by default
  91. In general, if you want to force inline a function or module, please consider adding
  92. the function's python module to MOD_INLINELIST first.
  93. Use the `manual_torch_name_rule_map` only when there are other functions under the same module that
  94. you don't want to inline them.
  95. """
  96. """
  97. Map of function objects to their tracing rules (Dynamo variables).
  98. * TorchInGraphFunctionVariable: The functions should be put into the FX graph or can be constant folded. E.g.,
  99. - torch.add: should be put into the FX graph.
  100. - torch.is_floating_point: constant folded.
  101. * SkipFunctionVariable: The objects should be skipped from tracing.
  102. * UserFunctionVariable: The functions should be inlined.
  103. For developers: If you add/remove a torch level API, it may trigger failures from
  104. test/dynamo/test_trace_rules.py:test_torch_name_rule_map_updated. To fix the failures:
  105. If you are adding a new torch level API or Dynamo implementation:
  106. * Add the name with the corresponding tracing rule to this map
  107. if you are adding a new in graph function or Dynamo implementation for an existing function.
  108. * Remove the object name from test/dynamo/test_trace_rules.ignored_c_binding_in_graph_function_names if it's there.
  109. If you are removing an existing torch level API:
  110. * Remove the entry represented the API from this map or test/dynamo/test_trace_rules.ignored_c_binding_in_graph_function_names
  111. depends on where it is.
  112. """
  113. manual_torch_name_rule_map = {
  114. "torch.onnx.is_in_onnx_export": TorchInGraphFunctionVariable,
  115. "torch.onnx.operators.shape_as_tensor": TorchInGraphFunctionVariable,
  116. "torch.overrides.is_tensor_like": TorchInGraphFunctionVariable,
  117. "torch.jit.is_scripting": TorchInGraphFunctionVariable,
  118. "torch.jit.is_tracing": TorchInGraphFunctionVariable,
  119. "torch.jit.annotate": TorchInGraphFunctionVariable,
  120. "torch.distributed.is_available": TorchInGraphFunctionVariable,
  121. "torch.distributed.is_initialized": TorchInGraphFunctionVariable,
  122. "torch.distributed.get_rank": TorchInGraphFunctionVariable,
  123. "torch.distributed.get_world_size": TorchInGraphFunctionVariable,
  124. "torch.distributed._tensor.api.DTensor#from_local": TorchInGraphFunctionVariable,
  125. "torch.distributed.distributed_c10d._get_group_size_by_name": TorchInGraphFunctionVariable,
  126. "torch.distributed.distributed_c10d._resolve_group_name_by_ranks_and_tag": TorchInGraphFunctionVariable,
  127. "torch.distributed.distributed_c10d._get_group_tag": TorchInGraphFunctionVariable,
  128. "torch.distributed.distributed_c10d.get_process_group_ranks": TorchInGraphFunctionVariable,
  129. "torch._utils.is_compiling": TorchInGraphFunctionVariable,
  130. "torch.overrides.get_default_nowrap_functions": TorchInGraphFunctionVariable,
  131. "torch.fx._symbolic_trace.is_fx_tracing": TorchInGraphFunctionVariable,
  132. "torch._dynamo.external_utils.is_compiling": TorchInGraphFunctionVariable,
  133. "torch.compiler.is_compiling": TorchInGraphFunctionVariable,
  134. "torch.compiler.is_dynamo_compiling": TorchInGraphFunctionVariable,
  135. "torch.autograd._profiler_enabled": SkipFunctionVariable,
  136. "torch._C._to_dlpack": SkipFunctionVariable,
  137. "torch.to_dlpack": SkipFunctionVariable,
  138. # We graph break on RNG state setters or getters like
  139. # `torch.get_rng_state` or `torch.set_rng_state`. These functions
  140. # are not aten operations and therefore they are completely ignored
  141. # by the AOT dispatcher. As a result, the AOT graph does not have
  142. # these setter or getter functions, producing an incorrect graph
  143. # when it comes to rng states.
  144. "torch.default_generator#get_state": SkipFunctionVariable,
  145. "torch._C.Generator#get_state": SkipFunctionVariable,
  146. "torch.get_rng_state": SkipFunctionVariable,
  147. "torch.cuda.get_rng_state": SkipFunctionVariable,
  148. "torch.default_generator#set_state": SkipFunctionVariable,
  149. "torch._C.Generator#set_state": SkipFunctionVariable,
  150. "torch.set_rng_state": SkipFunctionVariable,
  151. "torch.cuda.set_rng_state": SkipFunctionVariable,
  152. # https://github.com/pytorch/pytorch/issues/107187
  153. "torch.manual_seed": SkipFunctionVariable,
  154. # https://github.com/pytorch/pytorch/issues/93501
  155. "torch.nn.utils.rnn.pack_padded_sequence": SkipFunctionVariable,
  156. "torch.nn.Parameter": TorchInGraphFunctionVariable,
  157. "torch._nested_tensor_from_mask": SkipFunctionVariable,
  158. "torch._nested_from_padded": SkipFunctionVariable,
  159. "torch.nested.nested_tensor_from_jagged": UserFunctionVariable,
  160. # symbol operators implemented in Python
  161. "torch.sym_not": TorchInGraphFunctionVariable,
  162. "torch.sym_float": TorchInGraphFunctionVariable,
  163. "torch.sym_int": TorchInGraphFunctionVariable,
  164. "torch.sym_max": TorchInGraphFunctionVariable,
  165. "torch.sym_min": TorchInGraphFunctionVariable,
  166. "torch.sym_sqrt": TorchInGraphFunctionVariable,
  167. "torch.sym_ite": TorchInGraphFunctionVariable,
  168. "torch.Tensor#_make_wrapper_subclass": SkipFunctionVariable,
  169. "torch.Tensor#__init__": SkipFunctionVariable,
  170. "torch.cuda.set_device": SkipFunctionVariable,
  171. "torch.cuda.current_device": SkipFunctionVariable,
  172. "torch._C.autocast_decrement_nesting": SkipFunctionVariable,
  173. "torch._C.autocast_increment_nesting": SkipFunctionVariable,
  174. "torch.autograd.grad": SkipFunctionVariable,
  175. "torch.autograd.backward": SkipFunctionVariable,
  176. "torch._C.clear_autocast_cache": SkipFunctionVariable,
  177. "torch.distributions.constraints.is_dependent": SkipFunctionVariable,
  178. "torch.jit.isinstance": SkipFunctionVariable,
  179. "torch._C.set_anomaly_enabled": SkipFunctionVariable,
  180. "torch._C.set_autocast_cache_enabled": SkipFunctionVariable,
  181. "torch._C.set_autocast_cpu_dtype": SkipFunctionVariable,
  182. "torch._C.set_autocast_cpu_enabled": SkipFunctionVariable,
  183. "torch._C.set_autocast_enabled": SkipFunctionVariable,
  184. "torch._C.set_autocast_gpu_dtype": SkipFunctionVariable,
  185. "torch._C.set_autocast_ipu_dtype": SkipFunctionVariable,
  186. "torch._C.set_autocast_ipu_enabled": SkipFunctionVariable,
  187. "torch._C.set_autocast_xla_dtype": SkipFunctionVariable,
  188. "torch._C.set_autocast_xla_enabled": SkipFunctionVariable,
  189. "torch.resize_as_": SkipFunctionVariable,
  190. "torch.resize_as_sparse_": SkipFunctionVariable,
  191. "torch.get_default_device": TorchInGraphFunctionVariable,
  192. # functorch/vmap
  193. "torch._functorch.vmap._check_int_or_none": UserFunctionVariable,
  194. "torch._functorch.vmap._check_out_dims_is_int_or_int_pytree": UserFunctionVariable,
  195. "torch._functorch.vmap._check_randomness_arg": UserFunctionVariable,
  196. "torch._functorch.vmap._chunked_vmap": UserFunctionVariable,
  197. "torch._functorch.vmap._concat_chunked_outputs": UserFunctionVariable,
  198. "torch._functorch.vmap._create_batched_inputs": UserFunctionVariable,
  199. "torch._functorch.vmap._flat_vmap": UserFunctionVariable,
  200. "torch._functorch.vmap._flatten_chunks_output": UserFunctionVariable,
  201. "torch._functorch.vmap._get_chunked_inputs": UserFunctionVariable,
  202. "torch._functorch.vmap._get_name": UserFunctionVariable,
  203. "torch._functorch.vmap._maybe_remove_batch_dim": UserFunctionVariable,
  204. "torch._functorch.vmap._num_outputs": UserFunctionVariable,
  205. "torch._functorch.vmap._process_batched_inputs": UserFunctionVariable,
  206. "torch._functorch.vmap._unwrap_batched": UserFunctionVariable,
  207. "torch._functorch.vmap._validate_and_get_batch_size": UserFunctionVariable,
  208. "torch._functorch.vmap.doesnt_support_saved_tensors_hooks": UserFunctionVariable,
  209. "torch._functorch.vmap.get_chunk_sizes": UserFunctionVariable,
  210. # lazy_load_decompositions uses a lock that is not supported yet in dynamo
  211. # "torch._functorch.vmap.lazy_load_decompositions": UserFunctionVariable,
  212. "torch._functorch.vmap.restore_vmap": UserFunctionVariable,
  213. "torch._functorch.apis.vmap": UserFunctionVariable,
  214. "torch._functorch.vmap.unwrap_batched": UserFunctionVariable,
  215. "torch._functorch.vmap.vmap_impl": FunctorchHigherOrderVariable,
  216. "torch._functorch.vmap.wrap_batched": UserFunctionVariable,
  217. # functorch/grad
  218. "torch._functorch.eager_transforms.grad_impl": FunctorchHigherOrderVariable,
  219. "torch._functorch.apis.grad_and_value": UserFunctionVariable,
  220. "torch._functorch.eager_transforms._as_tuple": UserFunctionVariable,
  221. "torch._functorch.eager_transforms._check_unique_non_empty": UserFunctionVariable,
  222. "torch._functorch.eager_transforms._create_differentiable": UserFunctionVariable,
  223. "torch._functorch.eager_transforms._slice_argnums": UserFunctionVariable,
  224. "torch._functorch.eager_transforms._undo_create_differentiable": UserFunctionVariable,
  225. "torch._functorch.eager_transforms._validate_and_wrap_argnum": UserFunctionVariable,
  226. "torch._functorch.eager_transforms._validate_and_wrap_argnums": UserFunctionVariable,
  227. "torch._functorch.eager_transforms._wrap_all_tensors": UserFunctionVariable,
  228. "torch._functorch.eager_transforms._wrap_tensor_for_grad": UserFunctionVariable,
  229. # functorch/jacrev
  230. "torch._functorch.eager_transforms.jacrev": FunctorchHigherOrderVariable,
  231. "torch._functorch.eager_transforms.error_if_complex": UserFunctionVariable,
  232. "torch._functorch.eager_transforms._chunked_standard_basis_for_": UserFunctionVariable,
  233. "torch._functorch.eager_transforms._safe_zero_index": UserFunctionVariable,
  234. # functorch/vjp
  235. "torch._functorch.eager_transforms.vjp": FunctorchHigherOrderVariable,
  236. "torch._functorch.eager_transforms._vjp_with_argnums": UserFunctionVariable,
  237. "torch._functorch.eager_transforms.assert_non_empty_tensor_output": UserFunctionVariable,
  238. # functorch/jvp
  239. "torch._functorch.eager_transforms._jvp_with_argnums": UserFunctionVariable,
  240. "torch._functorch.eager_transforms.jvp": FunctorchHigherOrderVariable,
  241. "torch._functorch.eager_transforms._replace_args": UserFunctionVariable,
  242. "torch._functorch.eager_transforms.safe_unpack_dual": UserFunctionVariable,
  243. "torch._functorch.eager_transforms.assert_non_empty_list_of_tensors": UserFunctionVariable,
  244. "torch._functorch.eager_transforms.assert_output_is_tensor_or_tensors": UserFunctionVariable,
  245. "torch.autograd.forward_ad.enter_dual_level": UserFunctionVariable,
  246. "torch.autograd.forward_ad.exit_dual_level": UserFunctionVariable,
  247. "torch.autograd.forward_ad.make_dual": UserFunctionVariable,
  248. "torch.autograd.forward_ad.unpack_dual": UserFunctionVariable,
  249. # functorch/linearize
  250. "torch._functorch.eager_transforms.linearize": FunctorchHigherOrderVariable,
  251. # functorch/jacfwd
  252. "torch._functorch.eager_transforms.jacfwd": FunctorchHigherOrderVariable,
  253. "torch._functorch.eager_transforms._construct_standard_basis_for": UserFunctionVariable,
  254. "torch._functorch.eager_transforms.safe_unflatten": UserFunctionVariable,
  255. # functorch/hessian
  256. "torch._functorch.eager_transforms.hessian": FunctorchHigherOrderVariable,
  257. # functorch/deprecated
  258. "torch._functorch.deprecated.jvp": UserFunctionVariable,
  259. "torch._functorch.deprecated.hessian": UserFunctionVariable,
  260. "torch._functorch.deprecated.jacfwd": UserFunctionVariable,
  261. "torch._functorch.deprecated.jacrev": UserFunctionVariable,
  262. "torch._functorch.deprecated.grad": UserFunctionVariable,
  263. "torch._functorch.deprecated.grad_and_value": UserFunctionVariable,
  264. "torch._functorch.deprecated.vjp": UserFunctionVariable,
  265. #
  266. "torch._constrain_as_size": UserFunctionVariable,
  267. "torch._tensor._convert": UserFunctionVariable,
  268. "torch.jit._unwrap_optional": UserFunctionVariable,
  269. "torch.backends.mha.get_fastpath_enabled": UserFunctionVariable,
  270. "torch._C._functorch._add_batch_dim": TorchInGraphFunctionVariable,
  271. "torch._C._functorch._remove_batch_dim": TorchInGraphFunctionVariable,
  272. "torch._C._functorch._wrap_for_grad": TorchInGraphFunctionVariable,
  273. "torch._C._functorch._unwrap_for_grad": TorchInGraphFunctionVariable,
  274. "torch._C._functorch.maybe_current_level": TorchInGraphFunctionVariable,
  275. "torch._C._functorch.is_batchedtensor": TorchInGraphFunctionVariable,
  276. "torch._dynamo.mark_static": UserFunctionVariable,
  277. "torch.fx.experimental.symbolic_shapes.guard_size_oblivious": TorchInGraphFunctionVariable,
  278. "torch.cuda._get_device_properties": TorchInGraphFunctionVariable,
  279. "torch.utils.hooks.BackwardHook": TorchInGraphFunctionVariable,
  280. "torch.sparse_bsc_tensor": SkipFunctionVariable,
  281. "torch.sparse_bsr_tensor": SkipFunctionVariable,
  282. "torch.sparse_csc_tensor": SkipFunctionVariable,
  283. "torch.sparse_csr_tensor": SkipFunctionVariable,
  284. "torch.sparse_compressed_tensor": SkipFunctionVariable,
  285. "torch._C._autograd._unsafe_set_version_counter": TorchInGraphFunctionVariable,
  286. # avoid skipping user defined modules in distributed unit tests
  287. "torch/testing/_internal/common_fsdp.py#forward": UserFunctionVariable,
  288. f"torch/testing/_internal/common_fsdp.py#{TORCH_DYNAMO_RESUME_IN_PREFIX}": UserFunctionVariable,
  289. "torch/testing/_internal/distributed/_tensor/common_dtensor.py#forward": UserFunctionVariable,
  290. f"torch/testing/_internal/distributed/_tensor/common_dtensor.py#{TORCH_DYNAMO_RESUME_IN_PREFIX}": UserFunctionVariable,
  291. "torch/testing/_internal/common_distributed.py#forward": UserFunctionVariable,
  292. f"torch/testing/_internal/common_distributed.py#{TORCH_DYNAMO_RESUME_IN_PREFIX}": UserFunctionVariable,
  293. }
  294. # In graph functions (including constant folding) that are C bindings
  295. torch_c_binding_in_graph_functions = dict.fromkeys(
  296. [
  297. "math.acos",
  298. "math.acosh",
  299. "math.asin",
  300. "math.asinh",
  301. "math.atan",
  302. "math.atan2",
  303. "math.atanh",
  304. "math.ceil",
  305. "math.comb",
  306. "math.copysign",
  307. "math.cos",
  308. "math.cosh",
  309. "math.degrees",
  310. "math.dist",
  311. "math.erf",
  312. "math.erfc",
  313. "math.exp",
  314. "math.expm1",
  315. "math.fabs",
  316. "math.factorial",
  317. "math.floor",
  318. "math.fmod",
  319. "math.frexp",
  320. "math.fsum",
  321. "math.gamma",
  322. "math.gcd",
  323. "math.hypot",
  324. "math.isclose",
  325. "math.isfinite",
  326. "math.isinf",
  327. "math.isnan",
  328. "math.isqrt",
  329. "math.ldexp",
  330. "math.lgamma",
  331. "math.log",
  332. "math.log10",
  333. "math.log1p",
  334. "math.log2",
  335. "math.modf",
  336. "math.nextafter",
  337. "math.perm",
  338. "math.pow",
  339. "math.prod",
  340. "math.radians",
  341. "math.remainder",
  342. "math.sin",
  343. "math.sinh",
  344. "math.tan",
  345. "math.tanh",
  346. "math.trunc",
  347. "math.ulp",
  348. "torch._adaptive_avg_pool2d",
  349. "torch._adaptive_avg_pool3d",
  350. "torch._add_batch_dim",
  351. "torch._add_relu_",
  352. "torch._add_relu",
  353. "torch._addmm_activation",
  354. "torch._aminmax",
  355. "torch._amp_foreach_non_finite_check_and_unscale_",
  356. "torch._amp_update_scale_",
  357. "torch._assert_async",
  358. "torch._assert_tensor_metadata",
  359. "torch._batch_norm_impl_index",
  360. "torch._C._activate_gpu_trace",
  361. "torch._C._add_cached_tensor",
  362. "torch._C._add_docstr",
  363. "torch._C._are_functorch_transforms_active",
  364. "torch._C._autograd_init",
  365. "torch._C._awaitable_nowait",
  366. "torch._C._awaitable_wait",
  367. "torch._C._awaitable",
  368. "torch._C._backport_for_mobile_from_buffer_to_buffer",
  369. "torch._C._backport_for_mobile_from_buffer",
  370. "torch._C._backport_for_mobile_to_buffer",
  371. "torch._C._backport_for_mobile",
  372. "torch._C._broadcast_coalesced",
  373. "torch._C._broadcast_out",
  374. "torch._C._broadcast",
  375. "torch._C._c10d_init",
  376. "torch._C._calculate_package_version_based_on_upgraders",
  377. "torch._C._can_use_flash_attention",
  378. "torch._C._can_use_mem_efficient_attention",
  379. "torch._C._check_onnx_proto",
  380. "torch._C._check_sparse_tensor_invariants",
  381. "torch._C._collect_all",
  382. "torch._C._commit_update",
  383. "torch._C._compile_graph_to_code_table",
  384. "torch._C._construct_CUDA_Tensor_From_Storage_And_Metadata",
  385. "torch._C._construct_storage_from_data_pointer",
  386. "torch._C._conv_determine_backend_memory_format",
  387. "torch._C._cpu._is_cpu_support_avx2",
  388. "torch._C._cpu._is_cpu_support_avx512",
  389. "torch._C._cpu._is_cpu_support_vnni",
  390. "torch._C._crash_if_aten_asan",
  391. "torch._C._crash_if_csrc_asan",
  392. "torch._C._crash_if_csrc_ubsan",
  393. "torch._C._crash_if_debug_asserts_fail",
  394. "torch._C._crash_if_vptr_ubsan",
  395. "torch._C._create_function_from_graph",
  396. "torch._C._create_function_from_trace_with_dict",
  397. "torch._C._create_function_from_trace",
  398. "torch._C._create_graph_by_tracing",
  399. "torch._C._create_module_with_type",
  400. "torch._C._create_object_with_type",
  401. "torch._C._cuda_attach_out_of_memory_observer",
  402. "torch._C._cuda_beginAllocateCurrentStreamToPool",
  403. "torch._C._cuda_canDeviceAccessPeer",
  404. "torch._C._cuda_changeCurrentAllocator",
  405. "torch._C._cuda_checkPoolLiveAllocations",
  406. "torch._C._cuda_clearCublasWorkspaces",
  407. "torch._C._cuda_cudaCachingAllocator_raw_alloc",
  408. "torch._C._cuda_cudaCachingAllocator_raw_delete",
  409. "torch._C._cuda_cudaCachingAllocator_set_allocator_settings",
  410. "torch._C._cuda_cudaHostAllocator",
  411. "torch._C._cuda_customAllocator",
  412. "torch._C._cuda_emptyCache",
  413. "torch._C._cuda_endAllocateCurrentStreamToPool",
  414. "torch._C._cuda_exchangeDevice",
  415. "torch._C._cuda_get_conv_benchmark_empty_cache",
  416. "torch._C._cuda_get_cudnn_benchmark_limit",
  417. "torch._C._cuda_get_sync_debug_mode",
  418. "torch._C._cuda_getAllocator",
  419. "torch._C._cuda_getAllocatorBackend",
  420. "torch._C._cuda_getArchFlags",
  421. "torch._C._cuda_getCheckpointState",
  422. "torch._C._cuda_getCompiledVersion",
  423. "torch._C._cuda_getCurrentBlasHandle",
  424. "torch._C._cuda_getCurrentRawStream",
  425. "torch._C._cuda_getCurrentStream",
  426. "torch._C._cuda_getDefaultStream",
  427. "torch._C._cuda_getDevice",
  428. "torch._C._cuda_getDeviceCount",
  429. "torch._C._cuda_hasPrimaryContext",
  430. "torch._C._cuda_init",
  431. "torch._C._cuda_ipc_collect",
  432. "torch._C._cuda_isCurrentStreamCapturing",
  433. "torch._C._cuda_isHistoryEnabled",
  434. "torch._C._cuda_isInBadFork",
  435. "torch._C._cuda_jiterator_compile_and_launch_kernel",
  436. "torch._C._cuda_lock_mutex",
  437. "torch._C._cuda_maybeExchangeDevice",
  438. "torch._C._cuda_memorySnapshot",
  439. "torch._C._cuda_memoryStats",
  440. "torch._C._cuda_record_memory_history_legacy",
  441. "torch._C._cuda_record_memory_history",
  442. "torch._C._cuda_releasePool",
  443. "torch._C._cuda_resetAccumulatedMemoryStats",
  444. "torch._C._cuda_resetPeakMemoryStats",
  445. "torch._C._cuda_set_cudnn_benchmark_limit",
  446. "torch._C._cuda_set_sync_debug_mode",
  447. "torch._C._cuda_setCheckpointPoolState",
  448. "torch._C._cuda_setDevice",
  449. "torch._C._cuda_setMemoryFraction",
  450. "torch._C._cuda_setStream",
  451. "torch._C._cuda_sleep",
  452. "torch._C._cuda_synchronize",
  453. "torch._C._cuda_unlock_mutex",
  454. "torch._C._cudnn_set_conv_benchmark_empty_cache",
  455. "torch._C._cudnn.getCompileVersion",
  456. "torch._C._cudnn.getRuntimeVersion",
  457. "torch._C._cudnn.getVersionInt",
  458. "torch._C._current_autograd_node",
  459. "torch._C._current_graph_task_execution_order",
  460. "torch._C._current_graph_task_id",
  461. "torch._C._cxx_flags",
  462. "torch._C._debug_get_fusion_group_inlining",
  463. "torch._C._debug_only_are_vmap_fallback_warnings_enabled",
  464. "torch._C._debug_only_display_vmap_fallback_warnings",
  465. "torch._C._debug_set_autodiff_subgraph_inlining",
  466. "torch._C._debug_set_fusion_group_inlining",
  467. "torch._C._demangle",
  468. "torch._C._disabled_torch_dispatch_impl",
  469. "torch._C._disabled_torch_function_impl",
  470. "torch._C._dispatch_call_boxed",
  471. "torch._C._dispatch_check_all_invariants",
  472. "torch._C._dispatch_check_invariants",
  473. "torch._C._dispatch_dump_table",
  474. "torch._C._dispatch_dump",
  475. "torch._C._dispatch_find_dangling_impls",
  476. "torch._C._dispatch_find_schema_or_throw",
  477. "torch._C._dispatch_get_all_op_names",
  478. "torch._C._dispatch_get_backend_keyset_from_autograd",
  479. "torch._C._dispatch_get_registrations_for_dispatch_key",
  480. "torch._C._dispatch_has_backend_fallback",
  481. "torch._C._dispatch_has_computed_kernel_for_dispatch_key",
  482. "torch._C._dispatch_has_kernel_for_any_dispatch_key",
  483. "torch._C._dispatch_has_kernel_for_dispatch_key",
  484. "torch._C._dispatch_has_kernel",
  485. "torch._C._dispatch_is_alias_key",
  486. "torch._C._dispatch_is_included_in_alias",
  487. "torch._C._dispatch_is_main_interpreter",
  488. "torch._C._dispatch_isTensorSubclassLike",
  489. "torch._C._dispatch_key_for_device",
  490. "torch._C._dispatch_key_name",
  491. "torch._C._dispatch_key_parse",
  492. "torch._C._dispatch_key_set",
  493. "torch._C._dispatch_keys",
  494. "torch._C._dispatch_keyset_full_after",
  495. "torch._C._dispatch_keyset_full",
  496. "torch._C._dispatch_keyset_to_string",
  497. "torch._C._dispatch_library",
  498. "torch._C._dispatch_num_backends",
  499. "torch._C._dispatch_print_registrations_for_dispatch_key",
  500. "torch._C._dispatch_pystub",
  501. "torch._C._dispatch_set_report_error_callback",
  502. "torch._C._dispatch_tls_is_dispatch_key_excluded",
  503. "torch._C._dispatch_tls_is_dispatch_key_included",
  504. "torch._C._dispatch_tls_local_exclude_set",
  505. "torch._C._dispatch_tls_local_include_set",
  506. "torch._C._dispatch_tls_set_dispatch_key_excluded",
  507. "torch._C._dispatch_tls_set_dispatch_key_included",
  508. "torch._C._dist_autograd_init",
  509. "torch._C._dump_local_tls_set",
  510. "torch._C._dump_upgraders_map",
  511. "torch._C._enable_mobile_interface_call_export",
  512. "torch._C._enter_dual_level",
  513. "torch._C._error_if_any_worker_fails",
  514. "torch._C._exit_dual_level",
  515. "torch._C._export_operator_list",
  516. "torch._C._export_opnames",
  517. "torch._C._faulty_agent_init",
  518. "torch._C._fft.fft_fft",
  519. "torch._C._fft.fft_fft2",
  520. "torch._C._fft.fft_fftfreq",
  521. "torch._C._fft.fft_fftn",
  522. "torch._C._fft.fft_fftshift",
  523. "torch._C._fft.fft_hfft",
  524. "torch._C._fft.fft_hfft2",
  525. "torch._C._fft.fft_hfftn",
  526. "torch._C._fft.fft_ifft",
  527. "torch._C._fft.fft_ifft2",
  528. "torch._C._fft.fft_ifftn",
  529. "torch._C._fft.fft_ifftshift",
  530. "torch._C._fft.fft_ihfft",
  531. "torch._C._fft.fft_ihfft2",
  532. "torch._C._fft.fft_ihfftn",
  533. "torch._C._fft.fft_irfft",
  534. "torch._C._fft.fft_irfft2",
  535. "torch._C._fft.fft_irfftn",
  536. "torch._C._fft.fft_rfft",
  537. "torch._C._fft.fft_rfft2",
  538. "torch._C._fft.fft_rfftfreq",
  539. "torch._C._fft.fft_rfftn",
  540. "torch._C._free_And_Remove_DeleterFn",
  541. "torch._C._freeze_module",
  542. "torch._C._from_dlpack",
  543. "torch._C._functionality_to_backend_keys",
  544. "torch._C._functionalization_reapply_views_tls",
  545. "torch._C._fuse_to_static_module",
  546. "torch._C._gather_out",
  547. "torch._C._gather",
  548. "torch._C._generate_upgraders_graph",
  549. "torch._C._get_autograd_fallback_mode",
  550. "torch._C._get_backcompat_broadcast_warn",
  551. "torch._C._get_backcompat_keepdim_warn",
  552. "torch._C._get_blas_preferred_backend",
  553. "torch._C._get_caught_jit_exception_class_name",
  554. "torch._C._get_caught_jit_exception_original_msg",
  555. "torch._C._get_constant_bool_symnode",
  556. "torch._C._get_cpp_backtrace",
  557. "torch._C._get_cpu_capability",
  558. "torch._C._get_cublas_allow_bf16_reduced_precision_reduction",
  559. "torch._C._get_cublas_allow_fp16_reduced_precision_reduction",
  560. "torch._C._get_cublas_allow_tf32",
  561. "torch._C._get_cudnn_allow_tf32",
  562. "torch._C._get_cudnn_benchmark",
  563. "torch._C._get_cudnn_deterministic",
  564. "torch._C._get_cudnn_enabled",
  565. "torch._C._get_custom_class_python_wrapper",
  566. "torch._C._get_default_device",
  567. "torch._C._get_deterministic_algorithms_warn_only",
  568. "torch._C._get_deterministic_algorithms",
  569. "torch._C._get_deterministic_fill_uninitialized_memory",
  570. "torch._C._get_dispatch_mode",
  571. "torch._C._get_dispatch_stack_at",
  572. "torch._C._get_file_format",
  573. "torch._C._get_flash_sdp_enabled",
  574. "torch._C._get_float32_matmul_precision",
  575. "torch._C._get_function_stack_at",
  576. "torch._C._get_graph_executor_optimize",
  577. "torch._C._get_linalg_preferred_backend",
  578. "torch._C._get_math_sdp_enabled",
  579. "torch._C._get_max_operator_version",
  580. "torch._C._get_mem_efficient_sdp_enabled",
  581. "torch._C._get_mkldnn_enabled",
  582. "torch._C._get_cudnn_sdp_enabled",
  583. "torch._C._set_sdp_use_cudnn",
  584. "torch._C._get_mobile_model_contained_types_from_buffer",
  585. "torch._C._get_mobile_model_contained_types",
  586. "torch._C._get_model_bytecode_version_from_buffer",
  587. "torch._C._get_model_bytecode_version",
  588. "torch._C._get_model_extra_files_from_buffer",
  589. "torch._C._get_model_extra_files",
  590. "torch._C._get_model_ops_and_info_from_buffer",
  591. "torch._C._get_model_ops_and_info",
  592. "torch._C._get_module_info_from_flatbuffer",
  593. "torch._C._get_nnpack_enabled",
  594. "torch._C._get_obj_in_tls",
  595. "torch._C._get_operation_overload",
  596. "torch._C._get_operator_version_map",
  597. "torch._C._get_privateuse1_backend_name",
  598. "torch._C._get_qengine",
  599. "torch._C._get_schema",
  600. "torch._C._get_nested_int",
  601. "torch._C._get_tensor_metadata",
  602. "torch._C._get_tracing_state",
  603. "torch._C._get_upgrader_ranges",
  604. "torch._C._get_upgraders_entry_map",
  605. "torch._C._get_upgraders_map_size",
  606. "torch._C._get_value_trace",
  607. "torch._C._get_version_calculator_flag",
  608. "torch._C._get_warnAlways",
  609. "torch._C._graph_pool_handle",
  610. "torch._C._group_tensors_by_device_and_dtype",
  611. "torch._C._hack_do_not_use_clone_module_with_class",
  612. "torch._C._has_distributed",
  613. "torch._C._has_Standard_Deleter",
  614. "torch._C._has_storage",
  615. "torch._C._has_tensorexpr_cpp_tests",
  616. "torch._C._run_tensorexpr_cpp_tests",
  617. "torch._C._has_torch_function_unary",
  618. "torch._C._has_torch_function_variadic",
  619. "torch._C._has_torch_function",
  620. "torch._C._import_ir_module_from_package",
  621. "torch._C._increment_version",
  622. "torch._C._infer_size",
  623. "torch._C._init_names",
  624. "torch._C._initExtension",
  625. "torch._C._is_alias_of",
  626. "torch._C._is_any_autocast_enabled",
  627. "torch._C._is_cached_tensor",
  628. "torch._C._is_fwd_grad_enabled",
  629. "torch._C._is_key_in_tls",
  630. "torch._C._is_multithreading_enabled",
  631. "torch._C._is_torch_function_enabled",
  632. "torch._C._is_torch_function_mode_enabled",
  633. "torch._C._is_tracing",
  634. "torch._C._is_view_replay_enabled",
  635. "torch._C._is_xnnpack_enabled",
  636. "torch._C._itt.is_available",
  637. "torch._C._itt.mark",
  638. "torch._C._itt.rangePop",
  639. "torch._C._itt.rangePush",
  640. "torch._C._ivalue_debug_python_object",
  641. "torch._C._ivalue_tags_match",
  642. "torch._C._jit_assert_is_instance",
  643. "torch._C._jit_can_fuse_on_cpu_legacy",
  644. "torch._C._jit_can_fuse_on_cpu",
  645. "torch._C._jit_can_fuse_on_gpu",
  646. "torch._C._jit_cat_wo_conditionals",
  647. "torch._C._jit_check_alias_annotation",
  648. "torch._C._jit_clear_class_registry",
  649. "torch._C._jit_debug_fuser_num_cached_kernel_specs",
  650. "torch._C._jit_debug_module_iterators",
  651. "torch._C._jit_decay_packed_param_input_types",
  652. "torch._C._jit_decomposition_graph_for_node",
  653. "torch._C._jit_differentiate",
  654. "torch._C._jit_erase_non_input_shape_information",
  655. "torch._C._jit_flatten",
  656. "torch._C._jit_fuser_get_fused_kernel_code",
  657. "torch._C._jit_get_all_schemas",
  658. "torch._C._jit_get_custom_class_schemas",
  659. "torch._C._jit_get_emit_hooks",
  660. "torch._C._jit_get_inline_everything_mode",
  661. "torch._C._jit_get_logging_option",
  662. "torch._C._jit_get_num_profiled_runs",
  663. "torch._C._jit_get_operation",
  664. "torch._C._jit_get_schemas_for_operator",
  665. "torch._C._jit_get_te_cuda_pointwise_block_count",
  666. "torch._C._jit_get_te_cuda_pointwise_block_size",
  667. "torch._C._jit_get_te_cuda_pointwise_loop_levels",
  668. "torch._C._jit_get_te_generate_block_code",
  669. "torch._C._jit_get_te_must_use_llvm_cpu",
  670. "torch._C._jit_get_tracer_state_warn",
  671. "torch._C._jit_has_cpp_tests",
  672. "torch._C._jit_init",
  673. "torch._C._jit_interpret_graph",
  674. "torch._C._jit_is_onnx_log_enabled",
  675. "torch._C._jit_is_script_object",
  676. "torch._C._jit_llga_enabled",
  677. "torch._C._jit_nvfuser_can_be_enabled",
  678. "torch._C._jit_nvfuser_clear_comparison_callback",
  679. "torch._C._jit_nvfuser_enabled",
  680. "torch._C._jit_nvfuser_horizontal_mode",
  681. "torch._C._jit_nvfuser_set_comparison_callback",
  682. "torch._C._jit_nvfuser_single_node_mode",
  683. "torch._C._jit_object_is_non_holding",
  684. "torch._C._jit_onnx_convert_pattern_from_subblock",
  685. "torch._C._jit_onnx_create_full_scope_name",
  686. "torch._C._jit_onnx_list_model_parameters",
  687. "torch._C._jit_onnx_log",
  688. "torch._C._jit_opt_conditionals",
  689. "torch._C._jit_override_can_fuse_on_cpu_legacy",
  690. "torch._C._jit_override_can_fuse_on_cpu",
  691. "torch._C._jit_override_can_fuse_on_gpu",
  692. "torch._C._jit_pass_autocast",
  693. "torch._C._jit_pass_batch_mm",
  694. "torch._C._jit_pass_canonicalize_graph_fuser_ops",
  695. "torch._C._jit_pass_canonicalize",
  696. "torch._C._jit_pass_complete_shape_analysis",
  697. "torch._C._jit_pass_concat_frozen_linear",
  698. "torch._C._jit_pass_constant_loop_unrolling",
  699. "torch._C._jit_pass_constant_pooling",
  700. "torch._C._jit_pass_constant_propagation_immutable_types",
  701. "torch._C._jit_pass_constant_propagation",
  702. "torch._C._jit_pass_convert_frozen_ops_to_mkldnn",
  703. "torch._C._jit_pass_create_autodiff_subgraphs",
  704. "torch._C._jit_pass_create_functional_graphs",
  705. "torch._C._jit_pass_cse",
  706. "torch._C._jit_pass_custom_pattern_based_rewrite_graph",
  707. "torch._C._jit_pass_custom_pattern_based_rewrite",
  708. "torch._C._jit_pass_dbr_quant_remove_redundant_aliases",
  709. "torch._C._jit_pass_dce_allow_deleting_nodes_with_side_effects",
  710. "torch._C._jit_pass_dce",
  711. "torch._C._jit_pass_decompose_ops",
  712. "torch._C._jit_pass_dedup_module_uses",
  713. "torch._C._jit_pass_erase_number_types",
  714. "torch._C._jit_pass_erase_shape_information",
  715. "torch._C._jit_pass_filter_non_tensor_arguments",
  716. "torch._C._jit_pass_fixup_onnx_controlflow_node",
  717. "torch._C._jit_pass_fold_convbn",
  718. "torch._C._jit_pass_fold_frozen_conv_add_or_sub",
  719. "torch._C._jit_pass_fold_frozen_conv_bn",
  720. "torch._C._jit_pass_fold_frozen_conv_mul_or_div",
  721. "torch._C._jit_pass_fold_frozen_linear_bn",
  722. "torch._C._jit_pass_fold_prepacking_ops",
  723. "torch._C._jit_pass_functional_to_inplace_activation",
  724. "torch._C._jit_pass_fuse_add_relu",
  725. "torch._C._jit_pass_fuse_addmm",
  726. "torch._C._jit_pass_fuse_clamp_w_prepacked_linear_conv",
  727. "torch._C._jit_pass_fuse_frozen_conv_add_relu",
  728. "torch._C._jit_pass_fuse_linear",
  729. "torch._C._jit_pass_fuse_quantized_add_relu",
  730. "torch._C._jit_pass_fuse_tensorexprs",
  731. "torch._C._jit_pass_fuse",
  732. "torch._C._jit_pass_inline_fork_wait",
  733. "torch._C._jit_pass_inline_functional_graphs",
  734. "torch._C._jit_pass_inline",
  735. "torch._C._jit_pass_inplace_to_functional_activation",
  736. "torch._C._jit_pass_insert_observer_method_for_ondevice_ptq",
  737. "torch._C._jit_pass_insert_observers",
  738. "torch._C._jit_pass_insert_prepack_unpack",
  739. "torch._C._jit_pass_insert_prepacked_ops",
  740. "torch._C._jit_pass_insert_quant_dequant_for_ondevice_ptq",
  741. "torch._C._jit_pass_insert_quant_dequant",
  742. "torch._C._jit_pass_integer_value_refinement",
  743. "torch._C._jit_pass_lint",
  744. "torch._C._jit_pass_loop_unrolling",
  745. "torch._C._jit_pass_lower_all_tuples",
  746. "torch._C._jit_pass_lower_graph",
  747. "torch._C._jit_pass_metal_fold_prepacking_ops",
  748. "torch._C._jit_pass_metal_fuse_clamp_w_prepacked_conv",
  749. "torch._C._jit_pass_metal_insert_prepacked_ops",
  750. "torch._C._jit_pass_metal_optimize_for_mobile",
  751. "torch._C._jit_pass_onnx_assign_output_shape",
  752. "torch._C._jit_pass_onnx_assign_scoped_names_for_node_and_value",
  753. "torch._C._jit_pass_onnx_autograd_function_process",
  754. "torch._C._jit_pass_onnx_block",
  755. "torch._C._jit_pass_onnx_cast_all_constant_to_floating",
  756. "torch._C._jit_pass_onnx_clear_scope_records",
  757. "torch._C._jit_pass_onnx_constant_fold",
  758. "torch._C._jit_pass_onnx_deduplicate_initializers",
  759. "torch._C._jit_pass_onnx_eliminate_unused_items",
  760. "torch._C._jit_pass_onnx_eval_peephole",
  761. "torch._C._jit_pass_onnx_function_extraction",
  762. "torch._C._jit_pass_onnx_function_substitution",
  763. "torch._C._jit_pass_onnx_graph_shape_type_inference",
  764. "torch._C._jit_pass_onnx_lint",
  765. "torch._C._jit_pass_onnx_node_shape_type_inference",
  766. "torch._C._jit_pass_onnx_peephole",
  767. "torch._C._jit_pass_onnx_preprocess_caffe2",
  768. "torch._C._jit_pass_onnx_preprocess",
  769. "torch._C._jit_pass_onnx_quantization_insert_permutes",
  770. "torch._C._jit_pass_onnx_remove_inplace_ops_for_onnx",
  771. "torch._C._jit_pass_onnx_remove_print",
  772. "torch._C._jit_pass_onnx_scalar_type_analysis",
  773. "torch._C._jit_pass_onnx_set_dynamic_input_shape",
  774. "torch._C._jit_pass_onnx_track_scope_attributes",
  775. "torch._C._jit_pass_onnx_unpack_quantized_weights",
  776. "torch._C._jit_pass_onnx",
  777. "torch._C._jit_pass_optimize_for_inference",
  778. "torch._C._jit_pass_optimize_for_mobile",
  779. "torch._C._jit_pass_optimize_frozen_graph",
  780. "torch._C._jit_pass_pattern_based_rewrite",
  781. "torch._C._jit_pass_peephole_list_idioms",
  782. "torch._C._jit_pass_peephole",
  783. "torch._C._jit_pass_prepare_division_for_onnx",
  784. "torch._C._jit_pass_propagate_device",
  785. "torch._C._jit_pass_propagate_dtype",
  786. "torch._C._jit_pass_propagate_shapes_on_graph_and_build_compute",
  787. "torch._C._jit_pass_propagate_shapes_on_graph",
  788. "torch._C._jit_pass_quant_finalize_for_ondevice_ptq",
  789. "torch._C._jit_pass_quant_finalize",
  790. "torch._C._jit_pass_quant_fusion",
  791. "torch._C._jit_pass_refine_integer_values",
  792. "torch._C._jit_pass_refine_tuple_types",
  793. "torch._C._jit_pass_remove_dropout",
  794. "torch._C._jit_pass_remove_expands",
  795. "torch._C._jit_pass_remove_inplace_ops",
  796. "torch._C._jit_pass_remove_mutation",
  797. "torch._C._jit_pass_replace_old_ops_with_upgraders",
  798. "torch._C._jit_pass_replicate_dequantize",
  799. "torch._C._jit_pass_run_decompositions",
  800. "torch._C._jit_pass_specialize_autogradzero",
  801. "torch._C._jit_pass_swap_functional_linear",
  802. "torch._C._jit_pass_transform_conv1d_to_conv2d",
  803. "torch._C._jit_pass_transpose_frozen_linear",
  804. "torch._C._jit_pass_vulkan_fold_prepacking_ops",
  805. "torch._C._jit_pass_vulkan_fuse_clamp_w_prepacked_conv",
  806. "torch._C._jit_pass_vulkan_insert_prepacked_ops",
  807. "torch._C._jit_pass_vulkan_optimize_for_mobile",
  808. "torch._C._jit_register_decomposition_for_schema",
  809. "torch._C._jit_register_shape_compute_graph_for_node",
  810. "torch._C._jit_resolve_packet",
  811. "torch._C._jit_run_cpp_tests",
  812. "torch._C._jit_script_class_compile",
  813. "torch._C._jit_script_compile_overload",
  814. "torch._C._jit_script_compile",
  815. "torch._C._jit_script_interface_compile",
  816. "torch._C._jit_set_autocast_mode",
  817. "torch._C._jit_set_bailout_depth",
  818. "torch._C._jit_set_emit_hooks",
  819. "torch._C._jit_set_fusion_strategy",
  820. "torch._C._jit_set_inline_everything_mode",
  821. "torch._C._jit_set_llga_enabled",
  822. "torch._C._jit_set_logging_option",
  823. "torch._C._jit_set_logging_stream",
  824. "torch._C._jit_set_num_profiled_runs",
  825. "torch._C._jit_set_nvfuser_enabled",
  826. "torch._C._jit_set_nvfuser_guard_mode",
  827. "torch._C._jit_set_nvfuser_horizontal_mode",
  828. "torch._C._jit_set_nvfuser_single_node_mode",
  829. "torch._C._jit_set_nvfuser_skip_node_kind",
  830. "torch._C._jit_set_onnx_log_enabled",
  831. "torch._C._jit_set_onnx_log_output_stream",
  832. "torch._C._jit_set_profiling_executor",
  833. "torch._C._jit_set_profiling_mode",
  834. "torch._C._jit_set_symbolic_shapes_test_mode",
  835. "torch._C._jit_set_te_cuda_pointwise_block_count",
  836. "torch._C._jit_set_te_cuda_pointwise_block_size",
  837. "torch._C._jit_set_te_cuda_pointwise_loop_levels",
  838. "torch._C._jit_set_te_generate_block_code",
  839. "torch._C._jit_set_te_must_use_llvm_cpu",
  840. "torch._C._jit_set_texpr_dynamic_shape_enabled",
  841. "torch._C._jit_set_texpr_fuser_enabled",
  842. "torch._C._jit_set_texpr_reductions_enabled",
  843. "torch._C._jit_set_tracer_state_warn",
  844. "torch._C._jit_set_utf8_decoding_ignore",
  845. "torch._C._jit_shape_compute_graph_for_node",
  846. "torch._C._jit_symbolic_shapes_test_mode_enabled",
  847. "torch._C._jit_texpr_dynamic_shape_enabled",
  848. "torch._C._jit_texpr_fallback_allowed",
  849. "torch._C._jit_texpr_fuser_enabled",
  850. "torch._C._jit_texpr_reductions_enabled",
  851. "torch._C._jit_texpr_set_fallback_allowed",
  852. "torch._C._jit_to_backend_selective",
  853. "torch._C._jit_to_backend",
  854. "torch._C._jit_to_static_module",
  855. "torch._C._jit_trace_graph",
  856. "torch._C._jit_trace_module",
  857. "torch._C._jit_tree_views.FalseLiteral",
  858. "torch._C._jit_tree_views.NoneLiteral",
  859. "torch._C._jit_tree_views.TrueLiteral",
  860. "torch._C._jit_try_infer_type",
  861. "torch._C._jit_unflatten",
  862. "torch._C._last_executed_optimized_graph",
  863. "torch._C._len_torch_dispatch_stack",
  864. "torch._C._len_torch_function_stack",
  865. "torch._C._linalg._linalg_eigvals",
  866. "torch._C._linalg.linalg_cholesky_ex",
  867. "torch._C._linalg.linalg_cholesky",
  868. "torch._C._linalg.linalg_cond",
  869. "torch._C._linalg.linalg_cross",
  870. "torch._C._linalg.linalg_det",
  871. "torch._C._linalg.linalg_diagonal",
  872. "torch._C._linalg.linalg_eig",
  873. "torch._C._linalg.linalg_eigh",
  874. "torch._C._linalg.linalg_eigvals",
  875. "torch._C._linalg.linalg_eigvalsh",
  876. "torch._C._linalg.linalg_householder_product",
  877. "torch._C._linalg.linalg_inv_ex",
  878. "torch._C._linalg.linalg_inv",
  879. "torch._C._linalg.linalg_ldl_factor_ex",
  880. "torch._C._linalg.linalg_ldl_factor",
  881. "torch._C._linalg.linalg_ldl_solve",
  882. "torch._C._linalg.linalg_lstsq",
  883. "torch._C._linalg.linalg_lu_factor_ex",
  884. "torch._C._linalg.linalg_lu_factor",
  885. "torch._C._linalg.linalg_lu_solve",
  886. "torch._C._linalg.linalg_lu",
  887. "torch._C._linalg.linalg_matmul",
  888. "torch._C._linalg.linalg_matrix_exp",
  889. "torch._C._linalg.linalg_matrix_norm",
  890. "torch._C._linalg.linalg_matrix_power",
  891. "torch._C._linalg.linalg_matrix_rank",
  892. "torch._C._linalg.linalg_multi_dot",
  893. "torch._C._linalg.linalg_norm",
  894. "torch._C._linalg.linalg_pinv",
  895. "torch._C._linalg.linalg_qr",
  896. "torch._C._linalg.linalg_slogdet",
  897. "torch._C._linalg.linalg_solve_ex",
  898. "torch._C._linalg.linalg_solve_triangular",
  899. "torch._C._linalg.linalg_solve",
  900. "torch._C._linalg.linalg_svd",
  901. "torch._C._linalg.linalg_svdvals",
  902. "torch._C._linalg.linalg_tensorinv",
  903. "torch._C._linalg.linalg_tensorsolve",
  904. "torch._C._linalg.linalg_vander",
  905. "torch._C._linalg.linalg_vecdot",
  906. "torch._C._linalg.linalg_vector_norm",
  907. "torch._C._llvm_enabled",
  908. "torch._C._load_for_lite_interpreter_from_buffer",
  909. "torch._C._load_for_lite_interpreter",
  910. "torch._C._load_jit_module_from_bytes",
  911. "torch._C._load_jit_module_from_file",
  912. "torch._C._load_mobile_module_from_bytes",
  913. "torch._C._load_mobile_module_from_file",
  914. "torch._C._log_api_usage_metadata",
  915. "torch._C._log_api_usage_once",
  916. "torch._C._logging_set_logger",
  917. "torch._C._meta_in_tls_dispatch_include",
  918. "torch._C._mps_acquireEvent",
  919. "torch._C._mps_currentAllocatedMemory",
  920. "torch._C._mps_deviceSynchronize",
  921. "torch._C._mps_driverAllocatedMemory",
  922. "torch._C._mps_elapsedTimeOfEvents",
  923. "torch._C._mps_emptyCache",
  924. "torch._C._mps_get_default_generator",
  925. "torch._C._mps_is_available",
  926. "torch._C._mps_is_in_bad_fork",
  927. "torch._C._mps_is_on_macos_13_or_newer",
  928. "torch._C._mps_profilerStartTrace",
  929. "torch._C._mps_profilerStopTrace",
  930. "torch._C._mps_queryEvent",
  931. "torch._C._mps_recordEvent",
  932. "torch._C._mps_releaseEvent",
  933. "torch._C._mps_setMemoryFraction",
  934. "torch._C._mps_synchronizeEvent",
  935. "torch._C._mps_waitForEvent",
  936. "torch._C._multiprocessing_init",
  937. "torch._C._nccl_all_gather",
  938. "torch._C._nccl_all_reduce",
  939. "torch._C._nccl_broadcast",
  940. "torch._C._nccl_init_rank",
  941. "torch._C._nccl_reduce_scatter",
  942. "torch._C._nccl_reduce",
  943. "torch._C._nccl_unique_id",
  944. "torch._C._nccl_version_suffix",
  945. "torch._C._nccl_version",
  946. "torch._C._nested.nested_tensor",
  947. "torch._C._nested.nested_to_padded_tensor",
  948. "torch._C._new_symbolic_shape_symbol",
  949. "torch._C._nn_module_to_mobile",
  950. "torch._C._nn._conv_depthwise2d",
  951. "torch._C._nn._pad_circular",
  952. "torch._C._nn._pad_enum",
  953. "torch._C._nn._parse_to",
  954. "torch._C._nn._test_ambiguous_defaults",
  955. "torch._C._nn._test_optional_filled_intlist",
  956. "torch._C._nn._test_optional_floatlist",
  957. "torch._C._nn._test_optional_intlist",
  958. "torch._C._nn._test_string_default",
  959. "torch._C._nn._test_warn_in_autograd",
  960. "torch._C._nn._upsample_bicubic2d_aa",
  961. "torch._C._nn._upsample_bilinear2d_aa",
  962. "torch._C._nn._upsample_nearest_exact1d",
  963. "torch._C._nn._upsample_nearest_exact2d",
  964. "torch._C._nn._upsample_nearest_exact3d",
  965. "torch._C._nn.adaptive_avg_pool2d",
  966. "torch._C._nn.adaptive_avg_pool3d",
  967. "torch._C._nn.adaptive_max_pool2d",
  968. "torch._C._nn.adaptive_max_pool3d",
  969. "torch._C._nn.avg_pool2d",
  970. "torch._C._nn.avg_pool3d",
  971. "torch._C._nn.binary_cross_entropy",
  972. "torch._C._nn.col2im",
  973. "torch._C._nn.conv_depthwise3d",
  974. "torch._C._nn.cross_entropy_loss",
  975. "torch._C._nn.elu_",
  976. "torch._C._nn.elu",
  977. "torch._C._nn.flatten_dense_tensors",
  978. "torch._C._nn.fractional_max_pool2d",
  979. "torch._C._nn.fractional_max_pool3d",
  980. "torch._C._nn.gelu_",
  981. "torch._C._nn.gelu",
  982. "torch._C._nn.glu",
  983. "torch._C._nn.hardsigmoid_",
  984. "torch._C._nn.hardsigmoid",
  985. "torch._C._nn.hardswish_",
  986. "torch._C._nn.hardswish",
  987. "torch._C._nn.hardtanh_",
  988. "torch._C._nn.hardtanh",
  989. "torch._C._nn.huber_loss",
  990. "torch._C._nn.im2col",
  991. "torch._C._nn.l1_loss",
  992. "torch._C._nn.leaky_relu_",
  993. "torch._C._nn.leaky_relu",
  994. "torch._C._nn.linear",
  995. "torch._C._nn.log_sigmoid",
  996. "torch._C._nn.max_pool2d_with_indices",
  997. "torch._C._nn.max_pool3d_with_indices",
  998. "torch._C._nn.max_unpool2d",
  999. "torch._C._nn.max_unpool3d",
  1000. "torch._C._nn.mish_",
  1001. "torch._C._nn.mish",
  1002. "torch._C._nn.mkldnn_linear",
  1003. "torch._C._nn.mkldnn_reorder_conv2d_weight",
  1004. "torch._C._nn.mkldnn_reorder_conv3d_weight",
  1005. "torch._C._nn.mse_loss",
  1006. "torch._C._nn.multi_margin_loss",
  1007. "torch._C._nn.multilabel_margin_loss",
  1008. "torch._C._nn.nll_loss_nd",
  1009. "torch._C._nn.nll_loss",
  1010. "torch._C._nn.nll_loss2d",
  1011. "torch._C._nn.one_hot",
  1012. "torch._C._nn.pad_sequence",
  1013. "torch._C._nn.pad",
  1014. "torch._C._nn.reflection_pad1d",
  1015. "torch._C._nn.reflection_pad2d",
  1016. "torch._C._nn.reflection_pad3d",
  1017. "torch._C._nn.relu6_",
  1018. "torch._C._nn.relu6",
  1019. "torch._C._nn.replication_pad1d",
  1020. "torch._C._nn.replication_pad2d",
  1021. "torch._C._nn.replication_pad3d",
  1022. "torch._C._nn.rrelu_with_noise_",
  1023. "torch._C._nn.rrelu_with_noise",
  1024. "torch._C._nn.scaled_dot_product_attention",
  1025. "torch._C._nn.silu_",
  1026. "torch._C._nn.silu",
  1027. "torch._C._nn.slow_conv_dilated2d",
  1028. "torch._C._nn.slow_conv_dilated3d",
  1029. "torch._C._nn.slow_conv_transpose2d",
  1030. "torch._C._nn.slow_conv_transpose3d",
  1031. "torch._C._nn.slow_conv3d",
  1032. "torch._C._nn.smooth_l1_loss",
  1033. "torch._C._nn.soft_margin_loss",
  1034. "torch._C._nn.softplus",
  1035. "torch._C._nn.softshrink",
  1036. "torch._C._nn.thnn_conv2d",
  1037. "torch._C._nn.unflatten_dense_tensors",
  1038. "torch._C._nn.upsample_bicubic2d",
  1039. "torch._C._nn.upsample_bilinear2d",
  1040. "torch._C._nn.upsample_linear1d",
  1041. "torch._C._nn.upsample_nearest1d",
  1042. "torch._C._nn.upsample_nearest2d",
  1043. "torch._C._nn.upsample_nearest3d",
  1044. "torch._C._nn.upsample_trilinear3d",
  1045. "torch._C._non_sym_sizes",
  1046. "torch._C._overlaps",
  1047. "torch._C._parallel_info",
  1048. "torch._C._parse_dispatch_key",
  1049. "torch._C._parse_source_def",
  1050. "torch._C._pop_torch_dispatch_stack",
  1051. "torch._C._pop_torch_function_stack",
  1052. "torch._C._propagate_and_assign_input_shapes",
  1053. "torch._C._propagate_shapes",
  1054. "torch._C._propagate_xla_data",
  1055. "torch._C._push_on_torch_dispatch_stack",
  1056. "torch._C._push_on_torch_function_stack",
  1057. "torch._C._quantize_ondevice_ptq_dynamic",
  1058. "torch._C._register_py_class_for_device",
  1059. "torch._C._remove_cached_tensor",
  1060. "torch._C._remove_worker_pids",
  1061. "torch._C._rename_privateuse1_backend",
  1062. "torch._C._replace_",
  1063. "torch._C._replace_overloaded_method_decl",
  1064. "torch._C._resolve_type_from_object",
  1065. "torch._C._resolve_type",
  1066. "torch._C._rocm_is_backward_pass",
  1067. "torch._C._rpc_init",
  1068. "torch._C._run_emit_module_hook",
  1069. "torch._C._save_jit_module_to_bytes",
  1070. "torch._C._save_jit_module",
  1071. "torch._C._save_mobile_module_to_bytes",
  1072. "torch._C._save_mobile_module",
  1073. "torch._C._save_parameters",
  1074. "torch._C._scatter_out",
  1075. "torch._C._scatter",
  1076. "torch._C._select_conv_backend",
  1077. "torch._C._select_batch_norm_backend",
  1078. "torch._C._set_autograd_fallback_mode",
  1079. "torch._C._set_backcompat_broadcast_warn",
  1080. "torch._C._set_backcompat_keepdim_warn",
  1081. "torch._C._set_blas_preferred_backend",
  1082. "torch._C._set_cached_tensors_enabled",
  1083. "torch._C._set_check_sparse_tensor_invariants",
  1084. "torch._C._set_conj",
  1085. "torch._C._set_cublas_allow_bf16_reduced_precision_reduction",
  1086. "torch._C._set_cublas_allow_fp16_reduced_precision_reduction",
  1087. "torch._C._set_cublas_allow_tf32",
  1088. "torch._C._set_cudnn_allow_tf32",
  1089. "torch._C._set_cudnn_benchmark",
  1090. "torch._C._set_cudnn_deterministic",
  1091. "torch._C._set_cudnn_enabled",
  1092. "torch._C._set_default_dtype",
  1093. "torch._C._set_default_mobile_cpu_allocator",
  1094. "torch._C._set_default_tensor_type",
  1095. "torch._C._set_deterministic_algorithms",
  1096. "torch._C._set_deterministic_fill_uninitialized_memory",
  1097. "torch._C._set_dispatch_mode",
  1098. "torch._C._set_float32_matmul_precision",
  1099. "torch._C._set_fwd_grad_enabled",
  1100. "torch._C._set_grad_enabled",
  1101. "torch._C._set_graph_executor_optimize",
  1102. "torch._C._set_linalg_preferred_backend",
  1103. "torch._C._set_meta_in_tls_dispatch_include",
  1104. "torch._C._set_mkldnn_enabled",
  1105. "torch._C._set_multithreading_enabled",
  1106. "torch._C._set_neg",
  1107. "torch._C._set_nnpack_enabled",
  1108. "torch._C._set_print_stack_traces_on_fatal_signal",
  1109. "torch._C._set_qengine",
  1110. "torch._C._set_sdp_use_flash",
  1111. "torch._C._set_sdp_use_math",
  1112. "torch._C._set_sdp_use_mem_efficient",
  1113. "torch._C._set_should_use_format_with_string_table",
  1114. "torch._C._set_storage_access_error_msg",
  1115. "torch._C._set_tensor_metadata",
  1116. "torch._C._set_tracing_state",
  1117. "torch._C._set_value_trace",
  1118. "torch._C._set_view_replay_enabled",
  1119. "torch._C._set_warnAlways",
  1120. "torch._C._set_worker_pids",
  1121. "torch._C._set_worker_signal_handlers",
  1122. "torch._C._should_allow_numbers_as_tensors",
  1123. "torch._C._show_config",
  1124. "torch._C._sparse._sparse_addmm",
  1125. "torch._C._sparse._sparse_log_softmax",
  1126. "torch._C._sparse._sparse_mm_reduce_impl",
  1127. "torch._C._sparse._sparse_mm",
  1128. "torch._C._sparse._sparse_softmax",
  1129. "torch._C._sparse._spdiags",
  1130. "torch._C._sparse.sparse_sampled_addmm",
  1131. "torch._C._special.special_airy_ai",
  1132. "torch._C._special.special_bessel_j0",
  1133. "torch._C._special.special_bessel_j1",
  1134. "torch._C._special.special_bessel_y0",
  1135. "torch._C._special.special_bessel_y1",
  1136. "torch._C._special.special_chebyshev_polynomial_t",
  1137. "torch._C._special.special_chebyshev_polynomial_u",
  1138. "torch._C._special.special_chebyshev_polynomial_v",
  1139. "torch._C._special.special_chebyshev_polynomial_w",
  1140. "torch._C._special.special_digamma",
  1141. "torch._C._special.special_entr",
  1142. "torch._C._special.special_erf",
  1143. "torch._C._special.special_erfc",
  1144. "torch._C._special.special_erfcx",
  1145. "torch._C._special.special_erfinv",
  1146. "torch._C._special.special_exp2",
  1147. "torch._C._special.special_expit",
  1148. "torch._C._special.special_expm1",
  1149. "torch._C._special.special_gammainc",
  1150. "torch._C._special.special_gammaincc",
  1151. "torch._C._special.special_gammaln",
  1152. "torch._C._special.special_hermite_polynomial_h",
  1153. "torch._C._special.special_hermite_polynomial_he",
  1154. "torch._C._special.special_i0",
  1155. "torch._C._special.special_i0e",
  1156. "torch._C._special.special_i1",
  1157. "torch._C._special.special_i1e",
  1158. "torch._C._special.special_laguerre_polynomial_l",
  1159. "torch._C._special.special_legendre_polynomial_p",
  1160. "torch._C._special.special_log_ndtr",
  1161. "torch._C._special.special_log_softmax",
  1162. "torch._C._special.special_log1p",
  1163. "torch._C._special.special_logit",
  1164. "torch._C._special.special_logsumexp",
  1165. "torch._C._special.special_modified_bessel_i0",
  1166. "torch._C._special.special_modified_bessel_i1",
  1167. "torch._C._special.special_modified_bessel_k0",
  1168. "torch._C._special.special_modified_bessel_k1",
  1169. "torch._C._special.special_multigammaln",
  1170. "torch._C._special.special_ndtr",
  1171. "torch._C._special.special_ndtri",
  1172. "torch._C._special.special_polygamma",
  1173. "torch._C._special.special_psi",
  1174. "torch._C._special.special_round",
  1175. "torch._C._special.special_scaled_modified_bessel_k0",
  1176. "torch._C._special.special_scaled_modified_bessel_k1",
  1177. "torch._C._special.special_shifted_chebyshev_polynomial_t",
  1178. "torch._C._special.special_shifted_chebyshev_polynomial_u",
  1179. "torch._C._special.special_shifted_chebyshev_polynomial_v",
  1180. "torch._C._special.special_shifted_chebyshev_polynomial_w",
  1181. "torch._C._special.special_sinc",
  1182. "torch._C._special.special_softmax",
  1183. "torch._C._special.special_spherical_bessel_j0",
  1184. "torch._C._special.special_xlog1py",
  1185. "torch._C._special.special_xlogy",
  1186. "torch._C._special.special_zeta",
  1187. "torch._C._stash_obj_in_tls",
  1188. "torch._C._storage_id",
  1189. "torch._C._storage_Use_Count",
  1190. "torch._C._supported_qengines",
  1191. "torch._C._te.abs",
  1192. "torch._C._te.acos",
  1193. "torch._C._te.annotate_input_shapes",
  1194. "torch._C._te.asin",
  1195. "torch._C._te.atan",
  1196. "torch._C._te.atan2",
  1197. "torch._C._te.ceil",
  1198. "torch._C._te.Compute",
  1199. "torch._C._te.Compute2",
  1200. "torch._C._te.construct_codegen",
  1201. "torch._C._te.cos",
  1202. "torch._C._te.cosh",
  1203. "torch._C._te.erf",
  1204. "torch._C._te.erfc",
  1205. "torch._C._te.exp",
  1206. "torch._C._te.expm1",
  1207. "torch._C._te.fixup_missing_shape_info",
  1208. "torch._C._te.floor",
  1209. "torch._C._te.fmod",
  1210. "torch._C._te.frac",
  1211. "torch._C._te.ifThenElse",
  1212. "torch._C._te.is_graph_compilable",
  1213. "torch._C._te.isnan",
  1214. "torch._C._te.lgamma",
  1215. "torch._C._te.log",
  1216. "torch._C._te.log10",
  1217. "torch._C._te.log1p",
  1218. "torch._C._te.log2",
  1219. "torch._C._te.lower",
  1220. "torch._C._te.make_shapes_symbolic",
  1221. "torch._C._te.pow",
  1222. "torch._C._te.Reduce",
  1223. "torch._C._te.remainder",
  1224. "torch._C._te.remove_graph_output",
  1225. "torch._C._te.remove_unused_self_argument",
  1226. "torch._C._te.replace_list_output_with_tuple",
  1227. "torch._C._te.round",
  1228. "torch._C._te.rsqrt",
  1229. "torch._C._te.sigmoid",
  1230. "torch._C._te.simplify",
  1231. "torch._C._te.sin",
  1232. "torch._C._te.sinh",
  1233. "torch._C._te.sqrt",
  1234. "torch._C._te.tan",
  1235. "torch._C._te.tanh",
  1236. "torch._C._te.trim_graph",
  1237. "torch._C._te.trunc",
  1238. "torch._C._tensor_impl_raw_handle",
  1239. "torch._C._test_only_add_entry_to_op_version_map",
  1240. "torch._C._test_only_populate_upgraders",
  1241. "torch._C._test_only_remove_entry_to_op_version_map",
  1242. "torch._C._test_only_remove_upgraders",
  1243. "torch._C._to_functionality_key",
  1244. "torch._C._tracer_set_force_outplace",
  1245. "torch._C._tracer_set_get_unique_name_fn",
  1246. "torch._C._tracer_warn_use_python",
  1247. "torch._C._unset_default_mobile_cpu_allocator",
  1248. "torch._C._unset_dispatch_mode",
  1249. "torch._C._valgrind_supported_platform",
  1250. "torch._C._valgrind_toggle_and_dump_stats",
  1251. "torch._C._valgrind_toggle",
  1252. "torch._C._verbose.mkl_set_verbose",
  1253. "torch._C._verbose.mkldnn_set_verbose",
  1254. "torch._C._vmapmode_decrement_nesting",
  1255. "torch._C._vmapmode_increment_nesting",
  1256. "torch._C._warn_deprecation",
  1257. "torch._C._warn",
  1258. "torch._C._will_engine_execute_node",
  1259. "torch._C._wrap_tensor_impl",
  1260. "torch._C.fork",
  1261. "torch._C.get_autocast_cpu_dtype",
  1262. "torch._C.get_autocast_dtype",
  1263. "torch._C.get_autocast_gpu_dtype",
  1264. "torch._C.get_autocast_ipu_dtype",
  1265. "torch._C.get_autocast_xla_dtype",
  1266. "torch._C.get_default_dtype",
  1267. "torch._C.get_num_interop_threads",
  1268. "torch._C.get_num_threads",
  1269. "torch._C.import_ir_module_from_buffer",
  1270. "torch._C.import_ir_module",
  1271. "torch._C.init_num_threads",
  1272. "torch._C.is_anomaly_check_nan_enabled",
  1273. "torch._C.is_anomaly_enabled",
  1274. "torch._C.is_autocast_cache_enabled",
  1275. "torch._C.is_autocast_cpu_enabled",
  1276. "torch._C.is_autocast_enabled",
  1277. "torch._C.is_autocast_ipu_enabled",
  1278. "torch._C.is_autocast_xla_enabled",
  1279. "torch._C.is_grad_enabled",
  1280. "torch._C.is_inference_mode_enabled",
  1281. "torch._C.merge_type_from_type_comment",
  1282. "torch._C.parse_ir",
  1283. "torch._C.parse_schema",
  1284. "torch._C.parse_type_comment",
  1285. "torch._C.read_vitals",
  1286. "torch._C.set_vital",
  1287. "torch._C.unify_type_list",
  1288. "torch._C.vitals_enabled",
  1289. "torch._C.wait",
  1290. "torch._cast_Byte",
  1291. "torch._cast_Char",
  1292. "torch._cast_Double",
  1293. "torch._cast_Float",
  1294. "torch._cast_Half",
  1295. "torch._cast_Int",
  1296. "torch._cast_Long",
  1297. "torch._cast_Short",
  1298. "torch._choose_qparams_per_tensor",
  1299. "torch._chunk_cat",
  1300. "torch._coalesce",
  1301. "torch._compute_linear_combination",
  1302. "torch._conj_copy",
  1303. "torch._conj_physical",
  1304. "torch._conj",
  1305. "torch._convert_indices_from_coo_to_csr",
  1306. "torch._convert_indices_from_csr_to_coo",
  1307. "torch._convert_weight_to_int4pack",
  1308. "torch._convolution_mode",
  1309. "torch._convolution",
  1310. "torch._copy_from_and_resize",
  1311. "torch._copy_from",
  1312. "torch._cslt_compress",
  1313. "torch._cslt_sparse_mm",
  1314. "torch._ctc_loss",
  1315. "torch._cudnn_ctc_loss",
  1316. "torch._cudnn_init_dropout_state",
  1317. "torch._cudnn_rnn_flatten_weight",
  1318. "torch._cudnn_rnn",
  1319. "torch._cufft_clear_plan_cache",
  1320. "torch._cufft_get_plan_cache_max_size",
  1321. "torch._cufft_get_plan_cache_size",
  1322. "torch._cufft_set_plan_cache_max_size",
  1323. "torch._cummax_helper",
  1324. "torch._cummin_helper",
  1325. "torch._debug_has_internal_overlap",
  1326. "torch._dim_arange",
  1327. "torch._dirichlet_grad",
  1328. "torch._disable_functionalization",
  1329. "torch._efficientzerotensor",
  1330. "torch._embedding_bag_forward_only",
  1331. "torch._embedding_bag",
  1332. "torch._empty_affine_quantized",
  1333. "torch._empty_per_channel_affine_quantized",
  1334. "torch._enable_functionalization",
  1335. "torch._euclidean_dist",
  1336. "torch._fake_quantize_learnable_per_channel_affine",
  1337. "torch._fake_quantize_learnable_per_tensor_affine",
  1338. "torch._fake_quantize_per_tensor_affine_cachemask_tensor_qparams",
  1339. "torch._fft_c2c",
  1340. "torch._fft_c2r",
  1341. "torch._fft_r2c",
  1342. "torch._fill_mem_eff_dropout_mask_",
  1343. "torch._foobar",
  1344. "torch._foreach_abs_",
  1345. "torch._foreach_abs",
  1346. "torch._foreach_acos_",
  1347. "torch._foreach_acos",
  1348. "torch._foreach_add_",
  1349. "torch._foreach_add",
  1350. "torch._foreach_addcdiv_",
  1351. "torch._foreach_addcdiv",
  1352. "torch._foreach_addcmul_",
  1353. "torch._foreach_addcmul",
  1354. "torch._foreach_asin_",
  1355. "torch._foreach_asin",
  1356. "torch._foreach_atan_",
  1357. "torch._foreach_atan",
  1358. "torch._foreach_ceil_",
  1359. "torch._foreach_ceil",
  1360. "torch._foreach_clamp_max_",
  1361. "torch._foreach_clamp_max",
  1362. "torch._foreach_clamp_min_",
  1363. "torch._foreach_clamp_min",
  1364. "torch._foreach_copy_",
  1365. "torch._foreach_cos_",
  1366. "torch._foreach_cos",
  1367. "torch._foreach_cosh_",
  1368. "torch._foreach_cosh",
  1369. "torch._foreach_div_",
  1370. "torch._foreach_div",
  1371. "torch._foreach_erf_",
  1372. "torch._foreach_erf",
  1373. "torch._foreach_erfc_",
  1374. "torch._foreach_erfc",
  1375. "torch._foreach_exp_",
  1376. "torch._foreach_exp",
  1377. "torch._foreach_expm1_",
  1378. "torch._foreach_expm1",
  1379. "torch._foreach_floor_",
  1380. "torch._foreach_floor",
  1381. "torch._foreach_frac_",
  1382. "torch._foreach_frac",
  1383. "torch._foreach_lerp_",
  1384. "torch._foreach_lerp",
  1385. "torch._foreach_lgamma_",
  1386. "torch._foreach_lgamma",
  1387. "torch._foreach_log_",
  1388. "torch._foreach_log",
  1389. "torch._foreach_log10_",
  1390. "torch._foreach_log10",
  1391. "torch._foreach_log1p_",
  1392. "torch._foreach_log1p",
  1393. "torch._foreach_log2_",
  1394. "torch._foreach_log2",
  1395. "torch._foreach_maximum_",
  1396. "torch._foreach_maximum",
  1397. "torch._foreach_minimum_",
  1398. "torch._foreach_minimum",
  1399. "torch._foreach_mul_",
  1400. "torch._foreach_mul",
  1401. "torch._foreach_neg_",
  1402. "torch._foreach_neg",
  1403. "torch._foreach_norm",
  1404. "torch._foreach_pow_",
  1405. "torch._foreach_pow",
  1406. "torch._foreach_reciprocal_",
  1407. "torch._foreach_reciprocal",
  1408. "torch._foreach_round_",
  1409. "torch._foreach_round",
  1410. "torch._foreach_sigmoid_",
  1411. "torch._foreach_sigmoid",
  1412. "torch._foreach_sign_",
  1413. "torch._foreach_sign",
  1414. "torch._foreach_sin_",
  1415. "torch._foreach_sin",
  1416. "torch._foreach_sinh_",
  1417. "torch._foreach_sinh",
  1418. "torch._foreach_sqrt_",
  1419. "torch._foreach_sqrt",
  1420. "torch._foreach_sub_",
  1421. "torch._foreach_sub",
  1422. "torch._foreach_tan_",
  1423. "torch._foreach_tan",
  1424. "torch._foreach_tanh_",
  1425. "torch._foreach_tanh",
  1426. "torch._foreach_trunc_",
  1427. "torch._foreach_trunc",
  1428. "torch._foreach_zero_",
  1429. "torch._freeze_functional_tensor",
  1430. "torch._from_functional_tensor",
  1431. "torch._functional_assert_async",
  1432. "torch._functional_sym_constrain_range_for_size",
  1433. "torch._functional_sym_constrain_range",
  1434. "torch._functionalize_are_all_mutations_hidden_from_autograd",
  1435. "torch._functionalize_commit_update",
  1436. "torch._functionalize_enable_reapply_views",
  1437. "torch._functionalize_has_data_mutation",
  1438. "torch._functionalize_has_metadata_mutation",
  1439. "torch._functionalize_is_multi_output_view",
  1440. "torch._functionalize_mark_mutation_hidden_from_autograd",
  1441. "torch._functionalize_replace",
  1442. "torch._functionalize_sync",
  1443. "torch._functionalize_was_storage_changed",
  1444. "torch._fused_adam_",
  1445. "torch._fused_adamw_",
  1446. "torch._fused_dropout",
  1447. "torch._fused_moving_avg_obs_fq_helper",
  1448. "torch._fused_sdp_choice",
  1449. "torch._fw_primal_copy",
  1450. "torch._grid_sampler_2d_cpu_fallback",
  1451. "torch._has_compatible_shallow_copy_type",
  1452. "torch._histogramdd_bin_edges",
  1453. "torch._histogramdd_from_bin_cts",
  1454. "torch._histogramdd_from_bin_tensors",
  1455. "torch._index_put_impl_",
  1456. "torch._indices_copy",
  1457. "torch._int_mm",
  1458. "torch._is_all_true",
  1459. "torch._is_any_true",
  1460. "torch._is_functional_tensor",
  1461. "torch._is_zerotensor",
  1462. "torch._linalg_check_errors",
  1463. "torch._linalg_det",
  1464. "torch._linalg_eigh",
  1465. "torch._linalg_eigvals",
  1466. "torch._linalg_slogdet",
  1467. "torch._linalg_solve_ex",
  1468. "torch._linalg_svd",
  1469. "torch._log_softmax_backward_data",
  1470. "torch._log_softmax",
  1471. "torch._logcumsumexp",
  1472. "torch._lstm_mps",
  1473. "torch._lu_with_info",
  1474. "torch._make_dep_token",
  1475. "torch._make_dual_copy",
  1476. "torch._make_dual",
  1477. "torch._make_per_channel_quantized_tensor",
  1478. "torch._make_per_tensor_quantized_tensor",
  1479. "torch._masked_scale",
  1480. "torch._masked_softmax",
  1481. "torch._mirror_autograd_meta_to",
  1482. "torch._mixed_dtypes_linear",
  1483. "torch._mkldnn_reshape",
  1484. "torch._mkldnn_transpose_",
  1485. "torch._mkldnn_transpose",
  1486. "torch._mps_convolution_transpose",
  1487. "torch._mps_convolution",
  1488. "torch._native_batch_norm_legit_no_training",
  1489. "torch._native_batch_norm_legit",
  1490. "torch._native_multi_head_attention",
  1491. "torch._neg_view_copy",
  1492. "torch._neg_view",
  1493. "torch._nested_from_padded_and_nested_example",
  1494. "torch._nested_tensor_from_mask_left_aligned",
  1495. "torch._nested_tensor_from_tensor_list",
  1496. "torch._nested_tensor_softmax_with_shape",
  1497. "torch._nested_view_from_buffer_copy",
  1498. "torch._nested_view_from_buffer",
  1499. "torch._nnpack_available",
  1500. "torch._nnpack_spatial_convolution",
  1501. "torch._pack_padded_sequence",
  1502. "torch._pad_packed_sequence",
  1503. "torch._pin_memory",
  1504. "torch._prelu_kernel",
  1505. "torch._propagate_xla_data",
  1506. "torch._remove_batch_dim",
  1507. "torch._reshape_alias_copy",
  1508. "torch._reshape_from_tensor",
  1509. "torch._resize_output_",
  1510. "torch._rowwise_prune",
  1511. "torch._sample_dirichlet",
  1512. "torch._saturate_weight_to_fp16",
  1513. "torch._scaled_dot_product_attention_math",
  1514. "torch._scaled_dot_product_efficient_attention",
  1515. "torch._scaled_dot_product_flash_attention",
  1516. "torch._scaled_dot_product_flash_attention_for_cpu",
  1517. "torch._scaled_dot_product_cudnn_attention",
  1518. "torch._scaled_mm",
  1519. "torch._shape_as_tensor",
  1520. "torch._sobol_engine_draw",
  1521. "torch._sobol_engine_ff_",
  1522. "torch._sobol_engine_initialize_state_",
  1523. "torch._sobol_engine_scramble_",
  1524. "torch._softmax_backward_data",
  1525. "torch._softmax",
  1526. "torch._sparse_broadcast_to_copy",
  1527. "torch._sparse_broadcast_to",
  1528. "torch._sparse_csr_prod",
  1529. "torch._sparse_csr_sum",
  1530. "torch._sparse_log_softmax_backward_data",
  1531. "torch._sparse_semi_structured_addmm",
  1532. "torch._sparse_semi_structured_linear",
  1533. "torch._sparse_semi_structured_mm",
  1534. "torch._sparse_softmax_backward_data",
  1535. "torch._sparse_sparse_matmul",
  1536. "torch._sparse_sum",
  1537. "torch._stack",
  1538. "torch._standard_gamma_grad",
  1539. "torch._standard_gamma",
  1540. "torch._test_autograd_multiple_dispatch_view_copy",
  1541. "torch._test_autograd_multiple_dispatch_view",
  1542. "torch._test_autograd_multiple_dispatch",
  1543. "torch._test_check_tensor",
  1544. "torch._test_functorch_fallback",
  1545. "torch._test_serialization_subcmul",
  1546. "torch._to_cpu",
  1547. "torch._to_functional_tensor",
  1548. "torch._to_sparse_semi_structured",
  1549. "torch._transform_bias_rescale_qkv",
  1550. "torch._transformer_encoder_layer_fwd",
  1551. "torch._trilinear",
  1552. "torch._triton_multi_head_attention",
  1553. "torch._triton_scaled_dot_attention",
  1554. "torch._unique",
  1555. "torch._unique2",
  1556. "torch._unpack_dual",
  1557. "torch._unsafe_index_put",
  1558. "torch._unsafe_index",
  1559. "torch._use_cudnn_ctc_loss",
  1560. "torch._use_cudnn_rnn_flatten_weight",
  1561. "torch._values_copy",
  1562. "torch._weight_int4pack_mm",
  1563. "torch._weight_int8pack_mm",
  1564. "torch._weight_norm_interface",
  1565. "torch._weight_norm",
  1566. "torch.abs_",
  1567. "torch.abs",
  1568. "torch.absolute",
  1569. "torch.acos_",
  1570. "torch.acos",
  1571. "torch.acosh_",
  1572. "torch.acosh",
  1573. "torch.adaptive_avg_pool1d",
  1574. "torch.adaptive_max_pool1d",
  1575. "torch.add",
  1576. "torch.addbmm",
  1577. "torch.addcdiv",
  1578. "torch.addcmul",
  1579. "torch.addmm",
  1580. "torch.addmv_",
  1581. "torch.addmv",
  1582. "torch.addr",
  1583. "torch.adjoint",
  1584. "torch.affine_grid_generator",
  1585. "torch.alias_copy",
  1586. "torch.all",
  1587. "torch.allclose",
  1588. "torch.alpha_dropout_",
  1589. "torch.alpha_dropout",
  1590. "torch.amax",
  1591. "torch.amin",
  1592. "torch.aminmax",
  1593. "torch.angle",
  1594. "torch.any",
  1595. "torch.arange",
  1596. "torch.arccos_",
  1597. "torch.arccos",
  1598. "torch.arccosh_",
  1599. "torch.arccosh",
  1600. "torch.arcsin_",
  1601. "torch.arcsin",
  1602. "torch.arcsinh_",
  1603. "torch.arcsinh",
  1604. "torch.arctan_",
  1605. "torch.arctan",
  1606. "torch.arctan2",
  1607. "torch.arctanh_",
  1608. "torch.arctanh",
  1609. "torch.argmax",
  1610. "torch.argmin",
  1611. "torch.argsort",
  1612. "torch.argwhere",
  1613. "torch.as_strided_",
  1614. "torch.as_strided_copy",
  1615. "torch.as_strided_scatter",
  1616. "torch.as_strided",
  1617. "torch.as_tensor",
  1618. "torch.asarray",
  1619. "torch.asin_",
  1620. "torch.asin",
  1621. "torch.asinh_",
  1622. "torch.asinh",
  1623. "torch.atan_",
  1624. "torch.atan",
  1625. "torch.atan2",
  1626. "torch.atanh_",
  1627. "torch.atanh",
  1628. "torch.avg_pool1d",
  1629. "torch.baddbmm",
  1630. "torch.bartlett_window",
  1631. "torch.batch_norm_backward_elemt",
  1632. "torch.batch_norm_backward_reduce",
  1633. "torch.batch_norm_elemt",
  1634. "torch.batch_norm_gather_stats_with_counts",
  1635. "torch.batch_norm_gather_stats",
  1636. "torch.batch_norm_stats",
  1637. "torch.batch_norm_update_stats",
  1638. "torch.batch_norm",
  1639. "torch.bernoulli",
  1640. "torch.bilinear",
  1641. "torch.binary_cross_entropy_with_logits",
  1642. "torch.bincount",
  1643. "torch.binomial",
  1644. "torch.bitwise_and",
  1645. "torch.bitwise_left_shift",
  1646. "torch.bitwise_not",
  1647. "torch.bitwise_or",
  1648. "torch.bitwise_right_shift",
  1649. "torch.bitwise_xor",
  1650. "torch.blackman_window",
  1651. "torch.bmm",
  1652. "torch.broadcast_to",
  1653. "torch.bucketize",
  1654. "torch.can_cast",
  1655. "torch.cat",
  1656. "torch.ccol_indices_copy",
  1657. "torch.ceil_",
  1658. "torch.ceil",
  1659. "torch.celu_",
  1660. "torch.celu",
  1661. "torch.channel_shuffle",
  1662. "torch.cholesky_inverse",
  1663. "torch.cholesky_solve",
  1664. "torch.cholesky",
  1665. "torch.choose_qparams_optimized",
  1666. "torch.chunk",
  1667. "torch.clamp_",
  1668. "torch.clamp_max_",
  1669. "torch.clamp_max",
  1670. "torch.clamp_min_",
  1671. "torch.clamp_min",
  1672. "torch.clamp",
  1673. "torch.clip_",
  1674. "torch.clip",
  1675. "torch.clone",
  1676. "torch.col_indices_copy",
  1677. "torch.column_stack",
  1678. "torch.combinations",
  1679. "torch.complex",
  1680. "torch.concat",
  1681. "torch.concatenate",
  1682. "torch.conj_physical_",
  1683. "torch.conj_physical",
  1684. "torch.conj",
  1685. "torch.constant_pad_nd",
  1686. "torch.conv_tbc",
  1687. "torch.conv_transpose1d",
  1688. "torch.conv_transpose2d",
  1689. "torch.conv_transpose3d",
  1690. "torch.conv1d",
  1691. "torch.conv2d",
  1692. "torch.conv3d",
  1693. "torch.convolution",
  1694. "torch.copysign",
  1695. "torch.corrcoef",
  1696. "torch.cos_",
  1697. "torch.cos",
  1698. "torch.cosh_",
  1699. "torch.cosh",
  1700. "torch.cosine_embedding_loss",
  1701. "torch.cosine_similarity",
  1702. "torch.count_nonzero",
  1703. "torch.cov",
  1704. "torch.cross",
  1705. "torch.crow_indices_copy",
  1706. "torch.ctc_loss",
  1707. "torch.cudnn_affine_grid_generator",
  1708. "torch.cudnn_batch_norm",
  1709. "torch.cudnn_convolution_add_relu",
  1710. "torch.cudnn_convolution_relu",
  1711. "torch.cudnn_convolution_transpose",
  1712. "torch.cudnn_convolution",
  1713. "torch.cudnn_grid_sampler",
  1714. "torch.cudnn_is_acceptable",
  1715. "torch.cummax",
  1716. "torch.cummin",
  1717. "torch.cumprod",
  1718. "torch.cumsum",
  1719. "torch.cumulative_trapezoid",
  1720. "torch.deg2rad_",
  1721. "torch.deg2rad",
  1722. "torch.dequantize",
  1723. "torch.det",
  1724. "torch.detach_",
  1725. "torch.detach_copy",
  1726. "torch.detach",
  1727. "torch.diag_embed",
  1728. "torch.diag",
  1729. "torch.diagflat",
  1730. "torch.diagonal_copy",
  1731. "torch.diagonal_scatter",
  1732. "torch.diagonal",
  1733. "torch.diff",
  1734. "torch.digamma",
  1735. "torch.dist",
  1736. "torch.div",
  1737. "torch.divide",
  1738. "torch.dot",
  1739. "torch.dropout_",
  1740. "torch.dropout",
  1741. "torch.dsmm",
  1742. "torch.dsplit",
  1743. "torch.dstack",
  1744. "torch.embedding_bag",
  1745. "torch.embedding_renorm_",
  1746. "torch.embedding",
  1747. "torch.empty_like",
  1748. "torch.empty_permuted",
  1749. "torch.empty_quantized",
  1750. "torch.empty_strided",
  1751. "torch.empty",
  1752. "torch.eq",
  1753. "torch.equal",
  1754. "torch.erf_",
  1755. "torch.erf",
  1756. "torch.erfc_",
  1757. "torch.erfc",
  1758. "torch.erfinv",
  1759. "torch.exp_",
  1760. "torch.exp",
  1761. "torch.exp2_",
  1762. "torch.exp2",
  1763. "torch.expand_copy",
  1764. "torch.expm1_",
  1765. "torch.expm1",
  1766. "torch.eye",
  1767. "torch.fake_quantize_per_channel_affine",
  1768. "torch.fake_quantize_per_tensor_affine",
  1769. "torch.fbgemm_linear_fp16_weight_fp32_activation",
  1770. "torch.fbgemm_linear_fp16_weight",
  1771. "torch.fbgemm_linear_int8_weight_fp32_activation",
  1772. "torch.fbgemm_linear_int8_weight",
  1773. "torch.fbgemm_linear_quantize_weight",
  1774. "torch.fbgemm_pack_gemm_matrix_fp16",
  1775. "torch.fbgemm_pack_quantized_matrix",
  1776. "torch.feature_alpha_dropout_",
  1777. "torch.feature_alpha_dropout",
  1778. "torch.feature_dropout_",
  1779. "torch.feature_dropout",
  1780. "torch.fill_",
  1781. "torch.fill",
  1782. "torch.fix_",
  1783. "torch.fix",
  1784. "torch.flatten",
  1785. "torch.flip",
  1786. "torch.fliplr",
  1787. "torch.flipud",
  1788. "torch.float_power",
  1789. "torch.floor_",
  1790. "torch.floor_divide",
  1791. "torch.floor",
  1792. "torch.fmax",
  1793. "torch.fmin",
  1794. "torch.fmod",
  1795. "torch.frac_",
  1796. "torch.frac",
  1797. "torch.frexp",
  1798. "torch.frobenius_norm",
  1799. "torch.from_file",
  1800. "torch.from_numpy",
  1801. "torch.frombuffer",
  1802. "torch.full_like",
  1803. "torch.full",
  1804. "torch.fused_moving_avg_obs_fake_quant",
  1805. "torch.gather",
  1806. "torch.gcd_",
  1807. "torch.gcd",
  1808. "torch.ge",
  1809. "torch.geqrf",
  1810. "torch.ger",
  1811. "torch.get_device",
  1812. "torch.gradient",
  1813. "torch.greater_equal",
  1814. "torch.greater",
  1815. "torch.grid_sampler_2d",
  1816. "torch.grid_sampler_3d",
  1817. "torch.grid_sampler",
  1818. "torch.group_norm",
  1819. "torch.gru_cell",
  1820. "torch.gru",
  1821. "torch.gt",
  1822. "torch.hamming_window",
  1823. "torch.hann_window",
  1824. "torch.hardshrink",
  1825. "torch.heaviside",
  1826. "torch.hinge_embedding_loss",
  1827. "torch.histc",
  1828. "torch.histogram",
  1829. "torch.histogramdd",
  1830. "torch.hsmm",
  1831. "torch.hsplit",
  1832. "torch.hspmm",
  1833. "torch.hstack",
  1834. "torch.hypot",
  1835. "torch.i0_",
  1836. "torch.i0",
  1837. "torch.igamma",
  1838. "torch.igammac",
  1839. "torch.imag",
  1840. "torch.index_add",
  1841. "torch.index_copy",
  1842. "torch.index_fill",
  1843. "torch.index_put_",
  1844. "torch.index_put",
  1845. "torch.index_reduce",
  1846. "torch.index_select",
  1847. "torch.indices_copy",
  1848. "torch.inner",
  1849. "torch.instance_norm",
  1850. "torch.int_repr",
  1851. "torch.inverse",
  1852. "torch.is_complex",
  1853. "torch.is_conj",
  1854. "torch.is_distributed",
  1855. "torch.is_floating_point",
  1856. "torch.is_inference",
  1857. "torch.is_neg",
  1858. "torch.is_nonzero",
  1859. "torch.is_same_size",
  1860. "torch.is_signed",
  1861. "torch.is_vulkan_available",
  1862. "torch.isclose",
  1863. "torch.isfinite",
  1864. "torch.isin",
  1865. "torch.isinf",
  1866. "torch.isnan",
  1867. "torch.isneginf",
  1868. "torch.isposinf",
  1869. "torch.isreal",
  1870. "torch.istft",
  1871. "torch.kaiser_window",
  1872. "torch.kl_div",
  1873. "torch.kron",
  1874. "torch.kthvalue",
  1875. "torch.layer_norm",
  1876. "torch.lcm_",
  1877. "torch.lcm",
  1878. "torch.ldexp_",
  1879. "torch.ldexp",
  1880. "torch.le",
  1881. "torch.lerp",
  1882. "torch.less_equal",
  1883. "torch.less",
  1884. "torch.lgamma",
  1885. "torch.linspace",
  1886. "torch.log_",
  1887. "torch.log_softmax",
  1888. "torch.log",
  1889. "torch.log10_",
  1890. "torch.log10",
  1891. "torch.log1p_",
  1892. "torch.log1p",
  1893. "torch.log2_",
  1894. "torch.log2",
  1895. "torch.logaddexp",
  1896. "torch.logaddexp2",
  1897. "torch.logcumsumexp",
  1898. "torch.logdet",
  1899. "torch.logical_and",
  1900. "torch.logical_not",
  1901. "torch.logical_or",
  1902. "torch.logical_xor",
  1903. "torch.logit_",
  1904. "torch.logit",
  1905. "torch.logspace",
  1906. "torch.logsumexp",
  1907. "torch.lstm_cell",
  1908. "torch.lstm",
  1909. "torch.lt",
  1910. "torch.lu_solve",
  1911. "torch.lu_unpack",
  1912. "torch.margin_ranking_loss",
  1913. "torch.masked_fill",
  1914. "torch.masked_scatter",
  1915. "torch.masked_select",
  1916. "torch.matmul",
  1917. "torch.matrix_exp",
  1918. "torch.matrix_power",
  1919. "torch.max_pool1d_with_indices",
  1920. "torch.max_pool1d",
  1921. "torch.max_pool2d",
  1922. "torch.max_pool3d",
  1923. "torch.max",
  1924. "torch.maximum",
  1925. "torch.mean",
  1926. "torch.median",
  1927. "torch.min",
  1928. "torch.minimum",
  1929. "torch.miopen_batch_norm",
  1930. "torch.miopen_convolution_add_relu",
  1931. "torch.miopen_convolution_relu",
  1932. "torch.miopen_convolution_transpose",
  1933. "torch.miopen_convolution",
  1934. "torch.miopen_depthwise_convolution",
  1935. "torch.miopen_rnn",
  1936. "torch.mkldnn_adaptive_avg_pool2d",
  1937. "torch.mkldnn_convolution",
  1938. "torch.mkldnn_linear_backward_weights",
  1939. "torch.mkldnn_max_pool2d",
  1940. "torch.mkldnn_max_pool3d",
  1941. "torch.mkldnn_rnn_layer",
  1942. "torch.mm",
  1943. "torch.mode",
  1944. "torch.moveaxis",
  1945. "torch.movedim",
  1946. "torch.msort",
  1947. "torch.mul",
  1948. "torch.multinomial",
  1949. "torch.multiply",
  1950. "torch.mv",
  1951. "torch.mvlgamma",
  1952. "torch.nan_to_num_",
  1953. "torch.nan_to_num",
  1954. "torch.nanmean",
  1955. "torch.nanmedian",
  1956. "torch.nanquantile",
  1957. "torch.nansum",
  1958. "torch.narrow_copy",
  1959. "torch.narrow",
  1960. "torch.native_batch_norm",
  1961. "torch.native_channel_shuffle",
  1962. "torch.native_dropout",
  1963. "torch.native_group_norm",
  1964. "torch.native_layer_norm",
  1965. "torch.native_norm",
  1966. "torch.ne",
  1967. "torch.neg_",
  1968. "torch.neg",
  1969. "torch.negative_",
  1970. "torch.negative",
  1971. "torch.nextafter",
  1972. "torch.nonzero_static",
  1973. "torch.nonzero",
  1974. "torch.norm_except_dim",
  1975. "torch.normal",
  1976. "torch.not_equal",
  1977. "torch.nuclear_norm",
  1978. "torch.numel",
  1979. "torch.ones_like",
  1980. "torch.ones",
  1981. "torch.orgqr",
  1982. "torch.ormqr",
  1983. "torch.outer",
  1984. "torch.pairwise_distance",
  1985. "torch.pdist",
  1986. "torch.permute_copy",
  1987. "torch.permute",
  1988. "torch.pinverse",
  1989. "torch.pixel_shuffle",
  1990. "torch.pixel_unshuffle",
  1991. "torch.poisson_nll_loss",
  1992. "torch.poisson",
  1993. "torch.polar",
  1994. "torch.polygamma",
  1995. "torch.positive",
  1996. "torch.pow",
  1997. "torch.prelu",
  1998. "torch._print",
  1999. "torch.prod",
  2000. "torch.promote_types",
  2001. "torch.put",
  2002. "torch.q_per_channel_axis",
  2003. "torch.q_per_channel_scales",
  2004. "torch.q_per_channel_zero_points",
  2005. "torch.q_scale",
  2006. "torch.q_zero_point",
  2007. "torch.qr",
  2008. "torch.quantile",
  2009. "torch.quantize_per_channel",
  2010. "torch.quantize_per_tensor_dynamic",
  2011. "torch.quantize_per_tensor",
  2012. "torch.quantized_batch_norm",
  2013. "torch.quantized_gru_cell",
  2014. "torch.quantized_lstm_cell",
  2015. "torch.quantized_max_pool1d",
  2016. "torch.quantized_max_pool2d",
  2017. "torch.quantized_max_pool3d",
  2018. "torch.quantized_rnn_relu_cell",
  2019. "torch.quantized_rnn_tanh_cell",
  2020. "torch.rad2deg_",
  2021. "torch.rad2deg",
  2022. "torch.rand_like",
  2023. "torch.rand",
  2024. "torch.randint_like",
  2025. "torch.randint",
  2026. "torch.randn_like",
  2027. "torch.randn",
  2028. "torch.randperm",
  2029. "torch.range",
  2030. "torch.ravel",
  2031. "torch.real",
  2032. "torch.reciprocal_",
  2033. "torch.reciprocal",
  2034. "torch.relu_",
  2035. "torch.relu",
  2036. "torch.remainder",
  2037. "torch.renorm",
  2038. "torch.repeat_interleave",
  2039. "torch.reshape",
  2040. "torch.resolve_conj",
  2041. "torch.resolve_neg",
  2042. "torch.result_type",
  2043. "torch.rms_norm",
  2044. "torch.rnn_relu_cell",
  2045. "torch.rnn_relu",
  2046. "torch.rnn_tanh_cell",
  2047. "torch.rnn_tanh",
  2048. "torch.roll",
  2049. "torch.rot90",
  2050. "torch.round_",
  2051. "torch.round",
  2052. "torch.row_indices_copy",
  2053. "torch.row_stack",
  2054. "torch.rrelu_",
  2055. "torch.rrelu",
  2056. "torch.rsqrt_",
  2057. "torch.rsqrt",
  2058. "torch.rsub",
  2059. "torch.saddmm",
  2060. "torch.scalar_tensor",
  2061. "torch.scatter_add",
  2062. "torch.scatter_reduce",
  2063. "torch.scatter",
  2064. "torch.searchsorted",
  2065. "torch.segment_reduce",
  2066. "torch.select_copy",
  2067. "torch.select_scatter",
  2068. "torch.select",
  2069. "torch.selu_",
  2070. "torch.selu",
  2071. "torch.sgn",
  2072. "torch.sigmoid_",
  2073. "torch.sigmoid",
  2074. "torch.sign",
  2075. "torch.signal.windows.windows.sqrt",
  2076. "torch.signbit",
  2077. "torch.sin_",
  2078. "torch.sin",
  2079. "torch.sinc_",
  2080. "torch.sinc",
  2081. "torch.sinh_",
  2082. "torch.sinh",
  2083. "torch.slice_copy",
  2084. "torch.slice_scatter",
  2085. "torch.slogdet",
  2086. "torch.smm",
  2087. "torch.softmax",
  2088. "torch.sort",
  2089. "torch.split_copy",
  2090. "torch.split_with_sizes_copy",
  2091. "torch.split_with_sizes",
  2092. "torch.spmm",
  2093. "torch.sqrt_",
  2094. "torch.sqrt",
  2095. "torch.square_",
  2096. "torch.square",
  2097. "torch.squeeze_copy",
  2098. "torch.squeeze",
  2099. "torch.sspaddmm",
  2100. "torch.stack",
  2101. "torch.std_mean",
  2102. "torch.std",
  2103. "torch.sub",
  2104. "torch.subtract",
  2105. "torch.sum",
  2106. "torch.svd",
  2107. "torch.swapaxes",
  2108. "torch.swapdims",
  2109. "torch.sym_constrain_range_for_size",
  2110. "torch.sym_constrain_range",
  2111. "torch.t_copy",
  2112. "torch.t",
  2113. "torch.take_along_dim",
  2114. "torch.take",
  2115. "torch.tan_",
  2116. "torch.tan",
  2117. "torch.tanh_",
  2118. "torch.tanh",
  2119. "torch.tensor_split",
  2120. "torch.tensor",
  2121. "torch.threshold_",
  2122. "torch.threshold",
  2123. "torch.tile",
  2124. "torch.topk",
  2125. "torch.trace",
  2126. "torch.transpose_copy",
  2127. "torch.transpose",
  2128. "torch.trapezoid",
  2129. "torch.trapz",
  2130. "torch.triangular_solve",
  2131. "torch.tril_indices",
  2132. "torch.tril",
  2133. "torch.triplet_margin_loss",
  2134. "torch.triu_indices",
  2135. "torch.triu",
  2136. "torch.true_divide",
  2137. "torch.trunc_",
  2138. "torch.trunc",
  2139. "torch.unbind_copy",
  2140. "torch.unbind",
  2141. "torch.unflatten",
  2142. "torch.unfold_copy",
  2143. "torch.unsafe_chunk",
  2144. "torch.unsafe_split_with_sizes",
  2145. "torch.unsafe_split",
  2146. "torch.unsqueeze_copy",
  2147. "torch.unsqueeze",
  2148. "torch.values_copy",
  2149. "torch.vander",
  2150. "torch.var_mean",
  2151. "torch.var",
  2152. "torch.vdot",
  2153. "torch.view_as_complex_copy",
  2154. "torch.view_as_complex",
  2155. "torch.view_as_real_copy",
  2156. "torch.view_as_real",
  2157. "torch.view_copy",
  2158. "torch.vsplit",
  2159. "torch.vstack",
  2160. "torch.where",
  2161. "torch.xlogy_",
  2162. "torch.xlogy",
  2163. "torch.zero_",
  2164. "torch.zeros",
  2165. "torch.zeros_like",
  2166. "torch._fused_sgd_",
  2167. "torch.slice_inverse",
  2168. "torch._assert_scalar",
  2169. "torch._functional_assert_scalar",
  2170. ],
  2171. TorchInGraphFunctionVariable,
  2172. )
  2173. if sys.version_info >= (3, 9):
  2174. torch_c_binding_in_graph_functions["math.lcm"] = TorchInGraphFunctionVariable
  2175. if sys.version_info >= (3, 11):
  2176. torch_c_binding_in_graph_functions["math.exp2"] = TorchInGraphFunctionVariable
  2177. torch_c_binding_in_graph_functions["math.cbrt"] = TorchInGraphFunctionVariable
  2178. # In graph functions (including constant folding) that are not C bindings
  2179. torch_non_c_binding_in_graph_functions = dict.fromkeys(
  2180. [
  2181. "torch.__future__.get_overwrite_module_params_on_conversion",
  2182. "torch.__future__.set_overwrite_module_params_on_conversion",
  2183. "torch.__getattr__",
  2184. "torch._assert",
  2185. "torch._check_index",
  2186. "torch._check_is_size",
  2187. "torch._check_not_implemented",
  2188. "torch._check_tensor_all_with",
  2189. "torch._check_tensor_all",
  2190. "torch._check_type",
  2191. "torch._check_value",
  2192. "torch._check_with",
  2193. "torch._check",
  2194. "torch._compile._disable_dynamo",
  2195. "torch._functorch.apis.chunk_vmap",
  2196. "torch._functorch.autograd_function.custom_function_call_functionalize",
  2197. "torch._functorch.autograd_function.custom_function_call_grad",
  2198. "torch._functorch.autograd_function.custom_function_call_vmap_generate_rule",
  2199. "torch._functorch.autograd_function.custom_function_call_vmap",
  2200. "torch._functorch.autograd_function.generate_single_level_function",
  2201. "torch._functorch.autograd_function.get_tangents_in_dims",
  2202. "torch._functorch.autograd_function.has_overriden_vmap_rule",
  2203. "torch._functorch.autograd_function.reductify_leaf",
  2204. "torch._functorch.autograd_function.reductify",
  2205. "torch._functorch.autograd_function.validate_vmap_returns_tuple_of_two_elements",
  2206. "torch._functorch.autograd_function.vmapify_autograd_function",
  2207. "torch._functorch.autograd_function.wrap_outputs_maintaining_identity",
  2208. "torch._functorch.batch_norm_replacement.batch_norm_without_running_stats",
  2209. "torch._functorch.batch_norm_replacement.replace_all_batch_norm_modules_",
  2210. "torch._functorch.deprecated.combine_state_for_ensemble",
  2211. "torch._functorch.deprecated.functionalize",
  2212. "torch._functorch.deprecated.get_warning",
  2213. "torch._functorch.deprecated.make_functional_with_buffers",
  2214. "torch._functorch.deprecated.make_functional",
  2215. "torch._functorch.deprecated.setup_docs",
  2216. "torch._functorch.deprecated.warn_deprecated",
  2217. "torch._functorch.eager_transforms._any_differentiable",
  2218. "torch._functorch.eager_transforms._autograd_grad",
  2219. "torch._functorch.eager_transforms._vjp_treespec_compare",
  2220. "torch._functorch.eager_transforms._set_tensor_requires_grad",
  2221. "torch._functorch.eager_transforms._jvp_treespec_compare",
  2222. "torch._functorch.eager_transforms._linearize_treespec_compare",
  2223. "torch._functorch.eager_transforms._is_differentiable",
  2224. "torch._functorch.eager_transforms._maybe_unwrap_functional_tensor",
  2225. "torch._functorch.eager_transforms._maybe_wrap_functional_tensor",
  2226. "torch._functorch.eager_transforms._unwrap_all_tensors_from_functional",
  2227. "torch._functorch.eager_transforms._wrap_all_tensors_to_functional",
  2228. "torch._functorch.eager_transforms.assert_flat_tuple_of_tensors",
  2229. "torch._functorch.eager_transforms.functionalize",
  2230. "torch._functorch.eager_transforms.lazy_dynamo_disable",
  2231. "torch._functorch.eager_transforms.noop",
  2232. "torch._functorch.functional_call.construct_stacked_leaf",
  2233. "torch._functorch.functional_call.functional_call",
  2234. "torch._functorch.functional_call.stack_module_state",
  2235. "torch._functorch.pyfunctorch.coerce_cinterpreter",
  2236. "torch._functorch.pyfunctorch.dispatch_functorch",
  2237. "torch._functorch.pyfunctorch.nested",
  2238. "torch._functorch.pyfunctorch.retrieve_current_functorch_interpreter",
  2239. "torch._functorch.pyfunctorch.temporarily_pop_interpreter_stack",
  2240. "torch._functorch.utils.enable_single_level_autograd_function",
  2241. "torch._functorch.utils.exposed_in",
  2242. "torch._functorch.utils.unwrap_dead_wrappers",
  2243. "torch._functorch.vmap.lazy_load_decompositions",
  2244. "torch._guards.compile_context",
  2245. "torch._guards.detect_fake_mode",
  2246. "torch._guards.tracing",
  2247. "torch._higher_order_ops.map._has_potential_branch_input_alias",
  2248. "torch._higher_order_ops.map._has_potential_branch_input_mutation",
  2249. "torch._higher_order_ops.map._stack_pytree",
  2250. "torch._higher_order_ops.map._unstack_pytree",
  2251. "torch._higher_order_ops.map.create_fw_bw_graph",
  2252. "torch._higher_order_ops.map.map_autograd",
  2253. "torch._higher_order_ops.map.map_dense",
  2254. "torch._higher_order_ops.map.map_fake_tensor_mode",
  2255. "torch._higher_order_ops.map.map_functionalize",
  2256. "torch._higher_order_ops.map.map_proxy_torch_dispatch_mode",
  2257. "torch._higher_order_ops.map.map_wrapper",
  2258. "torch._higher_order_ops.map.trace_map",
  2259. "torch._higher_order_ops.out_dtype.elementwise_dtypes",
  2260. "torch._higher_order_ops.out_dtype.is_int_mm",
  2261. "torch._higher_order_ops.out_dtype.out_dtype_dense",
  2262. "torch._higher_order_ops.out_dtype.out_dtype_fake_tensor_mode",
  2263. "torch._higher_order_ops.out_dtype.out_dtype_fallback",
  2264. "torch._higher_order_ops.out_dtype.out_dtype_func",
  2265. "torch._higher_order_ops.out_dtype.out_dtype_proxy",
  2266. "torch._higher_order_ops.out_dtype.trace_out_dtype",
  2267. "torch._higher_order_ops.utils.autograd_not_implemented_inner",
  2268. "torch._higher_order_ops.utils.autograd_not_implemented",
  2269. "torch._linalg_utils._symeig",
  2270. "torch._linalg_utils.basis",
  2271. "torch._linalg_utils.bform",
  2272. "torch._linalg_utils.eig",
  2273. "torch._linalg_utils.get_floating_dtype",
  2274. "torch._linalg_utils.is_sparse",
  2275. "torch._linalg_utils.lstsq",
  2276. "torch._linalg_utils.matmul",
  2277. "torch._linalg_utils.matrix_rank",
  2278. "torch._linalg_utils.qform",
  2279. "torch._linalg_utils.solve",
  2280. "torch._linalg_utils.symeig",
  2281. "torch._load_global_deps",
  2282. "torch._lowrank._svd_lowrank",
  2283. "torch._lowrank.get_approximate_basis",
  2284. "torch._lowrank.pca_lowrank",
  2285. "torch._lowrank.svd_lowrank",
  2286. "torch._ops._compute_keyset",
  2287. "torch._ops._get_tensors",
  2288. "torch._ops._to_flat_tuple",
  2289. "torch._ops.add_cached_op",
  2290. "torch._ops.dl_open_guard",
  2291. "torch._ops.get_cached_ops",
  2292. "torch._ops.key_extractor",
  2293. "torch._ops.reset_cached_ops",
  2294. "torch._ops.resolve_key",
  2295. "torch._preload_cuda_deps",
  2296. "torch._register_device_module",
  2297. "torch._running_with_deploy",
  2298. "torch._utils._dummy_type",
  2299. "torch._weights_only_unpickler._get_allowed_globals",
  2300. "torch._weights_only_unpickler.load",
  2301. "torch.align_tensors",
  2302. "torch.amp.autocast_mode._enter_autocast",
  2303. "torch.amp.autocast_mode._exit_autocast",
  2304. "torch.amp.autocast_mode.autocast_decorator",
  2305. "torch.amp.autocast_mode.custom_bwd",
  2306. "torch.amp.autocast_mode.custom_fwd",
  2307. "torch.are_deterministic_algorithms_enabled",
  2308. "torch.atleast_1d",
  2309. "torch.atleast_2d",
  2310. "torch.atleast_3d",
  2311. "torch.autograd._calculate_shape",
  2312. "torch.autograd._is_checkpoint_valid",
  2313. "torch.autograd._make_grads",
  2314. "torch.autograd._register_py_tensor_class_for_device",
  2315. "torch.autograd._tensor_or_tensors_to_tuple",
  2316. "torch.autograd.forward_ad._maybe_load_decompositions",
  2317. "torch.autograd.function._iter_filter",
  2318. "torch.autograd.function._iter_jit_values",
  2319. "torch.autograd.function._iter_None_tensors",
  2320. "torch.autograd.function._iter_tensors_permissive",
  2321. "torch.autograd.function._iter_tensors",
  2322. "torch.autograd.function._jit_unwrap_structured",
  2323. "torch.autograd.function._map_tensor_data",
  2324. "torch.autograd.function._nested_map",
  2325. "torch.autograd.function._unflatten",
  2326. "torch.autograd.function.once_differentiable",
  2327. "torch.autograd.function.traceable",
  2328. "torch.autograd.functional._as_tuple_nocheck",
  2329. "torch.autograd.functional._as_tuple",
  2330. "torch.autograd.functional._autograd_grad",
  2331. "torch.autograd.functional._check_requires_grad",
  2332. "torch.autograd.functional._construct_standard_basis_for",
  2333. "torch.autograd.functional._fill_in_zeros",
  2334. "torch.autograd.functional._grad_postprocess",
  2335. "torch.autograd.functional._grad_preprocess",
  2336. "torch.autograd.functional._jacfwd",
  2337. "torch.autograd.functional._tuple_postprocess",
  2338. "torch.autograd.functional._validate_v",
  2339. "torch.autograd.functional.hessian",
  2340. "torch.autograd.functional.hvp",
  2341. "torch.autograd.functional.jacobian",
  2342. "torch.autograd.functional.jvp",
  2343. "torch.autograd.functional.vhp",
  2344. "torch.autograd.functional.vjp",
  2345. "torch.autograd.grad_mode._enter_inference_mode",
  2346. "torch.autograd.grad_mode._exit_inference_mode",
  2347. "torch.autograd.graph._get_sid",
  2348. "torch.autograd.graph._get_tid",
  2349. "torch.autograd.graph.allow_mutation_on_saved_tensors",
  2350. "torch.autograd.graph.get_gradient_edge",
  2351. "torch.autograd.graph.increment_version",
  2352. "torch.autograd.graph.register_multi_grad_hook",
  2353. "torch.autograd.variable",
  2354. "torch.backends.__allow_nonbracketed_mutation",
  2355. "torch.backends.cpu.get_cpu_capability",
  2356. "torch.backends.cuda.can_use_efficient_attention",
  2357. "torch.backends.cuda.can_use_flash_attention",
  2358. "torch.backends.cuda.enable_flash_sdp",
  2359. "torch.backends.cuda.enable_math_sdp",
  2360. "torch.backends.cuda.enable_mem_efficient_sdp",
  2361. "torch.backends.cuda.flash_sdp_enabled",
  2362. "torch.backends.cuda.is_built",
  2363. "torch.backends.cuda.math_sdp_enabled",
  2364. "torch.backends.cuda.mem_efficient_sdp_enabled",
  2365. "torch.backends.cuda.cudnn_sdp_enabled",
  2366. "torch.backends.cuda.enable_cudnn_sdp",
  2367. "torch.backends.cuda.preferred_blas_library",
  2368. "torch.backends.cuda.preferred_linalg_library",
  2369. "torch.backends.cuda.sdp_kernel",
  2370. "torch.backends.cudnn._init",
  2371. "torch.backends.cudnn.flags",
  2372. "torch.backends.cudnn.is_acceptable",
  2373. "torch.backends.cudnn.is_available",
  2374. "torch.backends.cudnn.set_flags",
  2375. "torch.backends.cudnn.version",
  2376. "torch.backends.disable_global_flags",
  2377. "torch.backends.flags_frozen",
  2378. "torch.backends.mkl.is_available",
  2379. "torch.backends.mkldnn.flags",
  2380. "torch.backends.mkldnn.is_available",
  2381. "torch.backends.mkldnn.set_flags",
  2382. "torch.backends.mps._init",
  2383. "torch.backends.mps.is_available",
  2384. "torch.backends.mps.is_built",
  2385. "torch.backends.mps.is_macos13_or_newer",
  2386. "torch.backends.openmp.is_available",
  2387. "torch.backends.quantized._get_qengine_id",
  2388. "torch.backends.quantized._get_qengine_str",
  2389. "torch.block_diag",
  2390. "torch.broadcast_tensors",
  2391. "torch.cartesian_prod",
  2392. "torch.cdist",
  2393. "torch.chain_matmul",
  2394. "torch.compile",
  2395. "torch.compiled_with_cxx11_abi",
  2396. "torch.cpu._is_cpu_support_avx2",
  2397. "torch.cpu._is_cpu_support_avx512",
  2398. "torch.cpu._is_cpu_support_vnni",
  2399. "torch.cpu.current_device",
  2400. "torch.cpu.current_stream",
  2401. "torch.cpu.device_count",
  2402. "torch.cpu.is_available",
  2403. "torch.cpu.set_device",
  2404. "torch.cpu.stream",
  2405. "torch.cpu.synchronize",
  2406. "torch.cuda._check_capability",
  2407. "torch.cuda._check_cubins",
  2408. "torch.cuda._device_count_amdsmi",
  2409. "torch.cuda._device_count_nvml",
  2410. "torch.cuda._get_amdsmi_handler",
  2411. "torch.cuda._get_amdsmi_device_index",
  2412. "torch.cuda._get_device",
  2413. "torch.cuda._get_generator",
  2414. "torch.cuda._get_nvml_device_index",
  2415. "torch.cuda._get_pynvml_handler",
  2416. "torch.cuda._get_rng_state_offset",
  2417. "torch.cuda._is_compiled",
  2418. "torch.cuda._lazy_call",
  2419. "torch.cuda._lazy_init",
  2420. "torch.cuda._memory_viz._block_extra_legacy",
  2421. "torch.cuda._memory_viz._block_extra",
  2422. "torch.cuda._memory_viz._format_size",
  2423. "torch.cuda._memory_viz._format_viz",
  2424. "torch.cuda._memory_viz._frame_filter",
  2425. "torch.cuda._memory_viz._frame_fmt",
  2426. "torch.cuda._memory_viz._frames_fmt",
  2427. "torch.cuda._memory_viz._profile_to_snapshot",
  2428. "torch.cuda._memory_viz._report_free",
  2429. "torch.cuda._memory_viz._write_blocks",
  2430. "torch.cuda._memory_viz.calc_active",
  2431. "torch.cuda._memory_viz.compare",
  2432. "torch.cuda._memory_viz.format_flamegraph",
  2433. "torch.cuda._memory_viz.memory",
  2434. "torch.cuda._memory_viz.profile_plot",
  2435. "torch.cuda._memory_viz.segment_plot",
  2436. "torch.cuda._memory_viz.segments",
  2437. "torch.cuda._memory_viz.segsum",
  2438. "torch.cuda._memory_viz.trace_plot",
  2439. "torch.cuda._memory_viz.trace",
  2440. "torch.cuda._nvml_based_avail",
  2441. "torch.cuda._parse_visible_devices",
  2442. "torch.cuda._raw_device_count_amdsmi",
  2443. "torch.cuda._raw_device_count_nvml",
  2444. "torch.cuda._raw_device_uuid_amdsmi",
  2445. "torch.cuda._raw_device_uuid_nvml",
  2446. "torch.cuda._register_triton_kernels",
  2447. "torch.cuda._set_rng_state_offset",
  2448. "torch.cuda._set_stream_by_id",
  2449. "torch.cuda._sleep",
  2450. "torch.cuda._transform_uuid_to_ordinals",
  2451. "torch.cuda._utils._get_device_index",
  2452. "torch.cuda.amp.autocast_mode._cast",
  2453. "torch.cuda.amp.autocast_mode.custom_bwd",
  2454. "torch.cuda.amp.autocast_mode.custom_fwd",
  2455. "torch.cuda.amp.common.amp_definitely_not_available",
  2456. "torch.amp.grad_scaler._refresh_per_optimizer_state",
  2457. "torch.cuda.can_device_access_peer",
  2458. "torch.cuda.check_error",
  2459. "torch.cuda.clock_rate",
  2460. "torch.cuda.cudart",
  2461. "torch.cuda.current_blas_handle",
  2462. "torch.cuda.current_stream",
  2463. "torch.cuda.default_stream",
  2464. "torch.cuda.device_count",
  2465. "torch.cuda.get_arch_list",
  2466. "torch.cuda.get_device_capability",
  2467. "torch.cuda.get_device_name",
  2468. "torch.cuda.get_device_properties",
  2469. "torch.cuda.get_gencode_flags",
  2470. "torch.cuda.get_sync_debug_mode",
  2471. "torch.cuda.graphs.graph_pool_handle",
  2472. "torch.cuda.graphs.is_current_stream_capturing",
  2473. "torch.cuda.graphs.make_graphed_callables",
  2474. "torch.cuda.init",
  2475. "torch.cuda.ipc_collect",
  2476. "torch.cuda.is_available",
  2477. "torch.cuda.is_bf16_supported",
  2478. "torch.cuda.is_initialized",
  2479. "torch.cuda.jiterator._create_jit_fn",
  2480. "torch.cuda.jiterator._create_multi_output_jit_fn",
  2481. "torch.cuda.memory_usage",
  2482. "torch.cuda.memory._dump_snapshot",
  2483. "torch.cuda.memory._free_mutex",
  2484. "torch.cuda.memory._get_current_allocator",
  2485. "torch.cuda.memory._host_allocator",
  2486. "torch.cuda.memory._record_memory_history_impl",
  2487. "torch.cuda.memory._record_memory_history_legacy",
  2488. "torch.cuda.memory._record_memory_history",
  2489. "torch.cuda.memory._save_memory_usage",
  2490. "torch.cuda.memory._save_segment_usage",
  2491. "torch.cuda.memory._set_allocator_settings",
  2492. "torch.cuda.memory._snapshot",
  2493. "torch.cuda.memory.caching_allocator_alloc",
  2494. "torch.cuda.memory.caching_allocator_delete",
  2495. "torch.cuda.memory.change_current_allocator",
  2496. "torch.cuda.memory.empty_cache",
  2497. "torch.cuda.memory.get_allocator_backend",
  2498. "torch.cuda.memory.list_gpu_processes",
  2499. "torch.cuda.memory.max_memory_allocated",
  2500. "torch.cuda.memory.max_memory_cached",
  2501. "torch.cuda.memory.max_memory_reserved",
  2502. "torch.cuda.memory.mem_get_info",
  2503. "torch.cuda.memory.memory_allocated",
  2504. "torch.cuda.memory.memory_cached",
  2505. "torch.cuda.memory.memory_reserved",
  2506. "torch.cuda.memory.memory_snapshot",
  2507. "torch.cuda.memory.memory_stats_as_nested_dict",
  2508. "torch.cuda.memory.memory_stats",
  2509. "torch.cuda.memory.memory_summary",
  2510. "torch.cuda.memory.reset_accumulated_memory_stats",
  2511. "torch.cuda.memory.reset_max_memory_allocated",
  2512. "torch.cuda.memory.reset_max_memory_cached",
  2513. "torch.cuda.memory.reset_peak_memory_stats",
  2514. "torch.cuda.memory.set_per_process_memory_fraction",
  2515. "torch.cuda.nccl._check_sequence_type",
  2516. "torch.cuda.nccl.all_gather",
  2517. "torch.cuda.nccl.all_reduce",
  2518. "torch.cuda.nccl.broadcast",
  2519. "torch.cuda.nccl.init_rank",
  2520. "torch.cuda.nccl.is_available",
  2521. "torch.cuda.nccl.reduce_scatter",
  2522. "torch.cuda.nccl.reduce",
  2523. "torch.cuda.nccl.unique_id",
  2524. "torch.cuda.nccl.version",
  2525. "torch.cuda.nvtx.mark",
  2526. "torch.cuda.nvtx.range_end",
  2527. "torch.cuda.nvtx.range_pop",
  2528. "torch.cuda.nvtx.range_push",
  2529. "torch.cuda.nvtx.range_start",
  2530. "torch.cuda.nvtx.range",
  2531. "torch.cuda.power_draw",
  2532. "torch.cuda.profiler.init",
  2533. "torch.cuda.profiler.profile",
  2534. "torch.cuda.profiler.start",
  2535. "torch.cuda.profiler.stop",
  2536. "torch.cuda.random.get_rng_state_all",
  2537. "torch.cuda.random.initial_seed",
  2538. "torch.cuda.random.manual_seed_all",
  2539. "torch.cuda.random.manual_seed",
  2540. "torch.cuda.random.seed_all",
  2541. "torch.cuda.random.seed",
  2542. "torch.cuda.random.set_rng_state_all",
  2543. "torch.cuda.set_stream",
  2544. "torch.cuda.set_sync_debug_mode",
  2545. "torch.cuda.stream",
  2546. "torch.cuda.synchronize",
  2547. "torch.cuda.temperature",
  2548. "torch.cuda.utilization",
  2549. "torch.einsum",
  2550. "torch.functional._check_list_size",
  2551. "torch.functional._consecutive_return_counts",
  2552. "torch.functional._consecutive_return_inverse_false",
  2553. "torch.functional._consecutive_return_inverse_true",
  2554. "torch.functional._consecutive_return_inverse",
  2555. "torch.functional._consecutive_return_output",
  2556. "torch.functional._lu_impl",
  2557. "torch.functional._lu_no_infos",
  2558. "torch.functional._lu_with_infos",
  2559. "torch.functional._meshgrid",
  2560. "torch.functional._return_counts",
  2561. "torch.functional._return_inverse_false",
  2562. "torch.functional._return_inverse_true",
  2563. "torch.functional._return_inverse",
  2564. "torch.functional._return_output",
  2565. "torch.functional._unique_consecutive_impl",
  2566. "torch.functional._unique_impl",
  2567. "torch.functional._unravel_index",
  2568. "torch.functional.broadcast_shapes",
  2569. "torch.functional.lu",
  2570. "torch.functional.unique",
  2571. "torch.functional.unravel_index",
  2572. "torch.futures.collect_all",
  2573. "torch.futures.wait_all",
  2574. "torch.fx.experimental.const_fold.split_const_subgraphs",
  2575. "torch.fx.experimental.proxy_tensor.make_fx",
  2576. "torch.get_deterministic_debug_mode",
  2577. "torch.get_float32_matmul_precision",
  2578. "torch.is_deterministic_algorithms_warn_only_enabled",
  2579. "torch.is_storage",
  2580. "torch.is_tensor",
  2581. "torch.is_warn_always_enabled",
  2582. "torch.masked._ops._any",
  2583. "torch.masked._ops._apply_docstring_templates",
  2584. "torch.masked._ops._canonical_dim",
  2585. "torch.masked._ops._combine_input_and_mask",
  2586. "torch.masked._ops._generate_docstring",
  2587. "torch.masked._ops._input_mask",
  2588. "torch.masked._ops._output_mask",
  2589. "torch.masked._ops._reduction_identity",
  2590. "torch.masked._ops._sparse_coo_flatten_indices",
  2591. "torch.masked._ops._sparse_coo_scatter_reduction_helper",
  2592. "torch.masked._ops._sparse_coo_where",
  2593. "torch.masked._ops._sparse_csr_segment_reduction_helper",
  2594. "torch.masked._ops._sparse_csr_where",
  2595. "torch.masked._ops._std_var",
  2596. "torch.masked._ops._where",
  2597. "torch.masked._ops.amax",
  2598. "torch.masked._ops.amin",
  2599. "torch.masked._ops.argmax",
  2600. "torch.masked._ops.argmin",
  2601. "torch.masked._ops.corresponding_real_dtype",
  2602. "torch.masked._ops.cumprod",
  2603. "torch.masked._ops.cumsum",
  2604. "torch.masked._ops.log_softmax",
  2605. "torch.masked._ops.logaddexp",
  2606. "torch.masked._ops.logsumexp",
  2607. "torch.masked._ops.mean",
  2608. "torch.masked._ops.median",
  2609. "torch.masked._ops.norm",
  2610. "torch.masked._ops.normalize",
  2611. "torch.masked._ops.prod",
  2612. "torch.masked._ops.softmax",
  2613. "torch.masked._ops.softmin",
  2614. "torch.masked._ops.std",
  2615. "torch.masked._ops.sum",
  2616. "torch.masked._ops.var",
  2617. "torch.meshgrid",
  2618. "torch.mps._get_default_mps_generator",
  2619. "torch.mps.current_allocated_memory",
  2620. "torch.mps.driver_allocated_memory",
  2621. "torch.mps.empty_cache",
  2622. "torch.mps.get_rng_state",
  2623. "torch.mps.manual_seed",
  2624. "torch.mps.profiler.profile",
  2625. "torch.mps.profiler.start",
  2626. "torch.mps.profiler.stop",
  2627. "torch.mps.seed",
  2628. "torch.mps.set_per_process_memory_fraction",
  2629. "torch.mps.set_rng_state",
  2630. "torch.mps.synchronize",
  2631. "torch.nested._internal.nested_tensor.buffer_from_jagged",
  2632. "torch.nested._internal.nested_tensor.get_tensor_symint",
  2633. "torch.nested._internal.nested_tensor.is_expandable_to",
  2634. "torch.nested._internal.nested_tensor.jagged_from_list",
  2635. "torch.nested._internal.nested_tensor.jagged_from_tensor_and_lengths",
  2636. "torch.nested._internal.nested_tensor.nested_view_from_values_offsets",
  2637. "torch.nested._internal.nested_tensor.nested_view_from_values_offsets_lengths",
  2638. "torch.nested.as_nested_tensor",
  2639. "torch.nested.narrow",
  2640. "torch.nested.nested_tensor",
  2641. "torch.nn._reduction.get_enum",
  2642. "torch.nn._reduction.legacy_get_enum",
  2643. "torch.nn._reduction.legacy_get_string",
  2644. "torch.nn.factory_kwargs",
  2645. "torch.nn.functional._adaptive_max_pool1d",
  2646. "torch.nn.functional._adaptive_max_pool2d",
  2647. "torch.nn.functional._adaptive_max_pool3d",
  2648. "torch.nn.functional._canonical_mask",
  2649. "torch.nn.functional._fractional_max_pool2d",
  2650. "torch.nn.functional._fractional_max_pool3d",
  2651. "torch.nn.functional._get_softmax_dim",
  2652. "torch.nn.functional._in_projection_packed",
  2653. "torch.nn.functional._in_projection",
  2654. "torch.nn.functional._is_integer",
  2655. "torch.nn.functional._max_pool1d",
  2656. "torch.nn.functional._max_pool2d",
  2657. "torch.nn.functional._max_pool3d",
  2658. "torch.nn.functional._mha_shape_check",
  2659. "torch.nn.functional._no_grad_embedding_renorm_",
  2660. "torch.nn.functional._none_or_dtype",
  2661. "torch.nn.functional._threshold",
  2662. "torch.nn.functional._unpool_output_size",
  2663. "torch.nn.functional._verify_batch_size",
  2664. "torch.nn.functional._verify_spatial_size",
  2665. "torch.nn.functional.adaptive_avg_pool2d",
  2666. "torch.nn.functional.adaptive_avg_pool3d",
  2667. "torch.nn.functional.adaptive_max_pool1d_with_indices",
  2668. "torch.nn.functional.adaptive_max_pool1d",
  2669. "torch.nn.functional.adaptive_max_pool2d_with_indices",
  2670. "torch.nn.functional.adaptive_max_pool2d",
  2671. "torch.nn.functional.adaptive_max_pool3d_with_indices",
  2672. "torch.nn.functional.adaptive_max_pool3d",
  2673. "torch.nn.functional.affine_grid",
  2674. "torch.nn.functional.alpha_dropout",
  2675. "torch.nn.functional.assert_int_or_pair",
  2676. "torch.nn.functional.batch_norm",
  2677. "torch.nn.functional.binary_cross_entropy_with_logits",
  2678. "torch.nn.functional.binary_cross_entropy",
  2679. "torch.nn.functional.celu",
  2680. "torch.nn.functional.cosine_embedding_loss",
  2681. "torch.nn.functional.cross_entropy",
  2682. "torch.nn.functional.ctc_loss",
  2683. "torch.nn.functional.dropout",
  2684. "torch.nn.functional.dropout1d",
  2685. "torch.nn.functional.dropout2d",
  2686. "torch.nn.functional.dropout3d",
  2687. "torch.nn.functional.elu",
  2688. "torch.nn.functional.embedding_bag",
  2689. "torch.nn.functional.embedding",
  2690. "torch.nn.functional.feature_alpha_dropout",
  2691. "torch.nn.functional.fold",
  2692. "torch.nn.functional.fractional_max_pool2d_with_indices",
  2693. "torch.nn.functional.fractional_max_pool2d",
  2694. "torch.nn.functional.fractional_max_pool3d_with_indices",
  2695. "torch.nn.functional.fractional_max_pool3d",
  2696. "torch.nn.functional.gaussian_nll_loss",
  2697. "torch.nn.functional.glu",
  2698. "torch.nn.functional.grid_sample",
  2699. "torch.nn.functional.group_norm",
  2700. "torch.nn.functional.gumbel_softmax",
  2701. "torch.nn.functional.hardsigmoid",
  2702. "torch.nn.functional.hardswish",
  2703. "torch.nn.functional.hardtanh",
  2704. "torch.nn.functional.hinge_embedding_loss",
  2705. "torch.nn.functional.huber_loss",
  2706. "torch.nn.functional.instance_norm",
  2707. "torch.nn.functional.interpolate",
  2708. "torch.nn.functional.kl_div",
  2709. "torch.nn.functional.l1_loss",
  2710. "torch.nn.functional.layer_norm",
  2711. "torch.nn.functional.leaky_relu",
  2712. "torch.nn.functional.local_response_norm",
  2713. "torch.nn.functional.log_softmax",
  2714. "torch.nn.functional.lp_pool1d",
  2715. "torch.nn.functional.lp_pool2d",
  2716. "torch.nn.functional.margin_ranking_loss",
  2717. "torch.nn.functional.max_pool1d_with_indices",
  2718. "torch.nn.functional.max_pool1d",
  2719. "torch.nn.functional.max_pool2d_with_indices",
  2720. "torch.nn.functional.max_pool2d",
  2721. "torch.nn.functional.max_pool3d_with_indices",
  2722. "torch.nn.functional.max_pool3d",
  2723. "torch.nn.functional.max_unpool1d",
  2724. "torch.nn.functional.max_unpool2d",
  2725. "torch.nn.functional.max_unpool3d",
  2726. "torch.nn.functional.mish",
  2727. "torch.nn.functional.mse_loss",
  2728. "torch.nn.functional.multi_head_attention_forward",
  2729. "torch.nn.functional.multi_margin_loss",
  2730. "torch.nn.functional.multilabel_margin_loss",
  2731. "torch.nn.functional.multilabel_soft_margin_loss",
  2732. "torch.nn.functional.nll_loss",
  2733. "torch.nn.functional.normalize",
  2734. "torch.nn.functional.poisson_nll_loss",
  2735. "torch.nn.functional.relu",
  2736. "torch.nn.functional.relu6",
  2737. "torch.nn.functional.rrelu",
  2738. "torch.nn.functional.selu",
  2739. "torch.nn.functional.sigmoid",
  2740. "torch.nn.functional.silu",
  2741. "torch.nn.functional.smooth_l1_loss",
  2742. "torch.nn.functional.soft_margin_loss",
  2743. "torch.nn.functional.softmax",
  2744. "torch.nn.functional.softmin",
  2745. "torch.nn.functional.softsign",
  2746. "torch.nn.functional.tanh",
  2747. "torch.nn.functional.tanhshrink",
  2748. "torch.nn.functional.triplet_margin_loss",
  2749. "torch.nn.functional.unfold",
  2750. "torch.nn.functional.upsample_bilinear",
  2751. "torch.nn.functional.upsample_nearest",
  2752. "torch.nn.functional.upsample",
  2753. "torch.nn.grad._pair",
  2754. "torch.nn.grad._single",
  2755. "torch.nn.grad._triple",
  2756. "torch.nn.grad.conv1d_input",
  2757. "torch.nn.grad.conv1d_weight",
  2758. "torch.nn.grad.conv2d_input",
  2759. "torch.nn.grad.conv2d_weight",
  2760. "torch.nn.grad.conv3d_input",
  2761. "torch.nn.grad.conv3d_weight",
  2762. "torch.nn.modules.activation._arg_requires_grad",
  2763. "torch.nn.modules.activation._check_arg_device",
  2764. "torch.nn.modules.activation._is_make_fx_tracing",
  2765. "torch.nn.modules.container._addindent",
  2766. "torch.nn.modules.transformer._detect_is_causal_mask",
  2767. "torch.nn.modules.transformer._generate_square_subsequent_mask",
  2768. "torch.nn.modules.transformer._get_activation_fn",
  2769. "torch.nn.modules.transformer._get_clones",
  2770. "torch.nn.modules.transformer._get_seq_len",
  2771. "torch.nn.modules.utils._list_with_default",
  2772. "torch.nn.modules.utils._ntuple",
  2773. "torch.nn.modules.utils._quadruple",
  2774. "torch.nn.modules.utils._reverse_repeat_tuple",
  2775. "torch.nn.modules.utils.consume_prefix_in_state_dict_if_present",
  2776. "torch.nn.parameter.is_lazy",
  2777. "torch.norm",
  2778. "torch.quantization.default_eval_fn",
  2779. "torch.random._seed_custom_device",
  2780. "torch.random.fork_rng",
  2781. "torch.random.initial_seed",
  2782. "torch.random.seed",
  2783. "torch.return_types.pytree_register_structseq",
  2784. "torch.set_default_device",
  2785. "torch.set_default_dtype",
  2786. "torch.set_default_tensor_type",
  2787. "torch.set_deterministic_debug_mode",
  2788. "torch.set_float32_matmul_precision",
  2789. "torch.set_warn_always",
  2790. "torch.signal.windows.windows._add_docstr",
  2791. "torch.signal.windows.windows._window_function_checks",
  2792. "torch.signal.windows.windows.bartlett",
  2793. "torch.signal.windows.windows.blackman",
  2794. "torch.signal.windows.windows.cosine",
  2795. "torch.signal.windows.windows.exponential",
  2796. "torch.signal.windows.windows.gaussian",
  2797. "torch.signal.windows.windows.general_cosine",
  2798. "torch.signal.windows.windows.general_hamming",
  2799. "torch.signal.windows.windows.hamming",
  2800. "torch.signal.windows.windows.hann",
  2801. "torch.signal.windows.windows.kaiser",
  2802. "torch.signal.windows.windows.merge_dicts",
  2803. "torch.signal.windows.windows.nuttall",
  2804. "torch.signal.windows.windows.parse_kwargs",
  2805. "torch.sparse.semi_structured.to_sparse_semi_structured",
  2806. "torch.sparse.sum",
  2807. "torch.split",
  2808. "torch.stft",
  2809. "torch.sym_float",
  2810. "torch.sym_int",
  2811. "torch.sym_ite",
  2812. "torch.sym_max",
  2813. "torch.sym_min",
  2814. "torch.sym_not",
  2815. "torch.tensordot",
  2816. "torch.typename",
  2817. "torch.unique_consecutive",
  2818. "torch.use_deterministic_algorithms",
  2819. ],
  2820. TorchInGraphFunctionVariable,
  2821. )
  2822. torch_name_rule_map = [
  2823. manual_torch_name_rule_map,
  2824. torch_c_binding_in_graph_functions,
  2825. torch_non_c_binding_in_graph_functions,
  2826. ]
  2827. """
  2828. Generate the torch object - Dynamo tracing rule (the wrapping variable) map.
  2829. """
  2830. @functools.lru_cache(None)
  2831. def get_torch_obj_rule_map():
  2832. d: Dict[Any, VariableTracker] = dict()
  2833. for m in torch_name_rule_map:
  2834. for k, v in m.items(): # type: ignore[attr-defined]
  2835. if ".py#" not in k:
  2836. obj = load_object(k)
  2837. else:
  2838. obj = _module_dir(torch) + k[len("torch/") :]
  2839. if obj is not None:
  2840. if obj in d and d[obj] != v:
  2841. raise AssertionError(
  2842. f"Duplicate torch object {obj} with different rules: {v}, {d[obj]}"
  2843. )
  2844. else:
  2845. d[obj] = v
  2846. return d
  2847. def _load_obj_from_str(fully_qualified_name):
  2848. module, obj_name = fully_qualified_name.rsplit(".", maxsplit=1)
  2849. return getattr(importlib.import_module(module), obj_name)
  2850. """
  2851. Load string represented torch objects.
  2852. """
  2853. def load_object(name):
  2854. try:
  2855. x = name.split("#")
  2856. if len(x) == 2:
  2857. obj = _load_obj_from_str(x[0])
  2858. val = getattr(obj, x[1])
  2859. else:
  2860. assert len(x) == 1, f"Invalid obj name {name}"
  2861. val = _load_obj_from_str(x[0])
  2862. val = unwrap_if_wrapper(val)
  2863. except (AttributeError, ImportError):
  2864. val = None
  2865. return val
  2866. """
  2867. Get all torch.Tensor methods which are allowed to be in graph functions.
  2868. """
  2869. @functools.lru_cache(None)
  2870. def get_tensor_method():
  2871. s = set()
  2872. for name in dir(torch.Tensor):
  2873. method = getattr(torch.Tensor, name)
  2874. if isinstance(
  2875. method, (types.MethodDescriptorType, types.WrapperDescriptorType)
  2876. ):
  2877. s.add(method)
  2878. return frozenset(s)
  2879. """
  2880. Return if a torch object is ATen op or torch.Tensor method.
  2881. """
  2882. def is_aten_op_or_tensor_method(obj):
  2883. return obj in get_tensor_method() or isinstance(
  2884. obj,
  2885. (torch._ops.OpOverloadPacket, torch._ops.OpOverload),
  2886. )
  2887. class FunctionIdSet:
  2888. """
  2889. Track a set of `id()`s of objects which are either allowed or not
  2890. allowed to go into the generated FX graph. Use to test for torch.*,
  2891. numpy.*, builtins.*, etc.
  2892. Support user modification to permit customization of what can be
  2893. added to the graph and what will cause a graph break.
  2894. """
  2895. function_ids: Optional[Set[int]] = None
  2896. function_names: Optional[Dict[int, str]] = None
  2897. def __init__(self, lazy_initializer: Callable[[], Union[Dict[int, str], Set[int]]]):
  2898. self.lazy_initializer = lazy_initializer
  2899. def __call__(self):
  2900. if self.function_ids is None:
  2901. value = self.lazy_initializer()
  2902. if isinstance(value, dict):
  2903. self.function_ids = set(value.keys())
  2904. self.function_names = value
  2905. else:
  2906. assert isinstance(value, set)
  2907. self.function_ids = value
  2908. return self.function_ids
  2909. def get_name(self, idx: int, default: str):
  2910. self() # lazy init
  2911. assert self.function_names is not None
  2912. return self.function_names.get(idx, default)
  2913. def add(self, idx: int):
  2914. function_ids = self() # lazy init
  2915. function_ids.add(idx)
  2916. def remove(self, idx: int):
  2917. function_ids = self()
  2918. if idx in function_ids:
  2919. function_ids.remove(idx)
  2920. def __contains__(self, idx: int):
  2921. return idx in self()
  2922. @FunctionIdSet
  2923. def _allowed_callable_ids() -> Dict[int, str]:
  2924. rv: Dict[int, str] = {}
  2925. return rv
  2926. @FunctionIdSet
  2927. def _disallowed_callable_ids() -> Dict[int, str]:
  2928. rv: Dict[int, str] = {}
  2929. return rv
  2930. @FunctionIdSet
  2931. def _builtin_function_ids() -> Dict[int, str]:
  2932. rv = {
  2933. id(v): f"builtins.{k}"
  2934. for k, v in builtins.__dict__.items()
  2935. if not k.startswith("_") and callable(v)
  2936. }
  2937. rv.update(
  2938. {
  2939. id(v): f"operator.{k}"
  2940. for k, v in operator.__dict__.items()
  2941. if not k.startswith("_") and callable(v)
  2942. }
  2943. )
  2944. rv.update(
  2945. {id(v): f"functools.{v.__name__}" for v in (itertools.chain, itertools.islice)}
  2946. )
  2947. rv.update(
  2948. {
  2949. id(cast): "typing.cast",
  2950. id(functools.reduce): "functools.reduce",
  2951. id(copy.deepcopy): "copy.deepcopy",
  2952. }
  2953. )
  2954. return rv
  2955. @FunctionIdSet
  2956. def _numpy_function_ids() -> Dict[int, str]:
  2957. rv = dict()
  2958. for mod in NP_SUPPORTED_MODULES:
  2959. rv.update(
  2960. {
  2961. id(v): f"{mod.__name__}.{k}"
  2962. for k, v in mod.__dict__.items()
  2963. if callable(v)
  2964. and (getattr(v, "__module__", None) or mod.__name__) == mod.__name__
  2965. }
  2966. )
  2967. return rv
  2968. @FunctionIdSet
  2969. def _builtin_constant_ids() -> Dict[int, str]:
  2970. """
  2971. Collects constant builtins by eliminating callable items.
  2972. """
  2973. rv = {
  2974. id(v): f"builtins.{k}"
  2975. for k, v in builtins.__dict__.items()
  2976. if not k.startswith("_") and not callable(v)
  2977. }
  2978. return rv
  2979. _lazy_module_init: Dict[str, List[Callable[[], None]]] = defaultdict(list)
  2980. def add_module_init_func(name: str, init_func: Callable[[], None]) -> None:
  2981. """Register a module without eagerly importing it"""
  2982. # If the module is already imported, eagerly run init
  2983. assert "." not in name, f"Expected a root module name, but got {name}"
  2984. assert name not in _lazy_module_init
  2985. _lazy_module_init[name].append(init_func)
  2986. def _maybe_init_lazy_module(obj: object) -> None:
  2987. module = getattr(obj, "__module__", None)
  2988. if module is None:
  2989. return
  2990. base_module = module.split(".")[0]
  2991. init_funcs = _lazy_module_init.pop(base_module, None)
  2992. if init_funcs is not None:
  2993. for fn in init_funcs:
  2994. fn()
  2995. def is_callable_allowed(obj) -> bool:
  2996. _maybe_init_lazy_module(obj)
  2997. return id(obj) in _allowed_callable_ids
  2998. def is_callable_disallowed(obj) -> bool:
  2999. _maybe_init_lazy_module(obj)
  3000. return id(obj) in _disallowed_callable_ids
  3001. def is_forbidden(obj) -> bool:
  3002. _maybe_init_lazy_module(obj)
  3003. return inspect.getattr_static(obj, "_dynamo_forbidden", False)
  3004. def is_builtin_callable(obj) -> bool:
  3005. return id(obj) in _builtin_function_ids
  3006. def is_builtin_constant(obj) -> bool:
  3007. return id(obj) in _builtin_constant_ids
  3008. def is_numpy(obj) -> bool:
  3009. if np is None:
  3010. return False
  3011. return isinstance(obj, (np.ndarray, np.generic)) or id(obj) in _numpy_function_ids
  3012. def is_numpy_dtype(obj) -> bool:
  3013. if np is None:
  3014. return False
  3015. return isinstance(obj, np.dtype)
  3016. def is_numpy_type_info(obj) -> bool:
  3017. if np is None:
  3018. return False
  3019. return isinstance(obj, (np.finfo, np.iinfo))
  3020. BUILTIN_SKIPLIST = (
  3021. abc,
  3022. collections,
  3023. contextlib,
  3024. copy,
  3025. copyreg,
  3026. dataclasses,
  3027. enum,
  3028. functools,
  3029. importlib,
  3030. inspect,
  3031. linecache,
  3032. logging,
  3033. multiprocessing,
  3034. operator,
  3035. os,
  3036. posixpath,
  3037. random,
  3038. re,
  3039. selectors,
  3040. signal,
  3041. tempfile,
  3042. threading,
  3043. tokenize,
  3044. torch, # torch/* is skipped by default unless specified in FUNC_INLINELIST or MOD_INLINELIST
  3045. traceback,
  3046. types,
  3047. typing,
  3048. unittest,
  3049. weakref,
  3050. _collections_abc,
  3051. _weakrefset,
  3052. )
  3053. # third party libraries skiplist is defined by str, because users may not use these libraries.
  3054. # we should use lazy import & skip in the future.
  3055. THIRDPARTY_SKIPLIST = (
  3056. "fx2trt_oss",
  3057. "hypothesis",
  3058. "networkx",
  3059. "numpy",
  3060. "omegaconf",
  3061. "onnx",
  3062. "onnxruntime",
  3063. "onnx_tf",
  3064. "pandas",
  3065. "sklearn",
  3066. "tabulate",
  3067. "tensorflow",
  3068. "tensorrt",
  3069. "torch2trt",
  3070. "tqdm",
  3071. "tree",
  3072. "tvm",
  3073. "xarray",
  3074. )
  3075. def _strip_init_py(s):
  3076. # TODO: Once we require py3.9 use removesuffix instead.
  3077. suffix = "__init__.py"
  3078. if s.endswith(suffix):
  3079. return s[: -len(suffix)]
  3080. else:
  3081. return s
  3082. def _module_dir(m: types.ModuleType):
  3083. # Protect against a module not exporting __file__ - this can happen for
  3084. # frozen modules, for example.
  3085. file = getattr(m, "__file__", None)
  3086. return file and _strip_init_py(file)
  3087. # These are legacy workarounds, don't add new modules to this list.
  3088. # Please use the MOD_INLINELIST instead to force inline functions under particular modules.
  3089. LEGACY_MOD_INLINELIST = {
  3090. "torch._dynamo.external_utils",
  3091. "torch._export.db.examples",
  3092. "torch._export.wrappers",
  3093. "torch._functorch.apis",
  3094. "torch._functorch.deprecated",
  3095. "torch._higher_order_ops.cond",
  3096. "torch.ao.quantization.pt2e.export_utils",
  3097. "torch.ao.quantization.pt2e.qat_utils",
  3098. "torch.ao.quantization.pt2e.representation.rewrite",
  3099. "torch.ao.quantization.pt2e.utils",
  3100. "torch.ao.quantization.quantizer.xnnpack_quantizer",
  3101. "torch.optim",
  3102. }
  3103. if torch.distributed.is_available():
  3104. LEGACY_MOD_INLINELIST |= {
  3105. "torch.distributed._tensor.api",
  3106. "torch.distributed._tensor.device_mesh",
  3107. "torch.distributed.device_mesh",
  3108. "torch.distributed.algorithms._checkpoint.checkpoint_wrapper",
  3109. "torch.distributed.tensor.parallel._data_parallel_utils",
  3110. "torch.distributed.tensor.parallel._utils",
  3111. "torch.distributed.tensor.parallel.style",
  3112. # we have to add replicate to LEGACY_MOD_INLINELIST to ensure
  3113. # the forward_hook won't be ignored.
  3114. "torch.distributed._composable.replicate",
  3115. }
  3116. # Force inline functions under these modules, even they are in *_SKIPLIST.
  3117. # We are using python module name instead of file or directory object to avoid circular dependency.
  3118. # Please keep this sorted alphabetically.
  3119. MOD_INLINELIST = {
  3120. "torch._refs",
  3121. "torch._prims",
  3122. "torch._decomp",
  3123. "torch._dynamo._trace_wrapped_higher_order_op",
  3124. "torch._dynamo.comptime",
  3125. "torch._dynamo.polyfill",
  3126. "torch._functorch.vmap",
  3127. "torch._functorch.autograd_function",
  3128. "torch._library.custom_ops",
  3129. "torch._functorch.eager_transforms",
  3130. "torch._inductor.test_operators",
  3131. "torch.amp.autocast_mode",
  3132. "torch.ao.nn",
  3133. "torch.autograd.function",
  3134. "torch.backends.cuda",
  3135. "torch.cuda.amp.autocast_mode",
  3136. "torch.distributions",
  3137. "torch.fx._pytree",
  3138. "torch.fx.passes.shape_prop",
  3139. "torch.nn",
  3140. "torch.random",
  3141. "torch.sparse",
  3142. "torch.testing",
  3143. "torch.testing._internal.hypothesis_utils",
  3144. "torch.utils._content_store",
  3145. "torch.utils._contextlib",
  3146. "torch.utils._foreach_utils",
  3147. "torch.utils._pytree",
  3148. "torch.utils.hooks",
  3149. "torch._tensor",
  3150. "torch._higher_order_ops.strict_mode",
  3151. "torch._higher_order_ops.while_loop",
  3152. "torch._higher_order_ops.associative_scan",
  3153. }
  3154. if torch.distributed.is_available():
  3155. MOD_INLINELIST.add("torch.distributed")
  3156. MOD_INLINELIST.add("torch.distributed._functional_collectives")
  3157. MOD_INLINELIST.add("torch.distributed._composable.replicate")
  3158. @functools.lru_cache(None)
  3159. def get_legacy_mod_inlinelist():
  3160. inlinelist = {
  3161. _module_dir(torch) + m[len("torch.") :].replace(".", "/")
  3162. for m in LEGACY_MOD_INLINELIST
  3163. }
  3164. return inlinelist
  3165. @functools.lru_cache(None)
  3166. def get_mod_inlinelist():
  3167. inlinelist = {
  3168. _module_dir(torch) + m[len("torch.") :].replace(".", "/")
  3169. for m in MOD_INLINELIST
  3170. }
  3171. return inlinelist
  3172. # skip some standard python builtin libs
  3173. SKIP_DIRS = [
  3174. "<frozen importlib",
  3175. "<__array_function__ internals>",
  3176. _config_module.__file__,
  3177. "triton/backends",
  3178. ]
  3179. SKIP_DIRS.extend(filter(None, (_module_dir(m) for m in BUILTIN_SKIPLIST)))
  3180. SKIP_DIRS_RE = re.compile(r"match nothing^")
  3181. is_fbcode = importlib.import_module("torch._inductor.config").is_fbcode()
  3182. # Skip fbcode paths(including torch.package paths) containing
  3183. # one of the following strings.
  3184. FBCODE_SKIP_DIRS = {
  3185. "torchrec/distributed",
  3186. "torchrec/fb/distributed",
  3187. "caffe2/torch/fb/sparsenn/pooled_embeddings_modules.py",
  3188. }
  3189. FBCODE_SKIP_DIRS_RE = re.compile(f".*({'|'.join(map(re.escape, FBCODE_SKIP_DIRS))})")
  3190. # TODO(yanboliang, anijain2305) - There are a few concerns that we should
  3191. # resolve
  3192. # 1) Audit if torchrec/distributed is even required in FBCODE_SKIPS_DIR
  3193. # 2) To inline just one file but skip others in a directory, we could use
  3194. # manual_torch_name_rule_map but this one is hard because FBCODE can add unusual
  3195. # names like torch_package.
  3196. # So, this is a stop gap solution till then.
  3197. FBCODE_INLINE_FILES_IN_SKIPPED_DIRS = {
  3198. "torchrec/distributed/types.py",
  3199. }
  3200. FBCODE_INLINE_FILES_IN_SKIPPED_DIRS_RE = re.compile(
  3201. f".*({'|'.join(map(re.escape, FBCODE_INLINE_FILES_IN_SKIPPED_DIRS))})"
  3202. )
  3203. # torch.optim is a special case,
  3204. # we usually want to inline it, but the directory
  3205. # structure does not match the module structure
  3206. # and we want to skip the functions in optim/lr_scheduler.py
  3207. # this has precedence over all other rules in check_file
  3208. FORCE_SKIP_FILES = {f"{_module_dir(torch)}optim/lr_scheduler.py"}
  3209. def _recompile_re():
  3210. global SKIP_DIRS_RE
  3211. SKIP_DIRS_RE = re.compile(rf"^[^\s<]*({'|'.join(map(re.escape, SKIP_DIRS))})")
  3212. def add(import_name: str):
  3213. if isinstance(import_name, types.ModuleType):
  3214. return add(import_name.__name__)
  3215. assert isinstance(import_name, str)
  3216. from importlib.util import find_spec
  3217. module_spec = find_spec(import_name)
  3218. if not module_spec:
  3219. return
  3220. origin = module_spec.origin
  3221. if origin is None:
  3222. return
  3223. SKIP_DIRS.append(_strip_init_py(origin))
  3224. _recompile_re()
  3225. @dataclasses.dataclass
  3226. class SkipResult:
  3227. skipped: bool
  3228. reason: Optional[str]
  3229. def check_file(filename, is_inlined_call=False):
  3230. """Should skip this file?"""
  3231. if filename is None:
  3232. return SkipResult(True, "filename is None")
  3233. if filename in FORCE_SKIP_FILES:
  3234. return SkipResult(True, "FORCE_SKIP_FILES")
  3235. if any(filename.startswith(d) for d in get_legacy_mod_inlinelist()):
  3236. return SkipResult(
  3237. False,
  3238. "LEGACY_MOD_INLINELIST",
  3239. )
  3240. if is_inlined_call and is_torch_inline_allowed(filename):
  3241. return SkipResult(
  3242. False,
  3243. "MOD_INLINELIST",
  3244. )
  3245. if (
  3246. is_fbcode
  3247. and bool(FBCODE_SKIP_DIRS_RE.match(filename))
  3248. and not bool(FBCODE_INLINE_FILES_IN_SKIPPED_DIRS_RE.match(filename))
  3249. ):
  3250. return SkipResult(
  3251. True,
  3252. "FBCODE_SKIP_DIRS",
  3253. )
  3254. if bool(SKIP_DIRS_RE.match(filename)):
  3255. return SkipResult(True, "SKIP_DIRS")
  3256. else:
  3257. return SkipResult(False, "inlined by default")
  3258. @dataclasses.dataclass
  3259. class FunctionInfo:
  3260. py_obj: Optional[object]
  3261. name: Optional[str]
  3262. filename: str
  3263. code: Optional[types.CodeType]
  3264. """
  3265. This is the main entry point to determine whether an object (function) should be inlined or skipped.
  3266. Let's illustrate the logic with an example:
  3267. @torch.compile
  3268. def f1(x, y):
  3269. ......
  3270. f2(x, y)
  3271. ......
  3272. def f2(x, y):
  3273. ......
  3274. f3(x, y)
  3275. ......
  3276. def f3(x, y):
  3277. ......
  3278. There are mainly three call sites of check/check_verbose:
  3279. * The compile region entrance (like function f1), the correspoinding code is located at eval_frame.py.
  3280. * When tracing the recursively called functions (like function f2 and f3).
  3281. * Dynamo decides inline/skip everytime it encounters a new recursively function call, and the call site
  3282. is in InliningInstructionTranslator.check_inlineable of symbolic_convert.py.
  3283. * If f2 is skipped by Dynamo, when evaluating the frame of f3, Dynamo need the inline/skip check again
  3284. and the call site is in catch_errors_wrapper.catch_errors of convert_frame.py.
  3285. * For global variables and function arguments, Dynamo needs to decide if they are wrapped as SkipFunctionVariable in builder.py.
  3286. `is_inlined_call` is used to indicate if the current function call is inlined (f2 is inlined call if it passes check)
  3287. or not (f3 is not inlined call if f2 is skipped). Inside of the `check_verbose` function, there are more rules
  3288. to be checked if this `is_inlined_call`.
  3289. The reason to have this flag is that if the upper level function call (e.g, f2) is skipped,
  3290. we don't want to inline the lower level function call (e.g, f3) by default.
  3291. """
  3292. def check_verbose(obj, is_inlined_call=False):
  3293. if isinstance(
  3294. obj, (UserFunctionVariable, UserMethodVariable, NestedUserFunctionVariable)
  3295. ):
  3296. try:
  3297. py_obj = obj.get_function()
  3298. except NotImplementedError:
  3299. py_obj = None
  3300. fi = FunctionInfo(py_obj, obj.get_name(), obj.get_filename(), obj.get_code())
  3301. elif isinstance(obj, types.CodeType):
  3302. fi = FunctionInfo(None, obj.co_name, obj.co_filename, obj)
  3303. elif isinstance(obj, (types.FunctionType, types.MethodType)):
  3304. fi = FunctionInfo(
  3305. obj, obj.__name__, getfile(obj), obj.__code__ # type: ignore[union-attr] # FIXME Add MethodType.__code__ to typeshed
  3306. )
  3307. else:
  3308. fi = FunctionInfo(obj, None, getfile(obj), None)
  3309. # Consulte the central trace rules defined in torch._dynamo.trace_rules.
  3310. reasons: Set[str] = set()
  3311. rule = torch._dynamo.trace_rules.lookup_inner(
  3312. fi.py_obj, fi.name, fi.filename, is_inlined_call, reasons
  3313. )
  3314. if rule in [UserFunctionVariable, FunctorchHigherOrderVariable]:
  3315. return SkipResult(
  3316. False,
  3317. f"inlined according trace_rules.lookup {reasons.pop()}",
  3318. )
  3319. else:
  3320. assert rule == SkipFunctionVariable, rule
  3321. return SkipResult(
  3322. True,
  3323. f"skipped according trace_rules.lookup {reasons.pop()}",
  3324. )
  3325. def check(obj, is_inlined_call=False):
  3326. return check_verbose(obj, is_inlined_call).skipped
  3327. # skip common third party libs
  3328. for _name in THIRDPARTY_SKIPLIST:
  3329. add(_name)
  3330. _recompile_re()
  3331. def is_torch_inline_allowed(filename):
  3332. return any(filename.startswith(d) for d in get_mod_inlinelist())
  3333. @functools.lru_cache(None)
  3334. def dynamo_dir():
  3335. import torch._dynamo
  3336. return _module_dir(torch._dynamo)
  3337. def is_torch(filename):
  3338. if filename.startswith(dynamo_dir()):
  3339. return False
  3340. return filename.startswith(_module_dir(torch))
  3341. """
  3342. Main entry point for looking up the trace rule (the Dynamo variable) for a given callable object.
  3343. """
  3344. def lookup_callable(obj):
  3345. if not hashable(obj):
  3346. return None
  3347. # Custom allow/disallow in graph takes precedence over the general lookup.
  3348. if is_callable_disallowed(obj):
  3349. return SkipFunctionVariable
  3350. if is_callable_allowed(obj):
  3351. return TorchInGraphFunctionVariable
  3352. if is_builtin_callable(obj):
  3353. return BuiltinVariable
  3354. """
  3355. Main entry point for looking up the trace rule (the Dynamo variable) for a given function object.
  3356. E.g, the lookup result of `torch.sin` is `TorchInGraphFunctionVariable`.
  3357. """
  3358. def lookup(obj):
  3359. return lookup_inner(obj)
  3360. def lookup_inner(
  3361. obj,
  3362. name=None,
  3363. filename=None,
  3364. is_direct_call=True,
  3365. reasons: Union[None, Set[str]] = None,
  3366. ):
  3367. # Step 1: lookup obj's tracing rule in `torch_name_rule_map`.
  3368. # The rules defined in `torch_name_rule_map` mainly includes two parts:
  3369. # - Manually defined rules for any functions.
  3370. # - The list of torch in graph functions.
  3371. if not hashable(obj):
  3372. if reasons is not None:
  3373. reasons.add("obj is not hashable")
  3374. return None
  3375. if obj is not None:
  3376. if is_aten_op_or_tensor_method(obj):
  3377. return TorchInGraphFunctionVariable
  3378. rule = get_torch_obj_rule_map().get(obj, None)
  3379. if rule is not None:
  3380. if reasons is not None:
  3381. reasons.add("get_torch_obj_rule_map")
  3382. return rule
  3383. elif name is not None and filename is not None and not is_direct_call:
  3384. if name.startswith(TORCH_DYNAMO_RESUME_IN_PREFIX):
  3385. rule = get_torch_obj_rule_map().get(
  3386. filename + "#" + TORCH_DYNAMO_RESUME_IN_PREFIX, None
  3387. )
  3388. else:
  3389. rule = get_torch_obj_rule_map().get(filename + "#" + name, None)
  3390. if rule is not None:
  3391. if reasons is not None:
  3392. reasons.add("get_torch_obj_rule_map")
  3393. return rule
  3394. # Step 2: lookup obj's tracing rule by function name.
  3395. if is_direct_call:
  3396. if name == "patched_init":
  3397. if reasons is not None:
  3398. reasons.add("func name is patched_init")
  3399. return SkipFunctionVariable
  3400. elif name == "__torch_function__":
  3401. if reasons is not None:
  3402. reasons.add("func name is __torch_function__")
  3403. return UserFunctionVariable
  3404. if not is_direct_call:
  3405. if name == "__getattr__":
  3406. # is_direct_call = False indicates that this is the top-level frame
  3407. # being traced (i.e., it is not inlined and not called from
  3408. # InliningInstructionTranslator). Tracing __getattr__ at the top
  3409. # level is unlikely because we inline it for
  3410. # UserDefinedObjectVariable. This scenario occurs only for
  3411. # UnspecializedNNModuleVariable, where Dynamo directly calls
  3412. # __getattr__ during trace time, generating LOAD_ATTR bytecode
  3413. # without going through the underlying __getattr__ data structures.
  3414. # When this optimized bytecode is executed, Dynamo is triggered
  3415. # again on the __getattr__ call. Therefore, we skip Dynamo tracing
  3416. # in this case.
  3417. if reasons is not None:
  3418. reasons.add(
  3419. "Tracing __getattr__ as the top level frame, unsuitable for tracing."
  3420. )
  3421. return SkipFunctionVariable
  3422. # Step 3: lookup obj's tracing rule by filename.
  3423. if filename is None:
  3424. filename = getfile(obj)
  3425. skip_result = check_file(filename, is_direct_call)
  3426. if reasons is not None:
  3427. reasons.add(skip_result.reason)
  3428. if skip_result.skipped:
  3429. return SkipFunctionVariable
  3430. else:
  3431. return UserFunctionVariable
  3432. def clear_lru_cache():
  3433. torch._dynamo.trace_rules.get_torch_obj_rule_map.cache_clear()
  3434. torch._dynamo.trace_rules.get_tensor_method.cache_clear()
  3435. torch._dynamo.trace_rules.get_legacy_mod_inlinelist.cache_clear()
  3436. torch._dynamo.trace_rules.get_mod_inlinelist.cache_clear()
  3437. torch._dynamo.trace_rules.dynamo_dir.cache_clear()