MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / fill_

Function fill_

imperative/python/megengine/module/init.py:13–20  ·  view source on GitHub ↗

Fills the given ``tensor`` with value ``val``. Args: tensor: tensor to be initialized. val: value to be filled throughout the tensor.

(tensor: Tensor, val: Union[float, int])

Source from the content-addressed store, hash-verified

11
12
13def fill_(tensor: Tensor, val: Union[float, int]) -> None:
14 """Fills the given ``tensor`` with value ``val``.
15
16 Args:
17 tensor: tensor to be initialized.
18 val: value to be filled throughout the tensor.
19 """
20 tensor._reset(full(shape=tensor.shape, value=val, dtype=tensor.dtype))
21
22
23def zeros_(tensor: Tensor) -> None:

Callers 3

test_fill_Function · 0.90
zeros_Function · 0.85
ones_Function · 0.85

Calls 2

fullFunction · 0.85
_resetMethod · 0.45

Tested by 1

test_fill_Function · 0.72