MCPcopy Create free account
hub / github.com/MegEngine/MegCC / load_setsubtensor

Function load_setsubtensor

runtime/src/vm/subtensor.c:207–240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

205
206#if ENABLE_INST_SETSUBTENSOR
207static TinyNNStatus load_setsubtensor(
208 flatbuffers_generic_t fbs_inst, Instruction* inst, VM* vm) {
209 SetSubTensor* set_subtensor = &inst->workload.set_subtensor;
210 ns(SetSubTensor_table_t) fbs_set_subtensor = (ns(SetSubTensor_table_t))(fbs_inst);
211 inst->tag = TinyNN_INST_SETSUBTENSOR;
212 flatbuffers_int32_vec_t fbs_inputs = ns(SetSubTensor_inputs(fbs_set_subtensor));
213 flatbuffers_int8_vec_t fbs_input_types =
214 ns(SetSubTensor_input_types(fbs_set_subtensor));
215 set_subtensor->nr_input = flatbuffers_int32_vec_len(fbs_inputs);
216
217 int total_input = set_subtensor->nr_input;
218 set_subtensor->inputs = tinynn_malloc(total_input * sizeof(Tensor*));
219 DeviceModel* model = get_active_device_model(vm);
220 LOG_DEBUG("\t setsubtensor inputs tensor number:%d\n", set_subtensor->nr_input);
221 //! parse the input
222 parase_inputs(
223 set_subtensor->inputs, total_input, model, vm->model, fbs_inputs,
224 fbs_input_types);
225
226 int32_t output_idx = ns(SetSubTensor_output(fbs_set_subtensor));
227 set_subtensor->output = model->tensors + output_idx;
228
229 ns(IndexDesc_vec_t) fbs_descs = ns(SetSubTensor_descs(fbs_set_subtensor));
230 ns(IndexDesc_vec_t) fbs_flags = ns(SetSubTensor_flags(fbs_set_subtensor));
231 parse_subtensor(&set_subtensor->descs, fbs_descs);
232 parse_subtensor(&set_subtensor->flags, fbs_flags);
233 TINYNN_ASSERT_MSG(
234 ns(IndexDesc_vec_len(fbs_descs)) == ns(IndexDesc_vec_len(fbs_flags)),
235 "The size of setsubtensor descs and flags is not equal.");
236 set_subtensor->nr_descs = ns(IndexDesc_vec_len(fbs_descs));
237 sort_descs(set_subtensor->descs, set_subtensor->nr_descs, set_subtensor->flags);
238
239 return TinyNN_SUCCESS;
240}
241static TinyNNStatus execute_setsubtensor(Instruction* inst, VM* vm) {
242 Tensor **inputs = inst->workload.set_subtensor.inputs,
243 *output = inst->workload.set_subtensor.output;

Callers

nothing calls this directly

Calls 5

tinynn_mallocFunction · 0.85
parase_inputsFunction · 0.85
parse_subtensorFunction · 0.85
sort_descsFunction · 0.85
get_active_device_modelFunction · 0.70

Tested by

no test coverage detected