MCPcopy Create free account
hub / github.com/XiaoMi/mace / generate_data

Function generate_data

tools/generate_data.py:32–47  ·  view source on GitHub ↗
(name, shape, input_file, tensor_range, input_data_type)

Source from the content-addressed store, hash-verified

30
31
32def generate_data(name, shape, input_file, tensor_range, input_data_type):
33 np.random.seed()
34 data = np.random.random(shape) * (tensor_range[1] - tensor_range[0]) \
35 + tensor_range[0]
36 input_file_name = common.formatted_file_name(input_file, name)
37 six.print_('Generate input file: ', input_file_name)
38 if input_data_type == 'float32' or input_data_type == 'float16' or \
39 input_data_type == 'bfloat16':
40 np_data_type = np.float32
41 elif input_data_type == 'int32':
42 np_data_type = np.int32
43 elif input_data_type == 'int16':
44 np_data_type = np.int16
45 elif input_data_type == 'uint8':
46 np_data_type = np.uint8
47 data.astype(np_data_type).tofile(input_file_name)
48
49
50def generate_input_data(input_file, input_node, input_shape, input_ranges,

Callers 1

generate_input_dataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected