/usr/local/lib64/python3.6/site-packages/torch/nn/__pycache__
Edit: /usr/local/lib64/python3.6/site-packages/torch/nn/__pycache__/cpp.cpython-36.pyc (3460B)
3
ûEgÎ ã @ s6 d Z ddlmZ G dd„ deƒZG dd„ dejƒZdS )z3Functionality for Python <-> C++ frontend inter-op.é )Únnc @ s\ e Zd ZdZdd„ Zedd„ ƒZdd„ Zdd „ Zd
d„ Z dd
„ Z
dd„ Zdd„ Zdd„ Z
dS )ÚOrderedDictWrapperaª
A wrapper around a C++ OrderedDict that dynamically evaluates the
OrderedDict getter on a bound C++ module, such that new changes on the C++
side are picked up. Otherwise accessing e.g. ``cpp_module._parameters`` just
once would get a frozen copy of the parameters at the time of access.
``torch.nn.Module`` accesses ``_parameters`` et al. via ``self.__dict__`` so
using properties does not work.
c C s || _ || _d S )N)Ú
cpp_moduleÚattr)Úselfr r © r ú8/usr/local/lib64/python3.6/site-packages/torch/nn/cpp.pyÚ__init__ s zOrderedDictWrapper.__init__c C s t | j| jƒS )N)Úgetattrr r )r r r r Úcpp_dict s zOrderedDictWrapper.cpp_dictc C s
| j jƒ S )N)r Úitems)r r r r r s zOrderedDictWrapper.itemsc C s
| j jƒ S )N)r Úkeys)r r r r r
s zOrderedDictWrapper.keysc C s
| j jƒ S )N)r Úvalues)r r r r r ! s zOrderedDictWrapper.valuesc C s
| j jƒ S )N)r Ú__iter__)r r r r r $ s zOrderedDictWrapper.__iter__c C s
| j jƒ S )N)r Ú__len__)r r r r r ' s zOrderedDictWrapper.__len__c C s | j j|ƒS )N)r Ú__contains__)r Úkeyr r r r * s zOrderedDictWrapper.__contains__c C s | j j|ƒS )N)r Ú__getitem__)r r r r r r - s zOrderedDictWrapper.__getitem__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r Úpropertyr r r
r r r r r r r r r r s r c sJ e Zd ZdZ‡ fdd„Zdd„ Zedd„ ƒZejdd„ ƒZd d
„ Z ‡ Z
S )Ú
ModuleWrapperzj
A subclass of ``torch.nn.Module`` that wraps a C++ frontend module and
delegates all access.
c sl || _ tt| ƒjƒ t|dƒ| _t|dƒ| _t|dƒ| _x.t|ƒD ]"}|j dƒsBt
| |t| j |ƒƒ qBW d S )NÚ_parametersÚ_buffersÚ_modulesÚ_)r Úsuperr r r r r r ÚdirÚ
startswithÚsetattrr
)r r r )Ú __class__r r r 7 s
zModuleWrapper.__init__c C sZ x6| j ƒ D ]*}||jƒ|_|jd k r
||jjƒ|j_q
W x| jƒ D ]}||jƒ|_qBW | S )N)Ú
parametersÚdataZ_gradÚbuffers)r ÚfnÚparamÚbufr r r Ú_applyD s
zModuleWrapper._applyc C s | j jS )N)r Útraining)r r r r r* R s zModuleWrapper.trainingc C s | j j|ƒ d S )N)r Ztrain)r Úmoder r r r* V s c C s
| j jƒ S )N)r Ú__repr__)r r r r r, Z s zModuleWrapper.__repr__)r r r r r r) r r* Úsetterr, Ú
__classcell__r r )r" r r 1 s
r N)r Ztorchr Úobjectr ÚModuler r r r r Ú
s +