@@ -157,6 +157,35 @@ __attribute__((objc_subclassing_restricted))
157157- (instancetype )initWithNativeInstance:(void *)nativeInstance
158158 NS_DESIGNATED_INITIALIZER NS_SWIFT_UNAVAILABLE (" " );
159159
160+ /* *
161+ * Creates a new tensor that shares the underlying data storage with the
162+ * given tensor, with metadata overrides. An empty array for
163+ * a parameter signifies that it should be inherited or derived.
164+ *
165+ * @param otherTensor The tensor instance to create a view of.
166+ * @param shape An override for the tensor's shape.
167+ * @param dimensionOrder An override for the tensor's dimension order.
168+ * @param strides An override for the tensor's strides.
169+ * @return A new ExecuTorchTensor instance that shares data with otherTensor.
170+ */
171+ - (instancetype )initWithTensor:(ExecuTorchTensor *)otherTensor
172+ shape:(NSArray <NSNumber *> *)shape
173+ dimensionOrder:(NSArray <NSNumber *> *)dimensionOrder
174+ strides:(NSArray <NSNumber *> *)strides
175+ NS_REFINED_FOR_SWIFT;
176+
177+ /* *
178+ * Creates a new tensor that shares the underlying data storage with the
179+ * given tensor, with an overridden shape.
180+ *
181+ * @param otherTensor The tensor instance to create a view of.
182+ * @param shape An override for the tensor's shape.
183+ * @return A new ExecuTorchTensor instance that shares data with otherTensor.
184+ */
185+ - (instancetype )initWithTensor:(ExecuTorchTensor *)otherTensor
186+ shape:(NSArray <NSNumber *> *)shape
187+ NS_SWIFT_UNAVAILABLE (" " );
188+
160189/* *
161190 * Creates a new tensor that shares the underlying data storage with the
162191 * given tensor. This new tensor is a view and does not own the data.
@@ -165,7 +194,7 @@ __attribute__((objc_subclassing_restricted))
165194 * @return A new ExecuTorchTensor instance that shares data with otherTensor.
166195 */
167196- (instancetype )initWithTensor:(ExecuTorchTensor *)otherTensor
168- NS_SWIFT_NAME (init(_:) );
197+ NS_SWIFT_UNAVAILABLE ( " " );
169198
170199/* *
171200 * Creates a deep copy of the tensor.
@@ -176,6 +205,17 @@ __attribute__((objc_subclassing_restricted))
176205 */
177206- (instancetype )copy;
178207
208+ /* *
209+ * Creates a deep copy of the tensor, potentially casting to a new data type.
210+ * The new tensor will have its own copy of the data.
211+ *
212+ * @param dataType The desired data type for the new tensor.
213+ * @return A new ExecuTorchTensor instance that is a duplicate (and possibly
214+ casted) of the current tensor.
215+ */
216+ - (instancetype )copyToDataType:(ExecuTorchDataType)dataType
217+ NS_SWIFT_NAME (copy(to:));
218+
179219/* *
180220 * Executes a block with a pointer to the tensor's immutable byte data.
181221 *
0 commit comments