import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda
reinterpret_tensor = torch._C._dynamo.guards._reinterpret_tensor


@triton.jit
def triton_poi_fused_cat_0(in_ptr0, in_ptr1, in_ptr2, in_ptr3, in_ptr4,
    in_ptr5, in_ptr6, in_ptr7, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x1 = xindex // 4096 % 32
    x0 = xindex % 4096
    x2 = xindex // 131072
    x3 = xindex
    tmp0 = x1
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 4, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (x0 + 4096 * x1 + 16384 * x2), tmp4, other=0.0)
    tmp6 = tmp0 >= tmp3
    tmp7 = tl.full([1], 8, tl.int64)
    tmp8 = tmp0 < tmp7
    tmp9 = tmp6 & tmp8
    tmp10 = tl.load(in_ptr1 + (x0 + 4096 * (-4 + x1) + 16384 * x2), tmp9,
        other=0.0)
    tmp11 = tmp0 >= tmp7
    tmp12 = tl.full([1], 12, tl.int64)
    tmp13 = tmp0 < tmp12
    tmp14 = tmp11 & tmp13
    tmp15 = tl.load(in_ptr2 + (x0 + 4096 * (-8 + x1) + 16384 * x2), tmp14,
        other=0.0)
    tmp16 = tmp0 >= tmp12
    tmp17 = tl.full([1], 16, tl.int64)
    tmp18 = tmp0 < tmp17
    tmp19 = tmp16 & tmp18
    tmp20 = tl.load(in_ptr3 + (x0 + 4096 * (-12 + x1) + 16384 * x2), tmp19,
        other=0.0)
    tmp21 = tmp0 >= tmp17
    tmp22 = tl.full([1], 20, tl.int64)
    tmp23 = tmp0 < tmp22
    tmp24 = tmp21 & tmp23
    tmp25 = tl.load(in_ptr4 + (x0 + 4096 * (-16 + x1) + 16384 * x2), tmp24,
        other=0.0)
    tmp26 = tmp0 >= tmp22
    tmp27 = tl.full([1], 24, tl.int64)
    tmp28 = tmp0 < tmp27
    tmp29 = tmp26 & tmp28
    tmp30 = tl.load(in_ptr5 + (x0 + 4096 * (-20 + x1) + 16384 * x2), tmp29,
        other=0.0)
    tmp31 = tmp0 >= tmp27
    tmp32 = tl.full([1], 28, tl.int64)
    tmp33 = tmp0 < tmp32
    tmp34 = tmp31 & tmp33
    tmp35 = tl.load(in_ptr6 + (x0 + 4096 * (-24 + x1) + 16384 * x2), tmp34,
        other=0.0)
    tmp36 = tmp0 >= tmp32
    tl.full([1], 32, tl.int64)
    tmp39 = tl.load(in_ptr7 + (x0 + 4096 * (-28 + x1) + 16384 * x2), tmp36,
        other=0.0)
    tmp40 = tl.where(tmp34, tmp35, tmp39)
    tmp41 = tl.where(tmp29, tmp30, tmp40)
    tmp42 = tl.where(tmp24, tmp25, tmp41)
    tmp43 = tl.where(tmp19, tmp20, tmp42)
    tmp44 = tl.where(tmp14, tmp15, tmp43)
    tmp45 = tl.where(tmp9, tmp10, tmp44)
    tmp46 = tl.where(tmp4, tmp5, tmp45)
    tl.store(out_ptr0 + x3, tmp46, None)


