Lines Matching refs:model

45                                            const Model& model) {  in validateGetSupportedOperations()  argument
49 model, [&](ErrorStatus status, const hidl_vec<bool>&) { in validateGetSupportedOperations()
56 const Model& model, ExecutionPreference preference, in validatePrepareModel() argument
62 device->prepareModel_1_3(model, preference, priority, {}, hidl_vec<hidl_handle>(), in validatePrepareModel()
90 Model model = originalModel; in validate() local
93 mutate(&model, &preference, &priority); in validate()
96 validateGetSupportedOperations(device, message, model); in validate()
99 validatePrepareModel(device, message, model, preference, priority); in validate()
102 static uint32_t addOperand(Model* model) { in addOperand() argument
103 return hidl_vec_push_back(&model->main.operands, in addOperand()
115 static uint32_t addOperand(Model* model, OperandLifeTime lifetime) { in addOperand() argument
116 uint32_t index = addOperand(model); in addOperand()
117 model->main.operands[index].numberOfConsumers = 1; in addOperand()
118 model->main.operands[index].lifetime = lifetime; in addOperand()
126 static size_t constantCopyExtraSize(const Model& model, size_t operandSize) { in constantCopyExtraSize() argument
127 const size_t operandValuesSize = model.operandValues.size(); in constantCopyExtraSize()
154 static void becomeConstantCopy(Model* model, Operand* operand) { in becomeConstantCopy() argument
161 if (model->operandValues.size() < sizeOfOperand) { in becomeConstantCopy()
162 model->operandValues.resize(sizeOfOperand); in becomeConstantCopy()
292 size_t sizeForBinder(const Model& model) { in sizeForBinder() argument
295 size += sizeForBinder(model.main); in sizeForBinder()
296 size += sizeForBinder(model.referenced); in sizeForBinder()
297 size += sizeForBinder(model.operandValues); in sizeForBinder()
298 size += sizeForBinder(model.pools); in sizeForBinder()
299 size += sizeForBinder(model.relaxComputationFloat32toFloat16); in sizeForBinder()
300 size += sizeForBinder(model.extensionNameToPrefix); in sizeForBinder()
333 static void mutateExecutionOrderTest(const sp<IDevice>& device, const Model& model) { in mutateExecutionOrderTest() argument
334 for (size_t operation = 0; operation < model.main.operations.size(); ++operation) { in mutateExecutionOrderTest()
335 const Operation& operationObj = model.main.operations[operation]; in mutateExecutionOrderTest()
337 if (model.main.operands[input].lifetime == OperandLifeTime::TEMPORARY_VARIABLE || in mutateExecutionOrderTest()
338 model.main.operands[input].lifetime == OperandLifeTime::SUBGRAPH_OUTPUT) { in mutateExecutionOrderTest()
346 validate(device, message, model, in mutateExecutionOrderTest()
347 [operation](Model* model, ExecutionPreference*, Priority*) { in mutateExecutionOrderTest() argument
348 auto& operations = model->main.operations; in mutateExecutionOrderTest()
356 if (model.main.operands[output].numberOfConsumers > 0) { in mutateExecutionOrderTest()
364 validate(device, message, model, in mutateExecutionOrderTest()
365 [operation](Model* model, ExecutionPreference*, Priority*) { in mutateExecutionOrderTest() argument
366 auto& operations = model->main.operations; in mutateExecutionOrderTest()
385 static void mutateOperandTypeTest(const sp<IDevice>& device, const Model& model) { in mutateOperandTypeTest() argument
386 for (size_t operand = 0; operand < model.main.operands.size(); ++operand) { in mutateOperandTypeTest()
391 validate(device, message, model, in mutateOperandTypeTest()
392 [operand, invalidOperandType](Model* model, ExecutionPreference*, Priority*) { in mutateOperandTypeTest() argument
393 model->main.operands[operand].type = in mutateOperandTypeTest()
425 static void mutateOperandRankTest(const sp<IDevice>& device, const Model& model) { in mutateOperandRankTest() argument
426 for (size_t operand = 0; operand < model.main.operands.size(); ++operand) { in mutateOperandRankTest()
427 const uint32_t invalidRank = getInvalidRank(model.main.operands[operand].type); in mutateOperandRankTest()
433 validate(device, message, model, in mutateOperandRankTest()
434 [operand, invalidRank](Model* model, ExecutionPreference*, Priority*) { in mutateOperandRankTest() argument
435 model->main.operands[operand].dimensions = in mutateOperandRankTest()
468 static void mutateOperandScaleTest(const sp<IDevice>& device, const Model& model) { in mutateOperandScaleTest() argument
469 for (size_t operand = 0; operand < model.main.operands.size(); ++operand) { in mutateOperandScaleTest()
470 const float invalidScale = getInvalidScale(model.main.operands[operand].type); in mutateOperandScaleTest()
473 validate(device, message, model, in mutateOperandScaleTest()
474 [operand, invalidScale](Model* model, ExecutionPreference*, Priority*) { in mutateOperandScaleTest() argument
475 model->main.operands[operand].scale = invalidScale; in mutateOperandScaleTest()
509 static void mutateOperandZeroPointTest(const sp<IDevice>& device, const Model& model) { in mutateOperandZeroPointTest() argument
510 for (size_t operand = 0; operand < model.main.operands.size(); ++operand) { in mutateOperandZeroPointTest()
512 getInvalidZeroPoints(model.main.operands[operand].type); in mutateOperandZeroPointTest()
517 validate(device, message, model, in mutateOperandZeroPointTest()
518 [operand, invalidZeroPoint](Model* model, ExecutionPreference*, Priority*) { in mutateOperandZeroPointTest() argument
519 model->main.operands[operand].zeroPoint = invalidZeroPoint; in mutateOperandZeroPointTest()
527 static std::vector<OperandLifeTime> getInvalidLifeTimes(const Model& model, size_t modelSize, in getInvalidLifeTimes() argument
567 exceedsBinderSizeLimit(modelSize + constantCopyExtraSize(model, operandSize))) { in getInvalidLifeTimes()
575 static void mutateOperandLifeTimeTest(const sp<IDevice>& device, const Model& model) { in mutateOperandLifeTimeTest() argument
576 const size_t modelSize = sizeForBinder(model); in mutateOperandLifeTimeTest()
577 for (size_t operand = 0; operand < model.main.operands.size(); ++operand) { in mutateOperandLifeTimeTest()
579 getInvalidLifeTimes(model, modelSize, model.main.operands[operand]); in mutateOperandLifeTimeTest()
584 toString(model.main.operands[operand].lifetime); in mutateOperandLifeTimeTest()
585 validate(device, message, model, in mutateOperandLifeTimeTest()
586 [operand, invalidLifeTime](Model* model, ExecutionPreference*, Priority*) { in mutateOperandLifeTimeTest() argument
588 Operand& operandObj = model->main.operands[operand]; in mutateOperandLifeTimeTest()
591 hidl_vec_remove(&model->main.inputIndexes, uint32_t(operand)); in mutateOperandLifeTimeTest()
595 hidl_vec_remove(&model->main.outputIndexes, uint32_t(operand)); in mutateOperandLifeTimeTest()
605 becomeConstantCopy(model, &operandObj); in mutateOperandLifeTimeTest()
609 hidl_vec_push_back(&model->main.inputIndexes, uint32_t(operand)); in mutateOperandLifeTimeTest()
612 hidl_vec_push_back(&model->main.outputIndexes, uint32_t(operand)); in mutateOperandLifeTimeTest()
624 static std::optional<OperandLifeTime> getInputOutputLifeTime(const Model& model, size_t modelSize, in getInputOutputLifeTime() argument
636 exceedsBinderSizeLimit(modelSize + constantCopyExtraSize(model, operandSize))) { in getInputOutputLifeTime()
663 static void mutateOperandInputOutputTest(const sp<IDevice>& device, const Model& model) { in mutateOperandInputOutputTest() argument
664 const size_t modelSize = sizeForBinder(model); in mutateOperandInputOutputTest()
665 for (size_t operand = 0; operand < model.main.operands.size(); ++operand) { in mutateOperandInputOutputTest()
667 getInputOutputLifeTime(model, modelSize, model.main.operands[operand]); in mutateOperandInputOutputTest()
672 toString(model.main.operands[operand].lifetime); in mutateOperandInputOutputTest()
673 validate(device, message, model, in mutateOperandInputOutputTest()
674 [operand, changedLifeTime](Model* model, ExecutionPreference*, Priority*) { in mutateOperandInputOutputTest() argument
676 Operand& operandObj = model->main.operands[operand]; in mutateOperandInputOutputTest()
680 becomeConstantCopy(model, &operandObj); in mutateOperandInputOutputTest()
697 static void mutateOperandNumberOfConsumersTest(const sp<IDevice>& device, const Model& model) { in mutateOperandNumberOfConsumersTest() argument
698 for (size_t operand = 0; operand < model.main.operands.size(); ++operand) { in mutateOperandNumberOfConsumersTest()
700 getInvalidNumberOfConsumers(model.main.operands[operand].numberOfConsumers); in mutateOperandNumberOfConsumersTest()
705 validate(device, message, model, in mutateOperandNumberOfConsumersTest()
706 [operand, invalidNumberOfConsumers](Model* model, ExecutionPreference*, in mutateOperandNumberOfConsumersTest()
708 model->main.operands[operand].numberOfConsumers = invalidNumberOfConsumers; in mutateOperandNumberOfConsumersTest()
716 static void mutateOperandAddWriterTest(const sp<IDevice>& device, const Model& model) { in mutateOperandAddWriterTest() argument
717 for (size_t operation = 0; operation < model.main.operations.size(); ++operation) { in mutateOperandAddWriterTest()
719 badOutputNum < model.main.operations[operation].outputs.size(); ++badOutputNum) { in mutateOperandAddWriterTest()
721 model.main.operations[operation].outputs[badOutputNum]; in mutateOperandAddWriterTest()
729 validate(device, message, model, in mutateOperandAddWriterTest()
730 [operation, badOutputNum](Model* model, ExecutionPreference*, Priority*) { in mutateOperandAddWriterTest() argument
731 Operation newOperation = model->main.operations[operation]; in mutateOperandAddWriterTest()
733 ++model->main.operands[input].numberOfConsumers; in mutateOperandAddWriterTest()
740 model->main.operands[newOperation.outputs[outputNum]]; in mutateOperandAddWriterTest()
749 hidl_vec_push_back(&model->main.operands, operandValue); in mutateOperandAddWriterTest()
756 hidl_vec_push_back(&model->main.operations, newOperation); in mutateOperandAddWriterTest()
826 static bool mutateOperationOperandTypeSkip(size_t operand, OperandType type, const Model& model) { in mutateOperationOperandTypeSkip() argument
828 if (type == model.main.operands[operand].type || type == OperandType::OEM || in mutateOperationOperandTypeSkip()
832 for (const Operation& operation : model.main.operations) { in mutateOperationOperandTypeSkip()
933 static void mutateOperationOperandTypeTest(const sp<IDevice>& device, const Model& model) { in mutateOperationOperandTypeTest() argument
934 for (size_t operand = 0; operand < model.main.operands.size(); ++operand) { in mutateOperationOperandTypeTest()
936 if (mutateOperationOperandTypeSkip(operand, invalidOperandType, model)) { in mutateOperationOperandTypeTest()
942 validate(device, message, model, in mutateOperationOperandTypeTest()
943 [operand, invalidOperandType](Model* model, ExecutionPreference*, Priority*) { in mutateOperationOperandTypeTest() argument
944 mutateOperand(&model->main.operands[operand], invalidOperandType); in mutateOperationOperandTypeTest()
958 static void mutateOperationTypeTest(const sp<IDevice>& device, const Model& model) { in mutateOperationTypeTest() argument
959 for (size_t operation = 0; operation < model.main.operations.size(); ++operation) { in mutateOperationTypeTest()
964 validate(device, message, model, in mutateOperationTypeTest()
965 [operation, invalidOperationType](Model* model, ExecutionPreference*, in mutateOperationTypeTest()
967 model->main.operations[operation].type = in mutateOperationTypeTest()
976 static void mutateOperationInputOperandIndexTest(const sp<IDevice>& device, const Model& model) { in mutateOperationInputOperandIndexTest() argument
977 for (size_t operation = 0; operation < model.main.operations.size(); ++operation) { in mutateOperationInputOperandIndexTest()
978 const uint32_t invalidOperand = model.main.operands.size(); in mutateOperationInputOperandIndexTest()
979 for (size_t input = 0; input < model.main.operations[operation].inputs.size(); ++input) { in mutateOperationInputOperandIndexTest()
983 validate(device, message, model, in mutateOperationInputOperandIndexTest()
984 [operation, input, invalidOperand](Model* model, ExecutionPreference*, in mutateOperationInputOperandIndexTest() argument
986 model->main.operations[operation].inputs[input] = invalidOperand; in mutateOperationInputOperandIndexTest()
994 static void mutateOperationOutputOperandIndexTest(const sp<IDevice>& device, const Model& model) { in mutateOperationOutputOperandIndexTest() argument
995 for (size_t operation = 0; operation < model.main.operations.size(); ++operation) { in mutateOperationOutputOperandIndexTest()
996 const uint32_t invalidOperand = model.main.operands.size(); in mutateOperationOutputOperandIndexTest()
997 for (size_t output = 0; output < model.main.operations[operation].outputs.size(); in mutateOperationOutputOperandIndexTest()
1002 validate(device, message, model, in mutateOperationOutputOperandIndexTest()
1003 [operation, output, invalidOperand](Model* model, ExecutionPreference*, in mutateOperationOutputOperandIndexTest() argument
1005 model->main.operations[operation].outputs[output] = invalidOperand; in mutateOperationOutputOperandIndexTest()
1013 static void mutateOperationRemoveWriteTest(const sp<IDevice>& device, const Model& model) { in mutateOperationRemoveWriteTest() argument
1014 for (size_t operation = 0; operation < model.main.operations.size(); ++operation) { in mutateOperationRemoveWriteTest()
1015 for (size_t outputNum = 0; outputNum < model.main.operations[operation].outputs.size(); in mutateOperationRemoveWriteTest()
1017 const uint32_t outputOperandIndex = model.main.operations[operation].outputs[outputNum]; in mutateOperationRemoveWriteTest()
1018 if (model.main.operands[outputOperandIndex].numberOfConsumers > 0) { in mutateOperationRemoveWriteTest()
1022 validate(device, message, model, in mutateOperationRemoveWriteTest()
1023 [operation, outputNum](Model* model, ExecutionPreference*, Priority*) { in mutateOperationRemoveWriteTest() argument
1025 model->main.operations[operation].outputs[outputNum]; in mutateOperationRemoveWriteTest()
1026 Operand operandValue = model->main.operands[outputOperandIndex]; in mutateOperationRemoveWriteTest()
1035 hidl_vec_push_back(&model->main.operands, operandValue); in mutateOperationRemoveWriteTest()
1056 static void removeOperand(Model* model, uint32_t index) { in removeOperand() argument
1057 hidl_vec_removeAt(&model->main.operands, index); in removeOperand()
1058 for (Operation& operation : model->main.operations) { in removeOperand()
1062 removeValueAndDecrementGreaterValues(&model->main.inputIndexes, index); in removeOperand()
1063 removeValueAndDecrementGreaterValues(&model->main.outputIndexes, index); in removeOperand()
1066 static bool removeOperandSkip(size_t operandIndex, const Model& model) { in removeOperandSkip() argument
1067 const Operand& operand = model.main.operands[operandIndex]; in removeOperandSkip()
1072 for (const Operation& operation : model.main.operations) { in removeOperandSkip()
1102 static void removeOperandTest(const sp<IDevice>& device, const Model& model) { in removeOperandTest() argument
1103 for (size_t operand = 0; operand < model.main.operands.size(); ++operand) { in removeOperandTest()
1104 if (removeOperandSkip(operand, model)) { in removeOperandTest()
1108 validate(device, message, model, [operand](Model* model, ExecutionPreference*, Priority*) { in removeOperandTest() argument
1109 removeOperand(model, operand); in removeOperandTest()
1116 static void removeOperation(Model* model, uint32_t index) { in removeOperation() argument
1117 for (uint32_t operand : model->main.operations[index].inputs) { in removeOperation()
1118 model->main.operands[operand].numberOfConsumers--; in removeOperation()
1120 hidl_vec_removeAt(&model->main.operations, index); in removeOperation()
1123 static void removeOperationTest(const sp<IDevice>& device, const Model& model) { in removeOperationTest() argument
1124 for (size_t operation = 0; operation < model.main.operations.size(); ++operation) { in removeOperationTest()
1126 validate(device, message, model, in removeOperationTest()
1127 [operation](Model* model, ExecutionPreference*, Priority*) { in removeOperationTest() argument
1128 removeOperation(model, operation); in removeOperationTest()
1207 static void removeOperationInputTest(const sp<IDevice>& device, const Model& model) { in removeOperationInputTest() argument
1208 for (size_t operation = 0; operation < model.main.operations.size(); ++operation) { in removeOperationInputTest()
1209 for (size_t input = 0; input < model.main.operations[operation].inputs.size(); ++input) { in removeOperationInputTest()
1210 const Operation& op = model.main.operations[operation]; in removeOperationInputTest()
1217 validate(device, message, model, in removeOperationInputTest()
1218 [operation, input](Model* model, ExecutionPreference*, Priority*) { in removeOperationInputTest() argument
1219 uint32_t operand = model->main.operations[operation].inputs[input]; in removeOperationInputTest()
1220 model->main.operands[operand].numberOfConsumers--; in removeOperationInputTest()
1221 hidl_vec_removeAt(&model->main.operations[operation].inputs, input); in removeOperationInputTest()
1229 static void removeOperationOutputTest(const sp<IDevice>& device, const Model& model) { in removeOperationOutputTest() argument
1230 for (size_t operation = 0; operation < model.main.operations.size(); ++operation) { in removeOperationOutputTest()
1231 for (size_t output = 0; output < model.main.operations[operation].outputs.size(); in removeOperationOutputTest()
1236 validate(device, message, model, in removeOperationOutputTest()
1237 [operation, output](Model* model, ExecutionPreference*, Priority*) { in removeOperationOutputTest() argument
1238 hidl_vec_removeAt(&model->main.operations[operation].outputs, output); in removeOperationOutputTest()
1266 static void addOperationInputTest(const sp<IDevice>& device, const Model& model) { in addOperationInputTest() argument
1267 for (size_t operation = 0; operation < model.main.operations.size(); ++operation) { in addOperationInputTest()
1268 if (addOperationInputSkip(model.main.operations[operation])) { in addOperationInputTest()
1272 validate(device, message, model, in addOperationInputTest()
1273 [operation](Model* model, ExecutionPreference*, Priority*) { in addOperationInputTest() argument
1274 uint32_t index = addOperand(model, OperandLifeTime::SUBGRAPH_INPUT); in addOperationInputTest()
1275 hidl_vec_push_back(&model->main.operations[operation].inputs, index); in addOperationInputTest()
1276 hidl_vec_push_back(&model->main.inputIndexes, index); in addOperationInputTest()
1283 static void addOperationOutputTest(const sp<IDevice>& device, const Model& model) { in addOperationOutputTest() argument
1284 for (size_t operation = 0; operation < model.main.operations.size(); ++operation) { in addOperationOutputTest()
1287 validate(device, message, model, in addOperationOutputTest()
1288 [operation](Model* model, ExecutionPreference*, Priority*) { in addOperationOutputTest() argument
1289 uint32_t index = addOperand(model, OperandLifeTime::SUBGRAPH_OUTPUT); in addOperationOutputTest()
1290 hidl_vec_push_back(&model->main.operations[operation].outputs, index); in addOperationOutputTest()
1291 hidl_vec_push_back(&model->main.outputIndexes, index); in addOperationOutputTest()
1303 static void mutateExecutionPreferenceTest(const sp<IDevice>& device, const Model& model) { in mutateExecutionPreferenceTest() argument
1307 validate(device, message, model, in mutateExecutionPreferenceTest()
1321 static void mutateExecutionPriorityTest(const sp<IDevice>& device, const Model& model) { in mutateExecutionPriorityTest() argument
1325 validate(device, message, model, in mutateExecutionPriorityTest()
1334 void validateModel(const sp<IDevice>& device, const Model& model) { in validateModel() argument
1335 mutateExecutionOrderTest(device, model); in validateModel()
1336 mutateOperandTypeTest(device, model); in validateModel()
1337 mutateOperandRankTest(device, model); in validateModel()
1338 mutateOperandScaleTest(device, model); in validateModel()
1339 mutateOperandZeroPointTest(device, model); in validateModel()
1340 mutateOperandLifeTimeTest(device, model); in validateModel()
1341 mutateOperandInputOutputTest(device, model); in validateModel()
1342 mutateOperandNumberOfConsumersTest(device, model); in validateModel()
1343 mutateOperandAddWriterTest(device, model); in validateModel()
1344 mutateOperationOperandTypeTest(device, model); in validateModel()
1345 mutateOperationTypeTest(device, model); in validateModel()
1346 mutateOperationInputOperandIndexTest(device, model); in validateModel()
1347 mutateOperationOutputOperandIndexTest(device, model); in validateModel()
1348 mutateOperationRemoveWriteTest(device, model); in validateModel()
1349 removeOperandTest(device, model); in validateModel()
1350 removeOperationTest(device, model); in validateModel()
1351 removeOperationInputTest(device, model); in validateModel()
1352 removeOperationOutputTest(device, model); in validateModel()
1353 addOperationInputTest(device, model); in validateModel()
1354 addOperationOutputTest(device, model); in validateModel()
1355 mutateExecutionPreferenceTest(device, model); in validateModel()
1356 mutateExecutionPriorityTest(device, model); in validateModel()