megengine.functional.square¶
- square(x)[source]¶
Element-wise
function.Calculates the square for each element
of the input tensor .- Parameters
x (
Tensor
) – input tensor. Should have a floating-point data type.- Return type
- Returns
a tensor containing the evaluated square root result for each element in
. The returned tensor must have a floating-point data type determined by Type promotion rules.
Examples
>>> F.square(2) Tensor(4, dtype=int32, device=xpux:0)
Element-wise square:
>>> x = Tensor([1, -2, -3, 4]) >>> F.square(x) Tensor([ 1 4 9 16], dtype=int32, device=xpux:0)