import os
import numpy as np
def gen_golden_data_simple():
input_dtype = np.float32
output_dtype = np.float32
input_shape = [16, 31]
output_shape = [16, 32]
input_x = np.arange(0, input_shape[0] * input_shape[1], 1, input_dtype).reshape(input_shape[0], input_shape[1])
golden = np.arange(0, output_shape[0] * output_shape[1], 1, output_dtype).reshape(output_shape[0], output_shape[1])
height = input_shape[0]
width = input_shape[1]
left_pad = 0
right_pad = 1
pad_value = 321
if width * (np.dtype(input_dtype).itemsize) % 32 == 0:
ori_width = input_shape[2]
for i in range(0, height):
for j in range(0, width):
if j >= ori_width and j <= ori_width + right_pad:
golden[i][j] = pad_value
if j < width:
input_x[i][j] = 0
else:
golden[i][j] = input_x[i][j]
else:
golden = np.zeros((output_shape[0], output_shape[1]), dtype = input_dtype)
for i in range(0, height):
for j in range(0, width + left_pad + right_pad):
if j <= left_pad - 1 or j >= width + left_pad:
golden[i][j] = pad_value
else:
golden[i][j] = input_x[i][j - left_pad]
os.makedirs("input", exist_ok=True)
input_x.tofile("./input/input_x.bin")
os.makedirs("output", exist_ok=True)
golden.tofile("./output/golden.bin")
if __name__ == "__main__":
gen_golden_data_simple()