| 16 | using namespace CoreML; |
| 17 | |
| 18 | int testSimpleNNShape() { |
| 19 | |
| 20 | Specification::Model m1; |
| 21 | |
| 22 | auto *topIn = m1.mutable_description()->add_input(); |
| 23 | topIn->set_name("input"); |
| 24 | auto *shape = topIn->mutable_type()->mutable_multiarraytype(); |
| 25 | shape->add_shape(4); |
| 26 | |
| 27 | auto *out = m1.mutable_description()->add_output(); |
| 28 | out->set_name("output"); |
| 29 | auto *outshape = out->mutable_type()->mutable_multiarraytype(); |
| 30 | outshape->add_shape(3); |
| 31 | |
| 32 | auto *nn = m1.mutable_neuralnetwork(); |
| 33 | |
| 34 | Specification::NeuralNetworkLayer *innerProductLayer = nn->add_layers(); |
| 35 | innerProductLayer->add_input("input"); |
| 36 | innerProductLayer->add_output("output"); |
| 37 | Specification::InnerProductLayerParams *innerProductParams = innerProductLayer->mutable_innerproduct(); |
| 38 | innerProductParams->set_inputchannels(4); |
| 39 | innerProductParams->set_outputchannels(3); |
| 40 | for (int i = 0; i < 12; i++) { |
| 41 | innerProductParams->mutable_weights()->add_floatvalue(1.0); |
| 42 | } |
| 43 | |
| 44 | innerProductParams->set_hasbias(false); |
| 45 | |
| 46 | Result res = validate<MLModelType_neuralNetwork>(m1); |
| 47 | ML_ASSERT_GOOD(res); |
| 48 | |
| 49 | NeuralNetworkShaper shapes = NeuralNetworkShaper(m1); |
| 50 | |
| 51 | ML_ASSERT(shapes.isValid()); |
| 52 | |
| 53 | return 0; |
| 54 | |
| 55 | } |
| 56 | |
| 57 | int testSimpleNNShapeBad() { |
| 58 |
nothing calls this directly
no test coverage detected