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

Function load_subtensor

runtime/src/vm/subtensor.c:99–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97}
98
99static TinyNNStatus load_subtensor(
100 flatbuffers_generic_t fbs_inst, Instruction* inst, VM* vm) {
101 SubTensor* subtensor = &inst->workload.subtensor;
102 ns(SubTensor_table_t) fbs_subtensor = (ns(SubTensor_table_t))(fbs_inst);
103 inst->tag = TinyNN_INST_SUBTENSOR;
104 flatbuffers_int32_vec_t fbs_inputs = ns(SubTensor_inputs(fbs_subtensor));
105 flatbuffers_int8_vec_t fbs_input_types = ns(SubTensor_input_types(fbs_subtensor));
106 subtensor->nr_input = flatbuffers_int32_vec_len(fbs_inputs);
107
108 int total_input = subtensor->nr_input;
109 subtensor->inputs = tinynn_malloc(total_input * sizeof(Tensor*));
110 DeviceModel* model = get_active_device_model(vm);
111 LOG_DEBUG("\t subtensor inputs tensor number:%d\n", subtensor->nr_input);
112 //! parse the input
113 parase_inputs(
114 subtensor->inputs, total_input, model, vm->model, fbs_inputs,
115 fbs_input_types);
116
117 int32_t output_idx = ns(SubTensor_output(fbs_subtensor));
118 subtensor->output = model->tensors + output_idx;
119
120 ns(IndexDesc_vec_t) fbs_descs = ns(SubTensor_descs(fbs_subtensor));
121 ns(IndexDesc_vec_t) fbs_flags = ns(SubTensor_flags(fbs_subtensor));
122 parse_subtensor(&subtensor->descs, fbs_descs);
123 parse_subtensor(&subtensor->flags, fbs_flags);
124 subtensor->nr_descs = ns(IndexDesc_vec_len(fbs_descs));
125 TINYNN_ASSERT_MSG(
126 ns(IndexDesc_vec_len(fbs_descs)) == ns(IndexDesc_vec_len(fbs_flags)),
127 "The size of subtensor descs and flags is not equal.");
128 sort_descs(subtensor->descs, subtensor->nr_descs, subtensor->flags);
129
130 return TinyNN_SUCCESS;
131}
132
133static TinyNNStatus execute_subtensor(Instruction* inst, VM* vm) {
134 Tensor **inputs = inst->workload.subtensor.inputs,

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