r"""Returns a new tensor having a specified shape and filled with zeros. Args: shape(int...): the shape of the output tensor. Keyword args: dtype(:attr:`.Tensor.dtype`, optional): output tensor data type. device(:attr:`.Tensor.device`, optional): device on which to
(
shape: Union[int, Tuple[int, ...]],
*,
dtype="float32",
device: Optional[CompNode] = None
)
| 357 | |
| 358 | |
| 359 | def zeros( |
| 360 | shape: Union[int, Tuple[int, ...]], |
| 361 | *, |
| 362 | dtype="float32", |
| 363 | device: Optional[CompNode] = None |
| 364 | ) -> Tensor: |
| 365 | r"""Returns a new tensor having a specified shape and filled with zeros. |
| 366 | |
| 367 | Args: |
| 368 | shape(int...): the shape of the output tensor. |
| 369 | |
| 370 | Keyword args: |
| 371 | dtype(:attr:`.Tensor.dtype`, optional): output tensor data type. |
| 372 | device(:attr:`.Tensor.device`, optional): device on which to place the created tensor. |
| 373 | |
| 374 | Returns: |
| 375 | a tensor containing zeros. |
| 376 | |
| 377 | Examples: |
| 378 | >>> F.zeros((2, 3)) |
| 379 | Tensor([[0. 0. 0.] |
| 380 | [0. 0. 0.]], device=xpux:0) |
| 381 | """ |
| 382 | if isinstance(shape, int): |
| 383 | shape = (shape,) |
| 384 | if device == None: |
| 385 | device = get_default_device() |
| 386 | op = builtin.Fill(0, dtype) |
| 387 | shape = astensor1d(shape, dtype="int32", device=device) |
| 388 | (x,) = apply(op, shape) |
| 389 | return x |
| 390 | |
| 391 | |
| 392 | def zeros_like(inp: Tensor) -> Tensor: |
no test coverage detected