(input_file, input_node, input_shape, input_ranges,
input_data_type)
| 225 | |
| 226 | |
| 227 | def generate_input_data(input_file, input_node, input_shape, input_ranges, |
| 228 | input_data_type): |
| 229 | np.random.seed() |
| 230 | for i in range(len(input_node)): |
| 231 | data = np.random.random(input_shape[i]) * ( |
| 232 | input_ranges[i][1] - input_ranges[i][0]) + input_ranges[i][0] |
| 233 | input_file_name = util.formatted_file_name(input_file, input_node[i]) |
| 234 | MaceLogger.info('Generate input file: %s' % input_file_name) |
| 235 | if input_data_type[i] == mace_pb2.DT_FLOAT or \ |
| 236 | input_data_type[i] == mace_pb2.DT_FLOAT16 or \ |
| 237 | input_data_type[i] == mace_pb2.DT_BFLOAT16: |
| 238 | np_data_type = np.float32 |
| 239 | elif input_data_type[i] == mace_pb2.DT_INT32: |
| 240 | np_data_type = np.int32 |
| 241 | else: |
| 242 | mace_check(False, "Invalid input_data_type[%s]: %s" % |
| 243 | (i, input_data_type[i])) |
| 244 | |
| 245 | data.astype(np_data_type).tofile(input_file_name) |
| 246 | |
| 247 | |
| 248 | def parse_args(): |
no test coverage detected