import os
import sys
import numpy as np
def gen_golden_data_simple():
np.set_printoptions(threshold=sys.maxsize)
shape = 32
mode = 0
count = 32
dtype = np.float32
is_dynamic = 0
tiling = np.array([shape, count, mode, is_dynamic], dtype="uint32")
src0 = np.random.uniform(10.0, 20.0, [32]).astype(dtype)
src1 = np.random.uniform(0, 10.0, [32]).astype(dtype)
condition = np.random.choice([True, False], size=shape)
golden = np.zeros([32]).astype(dtype)
if mode == 0:
golden = np.where(condition, src0, src1)
elif mode == 1:
src0_val = src0[0]
golden = np.where(condition, src0_val, src1)
elif mode == 2:
src1_val = src1[0]
golden = np.where(condition, src0, src1_val)
else:
src0_val = src0[0]
src1_val = src1[0]
golden = np.where(condition, src0_val, src1_val)
for i in range(shape - count):
golden[count + i] = 0
os.makedirs("input", exist_ok=True)
src0.tofile("./input/input_src0.bin")
src1.tofile("./input/input_src1.bin")
condition.tofile("./input/input_condition.bin")
tiling.tofile("./input/input_tiling.bin")
os.makedirs("output", exist_ok=True)
golden.tofile("./output/golden.bin")
if __name__ == "__main__":
gen_golden_data_simple()