Skip to content

Commit 3cc48c8

Browse files
authored
Make Tensor data type a generic arg.
Differential Revision: D76163831 Pull Request resolved: pytorch/executorch#11628
1 parent 927fefa commit 3cc48c8

File tree

9 files changed

+949
-227
lines changed

9 files changed

+949
-227
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
@_exported import ExecuTorch
10+
11+
@available(*, deprecated, message: "This API is experimental.")
12+
public extension Module {
13+
/// Executes a specific method with the provided input values.
14+
/// The method is loaded on demand if not already loaded.
15+
///
16+
/// - Parameters:
17+
/// - method: The name of the method to execute.
18+
/// - inputs: An array of `ValueConvertible` types representing the inputs.
19+
/// - Returns: An array of `Value` objects representing the outputs.
20+
/// - Throws: An error if method execution fails.
21+
func execute(_ method: String, _ inputs: [ValueConvertible]) throws -> [Value] {
22+
try __executeMethod(method, withInputs: inputs.map { $0.objcValue() } )
23+
}
24+
25+
/// Executes a specific method with a single input value.
26+
/// The method is loaded on demand if not already loaded.
27+
///
28+
/// - Parameters:
29+
/// - method: The name of the method to execute.
30+
/// - input: A single `ValueConvertible` type representing the input.
31+
/// - Returns: An array of `Value` objects representing the outputs.
32+
/// - Throws: An error if method execution fails.
33+
func execute(_ method: String, _ input: ValueConvertible) throws -> [Value] {
34+
try __executeMethod(method, withInputs: [input.objcValue()])
35+
}
36+
37+
/// Executes the "forward" method with the provided input values.
38+
/// The method is loaded on demand if not already loaded.
39+
///
40+
/// - Parameter inputs: An array of `ValueConvertible` types representing the inputs.
41+
/// - Returns: An array of `Value` objects representing the outputs.
42+
/// - Throws: An error if method execution fails.
43+
func forward(_ inputs: [ValueConvertible]) throws -> [Value] {
44+
try __executeMethod("forward", withInputs: inputs.map { $0.objcValue() })
45+
}
46+
47+
/// Executes the "forward" method with a single input value.
48+
/// The method is loaded on demand if not already loaded.
49+
///
50+
/// - Parameter input: A single `ValueConvertible` type representing the input.
51+
/// - Returns: An array of `Value` objects representing the outputs.
52+
/// - Throws: An error if method execution fails.
53+
func forward(_ input: ValueConvertible) throws -> [Value] {
54+
try __executeMethod("forward", withInputs: [input.objcValue()])
55+
}
56+
}

0 commit comments

Comments
 (0)