def method_paravartya_transpose():
    """
    Paravartya: Transpose and apply.
    Rearrange data layout for contiguous memory access.
    """
    # Convert from (B,C,H,W) to (B,H,W,C) - better for sliding windows
    x_t = x.permute(0, 2, 3, 1).contiguous()  # (B,H,W,C)
    w_t = w.permute(2, 3, 1, 0).contiguous()  # (kH,kW,C,K)
    
    # Pad and prepare
    x_padded = torch.nn.functional.pad(x_t, (0, 0, 1, 1, 1, 1))  # (B,H+2,W+2,C)
    
    # Now perform convolution with transposed layout
    out_list = []
    for b in range(B):
        for i in range(H):
            for j in range(W):
                # Extract patch and multiply
                patch = x_padded[b, i:i+kH, j:j+kW, :]  # (kH, kW, C)
                # Vectorized over all K filters
                out_patch = torch.einsum('hwc,cok->ok', patch, w_t)
                out_list.append(out_patch)
    
    # Reshape - this is the slow part, but shows the concept
    out_H, out_W = H, W
    result = torch.stack(out_list).view(B, out_H, out_W, K).permute(0, 3, 1, 2)
    return result

_ = benchmark(method_paravartya_transpose, "Paravartya transpose layout", runs=50)
