ones¶
- nvtripy.ones(shape: nvtripy.types.ShapeLike, dtype: dtype = float32) Tensor[source]¶
Creates a Tensor of the specified shape and dtype with all elements set to 1.
- Parameters:
shape (nvtripy.types.ShapeLike) – The desired shape of the tensor.
dtype (dtype) – Datatype of elements.
- Returns:
A tensor of shape
shapewith all elements set to 1.- Return type:
- INPUT REQUIREMENTS:
dtypeis one of [float32,float16,bfloat16,int8,int32,int64,bool]- OUTPUT GUARANTEES:
return[0].dtype==dtype
Example
1output = tp.ones([2, 3])
Local Variables¶>>> output tensor( [[1, 1, 1], [1, 1, 1]], dtype=float32, loc=gpu:0, shape=(2, 3))
See also