@@ -902,4 +902,82 @@ __attribute__((deprecated("This API is experimental.")))
902
902
903
903
@end
904
904
905
+ #pragma mark - Random Category
906
+
907
+ @interface ExecuTorchTensor (Random)
908
+
909
+ /* *
910
+ * Creates a tensor with random values, with full specification of shape, strides, data type, and shape dynamism.
911
+ *
912
+ * @param shape An NSArray of NSNumber objects representing the desired shape.
913
+ * @param strides An NSArray of NSNumber objects representing the desired strides.
914
+ * @param dataType An ExecuTorchDataType value specifying the element type.
915
+ * @param shapeDynamism An ExecuTorchShapeDynamism value specifying whether the shape is static or dynamic.
916
+ * @return A new ExecuTorchTensor instance filled with random values.
917
+ */
918
+ + (instancetype )randomTensorWithShape : (NSArray <NSNumber *> *)shape
919
+ strides : (NSArray <NSNumber *> *)strides
920
+ dataType : (ExecuTorchDataType)dataType
921
+ shapeDynamism : (ExecuTorchShapeDynamism)shapeDynamism
922
+ NS_SWIFT_NAME(rand(shape:strides:dataType:shapeDynamism:));
923
+
924
+ /* *
925
+ * Creates a tensor with random values, with the specified shape and data type.
926
+ *
927
+ * @param shape An NSArray of NSNumber objects representing the desired shape.
928
+ * @param dataType An ExecuTorchDataType value specifying the element type.
929
+ * @param shapeDynamism An ExecuTorchShapeDynamism value specifying whether the shape is static or dynamic.
930
+ * @return A new ExecuTorchTensor instance filled with random values.
931
+ */
932
+ + (instancetype )randomTensorWithShape : (NSArray <NSNumber *> *)shape
933
+ dataType : (ExecuTorchDataType)dataType
934
+ shapeDynamism : (ExecuTorchShapeDynamism)shapeDynamism
935
+ NS_SWIFT_NAME(rand(shape:dataType:shapeDynamism:));
936
+
937
+ /* *
938
+ * Creates a tensor with random values, with the specified shape (using dynamic bound shape) and data type.
939
+ *
940
+ * @param shape An NSArray of NSNumber objects representing the desired shape.
941
+ * @param dataType An ExecuTorchDataType value specifying the element type.
942
+ * @return A new ExecuTorchTensor instance filled with random values.
943
+ */
944
+ + (instancetype )randomTensorWithShape : (NSArray <NSNumber *> *)shape
945
+ dataType : (ExecuTorchDataType)dataType
946
+ NS_SWIFT_NAME(rand(shape:dataType:));
947
+
948
+ /* *
949
+ * Creates a tensor with random values similar to an existing tensor, with the specified data type and shape dynamism.
950
+ *
951
+ * @param tensor An existing ExecuTorchTensor instance whose shape and strides are used.
952
+ * @param dataType An ExecuTorchDataType value specifying the desired element type.
953
+ * @param shapeDynamism An ExecuTorchShapeDynamism value specifying whether the shape is static or dynamic.
954
+ * @return A new ExecuTorchTensor instance filled with random values.
955
+ */
956
+ + (instancetype )randomTensorLikeTensor : (ExecuTorchTensor *)tensor
957
+ dataType : (ExecuTorchDataType)dataType
958
+ shapeDynamism : (ExecuTorchShapeDynamism)shapeDynamism
959
+ NS_SWIFT_NAME(rand(like:dataType:shapeDynamism:));
960
+
961
+ /* *
962
+ * Creates a tensor with random values similar to an existing tensor, with the specified data type.
963
+ *
964
+ * @param tensor An existing ExecuTorchTensor instance whose shape and strides are used.
965
+ * @param dataType An ExecuTorchDataType value specifying the desired element type.
966
+ * @return A new ExecuTorchTensor instance filled with random values.
967
+ */
968
+ + (instancetype )randomTensorLikeTensor : (ExecuTorchTensor *)tensor
969
+ dataType : (ExecuTorchDataType)dataType
970
+ NS_SWIFT_NAME(rand(like:dataType:));
971
+
972
+ /* *
973
+ * Creates a tensor with random values similar to an existing tensor.
974
+ *
975
+ * @param tensor An existing ExecuTorchTensor instance.
976
+ * @return A new ExecuTorchTensor instance filled with random values.
977
+ */
978
+ + (instancetype )randomTensorLikeTensor : (ExecuTorchTensor *)tensor
979
+ NS_SWIFT_NAME(rand(like:));
980
+
981
+ @end
982
+
905
983
NS_ASSUME_NONNULL_END
0 commit comments