Rate this Page

Function torch::stable::new_zeros(const torch::stable::Tensor&, torch::headeronly::IntHeaderOnlyArrayRef, std::optional<torch::headeronly::ScalarType>, std::optional<torch::headeronly::Layout>, std::optional<torch::stable::Device>, std::optional<bool>)#

Function Documentation#

inline torch::stable::Tensor torch::stable::new_zeros(const torch::stable::Tensor &self, torch::headeronly::IntHeaderOnlyArrayRef size, std::optional<torch::headeronly::ScalarType> dtype = std::nullopt, std::optional<torch::headeronly::Layout> layout = std::nullopt, std::optional<torch::stable::Device> device = std::nullopt, std::optional<bool> pin_memory = std::nullopt)#

Stable version of the new_zeros op (2.10 version with full kwargs).

Creates a new zero-filled tensor with the specified size and options. This version supports all tensor creation kwargs. For versions < 2.10, a simpler overload that only takes dtype is available.

Minimum compatible version: PyTorch 2.10.

Parameters:
  • self – The input tensor whose properties may be inherited if kwargs are not provided.

  • size – The desired size of the output tensor.

  • dtype – Optional scalar type for the tensor elements.

  • layout – Optional memory layout (e.g., strided, sparse).

  • device – Optional device to place the tensor on.

  • pin_memory – Optional flag to use pinned memory (for CUDA tensors).

Returns:

A new zero-filled tensor with the specified properties.