Rate this Page

Function torch ::stable::new_zeros#

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)#

Stable version of the new_zeros op (2.9 version).

Creates a new tensor filled with zeros 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 and layout will be inherited.

  • 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 zero-filled tensor with the specified properties.