|
| 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