|
| virtual TensorPtr | empty (Shape shape, bool requiresGrad=false) const noexcept=0 |
| | Creates a new tensor of the specified shape without initializing the memory.
|
| |
| virtual TensorPtr | zeros (Shape shape, bool requiresGrad=false) const noexcept=0 |
| | Creates a new tensor of the specified shape. All entries are initialized to zero.
|
| |
| virtual TensorPtr | ones (Shape shape, bool requiresGrad=false) const noexcept=0 |
| | Creates a new tensor of the specified shape. All entries are initialized to one.
|
| |
|
virtual TensorPtr | rand (Shape shape, bool requiresGrad=false) const noexcept=0 |
| |
|
virtual TensorPtr | constant (int value, bool requiresGrad=false) const noexcept=0 |
| |
|
virtual TensorPtr | constant (float value, bool requiresGrad=false) const noexcept=0 |
| |
|
virtual TensorPtr | constant (double value, bool requiresGrad=false) const noexcept=0 |
| |
|
virtual TensorPtr | constant (InitializerTensor< float > &&value, bool requiresGrad=false) const noexcept=0 |
| |
|
virtual TensorPtr | fromBytesFP32 (const char *buffer, size_t bufsize, Shape shape) const noexcept=0 |
| |
|
template<typename T > |
| void | setDefaultFloatTensorType () |
| |
|
template<> |
| void | setDefaultFloatTensorType () |
| |
|
template<> |
| void | setDefaultFloatTensorType () |
| |
|
| static Device const & | cpu |
| | The CPU-device implementation.
|
| |
Definition at line 8 of file device.hpp.
◆ changeDefaultDevice()
| static auto dl::Device::changeDefaultDevice |
( |
Device & |
device | ) |
|
|
inlinestatic |
Temporarily modifies the default device.
Example call:
}
static auto changeDefaultDevice(Device &device)
Temporarily modifies the default device.
- Parameters
-
| device | The device that should be default for the current scope. |
- Returns
- A scopeguard for the default device.
- See also
- Device::getDefault()
Definition at line 93 of file device.hpp.
93 {
94 auto oldDefault = defaultDevice;
95 defaultDevice = &device;
97 }
◆ empty()
| virtual TensorPtr dl::Device::empty |
( |
Shape |
shape, |
|
|
bool |
requiresGrad = false |
|
) |
| const |
|
pure virtualnoexcept |
Creates a new tensor of the specified shape without initializing the memory.
- Parameters
-
| shape | The shape of the tensor. |
| requiresGrad | True if a gradient should be calculate for the newly constructed tensor. |
- Returns
- The newly created tensor.
◆ getDefault()
| static const Device & dl::Device::getDefault |
( |
| ) |
|
|
inlinestaticnoexcept |
Returns the default device for this thread.
The default device is thread local. That means that modifying the default device from another thread will not effect other threads.
- Returns
- The current default device.
- See also
- Device::changeDefaultDevice(Device&)
Definition at line 76 of file device.hpp.
76{ return *defaultDevice; }
◆ ones()
| virtual TensorPtr dl::Device::ones |
( |
Shape |
shape, |
|
|
bool |
requiresGrad = false |
|
) |
| const |
|
pure virtualnoexcept |
Creates a new tensor of the specified shape. All entries are initialized to one.
- Parameters
-
| shape | The shape of the tensor. |
| requiresGrad | True if a gradient should be calculate for the newly constructed tensor. |
- Returns
- The newly created tensor.
◆ zeros()
| virtual TensorPtr dl::Device::zeros |
( |
Shape |
shape, |
|
|
bool |
requiresGrad = false |
|
) |
| const |
|
pure virtualnoexcept |
Creates a new tensor of the specified shape. All entries are initialized to zero.
- Parameters
-
| shape | The shape of the tensor. |
| requiresGrad | True if a gradient should be calculate for the newly constructed tensor. |
- Returns
- The newly created tensor.
◆ cpu
The CPU-device implementation.
Definition at line 32 of file device.hpp.
The documentation for this class was generated from the following file: