| 40 | } |
| 41 | |
| 42 | std::vector<string> GenerateInputValues( |
| 43 | const std::vector<string>& input_layer, |
| 44 | const std::vector<string>& input_layer_type, |
| 45 | const std::vector<string>& input_layer_shape) { |
| 46 | std::vector<string> input_values; |
| 47 | input_values.resize(input_layer.size()); |
| 48 | for (int i = 0; i < input_layer.size(); i++) { |
| 49 | tensorflow::DataType type; |
| 50 | CHECK(DataTypeFromString(input_layer_type[i], &type)); |
| 51 | auto shape = Split<int>(input_layer_shape[i], ","); |
| 52 | |
| 53 | switch (type) { |
| 54 | case tensorflow::DT_FLOAT: |
| 55 | GenerateCsv<float>(shape, -0.5, 0.5, &input_values[i]); |
| 56 | break; |
| 57 | case tensorflow::DT_UINT8: |
| 58 | GenerateCsv<uint8_t>(shape, 0, 255, &input_values[i]); |
| 59 | break; |
| 60 | case tensorflow::DT_INT32: |
| 61 | GenerateCsv<int32_t>(shape, -100, 100, &input_values[i]); |
| 62 | break; |
| 63 | case tensorflow::DT_INT64: |
| 64 | GenerateCsv<int64_t>(shape, -100, 100, &input_values[i]); |
| 65 | break; |
| 66 | case tensorflow::DT_BOOL: |
| 67 | GenerateCsv<int>(shape, 0.01, 1.99, &input_values[i]); |
| 68 | break; |
| 69 | default: |
| 70 | fprintf(stderr, "Unsupported type %d (%s) when generating testspec.\n", |
| 71 | type, input_layer_type[i].c_str()); |
| 72 | input_values.clear(); |
| 73 | return input_values; |
| 74 | } |
| 75 | } |
| 76 | return input_values; |
| 77 | } |
| 78 | |
| 79 | bool GenerateTestSpecFromTensorflowModel( |
| 80 | std::iostream& stream, const string& tensorflow_model_path, |
no test coverage detected