@@ -15,13 +15,13 @@ namespace extension {
15
15
16
16
/* *
17
17
* A helper class for creating TensorPtr instances from raw data and tensor
18
- * properties. Note that the TensorPtr created by this class will not own the
19
- * data, so it must outlive the TensorPtr.
18
+ * properties. Note that the TensorPtr created by this class does not own the
19
+ * data, so the data must outlive the TensorPtr.
20
20
*
21
- * TensorPtrMaker provides a fluent interface for specifying various properties
22
- * of a tensor , such as its type, sizes, data pointer, dimension order, strides,
23
- * and shape dynamism. The final tensor is created by invoking make_tensor_ptr()
24
- * or converting TensorPtrMaker to TensorPtr.
21
+ * TensorPtrMaker provides a fluent interface for specifying various tensor
22
+ * properties , such as type, sizes, data pointer, dimension order, strides, and
23
+ * shape dynamism. The final tensor is created by invoking make_tensor_ptr() or
24
+ * by converting TensorPtrMaker to TensorPtr.
25
25
*/
26
26
class TensorPtrMaker final {
27
27
public:
@@ -99,11 +99,11 @@ class TensorPtrMaker final {
99
99
*/
100
100
TensorPtr make_tensor_ptr () && {
101
101
return ::executorch::extension::make_tensor_ptr (
102
- type_,
103
102
std::move (sizes_),
104
103
data_,
105
104
std::move (dim_order_),
106
105
std::move (strides_),
106
+ type_,
107
107
dynamism_,
108
108
std::move (deleter_));
109
109
}
@@ -167,16 +167,16 @@ inline TensorPtrMaker for_blob(
167
167
* Creates a TensorPtr from a raw data pointer and tensor sizes, with an
168
168
* optional dynamism setting.
169
169
*
170
- * This function is a convenient way to create a tensor from existing data, with
171
- * the option to specify whether the tensor's shape is static, dynamic, or
172
- * bounded .
170
+ * This function provides a convenient way to create a tensor from existing
171
+ * data, with the option to specify whether the tensor's shape is static or
172
+ * dynamic .
173
173
*
174
- * @param data A pointer to the raw data to be used by the tensor. It must
174
+ * @param data A pointer to the raw data used by the tensor. The data must
175
175
* outlive the TensorPtr created by this function.
176
176
* @param sizes A vector specifying the size of each dimension.
177
177
* @param type The scalar type of the tensor elements.
178
178
* @param dynamism Specifies whether the tensor's shape is static or dynamic.
179
- * @return A TensorPtr instance that manages the newly created Tensor.
179
+ * @return A TensorPtr instance managing the newly created Tensor.
180
180
*/
181
181
inline TensorPtr from_blob (
182
182
void * data,
@@ -195,15 +195,16 @@ inline TensorPtr from_blob(
195
195
*
196
196
* This function allows for the creation of a tensor from existing data, with
197
197
* the option to specify custom strides for each dimension and whether the
198
- * tensor' s shape is static, dynamic, or bounded.
198
+ * tensor’ s shape is static, dynamic, or bounded.
199
199
*
200
- * @param data A pointer to the raw data to be used by the tensor. It must
200
+ * @param data A pointer to the raw data used by the tensor. The data must
201
201
* outlive the TensorPtr created by this function.
202
202
* @param sizes A vector specifying the size of each dimension.
203
203
* @param strides A vector specifying the stride for each dimension.
204
204
* @param type The scalar type of the tensor elements.
205
- * @param dynamism Specifies whether the tensor's shape is static or dynamic.
206
- * @return A TensorPtr instance that manages the newly created Tensor.
205
+ * @param dynamism Specifies whether the tensor's shape is static, dynamic, or
206
+ * bounded.
207
+ * @return A TensorPtr instance managing the newly created Tensor.
207
208
*/
208
209
inline TensorPtr from_blob (
209
210
void * data,
@@ -306,9 +307,10 @@ TensorPtr empty_strided(
306
307
* This function allocates memory for the tensor elements but does not
307
308
* initialize them with any specific values.
308
309
*
309
- * @param other A reference to another tensor, whose size and properties will be
310
+ * @param other A reference to another tensor, whose size and properties are
310
311
* used.
311
- * @param type The scalar type of the tensor elements.
312
+ * @param type The scalar type of the tensor elements. If not provided, the
313
+ * scalar type of the other tensor is used.
312
314
* @param dynamism Specifies whether the tensor's shape is static or dynamic.
313
315
* @return A TensorPtr instance managing the newly created Tensor.
314
316
*/
@@ -397,7 +399,7 @@ inline TensorPtr full_like(
397
399
* Creates a TensorPtr filled with the specified value.
398
400
*
399
401
* @param sizes A vector specifying the size of each dimension.
400
- * @param fill_value The value to fill the tensor with .
402
+ * @param fill_value The value used to fill the tensor.
401
403
* @param type The scalar type of the tensor elements.
402
404
* @param dynamism Specifies whether the tensor's shape is static or dynamic.
403
405
* @return A TensorPtr instance managing the newly created Tensor.
@@ -412,11 +414,10 @@ inline TensorPtr full(
412
414
}
413
415
414
416
/* *
415
- * Creates a TensorPtr that holds a scalar value.
417
+ * Creates a TensorPtr holding a scalar value.
416
418
*
417
- * @param value The scalar value to create the tensor with .
419
+ * @param value The scalar value for the tensor.
418
420
* @param type The scalar type of the tensor elements.
419
- * @param dynamism Specifies whether the tensor's shape is static or dynamic.
420
421
* @return A TensorPtr instance managing the newly created scalar Tensor.
421
422
*/
422
423
inline TensorPtr scalar_tensor (
@@ -429,10 +430,10 @@ inline TensorPtr scalar_tensor(
429
430
* Creates a TensorPtr filled with ones, with the same size and properties as
430
431
* another tensor.
431
432
*
432
- * @param other A reference to another tensor, whose size and properties will be
433
+ * @param other A reference to another tensor, whose size and properties are
433
434
* used.
434
- * @param type The scalar type of the tensor elements. If not specified , the
435
- * scalar type of the ` other` tensor is used.
435
+ * @param type The scalar type of the tensor elements. If not provided , the
436
+ * scalar type of the other tensor is used.
436
437
* @param dynamism Specifies whether the tensor's shape is static or dynamic.
437
438
* @return A TensorPtr instance managing the newly created Tensor.
438
439
*/
@@ -553,7 +554,8 @@ inline TensorPtr rand(
553
554
}
554
555
555
556
/* *
556
- * Creates a TensorPtr filled with random values from a normal distribution.
557
+ * Creates a TensorPtr filled with random values between 0 and 1, with specified
558
+ * strides.
557
559
*
558
560
* @param sizes A vector specifying the size of each dimension.
559
561
* @param strides A vector specifying the stride for each dimension.
@@ -594,7 +596,8 @@ inline TensorPtr randn_like(
594
596
}
595
597
596
598
/* *
597
- * Creates a TensorPtr filled with random values from a normal distribution.
599
+ * Creates a TensorPtr filled with random values sampled from a normal
600
+ * distribution.
598
601
*
599
602
* @param sizes A vector specifying the size of each dimension.
600
603
* @param type The scalar type of the tensor elements.
@@ -661,10 +664,11 @@ inline TensorPtr randint_like(
661
664
}
662
665
663
666
/* *
664
- * Creates a TensorPtr filled with random integer values in the given range.
667
+ * Creates a TensorPtr filled with random integer values within the specified
668
+ * range.
665
669
*
666
- * @param low The lower bound (inclusive) of the random values.
667
- * @param high The upper bound (exclusive) of the random values.
670
+ * @param low The inclusive lower bound of the random values.
671
+ * @param high The exclusive upper bound of the random values.
668
672
* @param sizes A vector specifying the size of each dimension.
669
673
* @param type The scalar type of the tensor elements.
670
674
* @param dynamism Specifies whether the tensor's shape is static or dynamic.
0 commit comments