Beispiel #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)
Beispiel #2
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 = "gpu_transfer_pre{}_post{}.pkl".format(pre_train, post_train)
    model_path = os.path.abspath(model_path)
    train_op_schedule_gpu_general_dx(entities, 20, 50, model_path,
                                     logfile="process_transfer_pre_{}_(post{})_gpu.txt".format(pre_train, post_train),
                                     device="cuda:0")
    entities = []
    for i in post_train:
        args = arg_lst[i]
        entities.append(Entity(func_names[i], args))
    model_path = "gpu_transfer0_pre{}_post{}.pkl".format(pre_train, post_train)
    model_path = os.path.abspath(model_path)
    train_op_schedule_gpu_general_dx(entities, 20, 50, model_path,
                                     logfile="process_transfer_(pre_{})_post{}_gpu.txt".format(pre_train, post_train),
                                     device="cuda: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)
def run(batch_size,
        M,
        N,
        L,
        model_path,
        epoch=5,
        sample=16,
        number=100,
        test=False):
    entities = []
    args = (batch_size, M, N, L)
    entities.append(Entity("matmul_batch", args))
    model_path = os.path.abspath(model_path)
    if not test:
        beg = time.time()
        train_op_schedule_gpu_general_dx(entities, epoch, sample, model_path)
        end = time.time()
        print("{}({}):".format("matmul_batch", args))
        print("train done! use {}ms".format((end - beg) * 1e3))
    test_graph_schedule_gpu_general_dx(entities,
                                       model_path,
                                       sampling=True,
                                       number=number)
        (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")
    #     params = [int(x) for x in args.params.split(",")]
    #     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 = [
        (1, 14, 14, 14, 1024, 1, 1, 1, 512, 1, 0),
        (1, 28, 28, 28, 512, 1, 1, 1, 256, 1, 0),
        (1, 56, 56, 56, 192, 1, 1, 1, 128, 1, 0),
    ]

    names = [
        "yolo19_b1",
        "yolo7_b1",
        "yolo3_b1",
    ]

    for i in range(len(arg_lst)):
        batch_size, height, width, depth, channel, kernel_size, _, _, output_channel, stride, padding = arg_lst[i]
        model_path = "opt_conv3d_" + names[i] + "_cpu.pkl"
        entities = []
        func = FUNC_TABLE["conv3d_channel_batch"].func
        args = arg_lst[i]
        entities.append(Entity("conv3d_channel_batch", args))
        model_path = os.path.abspath(model_path)
        train_op_schedule_cpu_general_dx(entities, 20, 50, model_path, logfile="process_conv3d_" + names[i] + "_cpu.txt", device="cuda:2")
Beispiel #7
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")
Beispiel #8
0
    # for i in range(len(arg_lst)):
    #     print(arg_lst[i])
    #     N, H, W, C, kernel_size, _, K, stride, padding = arg_lst[i]
    #     cost10 = pytorch_baseliine(N, H, W, C, kernel_size, K, stride, padding, 10)
    #     cost100 = pytorch_baseliine(N, H, W, C, kernel_size, K, stride, padding, 100)
    #     cost1000 = pytorch_baseliine(N, H, W, C, kernel_size, K, stride, padding, 1000)
    #     logs = "[10:{},100:{},1000:{}]\n".format(cost10, cost100, cost1000)
    #     with open("logs_pytorch_conv_gpu.txt", "a") as f:
    #         f.write(logs)

    for i in range(len(arg_lst)):
        model_path = "../models/opt_conv_" + names[i] + "_gpu_new.pkl"
        entities = []
        func = FUNC_TABLE["conv2d_channel_batch"].func
        args = arg_lst[i]
        entities.append(Entity("conv2d_channel_batch", args))
        model_path = os.path.abspath(model_path)
        beg = time.time()
        train_op_schedule_gpu_general_dx(entities, 10, 32, model_path)
        end = time.time()
        logs = "{}({}):\n".format("conv2d_channel_batch",
                                  args) + "train done! use {}ms\n".format(
                                      (end - beg) * 1e3)
        cost10 = test_graph_schedule_gpu_general_dx(entities,
                                                    model_path,
                                                    number=10)[0]
        cost100 = test_graph_schedule_gpu_general_dx(entities,
                                                     model_path,
                                                     number=100)[0]
        cost1000 = test_graph_schedule_gpu_general_dx(entities,
                                                      model_path,
    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")