/usr/local/lib64/python3.6/site-packages/torch/nn/utils/__pycache__
Edit: /usr/local/lib64/python3.6/site-packages/torch/nn/utils/__pycache__/rnn.cpython-36.pyc (15934B)
3
EgBD @ s d dl mZ d dlZd dlZd dlmZ ddlmZ ddlmZ d dl m
Z
mZ edd d
ddgZejejeej eej d
e_
dd ZG dd deZd#ddZd$ddZdd Zd%ddZd&ddZd'dd Zd(d!d"ZdS )) )
namedtupleN)Tensor )_VF)Optional)ListTuplePackedSequence_databatch_sizessorted_indicesunsorted_indices)r
r r r
c C s | d krd S || S )N )optionalfnr r >/usr/local/lib64/python3.6/site-packages/torch/nn/utils/rnn.pybind s r c s e Zd ZdZd! fdd Zdd Zdd Zd d
Zdd Zd
d Z dd Z
dd Zdd Zdd Z
dd Zdd Zdd Zedd Zdd Z ZS )"PackedSequenceaq Holds the data and list of :attr:`batch_sizes` of a packed sequence.
All RNN modules accept packed sequences as inputs.
Note:
Instances of this class should never be created manually. They are meant
to be instantiated by functions like :func:`pack_padded_sequence`.
Batch sizes represent the number elements at each sequence step in
the batch, not the varying sequence lengths passed to
:func:`pack_padded_sequence`. For instance, given data ``abc`` and ``x``
the :class:`PackedSequence` would contain data ``axbc`` with
``batch_sizes=[2,1,1]``.
Attributes:
data (Tensor): Tensor containing packed sequence
batch_sizes (Tensor): Tensor of integers holding
information about the batch size at each sequence step
sorted_indices (Tensor, optional): Tensor of integers holding how this
:class:`PackedSequence` is constructed from sequences.
unsorted_indices (Tensor, optional): Tensor of integers holding how this
to recover the original sequences with correct order.
.. note::
:attr:`data` can be on arbitrary device and of arbitrary dtype.
:attr:`sorted_indices` and :attr:`unsorted_indices` must be ``torch.int64``
tensors on the same device as :attr:`data`.
However, :attr:`batch_sizes` should always be a CPU ``torch.int64`` tensor.
This invariant is maintained throughout :class:`PackedSequence` class,
and all functions that construct a `:class:PackedSequence` in PyTorch
(i.e., they only pass in tensors conforming to this constraint).
Nc s t t| j| ft|||| S )N)superr __new___packed_sequence_init_args)clsr
r r r
) __class__r r r ? s
zPackedSequence.__new__c C s2 t | | jj | jt| jdd t| jdd S )Nc S s | j S )N)
pin_memory)tr r r
M s z+PackedSequence.pin_memory..c S s | j S )N)r )r r r r r N s )typer
r r r r r
)selfr r r r I s zPackedSequence.pin_memoryc O sF t jf | jj| jjdj||}|jr2| j||S | j|ddi|S )N)dtypedevicer cuda)torchtensorr
r r tois_cuda)r argskwargsexr r r r P s zPackedSequence.cudac O sL t jf | jj| jjdj||}|jjdkr8| j||S | j|ddi|S )N)r r cpur )r! r" r
r r r# r )r r% r&