@@ -165,34 +165,35 @@ class Module {
165
165
const std::string& method_name);
166
166
167
167
/* *
168
- * Execute a specific method with the given input and retrieve output.
169
- * Loads the program and method before executing if needed.
168
+ * Execute a specific method with the given input values and retrieve the
169
+ * output values. Loads the program and method before executing if needed.
170
170
*
171
171
* @param[in] method_name The name of the method to execute.
172
- * @param[in] input A vector of input values to be passed to the method.
172
+ * @param[in] input_values A vector of input values to be passed to the
173
+ * method.
173
174
*
174
175
* @returns A Result object containing either a vector of output values
175
176
* from the method or an error to indicate failure.
176
177
*/
177
178
ET_NODISCARD
178
179
runtime::Result<std::vector<runtime::EValue>> execute (
179
180
const std::string& method_name,
180
- const std::vector<runtime::EValue>& input );
181
+ const std::vector<runtime::EValue>& input_values );
181
182
182
183
/* *
183
184
* Execute a specific method with a single input value.
184
185
* Loads the program and method before executing if needed.
185
186
*
186
187
* @param[in] method_name The name of the method to execute.
187
- * @param[in] input A value to be passed to the method.
188
+ * @param[in] input_value A value to be passed to the method.
188
189
*
189
190
* @returns A Result object containing either a vector of output values
190
191
* from the method or an error to indicate failure.
191
192
*/
192
193
ET_NODISCARD inline runtime::Result<std::vector<runtime::EValue>> execute (
193
194
const std::string& method_name,
194
- const runtime::EValue& input ) {
195
- return execute (method_name, std::vector<runtime::EValue>{input });
195
+ const runtime::EValue& input_value ) {
196
+ return execute (method_name, std::vector<runtime::EValue>{input_value });
196
197
}
197
198
198
199
/* *
@@ -210,19 +211,20 @@ class Module {
210
211
}
211
212
212
213
/* *
213
- * Retrieve the output value of a specific method with the given input.
214
+ * Retrieve the output value of a specific method with the given input values .
214
215
* Loads the program and method before execution if needed.
215
216
*
216
217
* @param[in] method_name The name of the method to execute.
217
- * @param[in] input A vector of input values to be passed to the method.
218
+ * @param[in] input_values A vector of input values to be passed to the
219
+ * method.
218
220
*
219
221
* @returns A Result object containing either the first output value from the
220
222
* method or an error to indicate failure.
221
223
*/
222
224
ET_NODISCARD inline runtime::Result<runtime::EValue> get (
223
225
const std::string& method_name,
224
- const std::vector<runtime::EValue>& input ) {
225
- auto result = ET_UNWRAP (execute (method_name, input ));
226
+ const std::vector<runtime::EValue>& input_values ) {
227
+ auto result = ET_UNWRAP (execute (method_name, input_values ));
226
228
if (result.empty ()) {
227
229
return runtime::Error::InvalidArgument;
228
230
}
@@ -234,15 +236,15 @@ class Module {
234
236
* Loads the program and method before execution if needed.
235
237
*
236
238
* @param[in] method_name The name of the method to execute.
237
- * @param[in] input A value to be passed to the method.
239
+ * @param[in] input_value A value to be passed to the method.
238
240
*
239
241
* @returns A Result object containing either the first output value from the
240
242
* method or an error to indicate failure.
241
243
*/
242
244
ET_NODISCARD inline runtime::Result<runtime::EValue> get (
243
245
const std::string& method_name,
244
- const runtime::EValue& input ) {
245
- return get (method_name, std::vector<runtime::EValue>{input });
246
+ const runtime::EValue& input_value ) {
247
+ return get (method_name, std::vector<runtime::EValue>{input_value });
246
248
}
247
249
248
250
/* *
@@ -260,31 +262,31 @@ class Module {
260
262
}
261
263
262
264
/* *
263
- * Execute the 'forward' method with the given input and retrieve output.
264
- * Loads the program and method before executing if needed.
265
+ * Execute the 'forward' method with the given input values and retrieve the
266
+ * output values. Loads the program and method before executing if needed.
265
267
*
266
- * @param[in] input A vector of input values for the 'forward' method.
268
+ * @param[in] input_values A vector of input values for the 'forward' method.
267
269
*
268
270
* @returns A Result object containing either a vector of output values
269
271
* from the 'forward' method or an error to indicate failure.
270
272
*/
271
273
ET_NODISCARD inline runtime::Result<std::vector<runtime::EValue>> forward (
272
- const std::vector<runtime::EValue>& input ) {
273
- return execute (" forward" , input );
274
+ const std::vector<runtime::EValue>& input_values ) {
275
+ return execute (" forward" , input_values );
274
276
}
275
277
276
278
/* *
277
279
* Execute the 'forward' method with a single value.
278
280
* Loads the program and method before executing if needed.
279
281
*
280
- * @param[in] input A value for the 'forward' method.
282
+ * @param[in] input_value A value for the 'forward' method.
281
283
*
282
284
* @returns A Result object containing either a vector of output values
283
285
* from the 'forward' method or an error to indicate failure.
284
286
*/
285
287
ET_NODISCARD inline runtime::Result<std::vector<runtime::EValue>> forward (
286
- const runtime::EValue& input ) {
287
- return forward (std::vector<runtime::EValue>{input });
288
+ const runtime::EValue& input_value ) {
289
+ return forward (std::vector<runtime::EValue>{input_value });
288
290
}
289
291
290
292
/* *
@@ -298,6 +300,42 @@ class Module {
298
300
return forward (std::vector<runtime::EValue>{});
299
301
}
300
302
303
+ /* *
304
+ * Sets the output tensor for a specific method.
305
+ *
306
+ * @param[in] method_name The name of the method.
307
+ * @param[in] output_value The EValue containing the Tensor to set as the
308
+ * method output.
309
+ * @param[in] output_index Zero-based index of the output to set.
310
+ *
311
+ * @returns An Error to indicate success or failure.
312
+ *
313
+ * @note Only Tensor outputs are currently supported for setting.
314
+ */
315
+ ET_NODISCARD
316
+ runtime::Error set_output (
317
+ const std::string& method_name,
318
+ runtime::EValue output_value,
319
+ size_t output_index = 0 );
320
+
321
+ /* *
322
+ * Sets the output tensor for the "forward" method.
323
+ *
324
+ * @param[in] output_value The EValue containing the Tensor to set as the
325
+ * method output.
326
+ * @param[in] output_index Zero-based index of the output to set.
327
+ *
328
+ * @returns An Error to indicate success or failure.
329
+ *
330
+ * @note Only Tensor outputs are currently supported for setting.
331
+ */
332
+ ET_NODISCARD
333
+ inline runtime::Error set_output (
334
+ runtime::EValue output_value,
335
+ size_t output_index = 0 ) {
336
+ return set_output (" forward" , output_value, output_index);
337
+ }
338
+
301
339
/* *
302
340
* Retrieves the EventTracer instance being used by the Module.
303
341
* EventTracer is used for tracking and logging events during the execution
@@ -310,19 +348,6 @@ class Module {
310
348
return event_tracer_.get ();
311
349
}
312
350
313
- /* *
314
- * Set output data pointer for forward method.
315
- *
316
- * @param[in] output_value A Tensor for the output of 'forward' method.
317
- * @param[in] output_index Index of the output in 'forward' method.
318
- *
319
- * @returns An Error to indicate success or failure of the loading process.
320
- */
321
- runtime::Error set_output_data_ptr (
322
- runtime::EValue output_value,
323
- size_t output_index,
324
- const std::string& method_name = " forward" );
325
-
326
351
private:
327
352
struct MethodHolder {
328
353
std::vector<std::vector<uint8_t >> planned_buffers;
0 commit comments