@triton.jit
def triton_red_fused_native_group_norm_1(in_ptr0, out_ptr0, out_ptr1,
    out_ptr2, xnumel, rnumel, XBLOCK: tl.constexpr, RBLOCK: tl.constexpr):
    xnumel = 128
    rnumel = 8192
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    rbase = tl.arange(0, RBLOCK)[None, :]
    x0 = xindex
    tmp2_mean = tl.zeros([XBLOCK, RBLOCK], tl.float32)
    tmp2_m2 = tl.zeros([XBLOCK, RBLOCK], tl.float32)
    tmp2_weight = tl.zeros([XBLOCK, RBLOCK], tl.float32)
    for roffset in range(0, rnumel, RBLOCK):
        rindex = roffset + rbase
        rmask = rindex < rnumel
        r1 = rindex
        tmp0 = tl.load(in_ptr0 + (r1 + 8192 * x0), rmask & xmask,
            eviction_policy='evict_first', other=0.0)
        tmp1 = tl.broadcast_to(tmp0, [XBLOCK, RBLOCK])
        tmp2_mean_next, tmp2_m2_next, tmp2_weight_next = (triton_helpers.
            welford_reduce(tmp1, tmp2_mean, tmp2_m2, tmp2_weight, roffset == 0)
            )
        tmp2_mean = tl.where(rmask & xmask, tmp2_mean_next, tmp2_mean)
        tmp2_m2 = tl.where(rmask & xmask, tmp2_m2_next, tmp2_m2)
        tmp2_weight = tl.where(rmask & xmask, tmp2_weight_next, tmp2_weight)
    tmp2_tmp, tmp3_tmp, tmp4_tmp = triton_helpers.welford(tmp2_mean,
        tmp2_m2, tmp2_weight, 1)
    tmp2 = tmp2_tmp[:, None]
    tmp3 = tmp3_tmp[:, None]
    tmp4 = tmp4_tmp[:, None]
    tl.store(out_ptr0 + x0, tmp2, xmask)
    tl.store(out_ptr1 + x0, tmp3, xmask)
    tl.store(out_ptr2 + x0, tmp4, xmask)


@triton.jit
def triton_per_fused_native_group_norm_2(in_ptr0, in_ptr1, in_ptr2,
    out_ptr0, out_ptr1, out_ptr2, xnumel, rnumel, XBLOCK: tl.constexpr):
    xnumel = 32
    RBLOCK: tl.constexpr = 4
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    rindex = tl.arange(0, RBLOCK)[None, :]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r1 = rindex
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + (r1 + 4 * x0), xmask, other=0.0)
    tmp1 = tl.load(in_ptr1 + (r1 + 4 * x0), xmask, other=0.0)
    tmp2 = tl.load(in_ptr2 + (r1 + 4 * x0), xmask, other=0.0)
    tmp3 = tl.broadcast_to(tmp0, [XBLOCK, RBLOCK])
    tmp4 = tl.broadcast_to(tmp1, [XBLOCK, RBLOCK])
    tmp5 = tl.broadcast_to(tmp2, [XBLOCK, RBLOCK])
    tmp7 = tl.where(xmask, tmp3, 0)
    tmp8 = tl.where(xmask, tmp4, 0)
    tmp9 = tl.where(xmask, tmp5, 0)
    tmp10, tmp11, tmp12 = triton_helpers.welford(tmp7, tmp8, tmp9, 1)
    tmp13 = tmp10[:, None]
    tmp14 = tmp11[:, None]
    tmp12[:, None]
    tmp16 = 32768.0
    tmp17 = tmp14 / tmp16
    tmp18 = 1e-05
    tmp19 = tmp17 + tmp18
    tmp20 = libdevice.rsqrt(tmp19)
    tl.store(out_ptr2 + x0, tmp20, xmask)
    tl.store(out_ptr0 + x0, tmp13, xmask)
    tl.store(out_ptr1 + x0, tmp14, xmask)


