megengine.functional.broadcast_to¶
- broadcast_to(inp, shape)[source]¶
Broadcasts a tensor to given shape.
- Parameters
- Return type
- Returns
output tensor.
Examples
>>> import numpy as np >>> data = Tensor(np.arange(0, 3, dtype=np.float32).reshape(3)) >>> out = F.broadcast_to(data, (2, 3)) >>> out.numpy() array([[0., 1., 2.], [0., 1., 2.]], dtype=float32)