コード例 #1
0
def run(batch_size,
        height,
        width,
        channel,
        kernel_size,
        output_channel,
        stride,
        padding,
        model_path,
        epoch=5,
        sample_size=16,
        number=100,
        test=False):
    entities = []
    func = FUNC_TABLE["conv2d_channel_batch"].func
    args = (batch_size, height, width, channel, kernel_size, kernel_size,
            output_channel, stride, padding)
    entities.append(Entity("conv2d_channel_batch", args))
    model_path = os.path.abspath(model_path)
    if not test:
        beg = time.time()
        train_op_schedule_cpu_general_dx(entities, epoch, sample_size,
                                         model_path)
        end = time.time()
        print("{}({}):".format("conv2d_channel_batch", args))
        print("train done! use {}ms".format((end - beg) * 1e3))
    test_graph_schedule_cpu_general_dx(func, args, model_path, number=number)
コード例 #2
0
def run(M, N, k, model_path, epoch=5, sample_size=16, number=100, test=False):
    entities = []
    func = FUNC_TABLE["gaussian_blur2d"].func
    args = (M, N, k)
    entities.append(Entity("gaussian_blur2d", args))
    model_path = os.path.abspath(model_path)
    if not test:
        beg = time.time()
        train_op_schedule_cpu_general_dx(entities, epoch, sample_size,
                                         model_path)
        end = time.time()
        print("{}({}):".format("gaussian_blur2d", args))
        print("train done! use {}ms".format((end - beg) * 1e3))
    test_graph_schedule_cpu_general_dx(func, args, model_path, number=number)
コード例 #3
0
def transfer(pre_train, post_train):
    entities = []
    for i in pre_train:
        args = arg_lst[i]
        entities.append(Entity(func_names[i], args))
    model_path = "cpu_transfer_pre{}_post{}.pkl".format(pre_train, post_train)
    model_path = os.path.abspath(model_path)
    train_op_schedule_cpu_general_dx(entities, 20, 50, model_path,
                                     logfile="process_transfer_pre{}_(post{})_cpu.txt".format(pre_train, post_train),
                                     device="cuda:3")
    entities = []
    for i in post_train:
        args = arg_lst[i]
        entities.append(Entity(func_names[i], args))
    model_path = "cpu_transfer_pre{}_post{}.pkl".format(pre_train, post_train)
    model_path = os.path.abspath(model_path)
    train_op_schedule_cpu_general_dx(entities, 20, 50, model_path,
                                     logfile="process_transfer_(pre_{})_post{}_cpu.txt".format(pre_train, post_train),
                                     device="cuda:3")
コード例 #4
0
        (1, 1024, 1024, 1024),
        (1, 2048, 2048, 2048),
        (1, 4096, 4096, 4096),
        (1, 1024, 32, 1024),
        (1, 32, 1024, 32),
    ]

    names = [
        "128_128_128_b1",
        "256_256_256_b1",
        "512_512_512_b1",
        "1024_1024_1024_b1",
        "2048_2048_2048_b1",
        "4096_4096_4096_b1",
        "1024_32_1024_b1",
        "32_1024_32_b1",
    ]
    for i in range(len(arg_lst)):
        model_path = "opt_gemm_" + names[i] + "_cpu.pkl"
        entities = []
        args = arg_lst[i]
        entities.append(Entity("matmul_batch", args))
        model_path = os.path.abspath(model_path)
        train_op_schedule_cpu_general_dx(entities,
                                         20,
                                         50,
                                         model_path,
                                         logfile="process_gemm_" + names[i] +
                                         "_cpu.txt",
                                         device="cuda:0")
コード例 #5
0
    #     batch_size, height, width, depth, channel, kernel_size, output_channel, stride, padding = params
    #     if use_torch:
    #         pytorch_baseliine(batch_size, height, width, depth, channel, kernel_size, output_channel, stride, padding, args.number)
    #     if use_auto:
    #         run(batch_size, height, width, depth, channel, kernel_size, output_channel, stride, padding,
    #             args.model_file_path, args.epoch, args.sample, args.number, test)
    # except Exception as e:
    #     raise ValueError("Bad parameters, please refer to usage")
    arg_lst = [
        (512, 512),
        (1024, 1024),
        (2048, 2048),
    ]

    names = ["512", "1024", "2048"]

    for i in range(len(arg_lst)):
        model_path = "opt_outer_" + names[i] + "_cpu.pkl"
        entities = []
        func = FUNC_TABLE["outer_product"].func
        args = arg_lst[i]
        entities.append(Entity("outer_product", args))
        model_path = os.path.abspath(model_path)
        train_op_schedule_cpu_general_dx(entities,
                                         10,
                                         20,
                                         model_path,
                                         logfile="process_outer_" + names[i] +
                                         "_cpu.txt",
                                         device="cuda:1")
コード例 #6
0
    use_auto = args.auto_schedule
    try:
        params = [int(x) for x in args.params.split(",")]
    except Exception as e:
        raise ValueError("Bad parameters, please refer to usage")
    M, N, K, L = params
    if use_numpy:
        cost = numpy_baseline(M, N, K, L, args.number)
    if use_auto:
        run(M, N, K, L, args.model_file_path, args.epoch, args.sample,
            args.number, test)

    arg_lst = [(1024, 1024, 8, 8), (32, 32, 32, 32), (256, 256, 16, 32)]

    names = ["1024_1024_8_8", "32_32_32_32", "256_256_16_32"]

    for i in range(len(arg_lst)):
        model_path = "../models/opt_mttkrp3_" + names[i] + "_cpu_process.pkl"
        entities = []
        func = FUNC_TABLE["dense_MTTKRP3"].func
        args = arg_lst[i]
        entities.append(Entity("dense_MTTKRP3", args))
        model_path = os.path.abspath(model_path)
        train_op_schedule_cpu_general_dx(entities,
                                         5,
                                         32,
                                         model_path,
                                         logfile="process_mttkrp_" + names[i] +
                                         "_cpu.txt",
                                         device="cuda:2")