Rate this Page

Function torch ::stable::new_empty#

Function Documentation#

inline torch::stable::Tensor torch::stable::new_empty(const torch::stable::Tensor &self, torch::headeronly::IntHeaderOnlyArrayRef size, std::optional<torch::headeronly::ScalarType> dtype = std::nullopt)#

Stable version of the new_empty op (2.9 version).

Creates a new uninitialized tensor with the specified size, inheriting device and layout from the input tensor. This version only supports the dtype kwarg. For the full kwargs version, use PyTorch 2.10+.

Minimum compatible version: PyTorch 2.9. For full kwargs support, use PyTorch 2.10+.

Parameters:
  • self – The input tensor whose device

  • size – The desired size of the output tensor.

  • dtype – Optional scalar type for the tensor elements. If not provided, inherits from self.

Returns:

A new uninitialized tensor with the specified properties.