@Namespace(value="c10") @NoOffset @Properties(inherit=torch.class) public class TensorOptions extends Pointer
Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.NativeDeallocator, Pointer.ReferenceCounter
Constructor and Description |
---|
TensorOptions() |
TensorOptions(byte layout) |
TensorOptions(Device device)
Constructs a
TensorOptions object with the given device. |
TensorOptions(long size)
Native array allocator.
|
TensorOptions(Pointer p)
Pointer cast constructor.
|
TensorOptions(torch.Layout layout)
Constructs a
TensorOptions object with the given layout. |
TensorOptions(torch.MemoryFormat memory_format)
Constructs a
TensorOptions object with the given memory format. |
TensorOptions(torch.ScalarType dtype)
legacy constructor to support ScalarType
|
TensorOptions(TypeMeta dtype)
Constructs a
TensorOptions object with the given dtype. |
Modifier and Type | Method and Description |
---|---|
torch.Backend |
backend() |
torch.DispatchKey |
computeDispatchKey() |
byte |
device_index()
Returns the device index of the
TensorOptions . |
TensorOptions |
device_index(byte device_index)
Return a copy of
TensorOptions , but with device set to CUDA, and the
device index set to the given one. |
DeviceOptional |
device_opt()
Returns the device of the
TensorOptions , or std::nullopt if
device is not specified. |
Device |
device()
Returns the device of the
TensorOptions . |
TensorOptions |
device(DeviceOptional device)
Return a copy of
TensorOptions with device set to the given one, or
cleared if device is nullopt . |
TypeMetaOptional |
dtype_opt()
Returns the dtype of the
TensorOptions , or std::nullopt if
device is not specified. |
TypeMeta |
dtype()
Returns the dtype of the
TensorOptions . |
TensorOptions |
dtype(ScalarTypeOptional dtype) |
TensorOptions |
dtype(TypeMetaOptional dtype)
Return a copy of
TensorOptions with dtype set to the given one. |
TensorOptions |
getPointer(long i) |
boolean |
has_device()
Returns whether the device is specified.
|
boolean |
has_dtype()
Returns whether the dtype is specified.
|
boolean |
has_layout()
Returns whether the layout is specified.
|
boolean |
has_memory_format()
Returns whether the
memory_layout is specified |
boolean |
has_pinned_memory()
Returns whether the
pinned_memory is specified. |
boolean |
has_requires_grad()
Returns whether the
requires_grad is specified. |
boolean |
is_sparse_compressed() |
boolean |
is_sparse_csr()
Returns if the layout is sparse CSR, deprecated, use
is_sparse_compressed() instead
|
boolean |
is_sparse()
Returns if the layout is sparse
|
LayoutOptional |
layout_opt()
Returns the layout of the
TensorOptions , or std::nullopt if
layout is not specified. |
torch.Layout |
layout()
Returns the layout of the
TensorOptions . |
TensorOptions |
layout(LayoutOptional layout)
Sets the layout of the
TensorOptions . |
MemoryFormatOptional |
memory_format_opt()
Returns the
memory_layout property of TensorOptions, or
std::nulloptif memory_format{@code is not specified. |
TensorOptions |
memory_format(MemoryFormatOptional memory_format)
Sets the
memory_format property on TensorOptions . |
TensorOptions |
merge_in(TensorOptions options)
Return the right-biased merge of two TensorOptions.
|
TensorOptions |
merge_memory_format(MemoryFormatOptional optional_memory_format) |
BoolOptional |
pinned_memory_opt()
Returns the
pinned_memory property of the TensorOptions , or
std::nullopt if pinned_memory is not specified. |
boolean |
pinned_memory()
Returns the
pinned_memory property of the TensorOptions . |
TensorOptions |
pinned_memory(BoolOptional pinned_memory)
Sets the
pinned_memory property on the TensorOptions . |
TensorOptions |
position(long position) |
BoolOptional |
requires_grad_opt()
Returns the
requires_grad property of the TensorOptions , or
std::nullopt if requires_grad is not specified. |
boolean |
requires_grad()
Returns the
requires_grad property of the TensorOptions . |
TensorOptions |
requires_grad(BoolOptional requires_grad)
Sets the
requires_grad property of the TensorOptions . |
boolean |
type_equal(TensorOptions other) |
address, asBuffer, asByteBuffer, availablePhysicalBytes, calloc, capacity, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, getDirectBufferAddress, getPointer, getPointer, getPointer, hashCode, interruptDeallocatorThread, isNull, isNull, limit, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetAddress, offsetof, offsetof, parseBytes, physicalBytes, physicalBytesInaccurate, position, put, realloc, referenceCount, releaseReference, retainReference, setNull, sizeof, sizeof, toString, totalBytes, totalCount, totalPhysicalBytes, withDeallocator, zero
public TensorOptions(Pointer p)
Pointer(Pointer)
.public TensorOptions(long size)
Pointer.position(long)
.public TensorOptions()
public TensorOptions(torch.Layout layout)
TensorOptions
object with the given layout.public TensorOptions(@ByRef(value=true) Device device)
TensorOptions
object with the given device.
See NOTE [ TensorOptions Constructors ] on why this is templatized.public TensorOptions(@ByVal TypeMeta dtype)
TensorOptions
object with the given dtype.public TensorOptions(torch.ScalarType dtype)
public TensorOptions(torch.MemoryFormat memory_format)
TensorOptions
object with the given memory format.public TensorOptions position(long position)
public TensorOptions getPointer(long i)
getPointer
in class Pointer
@ByVal @NoException(value=true) public TensorOptions device(@ByVal DeviceOptional device)
TensorOptions
with device
set to the given one, or
cleared if device
is nullopt
.@ByVal @NoException(value=true) public TensorOptions device_index(@Cast(value="c10::DeviceIndex") byte device_index)
TensorOptions
, but with device set to CUDA, and the
device index set to the given one.
TODO: This function encourages bad behavior (assuming CUDA is
the only device that matters). Get rid of it / rename it.@ByVal @NoException(value=true) public TensorOptions dtype(@ByVal TypeMetaOptional dtype)
TensorOptions
with dtype
set to the given one.@ByVal @NoException(value=true) public TensorOptions dtype(@ByVal ScalarTypeOptional dtype)
@ByVal @NoException(value=true) public TensorOptions layout(@ByVal LayoutOptional layout)
TensorOptions
.@ByVal @NoException(value=true) public TensorOptions requires_grad(@ByVal BoolOptional requires_grad)
requires_grad
property of the TensorOptions
.@ByVal @NoException(value=true) public TensorOptions pinned_memory(@ByVal BoolOptional pinned_memory)
pinned_memory
property on the TensorOptions
.@ByVal @NoException(value=true) public TensorOptions memory_format(@ByVal MemoryFormatOptional memory_format)
memory_format
property on TensorOptions
.@ByVal @NoException(value=true) public Device device()
TensorOptions
.@Cast(value="bool") @NoException(value=true) public boolean has_device()
@ByVal @NoException(value=true) public DeviceOptional device_opt()
TensorOptions
, or std::nullopt
if
device is not specified.@Cast(value="c10::DeviceIndex") @NoException(value=true) public byte device_index()
TensorOptions
.@ByVal @NoException(value=true) public TypeMeta dtype()
TensorOptions
.@Cast(value="bool") @NoException(value=true) public boolean has_dtype()
@ByVal @NoException(value=true) public TypeMetaOptional dtype_opt()
TensorOptions
, or std::nullopt
if
device is not specified.@NoException(value=true) public torch.Layout layout()
TensorOptions
.@Cast(value="bool") @NoException(value=true) public boolean has_layout()
@ByVal @NoException(value=true) public LayoutOptional layout_opt()
TensorOptions
, or std::nullopt
if
layout is not specified.@Cast(value="bool") @NoException(value=true) public boolean requires_grad()
requires_grad
property of the TensorOptions
.@Cast(value="bool") @NoException(value=true) public boolean has_requires_grad()
requires_grad
is specified.@ByVal @NoException(value=true) public BoolOptional requires_grad_opt()
requires_grad
property of the TensorOptions
, or
std::nullopt
if requires_grad
is not specified.@Cast(value="bool") @NoException(value=true) public boolean pinned_memory()
pinned_memory
property of the TensorOptions
.@Cast(value="bool") @NoException(value=true) public boolean has_pinned_memory()
pinned_memory
is specified.@Cast(value="bool") public boolean is_sparse_csr()
@Cast(value="bool") public boolean type_equal(@Const @ByRef TensorOptions other)
@ByVal @NoException(value=true) public BoolOptional pinned_memory_opt()
pinned_memory
property of the TensorOptions
, or
std::nullopt
if pinned_memory
is not specified.@Cast(value="bool") @NoException(value=true) public boolean has_memory_format()
memory_layout
is specified@ByVal @NoException(value=true) public MemoryFormatOptional memory_format_opt()
memory_layout
property of TensorOptions, or
std::nulloptif
memory_format{@code is not specified.public torch.Backend backend()
@ByVal @NoException(value=true) public TensorOptions merge_in(@ByVal TensorOptions options)
@ByVal @NoException(value=true) public TensorOptions merge_memory_format(@ByVal MemoryFormatOptional optional_memory_format)
public torch.DispatchKey computeDispatchKey()
Copyright © 2025. All rights reserved.