/usr/local/lib64/python3.6/site-packages/torch/__pycache__
NameSizeModeActions
autocast_mode.cpython-36.pyc90400644editdlrm
functional.cpython-36.pyc599640644editdlrm
hub.cpython-36.pyc191710644editdlrm
overrides.cpython-36.pyc1243060644editdlrm
quasirandom.cpython-36.pyc67390644editdlrm
random.cpython-36.pyc42710644editdlrm
serialization.cpython-36.pyc285820644editdlrm
storage.cpython-36.pyc83340644editdlrm
torch_version.cpython-36.pyc29650644editdlrm
types.cpython-36.pyc17350644editdlrm
version.cpython-36.pyc2720644editdlrm
_appdirs.cpython-36.pyc220230644editdlrm
_classes.cpython-36.pyc24730644editdlrm
_deploy.cpython-36.pyc22620644editdlrm
_jit_internal.cpython-36.pyc337230644editdlrm
_linalg_utils.cpython-36.pyc28830644editdlrm
_lobpcg.cpython-36.pyc302630644editdlrm
_lowrank.cpython-36.pyc94730644editdlrm
_namedtensor_internals.cpython-36.pyc48560644editdlrm
_ops.cpython-36.pyc41770644editdlrm
_python_dispatcher.cpython-36.pyc34110644editdlrm
_six.cpython-36.pyc10930644editdlrm
_sources.cpython-36.pyc40430644editdlrm
_storage_docs.cpython-36.pyc14360644editdlrm
_tensor.cpython-36.pyc372740644editdlrm
_tensor_docs.cpython-36.pyc1027930644editdlrm
_tensor_str.cpython-36.pyc115320644editdlrm
_torch_docs.cpython-36.pyc3646960644editdlrm
_utils.cpython-36.pyc168940644editdlrm
_utils_internal.cpython-36.pyc13220644editdlrm
_VF.cpython-36.pyc11120644editdlrm
_vmap_internals.cpython-36.pyc112100644editdlrm
__config__.cpython-36.pyc7330644editdlrm
__future__.cpython-36.pyc9840644editdlrm
__init__.cpython-36.pyc244180644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/torch/__pycache__/serialization.cpython-36.pyc (28582B)
3 Eg@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z m Z ddl mZddlmZddlmZddlmZddlmZmZmZmZmZmZmZmZmZddl Z ddl!Z!ddl"Z"d Z#ej$d j%Z&ej$d j%Z'ej$d j%Z(d Z)dZ*dZ+Gddde,Z-e ddZ.gZ/e0dddZ1ddZ2dfddZ3ddZ4ddZ5d d!Z6d"d#Z7d$d%Z8e2d&e4e6e2d'e5e8ed(d)d*Z9d+d,Z:d-d.Z;d/d0ZZ?Gd5d6d6e?Z@Gd7d8d8e?ZAGd9d:d:e?ZBd;d<ZCGd=d>d>e?ZDGd?d@d@e?ZEGdAdBdBe?ZFdCdDZGe0ddEdFZHdGdHZIe0ddIdJZJdddKdLZKe!e#dfeeLejMeeeNfddMdNdOZOdddPdQZPdRdSZQde!fdTdUZRdVdWZSieS_Te j!ejUdXdYdZd[ZVeeNeLfeLd\d]d^ZWd_d`ZXdgdbdcZYdddeZZdS)hN)closingcontextmanager)_import_dotted_name)string_classes)get_source_lines_and_file)Storage) AnyBinaryIOcastDictOptionalTypeTupleUnionIOz=lz=iz=hll|9 QC i,c@s eZdZdS)SourceChangeWarningN)__name__ __module__ __qualname__rr?/usr/local/lib64/python3.6/site-packages/torch/serialization.pyrsrccstj}|Vtj|dS)N)tempfilemkdtempshutilrmtree)pathrrrr#sr)returncCsdg}|j}|jd}x.|dkrD|j|t|dkr8P|jd}qW|j|ddddg}||kS)NrPK)tellreadappendlenseek)f read_bytesstartbyteZlocal_header_magic_numberrrr _is_zipfile-s       r/cCs |||f}tj|tjdS)N)_package_registryr(sort)prioritytaggerZ deserializerZ queue_elemrrrregister_packageEs  r4Tcsy2|jjdtfddt|D}||k}WnZtk r}z>d|j|jt|f}|rjt||ntj |dd}WYdd}~XnX|S)a Check if a module's version satisfies requirements Usually, a module's version string will be like 'x.y.z', which would be represented as a tuple (x, y, z), but sometimes it could be an unexpected format. If the version string does not match the given tuple's format up to the length of the tuple, then error and exit or emit a warning. Args: module: the module to check the version of req_version_tuple: tuple (usually of ints) representing the required version error_if_malformed: whether we should exit if module version string is malformed Returns: requirement_is_met: bool .c3s"|]\}}t||VqdS)N)type).0idxZ req_field) version_strsrr `sz8check_module_version_greater_or_equal..zQ'%s' module version string is malformed '%s' and cannot be compared with tuple %sz1, but continuing assuming that requirement is metTN) __version__splittuple enumerate Exceptionrstr RuntimeErrorwarningswarn)moduleZreq_version_tupleZerror_if_malformedZmodule_versionZrequirement_is_metemessager)r9r%check_module_version_greater_or_equalKs   rGcCst|jdkrdSdS)Ntorchcpu)r6r)objrrr_cpu_tagtsrKcCs"t|jdkrdt|jSdS)Nz torch.cudazcuda:)r6rr@Z get_device)rJrrr _cuda_tagysrLcCs|dkr |SdS)NrIr)rJlocationrrr_cpu_deserialize~srNcCsNtjjj|d}tjjs"tdtjj}||krJtd|d|d|S)NTzAttempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU.z0Attempting to deserialize object on CUDA device z" but torch.cuda.device_count() is zU. Please use torch.load with map_location to map your storages to an existing device.)rHcuda_utilsZ_get_device_indexZ is_availablerA device_count)rMdevicerQrrrvalidate_cuda_devices  rSc Cs`|jdr\t|}t|ddrRttjt|j}tjj|||jSQRXn |j|SdS)NrO_torch_load_uninitializedF) startswithrSgetattrrHrOr6rrRsize)rJrMrR storage_typerrr_cuda_deserializes  rY )storagecCs:x"tD]\}}}||}|r|SqWtdtj|dS)Nz-don't know how to determine data location of )r0rArHtypename)r\_r3rMrrr location_tags r_cCsLx(tD] \}}}|||}|dk r|SqWtdtj|d|ddS)Nz+don't know how to restore data location of z (tagged with ))r0rArHr])r\rMr^fnresultrrrdefault_restore_locations  rccCs tt|jS)N)rVrHr)rXrrrnormalize_storage_typesrdcCs&t|}t|j}t||jjddS)NrZTensor)r6rrrVrreplace)r\rXrDrrrstorage_to_tensor_types rfcCst|tpt|tjS)N) isinstancer@pathlibPath)name_or_bufferrrr_is_paths rkc@s$eZdZddZddZddZdS)_openercCs ||_dS)N) file_like)selfrmrrr__init__sz_opener.__init__cCs|jS)N)rm)rnrrr __enter__sz_opener.__enter__cGsdS)Nr)rnargsrrr__exit__sz_opener.__exit__N)rrrrorprrrrrrrlsrlcs$eZdZfddZddZZS) _open_filecstt|jt||dS)N)superrsroopen)rnnamemode) __class__rrrosz_open_file.__init__cGs|jjdS)N)rmclose)rnrqrrrrrsz_open_file.__exit__)rrrrorr __classcell__rr)rxrrss rscseZdZfddZZS)_open_buffer_readercstt|j|t|dS)N)rtr{ro_check_seekable)rnbuffer)rxrrrosz_open_buffer_reader.__init__)rrrrorzrr)rxrr{sr{c@seZdZddZdS)_open_buffer_writercGs|jjdS)N)rmflush)rnrqrrrrrsz_open_buffer_writer.__exit__N)rrrrrrrrrr~sr~cCsDt|rt||Sd|kr"t|Sd|kr2t|Std|dS)Nwrz$Expected 'r' or 'w' in mode but got )rkrsr~r{rA)rjrwrrr_open_file_likes rcs"eZdZddfdd ZZS)_open_zipfile_readerN)rcstt|jtjj|dS)N)rtrrorH_CZPyTorchFileReader)rnrj)rxrrrosz_open_zipfile_reader.__init__)rrrrorzrr)rxrrsrcs0eZdZddfdd ZddddZZS)_open_zipfile_writer_fileN)rcs tt|jtjjt|dS)N)rtrrorHrPyTorchFileWriterr@)rnrv)rxrrrosz"_open_zipfile_writer_file.__init__cGs|jjdS)N)rmwrite_end_of_file)rnrqrrrrrsz"_open_zipfile_writer_file.__exit__)rrrrorrrzrr)rxrrsrcs0eZdZddfdd ZddddZZS)_open_zipfile_writer_bufferN)rcs"||_tt|jtjj|dS)N)r}rtrrorHrr)rnr})rxrrrosz$_open_zipfile_writer_buffer.__init__cGs|jj|jjdS)N)rmrr}r)rnrqrrrrrs z$_open_zipfile_writer_buffer.__exit__)rrrrorrrzrr)rxrrsrcCst|rt}nt}||S)N)rkrr)rj containerrrr_open_zipfile_writersrc Cs*dg}y |j|kStk r$dSXdS)NgzipF)rAttributeError)r+Zcompress_modulesrrr_is_compressed_files  rc CsFt|r dSy |jdkStjk r.dStk r@dSXdS)z Checks if f is a file that should be read directly. It should be read directly if it is backed by a real file (has a fileno) and is not a a compressed file (e.g. gzip) FrN)rfilenoioUnsupportedOperationr)r+rrr_should_read_directlys rcCsVdd}y|j|jdStjtfk rP}z|ddg|WYdd}~XnXdS)NcSsBx8|D]0}|t|krt|ddd}t||qW|dS)Nz7. You can only torch.load from a file that is seekable.z; Please pre-load the data into a buffer like io.BytesIO andz try to load from it instead.)r@r6)patternsrEpmsgrrr raise_err_msg*s   z&_check_seekable..raise_err_msgTr*r&F)r*r&rrr)r+rrErrrr|(s  r|cCs@|jdkr= %s, but you have dill %s. Please upgrade dill or switch to 'pickle'r5cSsg|] }t|qSr)r@)r7numrrr Isz'_check_dill_version..N)rrr)rrG ValueErrorjoinr;) pickle_moduleZrequired_dill_versionrrr_check_dill_version:s  r)r+rcCsVt|t|d:}|r:t|}t||||dSQRXt||||WdQRXdS)asave(obj, f, pickle_module=pickle, pickle_protocol=DEFAULT_PROTOCOL, _use_new_zipfile_serialization=True) Saves an object to a disk file. See also: :ref:`saving-loading-tensors` Args: obj: saved object f: a file-like object (has to implement write and flush) or a string or os.PathLike object containing a file name pickle_module: module used for pickling metadata and objects pickle_protocol: can be specified to override the default protocol .. note:: A common PyTorch convention is to save tensors using .pt file extension. .. note:: PyTorch preserves storage sharing across serialization. See :ref:`preserve-storage-sharing` for more details. .. note:: The 1.6 release of PyTorch switched ``torch.save`` to use a new zipfile-based file format. ``torch.load`` still retains the ability to load files in the old format. If for any reason you want ``torch.save`` to use the old format, pass the kwarg ``_use_new_zipfile_serialization=False``. Example: >>> # Save to file >>> x = torch.tensor([0, 1, 2, 3, 4]) >>> torch.save(x, 'tensor.pt') >>> # Save to io.BytesIO buffer >>> buffer = io.BytesIO() >>> torch.save(x, buffer) wbN)rrr_save _legacy_save)rJr+rpickle_protocolZ_use_new_zipfile_serialization opened_fileopened_zipfilerrrsaveMs)   rc sddljiitttdfdd }tttjdktt t t dd}|j t ||d|j t||d|j |||d|j||d}||_|j |tj}|j |||d|jx"|D]}|j|t|d qWdS) Nr)rJrc st|trt|jr|kr"dSd|<d}}yt|\}}}dj|}Wn(tk rvtjd|j dYnXd|||fSt j |rt t |}tt|}d}t|j}t|}||<|j|jk} | rt|j||jf} nd} d||||j| fSdS)NTr z4Couldn't retrieve source code for container of type z3. It won't be checked for correctness upon loading.rDrr\)rgr6 issubclassModulerrr?rBrCrrH is_storager rrdr@_cdatar_rW) rJ source_filesourceZ source_linesr^rXoffsetobj_keyrMZis_view view_metadata)nnserialized_container_typesserialized_storagesrr persistent_ids<      z#_legacy_save..persistent_idlittle)shortintlong)protocol_versionZ little_endianZ type_sizes)protocolT)Ztorch.nnrr r rdictPROTOCOL_VERSIONsys byteorder SHORT_SIZEINT_SIZE LONG_SIZEdump MAGIC_NUMBERPicklerrsortedkeysrZ _write_filer) rJr+rrrZsys_infopicklerZserialized_storage_keyskeyr)rrrrrs, ,    rc siifdd}tj}|j||d}||_|j||j}|jd|t|x\tj D]L}d|} |} | j j dkr| j } | j | j} |j| | j| qdWdS)NcsRtj|rNtt|}j|jtt}t|}||<d||||j fSdS)Nr\) rHrrdr6 setdefaultrr@r)r_rW)rJrXrrM)id_maprrrrs   z_save..persistent_id)rzdata.pklzdata/rI)rBytesIOrrrgetvalueZ write_recordr)rrrRr6rIrWZ element_sizeZdata_ptr) rJzip_filerrrZdata_bufrZ data_valuerrvr\ num_bytesr)rrrrs    rcKst|d|jkrd|d<t|dl}t|r|j}t|<}t|rltjdt |j |t j j |St|||f|SQRXt|||f|SQRXdS)a}load(f, map_location=None, pickle_module=pickle, **pickle_load_args) Loads an object saved with :func:`torch.save` from a file. :func:`torch.load` uses Python's unpickling facilities but treats storages, which underlie tensors, specially. They are first deserialized on the CPU and are then moved to the device they were saved from. If this fails (e.g. because the run time system doesn't have certain devices), an exception is raised. However, storages can be dynamically remapped to an alternative set of devices using the :attr:`map_location` argument. If :attr:`map_location` is a callable, it will be called once for each serialized storage with two arguments: storage and location. The storage argument will be the initial deserialization of the storage, residing on the CPU. Each serialized storage has a location tag associated with it which identifies the device it was saved from, and this tag is the second argument passed to :attr:`map_location`. The builtin location tags are ``'cpu'`` for CPU tensors and ``'cuda:device_id'`` (e.g. ``'cuda:2'``) for CUDA tensors. :attr:`map_location` should return either ``None`` or a storage. If :attr:`map_location` returns a storage, it will be used as the final deserialized object, already moved to the right device. Otherwise, :func:`torch.load` will fall back to the default behavior, as if :attr:`map_location` wasn't specified. If :attr:`map_location` is a :class:`torch.device` object or a string containing a device tag, it indicates the location where all tensors should be loaded. Otherwise, if :attr:`map_location` is a dict, it will be used to remap location tags appearing in the file (keys), to ones that specify where to put the storages (values). User extensions can register their own location tags and tagging and deserialization methods using :func:`torch.serialization.register_package`. Args: f: a file-like object (has to implement :meth:`read`, :meth:`readline`, :meth:`tell`, and :meth:`seek`), or a string or os.PathLike object containing a file name map_location: a function, :class:`torch.device`, string or a dict specifying how to remap storage locations pickle_module: module used for unpickling metadata and objects (has to match the :attr:`pickle_module` used to serialize file) pickle_load_args: (Python 3 only) optional keyword arguments passed over to :func:`pickle_module.load` and :func:`pickle_module.Unpickler`, e.g., :attr:`errors=...`. .. warning:: :func:`torch.load()` uses ``pickle`` module implicitly, which is known to be insecure. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling. Never load data that could have come from an untrusted source, or that could have been tampered with. **Only load data you trust**. .. note:: When you call :func:`torch.load()` on a file which contains GPU tensors, those tensors will be loaded to GPU by default. You can call ``torch.load(.., map_location='cpu')`` and then :meth:`load_state_dict` to avoid GPU RAM surge when loading a model checkpoint. .. note:: By default, we decode byte strings as ``utf-8``. This is to avoid a common error case ``UnicodeDecodeError: 'ascii' codec can't decode byte 0x...`` when loading files saved by Python 2 in Python 3. If this default is incorrect, you may use an extra :attr:`encoding` keyword argument to specify how these objects should be loaded, e.g., :attr:`encoding='latin1'` decodes them to strings using ``latin1`` encoding, and :attr:`encoding='bytes'` keeps them as byte arrays which can be decoded later with ``byte_array.decode(...)``. Example: >>> torch.load('tensors.pt') # Load all tensors onto the CPU >>> torch.load('tensors.pt', map_location=torch.device('cpu')) # Load all tensors onto the CPU, using a function >>> torch.load('tensors.pt', map_location=lambda storage, loc: storage) # Load all tensors onto GPU 1 >>> torch.load('tensors.pt', map_location=lambda storage, loc: storage.cuda(1)) # Map tensors from GPU 1 to GPU 0 >>> torch.load('tensors.pt', map_location={'cuda:1':'cuda:0'}) # Load tensor from io.BytesIO object >>> with open('tensor.pt', 'rb') as f: ... buffer = io.BytesIO(f.read()) >>> torch.load(buffer) # Load a module with 'ascii' encoding for unpickling >>> torch.load('module.pt', encoding='ascii') encodingzutf-8rbz'torch.load' received a zip file that looks like a TorchScript archive dispatching to 'torch.jit.load' (call 'torch.jit.load' directly to silence this warning)N)rrrr/r&r_is_torchscript_ziprBrC UserWarningr*rHZjitload_load _legacy_load)r+ map_locationrpickle_load_argsrZ orig_positionrrrrrsW     rcCs>tj}|s6x*tjjD]}t|tjr||t|<qW||S)z@Get layout extension object from its string representation. ) _get_layoutcacherH__dict__valuesrglayoutr@)rvrvrrrres  rcCstt|ffS)N)rr@)rJrrrqsrc sit|ddfdd}ifdd}t|t|}|r|jdkry||Stjk rt|rt|jdd|j dYnXt |d  rdt j kodknrtd t |dj|f}|tkrtdj|f}|tkrtd|j|f} j|f} || _| j} j|f} |rb|jnd} x@| D]8}|ks~t|j|| || dk rl|j} qlWtjj| S)Nc SsJydjt|d}Wn(tk r>tjd|jddSX||krF|jr |jd}tj|j d|j d||dd}dj|}ytt |dL}|j dd }|j d|dkr|j |n|t |ks|j|krtWdQRXd |d |d } Wn"tk rd |d} YnXnd} dtj|d| } tj| tdS)Nr rz4Couldn't retrieve source code for container of type z3. It won't be checked for correctness upon loading.z.patch )Zlinetermza+rzSaved a reverse patch to z. Run `patch -p0 < z` to revert your changes.z;Tried to save a patch, but couldn't create a writable file zD. Make sure it doesn't exist and your working directory is writable.zyou can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.zsource code of class 'z' has changed. )rrr?rBrCrZ dump_patchesdifflibZ unified_diffr<rur*writer)r'IOErrorrHr]r) Zcontainer_typerZoriginal_sourceZcurrent_source file_nameZdifflinesr+ file_sizerrrr_check_container_sourceys8         z-_legacy_load.._check_container_sourcec"s:ifdd}ttj|dtjd}t}|jd|dttjj|ddd}j |f}xDt |D]8}j |f}|\}}} | j |} | |} | |<qtWj |f} x0| D](\} } }}| }||||| <qWWdQRX|jd |dttjj|d dd}j |f}xt |D]}j |f}|\}}}|}t |}t jd |jd \}|jd t jd |d |jd|}t jd |d |jd|}t jd|jd\}|j||||}||<q8WWdQRX|jd}j|f}||_|j }|SQRXWdQRXdS)Ncs6t|tr*t|ddr"||dSt|S)Nrr)rgr=allr)saved_id)rdeserialized_objectsrrpersistent_loads  z:_legacy_load..legacy_load..persistent_loadzr:)fileobjrwformatZstorages)rrrZtensorsz.legacy_loadc st|tstt|d}|dd}|dkrNt|ddrF||dS|dkr|\}}}}}t|}|kr||}d|_|||<|} |dk r|\} } } | kr| | | | | <| S| Sntd|ddS)NrrrDr\TzUnknown saved id type: %s)rgr=AssertionError_maybe_decode_asciirrTrA) rr]data data_typeZroot_keyrMrWrrJr\Zview_keyrZ view_size)rrrrrrs,   z%_legacy_load..persistent_loadrz9 is a zip archive (did you mean to use torch.jit.load()?)readintorrrztorch.load does not work with file-like objects that do not implement readinto on Python 3.8.0 and 3.8.1. Received object of type "zH". Please update to Python 3.8.2 or newer to restore this functionality.z#Invalid magic number; corrupt file?zInvalid protocol version: %s)rrr)rrr)_get_restore_locationr|rr&rTarErrorr/rArvr*hasattrr version_infor6rrrrrrZ_set_from_filerHrP_validate_loaded_sparse_tensors)r+rrrrrZf_should_read_directlyZ magic_numberrZ _sys_inforrbZdeserialized_storage_keysrrr)rrrrrrrtsL(4&      r) bytes_strrcCst|tr|jdS|S)Nascii)rgbytesdecode)r rrrr#s  rcshdkrt}nVttr&fdd}n>ttr>fdd}n&ttjrXfdd}n fdd}|S)Ncsj||}t||S)N)getrc)r\rM)rrrr3s z/_get_restore_location..restore_locationcs t|S)N)rc)r\rM)rrrr7scst|tS)N)rcr@)r\rM)rrrr:scs ||}|dkrt||}|S)N)rc)r\rMrb)rrrr=s  )rcrgr_string_classesrHrR)rrr)rrr/s    rdata.pklc  st|ifddfdd}ddiGfddd|j}tjj|}||f|}||_|j} tjj | S) Ncs8d|}|dj}j|||j}|||<dS)Nzdata/r)dtypeZget_storage_from_recordr\)rrWrrMrvrr\)loaded_storagesrrrr load_tensorIs  z_load..load_tensorcspt|tstt|d}|dd}|dks>td|d|\}}}}|krd|||t||}|S)Nrrr\zBUnknown typename for persistent_load, expected 'storage' but got '')rgr=rr)rr]rrrrMrWr\)rrrrrPs    z_load..persistent_loadz torch.tensorz torch._tensorcseZdZfddZZS)z_load..UnpicklerWrappercsj||}tj||S)N)r rt find_class)rnmod_namerv)rxload_module_mappingrrris z*_load..UnpicklerWrapper.find_class)rrrrrzr)r)rxrUnpicklerWrapperesr) rrrrZ get_recordrrrHrPr) rrrrrrrZ data_filerrbr)rrrrrrrDs   rcCs d|jkS)Nz constants.pkl)Zget_all_records)rrrrrysr)T)r)[rrrrrrrHrrrB contextlibrrrPrZ_sixrrZtorch._sourcesrZ torch.typesrtypingr r r r r rrrrcopyregrrhDEFAULT_PROTOCOLStructrWrrrrrZSTORAGE_KEY_SEPARATORWarningrrr0boolr/r4rGrKrLrNrSrYr_rcrdrfrkobjectrlrsr{r~rrrrrrrr|rr@PathLiker rrrrrrrrrrrrrrrrs    ,     )        *2I-o 0  5