~L inUddlmZddlZddlZddlZddlZddlZddlZddlm Z m Z m Z m Z mZmZddlmZddlZddlmZmZddlmZmZmZe rddlmZdd gZ ddlZd ZejBZ"iZ#d e$d <eddZ%GddZ&dZ'Gdd ejPjRe&Z*dZ+ejXdZ-ejXdZ.ejXdZ/dZ0dZ1d a2dZ3dZ4d'dZ5dZ6d(dZ7Gd dZ8ejre8jt_9e&jvjre8jv_9e&jxjre8jx_9ejre8jz_9Gd!d"e:Z>Gd#d$e8e>%Z?d)d&Z@y#e $rd ZdZYTwxYw)*) annotationsN)AnycastOptional TYPE_CHECKINGTypeVarUnion)Self)_to_type)_bool_intStorage)DeviceLikeType TypedStorageUntypedStorageTFzdict[int, threading.RLock]_share_memory_mapT!Union[_StorageBase, TypedStorage])boundc&eZdZUded<dZded<dZded<ded<d Zd ed <d Zd ed <dZd]dZ dZ dZ d^d_dZ d`dZ d]dZd]dZ da dbdZ da d`dZdad`dZd]dZd]dZd]dZdcdZdZdZedddZeddd Zeded!Zed d d" ded#Zed d$d%Zeded&Zeded'Z d`d(Z!d)Z"dfd*Z#d`d+Z$d,Z%d-Z&d.Z'dcd/Z(eded0Z)d1Z*ed2Z+e,d3Z-e,d4Z.ed`d5Z/ed`d6Z0d7Z1dgd8Z2d9Z3d:Z4d;Z5d<Z6d=Z7fd>Z8d?Z9d@Z:dAZ;dBZdFZ?dGZ@dHZAdIZBdJZCdKZDdLZEdMZFdNZGdOZHdPZIdQZJdRZKdSZLdTZMdUZNdidjdVZOdidjdWZPdXZQedYd$dZZRd[ZSd\ZTxZUS)k _StorageBaser_cdataFr is_sparse is_sparse_csrz torch.devicedeviceN_Optional[torch.device] _fake_devicez_Optional[int]_checkpoint_offsetcyNselfargskwargss S/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/torch/storage.py__init__z_StorageBase.__init__5s ctr!NotImplementedErrorr$s r'__len__z_StorageBase.__len__8!!r)ctr!r+r$idxs r' __getitem__z_StorageBase.__getitem__;r/r)ctr!r+r#s r' __setitem__z_StorageBase.__setitem__>r/r)ctr!r+r$source non_blockings r'copy_z_StorageBase.copy_Ar/r)ctr!r+r-s r'newz_StorageBase.newDr/r)ctr!r+r-s r'nbytesz_StorageBase.nbytesGr/r)c"|jSr!)r>r-s r'sizez_StorageBase.sizeJs{{}r)ct|||Sr!)r )r$dtyper9s r'typez_StorageBase.typeMsT5,//r)c|rtjd|ntjd}|j||S)aReturns a copy of this object in CUDA memory. If this object is already in CUDA memory and on the correct device, then no copy is performed and the original object is returned. Args: device (int): The destination GPU id. Defaults to the current device. non_blocking (bool): If ``True`` and the source is in pinned memory, the copy will be asynchronous with respect to the host. Otherwise, the argument has no effect. cudarr9torchrtor$rr9device2s r'rEz_StorageBase.cudaRs439%,,vv.ell6>RwwgLwAAr)c|rtjd|ntjd}|j||S)aReturns a copy of this object in HPU memory. If this object is already in HPU memory and on the correct device, then no copy is performed and the original object is returned. Args: device (int): The destination HPU id. Defaults to the current device. non_blocking (bool): If ``True`` and the source is in pinned memory, the copy will be asynchronous with respect to the host. Otherwise, the argument has no effect. hpurFrGrJs r'rMz_StorageBase.hpucs428%,,uf-U\\%=PwwgLwAAr)ctr!r+r-s r' element_sizez_StorageBase.element_sizerr/r)c.|jjSr!)rindexr-s r' get_devicez_StorageBase.get_deviceus{{   r)ctr!r+r-s r'data_ptrz_StorageBase.data_ptrxr/r)ctr!r+r-s r' resizablez_StorageBase.resizable{r/r)ctr!r+r#s r'_share_filename_cpu_z!_StorageBase._share_filename_cpu_r/r)ctr!r+r#s r'_share_fd_cpu_z_StorageBase._share_fd_cpu_r/r)ctr!r+clsr@s r'_new_using_filename_cpuz$_StorageBase._new_using_filename_cpu!!r)ctr!r+r\s r'_new_using_fd_cpuz_StorageBase._new_using_fd_cpur_r)ctr!r+r]r%r&s r' from_bufferz_StorageBase.from_bufferr_r))rrBctr!r+)r]managerobjr@rrBs r'_new_shared_filename_cpuz%_StorageBase._new_shared_filename_cpus "!r)rc&|j|i|Sr!)_release_ipc_counter_cudar]rr%r&s r'_release_ipc_counterz!_StorageBase._release_ipc_counters,s,,d=f==r)ctr!r+rcs r'rkz&_StorageBase._release_ipc_counter_cudar_r)ctr!r+rcs r'_new_with_weak_ptrz_StorageBase._new_with_weak_ptrr_r)ctr!r+r-s r'_shared_decrefz_StorageBase._shared_decrefr/r)ctr!r+r#s r' _write_filez_StorageBase._write_filer/r)ctr!r+r$r@s r'resize_z_StorageBase.resize_r/r)ctr!r+r#s r' _weak_refz_StorageBase._weak_refr/r)ctr!r+r#s r'_set_from_filez_StorageBase._set_from_filer/r)ctr!r+r#s r' _set_cdataz_StorageBase._set_cdatar/r)ctr!r+r#s r' _share_cuda_z_StorageBase._share_cuda_r/r)ctr!r+r-s r' is_sharedz_StorageBase.is_sharedr/r)ctr!r+rcs r'_new_shared_cudaz_StorageBase._new_shared_cudar_r)ctr!r+r#s r'_shared_increfz_StorageBase._shared_increfr/r)ctr!r+rcs r'_free_weak_refz_StorageBase._free_weak_refr_r)ctr!r+r-s r'is_cudaz_StorageBase.is_cudar_r)ctr!r+r-s r'is_hpuz_StorageBase.is_hpur_r)ctr!r+)r]filenamesharedr>s r' from_filez_StorageBase.from_filer_r)ctr!r+rcs r'_expiredz_StorageBase._expiredr_r)ctr!r+r#s r' _byteswapz_StorageBase._byteswapr/r)ctr!r+r#s r' _get_filenamez_StorageBase._get_filenamer/r)cdtjdjdtd}jjdk(rd|zSddj fd t jDz}|d z|zS) N[z(device= ) of size ]meta...   c3:K|]}t|ywr!str.0ir$s r' z(_StorageBase.__repr__..s#MQCQL#M )rHtypenamerlenrCjoinranger@r$info_strdata_strs` r'__repr__z_StorageBase.__repr__su~~d+,HT[[MCPTI;VWX ;;  v %X% %#M% :L#MMM$))r)cZtfdtjDS)Nc3(K|] }| ywr!r"rs r'rz(_StorageBase.__iter__..8DG8)iterrr@r-s`r'__iter__z_StorageBase.__iter__s8U499;%7888r)c"|jSr!)cloner-s r'__copy__z_StorageBase.__copy__szz|r)c|jdi}|j|vr||jS|j}|||j<|S)NrH) setdefaultrr)r$memo new_storages r' __deepcopy__z_StorageBase.__deepcopy__sLw+ ;;$  $ $jjl 'T[[r)ctj}tj||dt|j ffSNF)_use_new_zipfile_serializationioBytesIOrHsave_load_from_bytesgetvaluer$bs r' __reduce__z_StorageBase.__reduce__0 JJL 45A 1::rr:r-s r'rz_StorageBase.clones*tDz$++- <BB4HHr)ct|Sz6Return a list containing the elements of this storage.)listr-s r'tolistz_StorageBase.tolists Dzr)c|jjdk7r3tj|j j |dS|S)AReturn a CPU copy of this storage if it's not already on the CPU.cpuFrrCrHrr@r:r-s r'rz_StorageBase.cpus= ;;  u $'' 4::4G G r)c|jjdk7r5tj|j dj |dS|S)zAReturn a MPS copy of this storage if it's not already on the MPS.mpsriFrr-s r'rz_StorageBase.mps s? ;;  u $'' EBHHuU U r)ct|tjstdt |tj gtj |jjtt|j|j}|j|jk(r|j}|SNz*Argument 'dtype' must be torch.dtype, not rBr) isinstancerHrB TypeErrorrCtensoruint8rset_rrrI_typed_storagerTrr$rBstorages r'r z_StorageBase._tos%-He VW W LL5;;t{{ C T$w% & RY ^       0mmoGr)r9czt|tjstj|}t|||Sr!)rrHrr )r$rr9s r'rIz_StorageBase.to s-&%,,/\\&)F4..r)c@|jtjSz"Casts this storage to double type.)r rHdoubler-s r'rz_StorageBase.double%xx %%r)c@|jtjSz!Casts this storage to float type.)r rHfloatr-s r'rz_StorageBase.float)xx $$r)c@|jtjSz Casts this storage to half type.)r rHhalfr-s r'rz_StorageBase.half-xx ##r)c@|jtjSz Casts this storage to long type.)r rHlongr-s r'rz_StorageBase.long1rr)c@|jtjSzCasts this storage to int type.)r rHintr-s r'rz_StorageBase.int5sxx ""r)c@|jtjSz!Casts this storage to short type.)r rHshortr-s r'rz_StorageBase.short9rr)c@|jtjSz Casts this storage to char type.)r rHint8r-s r'charz_StorageBase.char=rr)c@|jtjSz Casts this storage to byte type.)r rHrr-s r'bytez_StorageBase.byteArr)c@|jtjSz Casts this storage to bool type.)r rHboolr-s r'rz_StorageBase.boolErr)c@|jtjSz$Casts this storage to bfloat16 type.)r rHbfloat16r-s r'r z_StorageBase.bfloat16Isxx''r)c@|jtjSz*Casts this storage to complex double type.)r rHcdoubler-s r'complex_doublez_StorageBase.complex_doubleMsxx &&r)c@|jtjSz)Casts this storage to complex float type.)r rHcfloatr-s r' complex_floatz_StorageBase.complex_floatQrr)c@|jtjSz&Casts this storage to float8_e5m2 type)r rH float8_e5m2r-s r'rz_StorageBase.float8_e5m2Usxx))**r)c@|jtjSz(Casts this storage to float8_e4m3fn type)r rH float8_e4m3fnr-s r'rz_StorageBase.float8_e4m3fnYsxx++,,r)c@|jtjSz*Casts this storage to float8_e5m2fnuz type)r rHfloat8_e5m2fnuzr-s r'rz_StorageBase.float8_e5m2fnuz]xx--..r)c@|jtjSz*Casts this storage to float8_e4m3fnuz type)r rHfloat8_e4m3fnuzr-s r'rz_StorageBase.float8_e4m3fnuzarr)ctjgtj|jj t t |j|S)a-Determine whether the CPU storage is already pinned on device. Args: device (str or torch.device): The device to pin memory on (default: ``'cuda'``). This argument is discouraged and subject to deprecated. Returns: A boolean variable. r)rHrrrrrr is_pinnedr$rs r'r z_StorageBase.is_pinnedes< LL5;;t{{ C T$w% & Yv  r)cF|jjdk7rtd|jdtjgtj |jj tt|j|}|jS)a3Copy the CPU storage to pinned memory, if it's not already pinned. Args: device (str or torch.device): The device to pin memory on (default: ``'cuda'``). This argument is discouraged and subject to deprecated. Returns: A pinned CPU storage. rz cannot pin 'z' only CPU memory can be pinnedr) rrCrrHrrrrr pin_memoryuntyped_storage)r$r pinned_tensors r'r#z_StorageBase.pin_memoryus| ;;  u $l499;-7VWX X LL5;;t{{ C T$w% & Z   ,,..r)cddlm}|jjdtj j fvr |S|dk(r|j|S|j|S).See :meth:`torch.UntypedStorage.share_memory_`rget_sharing_strategyrE file_system) torch.multiprocessingr)rrCrH_C_get_privateuse1_backend_namerXrZ)r$r)s r' share_memory_z_StorageBase.share_memory_sf> ;;  (N(N(PQ Q   " #} 4  % % '     ! r)rcddlm}tj|}|jdtj j dfvr |||S|dk(r|j|S|j|S)>Create a new storage in shared memory with the same data type.rr(rErMrir*) r+r)rHrrCr,r-r^ra)r]r@rr)s r' _new_sharedz_StorageBase._new_sharedso ?f% ;;6588#I#I#KUS StF+ + ! #} 4..t4 4((. .r)c|Sr!r"r-s r'untypedz_StorageBase.untypeds r)ctjj|}|jrt t |dz d}|j |y)zSwap bytes in underlying data.N)rH_utils _element_size is_complexmaxrr)r$rB elem_sizes r'byteswapz_StorageBase.byteswaps@LL..u5   C A .2I y!r)returnrr!)r8rr9z_Optional[_bool]r>r)r>rNF)rB_Optional[str]r9r r>r)r>r )r@rr>r r>r )r@rr>r@)rrr9r rErzUnion[str, torch.device])V__name__ __module__ __qualname____annotations__rrrrr(r.r3r5r:r<r>r@rCrErMrOrRrTrVrXrZ classmethodr^rardrhrmrkrprrrtrwryr{r}rrrrrpropertyrrrrrrrrrrrrrrrrr rIrrrrrrrrrr r rrrrrr r#r.r1r3r< __classcell__rs@r'rr)s KIu M5 -1L)0)-- """"""CH0#0:?0 *0 ).B *B" B"!"""""""""" "  " "04>>"""""""""""""""""""""""""""*93 2I  CH/ &%$$#%$%$('&+-// /( ). / /"r)rcBtjfd}|S)Ncrd}d}t5|j}|tvr t|}n4tjt|<t|j |}ddd| |5 ddd |g|i||?|j|k(sJt5t|j t|=dddSS#1swYexYw#1swYcxYw#1swYSxYw#|K|j|k(sJt5t|j t|=dddw#1swYwxYwwxYwr!)_share_memory_lockrr threadingRLockacquirerelease)r$r%r&to_freeto_waitkeyfns r'wrapperz-_share_memory_lock_protected..wrappersM  ++C''+C0)2):!#&!#&..0      3d,T,V,"{{g---'3%g.668)'233 #)    33 "{{g---'3%g.668)'2333 #sHAC+C6 C'CC CC$ 'D6D) D6)D2 .D6) functoolswraps)rWrXs` r'_share_memory_lock_protectedr[s%__R33> Nr)ceZdZfdZedZedZeddZefdZ efdZ efdZ xZ S) rcj|jjdk(r tdt||i|S)Nr$Not available for 'meta' device type)rrCr,rr3r$r%r&rs r'r3zUntypedStorage.__getitem__s6 ;;  v %%&LM Mw"D3F33r)c4|jjdk(SNrErrCr-s r'rzUntypedStorage.is_cudas{{6))r)c4|jjdk(SNrMrbr-s r'rzUntypedStorage.is_hpus{{5((r)c"|jS)zReturns the file name associated with this storage. The file name will be a string if the storage is on CPU and was created via :meth:`~torch.from_file()` with ``shared`` as ``True``. This attribute is ``None`` otherwise. )rr-s r'rzUntypedStorage.filenames!!##r)c"t||i|S)a{ Moves the storage to shared memory. This is a no-op for storages already in shared memory and for CUDA storages, which do not need to be moved for sharing across processes. Storages in shared memory cannot be resized. Note that to mitigate issues like `this `_ it is thread safe to call this function from multiple threads on the same object. It is NOT thread safe though to call any other function on self without proper synchronization. Please see :doc:`/notes/multiprocessing` for more details. .. note:: When all references to a storage in shared memory are deleted, the associated shared memory object will also be deleted. PyTorch has a special cleanup process to ensure that this happens even if the current process exits unexpectedly. It is worth noting the difference between :meth:`share_memory_` and :meth:`from_file` with ``shared = True`` #. ``share_memory_`` uses `shm_open(3) `_ to create a POSIX shared memory object while :meth:`from_file` uses `open(2) `_ to open the filename passed by the user. #. Both use an `mmap(2) call `_ with ``MAP_SHARED`` to map the file/object into the current virtual address space #. ``share_memory_`` will call ``shm_unlink(3)`` on the object after mapping it to make sure the shared memory object is freed when no process has the object open. ``torch.from_file(shared=True)`` does not unlink the file. This file is persistent and will remain until it is deleted by the user. Returns: ``self`` )rr.r_s r'r.zUntypedStorage.share_memory_sBw$d5f55r)c"t||i|Sr!)rrZr_s r'rZzUntypedStorage._share_fd_cpu_ sw%t6v66r)c"t||i|Sr!)rrXr_s r'rXz#UntypedStorage._share_filename_cpu_sw+T.is_first_times$2LA2;;LII Ir)aTypedStorage is deprecated. It will be removed in the future and UntypedStorage will be the only storage class. This should only matter to you if you are using storages directly. To access UntypedStorage directly, use tensor.untyped_storage() instead of tensor.storage()r6) stacklevelTr)rwarningswarn UserWarningrr)rrmessages r'rrsLJ ./=? Q   g{zA~F=A#,,\:4Cr)c*dtjd<y)NFr)rrr"r)r'!_reset_warn_typed_storage_removalrs9>((6r)cx|jddd}|dtjjdfvr|Sy)N.r6rErMr)rsplitrHr,r-)module last_parts r'_get_device_from_modulers< c1%b)IVUXXCCEuMMr)c8eZdZUdZded<dZded<ded<ed Zedfd Zd Z ddddd fd Z ddddddZ edZ edZ dZdgdZdZdhdZdZdZdZdZdidjdZdZdZ dk dldZdkdgdZdkdgdZdd dmd!Zd"Zd#Zdnd$Zd%Z d&Z!d'Z"d(Z#d)Z$d*Z%fd+Z&d,Z'd-Z(d.Z)dodpd/Z*dodpd0Z+d1Z,d2Z-dd3d4Z.ed5Z/ed6Z0d7Z1d8Z2d9Z3d:Z4d;Z5d<Z6d=Z7d>Z8d?Z9d@Z:e;dAZe;dddDdEZ?dFZ@dGZAdHZBdIZCdJZDdKZEdLZFdMZGdNZHdOZIdPZJdQZKdRZLdSZMdTZNdUZOdVZPe;dWZQe;dXZRdYZSdZZTd[ZUd\ZVd]ZWd^ZXe;d_ZYd`ZZdaZ[e;dd3dbZ\dcZ]ddZ^deZ_xZ`S)qrFr rNrr torch.dtyperBc|jSr!)rBr-s r'_dtypezTypedStorage._dtypes zzr)c.|jjS)zReturns the file name associated with this storage if the storage was memory mapped from a file. or ``None`` if the storage was not created by memory mapping a file.)rrr-s r'rzTypedStorage.filenames$$---r)cnt|jtd|j||S)Nr)r_setitemslice_size)r$values r'fill_zTypedStorage.fill_s(#% eAtzz|,e4 r)) wrap_storagerBr _internalc|s t|tjjk(r t d|t k(rt ||S|d}|t |dz|t |dz|t|dkDrt |dzt|dk(rRt|dsDt|dtjjst|dt|dzt ||j t#|j$d d St|dk7rt |d zt|tj&st|d t|zt#|j$}|j(j|k7r(t |d |d|j(jzt |||j*d dS)Nz8Only child classes of _LegacyStorage can be instantiatedz.__new__ received an invalid combination of arguments. Expected one of: * no arguments * (int size) * (Sequence data) * (*, UntypedStorage wrap_storage)z. Keyword argument 'device' cannot be specifiedz- Keyword argument 'dtype' cannot be specifiedr6 Too many positional argumentsr Argument type not recognized: T)rBrrB No positional arguments should be given when using 'wrap_storage'9 Argument 'wrap_storage' must be UntypedStorage, but got z" Device of 'wrap_storage' must be z , but got rrBr)rrHr_LegacyStorage RuntimeErrorrr__new__rrr collectionsabcSequencerrCrrrFrrrB) r]rrBrrr% arg_error_msg cls_devicers r'rzTypedStorage.__new__s ' ) %--.. .J  , 7?3' '%66 !"!$UU "!$TT#t9q=&%(II IN"47O&tAw 0H0HI#%>B" t9>&%)) ",0D0DE#%VW[\hWiVjkl 5S^^D &&++z9&%? |$\%8%8%=%=$>@@ $!-))" r))rrBrrc|s td}|t|dk7rt|dz|t|dzt|tj st |dt|z|t|dz||_t|tjst |dt|z||_ y|t jn||_t j|dn|}|j tjtjtjtjtj fvr|jd k(r td t|dk(rt j| |_ yt|d k(rt#|dr:t jt%|d|j'z| |_ yt|dt(j*j,r t/|d|j ||_ yt |d t|dzt|dz)Na1TypedStorage.__init__ received an invalid combination of arguments. Expected one of: * (*, torch.device device, torch.dtype dtype) * (int size, *, torch.device device, torch.dtype dtype) * (Sequence data, *, torch.device device, torch.dtype dtype) * (*, UntypedStorage wrap_storage, torch.dtype dtype)rrz# Argument 'dtype' must be specifiedz+ Argument 'dtype' must be torch.dtype, not zG Argument 'device' should not be specified when 'wrap_storage' is givenrrrE/Cannot create CUDA storage with quantized dtyperir6rr)rrrrrHrBrrCrrget_default_dtyperrrrrrrrr8rrrr)r$rrBrrr%rs r'r(zTypedStorage.__init__sW ' ) E   #4yA~"!%% }"!$JJeU[[1!DT%[MRS !"!`a DJlE,@,@A!RSWXdSeRfgh %1D !7%vFFzz   ;;&(&I4yA~(-(<(zTypedStorage.nbytess#%||~r)c6|jjSr!)rr>r-s r'rzTypedStorage._nbytes s$$++--r)ct|^|j}||jdz|jzSdj |jt |jgS|j j ||S)Nr)r_get_legacy_storage_classrFrErrCr)r$rBr9 legacy_classs r'rCzTypedStorage.type s| $% =99;L'#..4|7L7LLL88T__d4j.A.ABC C((--e\B Br)c8t|jtjtjtj tj tjfvr td|jj||}|j|S)Nr) rrBrHrrrrrrrrEr)r$rr9 cuda_storages r'rEzTypedStorage.cudass#% :: LL NN NN LL KK   PQ Q,,11&,G ((66r)c8t|jtjtjtj tj tjfvr td|jj||}|j|S)Nz.Cannot create HPU storage with quantized dtype) rrBrHrrrrrrrrMr)r$rr9 hpu_storages r'rMzTypedStorage.hpu+ss#% :: LL NN NN LL KK   OP P++// E ((55r)rctt|tjstj|}|jtj tj tjtjtjfvr'td|jjd|jj||}|j|S)NzCannot create z storage with quantized dtyperF)rrrHrrBrrrrrrrCupperrrIr)r$rr9 to_storages r'rIzTypedStorage.to8s#%&%,,/\\&)F :: LL NN NN LL KK    !2!2!4 55RS **--V,-W ((44r)c6t|jSr!)rr8r-s r'rOzTypedStorage.element_sizeIs#%!!##r)cTtjj|jSr!)rHr7r8rBr-s r'r8zTypedStorage._element_sizeNs||))$**55r)cJt|jjSr!)rrrRr-s r'rRzTypedStorage.get_deviceQs#%$$//11r)c Jtdtjdjdjdt d }jj dk(rd|zSdd jfd tjDz}|d z|zS) Nrz(dtype=z , device=rrrrrrc3:K|]}t|ywr!rrs r'rz'TypedStorage.__str__..^s'QDG 'Qrr) rrHrrBrrrCrrr@rs` r'__str__zTypedStorage.__str__Us#%t$%WTZZL9kk]*SYKq :  ;;  v %X% %UZZ'QeDIIK>P'QQQHd?X- -r)c,tt|Sr!)rrr-s r'rzTypedStorage.__repr__as#%4yr)cnttfdtjDS)Nc3(K|] }| ywr!r"rs r'rz(TypedStorage.__iter__..grr)rrrr@r-s`r'rzTypedStorage.__iter__es%#%8U499;%7888r)crt|jtj|jSr!)rrcopyrr-s r'rzTypedStorage.__copy__is(#%((43H3H)IJJr)c8t|j|Sr!)r _deepcopyr$rs r'rzTypedStorage.__deepcopy__ms#%~~d##r)c`|jtj|j|Sr!)rrdeepcopyrrs r'rzTypedStorage._deepcopyrs$((t7L7Ld)STTr)cVtt| |jzSr!)rrrr>rs r'rzTypedStorage.__sizeof__us"#%w!#dkkm33r)cht|j|jjS)r)rrrrr-s r'rzTypedStorage.cloneys(#%(()>)>)D)D)FGGr)c,tt|Sr)rrr-s r'rzTypedStorage.tolist~s#%Dzr)cht|j|jjS)r)rrrrr-s r'rzTypedStorage.cpus(#%(()>)>)B)B)DEEr)cLt|jj|S)a2Determine whether the CPU TypedStorage is already pinned on device. Args: device (str or torch.device): The device to pin memory on (default: ``'cuda'``). This argument is discouraged and subject to deprecated. Returns: A boolean variable. )rrr r!s r'r zTypedStorage.is_pinneds! $%$$..v66r)clt|j|jj|S)a8Copy the CPU TypedStorage to pinned memory, if it's not already pinned. Args: device (str or torch.device): The device to pin memory on (default: ``'cuda'``). This argument is discouraged and subject to deprecated. Returns: A pinned CPU storage. ri)rrrr#r!s r'r#zTypedStorage.pin_memorys4 $%((  ! ! , ,F , ;  r)c6t|jS)r')r_share_memory_r-s r'r.zTypedStorage.share_memory_s#%""$$r)c:|jj|Sr!)rr.r-s r'rzTypedStorage._share_memory_s ++- r)ric|d}tj|}tjj||j z|}t ||j dS)r0rriTr)rHrrr1r8rrB)r$r@rr$s r'r1zTypedStorage._new_sharedsb >Ff%..:: 4%%' '; ( d  r)c.|jjSr!)rrr-s r'rzTypedStorage._cdatas$$+++r)cBt|jjSr!)rrrr-s r'rzTypedStorage.devices#%$$+++r)c6t|jSr!rr-s r'r@zTypedStorage.sizerr)cX|jj|jzSr!)rr>r8r-s r'rzTypedStorage._sizes'$$++-1C1C1EEEr)c6t|jSr!)r_pickle_storage_typer-s r'pickle_storage_typez TypedStorage.pickle_storage_types#%((**r)c t|jS#t$r}td|jd|d}~wwxYw)Nzdtype z is not recognized)rrBKeyError)r$es r'r%z!TypedStorage._pickle_storage_typesG K-/ ; ; KVDJJ%vFF{{e#"I&++W5:4H4H4T4T5"5&,5O  CIN"N!"N JJE#22>>"&,OQUVVr)czt|tjstdt |tj g|j|j j|j|j}|j|jk(r|j}|Sr) rrHrBrrCrrrrIrrTrrs r'r zTypedStorage._tos%-He VW W LL4::dkk B T$Z RY ^       0mmoGr)cTt|jtjSr)rr rHrr-s r'rzTypedStorage.double*#%xx %%r)cTt|jtjSr)rr rHrr-s r'rzTypedStorage.float/#%xx $$r)cTt|jtjSr)rr rHrr-s r'rzTypedStorage.half4#%xx ##r)cTt|jtjSr)rr rHrr-s r'rzTypedStorage.long9r>r)cTt|jtjSr)rr rHrr-s r'rzTypedStorage.int>s#%xx ""r)cTt|jtjSr)rr rHrr-s r'rzTypedStorage.shortCr<r)cTt|jtjSr)rr rHrr-s r'rzTypedStorage.charHr>r)cTt|jtjSr)rr rHrr-s r'rzTypedStorage.byteMr<r)cTt|jtjSr)rr rHrr-s r'rzTypedStorage.boolRr>r)cTt|jtjSr)rr rHr r-s r'r zTypedStorage.bfloat16Ws#%xx''r)cTt|jtjSr )rr rHr r-s r'r zTypedStorage.complex_double\s#%xx &&r)cTt|jtjSr)rr rHrr-s r'rzTypedStorage.complex_floatar:r)cTt|jtjSr)rr rHrr-s r'rzTypedStorage.float8_e5m2fs#%xx))**r)cTt|jtjSr)rr rHrr-s r'rzTypedStorage.float8_e4m3fnks#%xx++,,r)cTt|jtjSr)rr rHrr-s r'rzTypedStorage.float8_e5m2fnuzp#%xx--..r)cTt|jtjSr)rr rHrr-s r'rzTypedStorage.float8_e4m3fnuzurKr)ct|tk(r tdtj |||t j j|jz}||}|S)afrom_file(filename, shared=False, size=0) -> Storage Creates a CPU storage backed by a memory-mapped file. If ``shared`` is ``True``, then memory is shared between all processes. All changes are written to the file. If ``shared`` is ``False``, then the changes on the storage do not affect the file. ``size`` is the number of elements in the storage. If ``shared`` is ``False``, then the file must contain at least ``size * sizeof(Type)`` bytes (``Type`` is the type of storage). If ``shared`` is ``True`` the file will be created if needed. Args: filename (str): file name to map shared (bool): whether to share memory (whether ``MAP_SHARED`` or ``MAP_PRIVATE`` is passed to the underlying `mmap(2) call `_) size (int): number of elements in the storage z/from_file can only be called on derived classesr) rrrrrrHr7r8rB)r]rrr@r$rs r'rzTypedStorage.from_filezs^( $% , PQ Q(22 fdU\\%?%? %JJ ?3r)c,tj|i|Sr!)rrrcs r'rzTypedStorage._expireds&&777r)c:|jj|i|Sr!)rrtr#s r'rtzTypedStorage._write_files 0t$$00$A&AAr)c:|jj|i|Sr!)rr{r#s r'r{zTypedStorage._set_from_file 3t$$33TDVDDr)c:|jj|i|Sr!)rr}r#s r'r}zTypedStorage._set_cdatas /t$$//@@@r)c:|jj|i|Sr!)rrr#s r'rzTypedStorage._share_cuda_s 1t$$114B6BBr)c6t|jSr!)r _is_sharedr-s r'rzTypedStorage.is_shareds#%  r)c6|jjSr!)rrr-s r'rUzTypedStorage._is_shareds$$..00r)c@tjj|i|Sr!)rHrrrcs r'rzTypedStorage._new_shared_cudas##44dEfEEr)cn|jj|i|\}}}||||jzfSr!)rrXr8)r$r%r&manager_handlestorage_handler@s r'rXz!TypedStorage._share_filename_cpu_sH 7D ! ! 6 6 G G    ~tt7I7I7K/KKKr)c:|jj|Sr!)rrrr-s r'rrzTypedStorage._shared_decrefs ,,. r)c@tjj|i|Sr!rHrrkrls r'rmz!TypedStorage._release_ipc_counter##==tNvNNr)c:|jj|i|Sr!)rrr#s r'rzTypedStorage._shared_increfrQr)cj|jj|i|\}}|||jzfSr!)rrZr8)r$r%r&fdr@s r'rZzTypedStorage._share_fd_cpu_s<74((77HHD44--////r)c|jtvryt|j}|jjdddtj j fvry|jjdk(rtn#tt|jj} t||S#t$rYywxYw)NrrErM) rBrrrCrHr,r-getattrAttributeError)r$ storage_namers r'rz&TypedStorage._get_legacy_storage_classs ::79 913DJJ? ;;      HH 2 2 4 $  [[%%.EGE4;;CSCS4T  6<0 0  s, B88 CCrBrA)Fr!)r8rr9z_Optional[bool]r?)rBr@r9rr>z&Union[_StorageBase, TypedStorage, str])rrr9rr>r r=rCrD)arErFrGrrHrrJrrrrr(rrr3rr.rr5rr3rr:r>rrCrErMrIrOr8rRr rrrrrrrrrr r#r.rr1rrr@rr&r%rrTr,rVrwr0rIrryrdr5r rrrrrrrrrr r rrrrrrrrtr{r}rrrUrrXrrrmrrZrrKrLs@r'rrs Iu,0L)0  ..  Z~ YVv;;::% <*4)! F"*2X . !%"CCC 0 C" 7 6BG5"$ 62 .9K$ U4H  F 7  % +/  ,,,, F + K 3  01 C>>@11'+DWW> & % $ $ # % $ % $ ( ' & + - / / 888BEAC! 1FFL04OOE0r)ceZdZUded<dZy)_LegacyStorageMetarrBct|tk(rIt|j}||jjk(xr|j |j k(Syr?)rCrrrFrrB)r]instancers r'__instancecheck__z$_LegacyStorageMeta.__instancecheck__sM >\ )0@J(//"6"66 X^^+ r)N)rErFrGrHrjr"r)r'rgrgs r)rgc<eZdZedZedZedZy)rc~tjj||jz}||S)r0r)rHrr1r8)r]r@r$s r'r1z_LegacyStorage._new_shareds5 ..::4#%BUBUBW;WX00r)c@tjj|i|Sr!r]rcs r'rmz#_LegacyStorage._release_ipc_counterr^r)c|tjj|jz}|tjj |||S)Nr)rHr7r8rBrrh)r]rfrgr@ bytes_sizes r'_new_shared_filenamez#_LegacyStorage._new_shared_filenamesGELL66syyAA --FFj  r)N)rErFrGrIr1rmrpr"r)r'rrs>11 OO  r)r) metaclassc` t|S#t$r}td|d|d}~wwxYw)Nzpickle storage type "z" is not recognized)rr()r&r)s r'#_get_dtype_from_pickle_storage_typers sE)+,?@@ #$7#88K L  s  -(-)r5)rr)r&r)A __future__rrrrYrrPrtypingrrr _Optionalrrr typing_extensionsr rH torch._utilsr r torch.typesr rrtorch._prims_commonr__all__numpyrrModuleNotFoundErrorLockrOrrHrrr[r, StorageBaserrcacherxrrrrrrrrrrr__doc__rCrErMrIrgrrsr"r)r'rs#  RR" #,,2 + ,I $Y^^%02-2 C:;B"B"J !H@=UXX))<@=F9 , 6  82"&+".5 B(?@ @ F"MM (--55 '++33 ++    \-? *W/I BsF'' F43F4