renfeier commented on PR #11793:
URL: https://github.com/apache/tvm/pull/11793#issuecomment-1198861264

   hi, @ArmageddonKnight 
   it seems the tvm transform config "tir.enable_local_pad "does not work since 
the same schedule build  result kernel src code are the same when set config 
tir.enable.lcal_pad true/false, when i use the test example you upload before, 
example code will show belows:
    -------------------------------------------------
    def save_kernel_source(kernel, log_kernel_filename):
        kernel_src=kernel.imported_modules[0].get_source()
        if log_kernel_filename is not None:
            with open(log_kernel_filename, 'w') as fout:
                fout.write("{}".format(kernel_src))
        else:
            print({}.format(kernel_src))
   
    @tvm.testing.requires_gpu
    @tvm.testing.requires_cuda
    def test_dense_local_padding():
        """
        Test that local padding is delivering the correct compute outcome.
        """
        x_np = np.random.uniform(-0.1, 0.1, size=(960, 770)).astype(np.float32)
        w_np = np.random.uniform(-0.1, 0.1, size=(770, 2304)).astype(np.float32)
        y_np = np.matmul(x_np, w_np)
        y_empty = np.empty(shape=y_np.shape, dtype=y_np.dtype)
        tir_sched = Schedule(Dense_960x770x2304)
        sample_dense_sched(tir_sched)
        with tvm.transform.PassContext(config={"tir.enable_local_pad": False}):
            nopad_cuda_kernel = tvm.build(tir_sched.mod["main"], [], 
target="cuda")
            save_kernel_source(nopad_cuda_kernel, "nolocalpad_kernel.cu")
        with tvm.transform.PassContext(config={"tir.enable_local_pad": True}):
            cuda_kernel = tvm.build(tir_sched.mod["main"], [], target="cuda")
            save_kernel_source(cuda_kernel, "localpad_kernel.cu")
    
        cuda_ctx = tvm.cuda()
        module_data = [x_np, w_np, y_empty]
        module_data = [tvm.nd.array(d, device=cuda_ctx) for d in module_data]
        cuda_kernel(*module_data)
        np.testing.assert_allclose(module_data[-1].numpy(), y_np, atol=1e-3, 
rtol=1e-3)
   
---------------------------------------------------------------------------------------
   the localpad_kernel.cu are same with nolocalpad_kernel.cu


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to