| 97 | } |
| 98 | |
| 99 | static 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 | |
| 133 | static TinyNNStatus execute_subtensor(Instruction* inst, VM* vm) { |
| 134 | Tensor **inputs = inst->workload.subtensor.inputs, |
nothing calls this directly
no test coverage detected