File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -998,6 +998,28 @@ Method::get_outputs(EValue* output_evalues, size_t length) {
998
998
return Error::Ok;
999
999
}
1000
1000
1001
+ __ET_NODISCARD Error Method::get_inputs (EValue* input_evalues, size_t length) {
1002
+ ET_CHECK_OR_RETURN_ERROR (
1003
+ initialized (),
1004
+ InvalidState,
1005
+ " Inputs can not be retrieved until method has been initialized." );
1006
+
1007
+ ET_CHECK_OR_RETURN_ERROR (
1008
+ length >= inputs_size (),
1009
+ InvalidArgument,
1010
+ " The given array is not large enough to hold all inputs." );
1011
+
1012
+ for (size_t i = 0 ; i < inputs_size (); i++) {
1013
+ input_evalues[i] = values_[get_input_index (i)];
1014
+ }
1015
+
1016
+ for (size_t i = inputs_size (); i < length; i++) {
1017
+ input_evalues[i] = EValue ();
1018
+ }
1019
+
1020
+ return Error::Ok;
1021
+ }
1022
+
1001
1023
Error Method::execute_instruction () {
1002
1024
auto & chain = chains_[step_state_.chain_idx ];
1003
1025
auto instructions = chain.s_chain_ ->instructions ();
Original file line number Diff line number Diff line change @@ -162,6 +162,22 @@ class Method final {
162
162
*/
163
163
__ET_NODISCARD Error get_outputs (EValue* output_evalues, size_t length);
164
164
165
+ /* *
166
+ * Copies the method's inputs into the provided array.
167
+ *
168
+ * WARNING: The input contains shallow copies of internal tensor inputs.
169
+ * Please do not mutate returned Tensor elements.
170
+ *
171
+ * @param[in] input_evalues The array to copy the inputs into. The first
172
+ * `inputs_size()` elements will be set to the corresponding input
173
+ * values. The rest of the array will be set to the EValue value None.
174
+ * @param[in] length The size of the `input_evalues` array in elements. Must
175
+ * be greater than or equal to `inputs_size()`.
176
+ *
177
+ * @returns Error::Ok on success, non-Ok on failure.
178
+ */
179
+ __ET_NODISCARD Error get_inputs (EValue* input_evalues, size_t length);
180
+
165
181
/* *
166
182
* Execute the method.
167
183
*
You can’t perform that action at this time.
0 commit comments