| 347 | } |
| 348 | |
| 349 | int testDefaultOptionalValueGood() { |
| 350 | |
| 351 | Specification::Model m; |
| 352 | |
| 353 | auto *in1 = m.mutable_description()->add_input(); |
| 354 | in1->set_name("input1"); |
| 355 | auto *inShape1 = in1->mutable_type()->mutable_multiarraytype(); |
| 356 | inShape1->set_datatype(Specification::ArrayFeatureType::ArrayDataType::ArrayFeatureType_ArrayDataType_FLOAT32); |
| 357 | inShape1->add_shape(3); |
| 358 | inShape1->add_shape(5); |
| 359 | inShape1->add_shape(2); |
| 360 | |
| 361 | auto *in2 = m.mutable_description()->add_input(); |
| 362 | in2->set_name("input2"); |
| 363 | auto type = in2->mutable_type(); |
| 364 | type->set_isoptional(true); |
| 365 | auto arr = type->mutable_multiarraytype(); |
| 366 | arr->set_datatype(Specification::ArrayFeatureType::ArrayDataType::ArrayFeatureType_ArrayDataType_INT32); |
| 367 | arr->set_intdefaultvalue(2); |
| 368 | arr->add_shape(3); |
| 369 | arr->add_shape(5); |
| 370 | arr->add_shape(2); |
| 371 | |
| 372 | auto *out = m.mutable_description()->add_output(); |
| 373 | out->set_name("output"); |
| 374 | auto *outShape = out->mutable_type()->mutable_multiarraytype(); |
| 375 | outShape->set_datatype(Specification::ArrayFeatureType::ArrayDataType::ArrayFeatureType_ArrayDataType_FLOAT32); |
| 376 | outShape->add_shape(3); |
| 377 | outShape->add_shape(5); |
| 378 | outShape->add_shape(1); |
| 379 | |
| 380 | const auto nn = m.mutable_neuralnetwork(); |
| 381 | nn->set_arrayinputshapemapping(Specification::NeuralNetworkMultiArrayShapeMapping::EXACT_ARRAY_MAPPING); |
| 382 | |
| 383 | auto *layers = nn->add_layers(); |
| 384 | layers->add_input("input1"); |
| 385 | layers->add_input("input2"); |
| 386 | layers->add_output("output"); |
| 387 | layers->add_inputtensor()->set_rank(3); |
| 388 | layers->add_inputtensor()->set_rank(3); |
| 389 | |
| 390 | auto *params = layers->mutable_stack(); |
| 391 | params->set_axis(2); |
| 392 | |
| 393 | m.set_specificationversion(5); |
| 394 | // axis should be in range [-(rank + 1), rank + 1) |
| 395 | Result res = Model::validate(m); |
| 396 | ML_ASSERT_GOOD(res); |
| 397 | return 0; |
| 398 | } |
| 399 | |
| 400 | int testNNValidatorMissingInput() { |
| 401 | |