@Namespace(value="torch::nn::utils::rnn") @NoOffset @Properties(inherit=torch.class) public class PackedSequence extends Pointer
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 pack_padded_sequence
.
Batch sizes represent the number elements at each sequence step in
the batch, not the varying sequence lengths passed to
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::
data
can be on arbitrary device and of arbitrary dtype.
sorted_indices
and unsorted_indices
must be torch::kInt64
tensors on the same device as data
.
However, batch_sizes
should always be a CPU torch::kInt64 tensor.
This invariant is maintained throughout PackedSequence
class,
and all functions that construct a PackedSequence
in libtorch
(i.e., they only pass in tensors conforming to this constraint).Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.NativeDeallocator, Pointer.ReferenceCounter
Constructor and Description |
---|
PackedSequence(Pointer p)
Pointer cast constructor.
|
PackedSequence(Tensor data,
Tensor batch_sizes) |
PackedSequence(Tensor data,
Tensor batch_sizes,
Tensor sorted_indices,
Tensor unsorted_indices) |
Modifier and Type | Method and Description |
---|---|
Tensor |
batch_sizes() |
PackedSequence |
cpu() |
PackedSequence |
cuda() |
Tensor |
data() |
boolean |
is_cuda()
Returns true if
data_ stored on a gpu |
boolean |
is_pinned()
Returns true if
data_ stored on in pinned memory |
PackedSequence |
pin_memory() |
Tensor |
sorted_indices() |
PackedSequence |
to(TensorOptions options) |
Tensor |
unsorted_indices() |
address, asBuffer, asByteBuffer, availablePhysicalBytes, calloc, capacity, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, getDirectBufferAddress, getPointer, getPointer, getPointer, getPointer, hashCode, interruptDeallocatorThread, isNull, isNull, limit, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetAddress, offsetof, offsetof, parseBytes, physicalBytes, physicalBytesInaccurate, position, position, put, realloc, referenceCount, releaseReference, retainReference, setNull, sizeof, sizeof, toString, totalBytes, totalCount, totalPhysicalBytes, withDeallocator, zero
public PackedSequence(Pointer p)
Pointer(Pointer)
.public PackedSequence(@ByVal Tensor data, @ByVal Tensor batch_sizes, @ByVal(nullValue="torch::Tensor{}") Tensor sorted_indices, @ByVal(nullValue="torch::Tensor{}") Tensor unsorted_indices)
@ByVal public PackedSequence pin_memory()
@ByVal public PackedSequence to(@ByVal TensorOptions options)
@ByVal public PackedSequence cuda()
@ByVal public PackedSequence cpu()
Copyright © 2024. All rights reserved.