@triton.jit
def triton_poi_fused_add_native_group_norm_3(in_ptr0, in_ptr1, in_ptr2,
    in_ptr3, in_ptr4, in_ptr5, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x3 = xindex
    x4 = xindex // 4096
    x1 = xindex // 4096 % 64
    tmp0 = tl.load(in_ptr0 + x3, None)
    tmp1 = tl.load(in_ptr1 + x4 // 8, None, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr2 + x4 // 8, None, eviction_policy='evict_last')
    tmp10 = tl.load(in_ptr3 + x1, None, eviction_policy='evict_last')
    tmp12 = tl.load(in_ptr4 + x1, None, eviction_policy='evict_last')
    tmp14 = tl.load(in_ptr5 + x3, None)
    tmp2 = tmp0 - tmp1
    tmp4 = 32768.0
    tmp5 = tmp3 / tmp4
    tmp6 = 1e-05
    tmp7 = tmp5 + tmp6
    tmp8 = libdevice.rsqrt(tmp7)
    tmp9 = tmp2 * tmp8
    tmp11 = tmp9 * tmp10
    tmp13 = tmp11 + tmp12
    tmp15 = tmp13 + tmp14
    tl.store(out_ptr0 + x3, tmp15, None)


@triton.jit
def triton_poi_fused_transpose_4(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.
    constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x0 = xindex % 16384
    x1 = xindex // 16384
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + (114688 + x0 + 131072 * x1), None)
    tl.store(out_ptr0 + x2, tmp0, None)


@triton.jit
def triton_poi_fused_transpose_5(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.
    constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x0 = xindex % 16384
    x1 = xindex // 16384
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + (98304 + x0 + 131072 * x1), None)
    tl.store(out_ptr0 + x2, tmp0, None)


@triton.jit
def triton_poi_fused_transpose_6(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.
    constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x0 = xindex % 16384
    x1 = xindex // 16384
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + (81920 + x0 + 131072 * x1), None)
    tl.store(out_ptr0 + x2, tmp0, None)


@triton.jit
def triton_poi_fused_transpose_7(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.
    constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x0 = xindex % 16384
    x1 = xindex // 16384
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + (65536 + x0 + 131072 * x1), None)
    tl.store(out_ptr0 + x2, tmp0, None)


@triton.jit
def triton_poi_fused_transpose_8(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.
    constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x0 = xindex % 16384
    x1 = xindex // 16384
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + (49152 + x0 + 131072 * x1), None)
    tl.store(out_ptr0 + x2, tmp0, None)


@triton.jit
def triton_poi_fused_transpose_9(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.
    constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x0 = xindex % 16384
    x1 = xindex // 16384
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + (32768 + x0 + 131072 * x1), None)
    tl.store(out_ptr0 + x2, tmp0, None)


@triton.jit
def triton_poi_fused_transpose_10(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.
    constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x0 = xindex % 16384
    x1 = xindex // 16384
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + (16384 + x0 + 131072 * x1), None)
    tl.store(out_ptr0 + x2, tmp0, None)


@triton.jit
def triton_poi_fused_transpose_11(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.
    constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x0 = xindex % 16384
    x1 = xindex // 16384
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 + 131072 * x1), None)
    tl.store(out_ptr0 + x2, tmp0, None)


def call(args):
    (primals_1, primals_2, primals_3, primals_4, primals_5, primals_6,
        primals_7) = args
    args.clear()
    assert_size_stride(primals_1, (4, 64, 64, 64), (262144, 4096, 64, 1))
    assert_size_stride(primals_2, (32, 64, 1, 1), (64, 1, 1, 1))
    assert_size_stride(primals_3, (32, 64, 1, 1), (64, 1, 1, 1))
    assert_size_stride(primals_4, (32, 64, 1, 1), (64, 1, 1, 1))
    assert_size_stride(primals_5, (64, 4, 1, 1), (4, 1, 1, 1))
    assert_size_stride(primals_6, (64,), (1,))
    assert_size_stride(primals_7, (64,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = extern_kernels.convolution(primals_1, primals_2, stride=(1, 
            1), padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf0, (4, 32, 64, 64), (131072, 4096, 64, 1))
        buf1 = extern_kernels.convolution(primals_1, primals_3, stride=(1, 
            1), padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf1, (4, 32, 64, 64), (131072, 4096, 64, 1))
        buf2 = extern_kernels.convolution(primals_1, primals_4, stride=(1, 
            1), padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf2, (4, 32, 64, 64), (131072, 4096, 64, 1))
        buf3 = empty_strided_cuda((4, 1, 1), (1, 1, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf1, (4, 1, 16384), (131072,
            0, 1), 0), reinterpret_tensor(buf2, (4, 16384, 1), (131072, 1, 
            0), 0), out=buf3)
        buf4 = empty_strided_cuda((4, 1, 16384), (16384, 16384, 1), torch.
            float32)
        extern_kernels.bmm(buf3, reinterpret_tensor(buf0, (4, 1, 16384), (
            131072, 0, 1), 0), out=buf4)
        buf5 = empty_strided_cuda((4, 1, 1), (1, 1, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf1, (4, 1, 16384), (131072,
            0, 1), 16384), reinterpret_tensor(buf2, (4, 16384, 1), (131072,
            1, 0), 16384), out=buf5)
        buf6 = empty_strided_cuda((4, 1, 16384), (16384, 16384, 1), torch.
            float32)
        extern_kernels.bmm(buf5, reinterpret_tensor(buf0, (4, 1, 16384), (
            131072, 0, 1), 16384), out=buf6)
        buf7 = empty_strided_cuda((4, 1, 1), (1, 1, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf1, (4, 1, 16384), (131072,
            0, 1), 32768), reinterpret_tensor(buf2, (4, 16384, 1), (131072,
            1, 0), 32768), out=buf7)
        buf8 = empty_strided_cuda((4, 1, 16384), (16384, 16384, 1), torch.
            float32)
        extern_kernels.bmm(buf7, reinterpret_tensor(buf0, (4, 1, 16384), (
            131072, 0, 1), 32768), out=buf8)
        buf9 = empty_strided_cuda((4, 1, 1), (1, 1, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf1, (4, 1, 16384), (131072,
            0, 1), 49152), reinterpret_tensor(buf2, (4, 16384, 1), (131072,
            1, 0), 49152), out=buf9)
        buf10 = empty_strided_cuda((4, 1, 16384), (16384, 16384, 1), torch.
            float32)
        extern_kernels.bmm(buf9, reinterpret_tensor(buf0, (4, 1, 16384), (
            131072, 0, 1), 49152), out=buf10)
        buf11 = empty_strided_cuda((4, 1, 1), (1, 1, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf1, (4, 1, 16384), (131072,
            0, 1), 65536), reinterpret_tensor(buf2, (4, 16384, 1), (131072,
            1, 0), 65536), out=buf11)
        buf12 = empty_strided_cuda((4, 1, 16384), (16384, 16384, 1), torch.
            float32)
        extern_kernels.bmm(buf11, reinterpret_tensor(buf0, (4, 1, 16384), (
            131072, 0, 1), 65536), out=buf12)
        buf13 = empty_strided_cuda((4, 1, 1), (1, 1, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf1, (4, 1, 16384), (131072,
            0, 1), 81920), reinterpret_tensor(buf2, (4, 16384, 1), (131072,
            1, 0), 81920), out=buf13)
        buf14 = empty_strided_cuda((4, 1, 16384), (16384, 16384, 1), torch.
            float32)
        extern_kernels.bmm(buf13, reinterpret_tensor(buf0, (4, 1, 16384), (
            131072, 0, 1), 81920), out=buf14)
        buf15 = empty_strided_cuda((4, 1, 1), (1, 1, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf1, (4, 1, 16384), (131072,
            0, 1), 98304), reinterpret_tensor(buf2, (4, 16384, 1), (131072,
            1, 0), 98304), out=buf15)
        buf16 = empty_strided_cuda((4, 1, 16384), (16384, 16384, 1), torch.
            float32)
        extern_kernels.bmm(buf15, reinterpret_tensor(buf0, (4, 1, 16384), (
            131072, 0, 1), 98304), out=buf16)
        buf17 = empty_strided_cuda((4, 1, 1), (1, 1, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf1, (4, 1, 16384), (131072,
            0, 1), 114688), reinterpret_tensor(buf2, (4, 16384, 1), (131072,
            1, 0), 114688), out=buf17)
        buf18 = empty_strided_cuda((4, 1, 16384), (16384, 16384, 1), torch.
            float32)
        extern_kernels.bmm(buf17, reinterpret_tensor(buf0, (4, 1, 16384), (
            131072, 0, 1), 114688), out=buf18)
        buf19 = empty_strided_cuda((4, 32, 64, 64), (131072, 4096, 64, 1),
            torch.float32)
        get_raw_stream(0)
        triton_poi_fused_cat_0[grid(524288)](buf4, buf6, buf8, buf10, buf12,
            buf14, buf16, buf18, buf19, 524288, XBLOCK=1024, num_warps=4,
            num_stages=1)
        buf20 = extern_kernels.convolution(buf19, primals_5, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=8, bias=None)
        assert_size_stride(buf20, (4, 64, 64, 64), (262144, 4096, 64, 1))
        buf21 = empty_strided_cuda((4, 8, 1, 1, 4), (32, 4, 128, 128, 1),
            torch.float32)
        buf22 = empty_strided_cuda((4, 8, 1, 1, 4), (32, 4, 128, 128, 1),
            torch.float32)
        buf23 = empty_strided_cuda((4, 8, 1, 1, 4), (32, 4, 128, 128, 1),
            torch.float32)
        triton_red_fused_native_group_norm_1[grid(128)](buf20, buf21, buf22,
            buf23, 128, 8192, XBLOCK=1, RBLOCK=2048, num_warps=16, num_stages=1
            )
        buf24 = empty_strided_cuda((4, 8, 1, 1), (8, 1, 32, 32), torch.float32)
        buf25 = empty_strided_cuda((4, 8, 1, 1), (8, 1, 32, 32), torch.float32)
        buf27 = empty_strided_cuda((4, 8, 1, 1), (8, 1, 32, 32), torch.float32)
        triton_per_fused_native_group_norm_2[grid(32)](buf21, buf22, buf23,
            buf24, buf25, buf27, 32, 4, XBLOCK=32, num_warps=2, num_stages=1)
        del buf21
        del buf22
        del buf23
        buf28 = empty_strided_cuda((4, 64, 64, 64), (262144, 4096, 64, 1),
            torch.float32)
        triton_poi_fused_add_native_group_norm_3[grid(1048576)](buf20,
            buf24, buf25, primals_6, primals_7, primals_1, buf28, 1048576,
            XBLOCK=1024, num_warps=4, num_stages=1)
        del buf25
        del primals_7
        buf29 = reinterpret_tensor(buf8, (4, 16384, 1), (16384, 1, 16384), 0)
        del buf8
        triton_poi_fused_transpose_4[grid(65536)](buf0, buf29, 65536,
            XBLOCK=256, num_warps=4, num_stages=1)
        buf30 = reinterpret_tensor(buf6, (4, 16384, 1), (16384, 1, 16384), 0)
        del buf6
        triton_poi_fused_transpose_4[grid(65536)](buf1, buf30, 65536,
            XBLOCK=256, num_warps=4, num_stages=1)
        buf31 = buf4
        del buf4
        triton_poi_fused_transpose_4[grid(65536)](buf2, buf31, 65536,
            XBLOCK=256, num_warps=4, num_stages=1)
        buf32 = reinterpret_tensor(buf18, (4, 16384, 1), (16384, 1, 16384), 0)
        del buf18
        triton_poi_fused_transpose_5[grid(65536)](buf0, buf32, 65536,
            XBLOCK=512, num_warps=4, num_stages=1)
        buf33 = reinterpret_tensor(buf16, (4, 16384, 1), (16384, 1, 16384), 0)
        del buf16
        triton_poi_fused_transpose_5[grid(65536)](buf1, buf33, 65536,
            XBLOCK=512, num_warps=4, num_stages=1)
        buf34 = buf14
        del buf14
        triton_poi_fused_transpose_5[grid(65536)](buf2, buf34, 65536,
            XBLOCK=512, num_warps=4, num_stages=1)
        buf35 = reinterpret_tensor(buf12, (4, 16384, 1), (16384, 1, 16384), 0)
        del buf12
        triton_poi_fused_transpose_6[grid(65536)](buf0, buf35, 65536,
            XBLOCK=512, num_warps=4, num_stages=1)
        buf36 = reinterpret_tensor(buf10, (4, 16384, 1), (16384, 1, 16384), 0)
        del buf10
        triton_poi_fused_transpose_6[grid(65536)](buf1, buf36, 65536,
            XBLOCK=512, num_warps=4, num_stages=1)
        buf37 = empty_strided_cuda((4, 1, 16384), (16384, 16384, 1), torch.
            float32)
        triton_poi_fused_transpose_6[grid(65536)](buf2, buf37, 65536,
            XBLOCK=512, num_warps=4, num_stages=1)
        buf38 = empty_strided_cuda((4, 16384, 1), (16384, 1, 16384), torch.
            float32)
        triton_poi_fused_transpose_7[grid(65536)](buf0, buf38, 65536,
            XBLOCK=512, num_warps=4, num_stages=1)
        buf39 = empty_strided_cuda((4, 16384, 1), (16384, 1, 16384), torch.
            float32)
        triton_poi_fused_transpose_7[grid(65536)](buf1, buf39, 65536,
            XBLOCK=512, num_warps=4, num_stages=1)
        buf40 = empty_strided_cuda((4, 1, 16384), (16384, 16384, 1), torch.
            float32)
        triton_poi_fused_transpose_7[grid(65536)](buf2, buf40, 65536,
            XBLOCK=512, num_warps=4, num_stages=1)
        buf41 = empty_strided_cuda((4, 16384, 1), (16384, 1, 16384), torch.
            float32)
        triton_poi_fused_transpose_8[grid(65536)](buf0, buf41, 65536,
            XBLOCK=512, num_warps=4, num_stages=1)
        buf42 = empty_strided_cuda((4, 16384, 1), (16384, 1, 16384), torch.
            float32)
        triton_poi_fused_transpose_8[grid(65536)](buf1, buf42, 65536,
            XBLOCK=512, num_warps=4, num_stages=1)
        buf43 = empty_strided_cuda((4, 1, 16384), (16384, 16384, 1), torch.
            float32)
        triton_poi_fused_transpose_8[grid(65536)](buf2, buf43, 65536,
            XBLOCK=512, num_warps=4, num_stages=1)
        buf44 = empty_strided_cuda((4, 16384, 1), (16384, 1, 16384), torch.
            float32)
        triton_poi_fused_transpose_9[grid(65536)](buf0, buf44, 65536,
            XBLOCK=512, num_warps=4, num_stages=1)
        buf45 = empty_strided_cuda((4, 16384, 1), (16384, 1, 16384), torch.
            float32)
        triton_poi_fused_transpose_9[grid(65536)](buf1, buf45, 65536,
            XBLOCK=512, num_warps=4, num_stages=1)
        buf46 = empty_strided_cuda((4, 1, 16384), (16384, 16384, 1), torch.
            float32)
        triton_poi_fused_transpose_9[grid(65536)](buf2, buf46, 65536,
            XBLOCK=512, num_warps=4, num_stages=1)
        buf47 = empty_strided_cuda((4, 16384, 1), (16384, 1, 16384), torch.
            float32)
        triton_poi_fused_transpose_10[grid(65536)](buf0, buf47, 65536,
            XBLOCK=512, num_warps=4, num_stages=1)
        buf48 = empty_strided_cuda((4, 16384, 1), (16384, 1, 16384), torch.
            float32)
        triton_poi_fused_transpose_10[grid(65536)](buf1, buf48, 65536,
            XBLOCK=512, num_warps=4, num_stages=1)
        buf49 = empty_strided_cuda((4, 1, 16384), (16384, 16384, 1), torch.
            float32)
        triton_poi_fused_transpose_10[grid(65536)](buf2, buf49, 65536,
            XBLOCK=512, num_warps=4, num_stages=1)
        buf50 = empty_strided_cuda((4, 16384, 1), (16384, 1, 16384), torch.
            float32)
        triton_poi_fused_transpose_11[grid(65536)](buf0, buf50, 65536,
            XBLOCK=512, num_warps=4, num_stages=1)
        del buf0
        buf51 = empty_strided_cuda((4, 16384, 1), (16384, 1, 16384), torch.
            float32)
        triton_poi_fused_transpose_11[grid(65536)](buf1, buf51, 65536,
            XBLOCK=512, num_warps=4, num_stages=1)
        del buf1
        buf52 = empty_strided_cuda((4, 1, 16384), (16384, 16384, 1), torch.
            float32)
        triton_poi_fused_transpose_11[grid(65536)](buf2, buf52, 65536,
            XBLOCK=512, num_warps=4, num_stages=1)
        del buf2
    return (buf28, primals_1, primals_2, primals_3, primals_4, primals_5,
        primals_6, buf19, buf20, reinterpret_tensor(buf24, (4, 8), (8, 1), 
        0), reinterpret_tensor(buf27, (4, 8), (8, 1), 0), buf17, buf29,
        buf30, buf31, buf15, buf32, buf33, buf34, buf13, buf35, buf36,
        buf37, buf11, buf38, buf39, buf40, buf9, buf41, buf42, buf43, buf7,
        buf44, buf45, buf46, buf5, buf47, buf48, buf49, buf3, buf50, buf51,
        buf52)


class SpatialCGNLNew(nn.Module):
    """Spatial CGNL block with dot production kernel for image classfication.
    """

    def __init__(self, inplanes, planes, use_scale=False, groups=8):
        self.use_scale = use_scale
        self.groups = groups
        super(SpatialCGNLNew, self).__init__()
        self.t = nn.Conv2d(inplanes, planes, kernel_size=1, stride=1, bias=
            False)
        self.p = nn.Conv2d(inplanes, planes, kernel_size=1, stride=1, bias=
            False)
        self.g = nn.Conv2d(inplanes, planes, kernel_size=1, stride=1, bias=
            False)
        self.z = nn.Conv2d(planes, inplanes, kernel_size=1, stride=1,
            groups=self.groups, bias=False)
        self.gn = nn.GroupNorm(num_groups=self.groups, num_channels=inplanes)
        if self.use_scale:
            None
        if self.groups:
            None

    def kernel(self, t, p, g, b, c, h, w):
        """The linear kernel (dot production).
        Args:
            t: output of conv theata
            p: output of conv phi
            g: output of conv g
            b: batch size
            c: channels number
            h: height of featuremaps
            w: width of featuremaps
        """
        t = t.view(b, 1, c * h * w)
        p = p.view(b, 1, c * h * w)
        g = g.view(b, c * h * w, 1)
        att = torch.bmm(p, g)
        if self.use_scale:
            att = att.div((c * h * w) ** 0.5)
        x = torch.bmm(att, t)
        x = x.view(b, c, h, w)
        return x

    def forward(self, input_0):
        primals_2 = self.t.weight
        primals_3 = self.p.weight
        primals_4 = self.g.weight
        primals_5 = self.z.weight
        primals_6 = self.gn.weight
        primals_7 = self.gn.bias
        primals_1 = input_0
        output = call([primals_1, primals_2, primals_3, primals_4,
            primals_5, primals_6, primals_7])
        return output[0]


Measured latency_ms: 0.114701