L iNddlmZddlZddlmZddlmZmZmZm Z ddl m Z erddl m Z ddlZddlZddlZddlZddlZddlZddlZddlZddlmZe dZe d Zej4dd Zej4dd ZGd d ej:j<Zy)) annotationsN) nullcontext)AnyCallable TYPE_CHECKINGTypeVar) ParamSpec)Sequence)torch_function_passthrough_P_Rc  ttjftjtjjftjjtjjjftjtjjftj tjj ftj tjj fg}itjjtjjtjjtjjtjjtjjtjjtjjtjj tjj"tjj$tjj&tjj(tjj*tjj,tjj.tjj0tjj2tjj4tjj6tjj8tjj:tjj<tjj<tjj>tjj>tjj@tjj@tjjBtjjBtjjDtjjDtjjFtjjFtjjHtjjHtjjJtjjJtjjLtjNjPtjjRtjNjRi}|D]M\}}|jTD]9}|jVjY|||jVjY|<;Ot[tjD]c}|tjjTvs tjjVjY||t]tj|<etjj^jTD]e}t]tj|dxst]t|}tjj^jVjY|||<g|S)z} Mapping of torch API functions to torch._refs functions. E.g. torch_to_refs_map()[torch.add] == torch._refs.add N)0torch_refsnn functionalspecialfftlinalgTensor __invert__ bitwise_not__xor__ bitwise_xor__and__ bitwise_and__or__ bitwise_or__eq__eq__rsub__rsub __rtruediv__rtruediv __floordiv__ floor_divide __rfloordiv__ rfloordiv__pow__pow__rpow__rpow new_emptynew_full new_zerosnew_onesfill_zero_to sum_to_sizecopy__primscopy_toresize__all____dict__getdirgetattr _conversions)modulesr mod_torchmod_refss tensor_attrs Z/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/torch/_prims/context.pytorch_to_refs_maprFs0   5;;>>"   ekknn778  ++, EKKOO$ u{{))* G !8!8 ekk55  ekk55  U[[33   U[[^^   u{{//   !!5;;#7#7  !!5;;#;#;  ""EKK$9$9  ekkoo  u{{//   5 5  u{{33   5 5  u{{33  EKK--!"  EKK--#$     %++"9"9 ELL00 U\\00-A0 'D 8!! DA+3+<+<+@+@+CAi  $$Q' ( DD  F  ## #*/++*>*>*B*B1*EAgellA& 'F [[ % % - -BellAt4Iq8I 11::>>qA+B HctjjDchc]+}tjjj |-c}Scc}w)zJ Set of all prim functions, e.g., torch._prims.add in all_prims() )rr6r9r:r;)rCs rE all_primsrIRs7 38,,2F2F GQELL ! ! % %a ( GG Gs0AcPeZdZdZddef ddZ d d dZy) TorchRefsModeaB Switches the interpretation of torch.* functions and Tensor methods to use PrimTorch refs in torch._refs. (Direct calls to _refs are unaffected.) >>> # xdoctest: +SKIP >>> with TorchRefsMode(): ... torch.add(x, y) # calls torch._refs.add(x, y) By default, this context manager will fall back on the torch.* if the ref does not exist; set strict=True to error if this occurs. If the ref exists we still would like to fall back on the torch.* sometimes, this behavior can be customized by passing a function to should_fallback_fn. Fcy)NF)_s rEzTorchRefsMode.lsrGc.||_||_||_y)N)strictshould_fallback_fnprims_mode_cls)selfrQrRrSs rE__init__zTorchRefsMode.__init__is  "4,rGNct|i}|tvs |tvr"|j5||i|cdddSt}|j |d}|Ot |t jjr+t jjj |d}n|t |t jjrat|dd}|&|jrt||jdd}|*t jjj |d}|1|j|||||r||i|S|5||i|cdddS|jr+t!dt j"j%|||i|S#1swYpxYw#1swYUxYw)Ndefaultrzno _refs support for )r rIrSrFr; isinstancer_ops OpOverload_decompdecomposition_tableOpOverloadPacketr=_dirrRrQ RuntimeError overrides resolve_name)rT orig_functypesargskwargsmappingfuncrWs rE__torch_function__z TorchRefsMode.__torch_function__ss >F 2 2i9;6N$$& 2 $1&1 2 2#%{{9d+ >!)Y^^A->E"}}88<rs""88'(  :t_ T] 3 3 l HHD*EOO55D*rG