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.triton_helpers import libdevice
import torch.nn as nn
import torch.nn.functional as F
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_convolution_0(in_ptr0, out_ptr0, ynumel, xnumel,
    YBLOCK: tl.constexpr, XBLOCK: tl.constexpr):
    ynumel = 16
    xnumel = 4
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    ymask = yindex < ynumel
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x2 = xindex
    y0 = yindex % 4
    y1 = yindex // 4
    y3 = yindex
    tmp0 = tl.load(in_ptr0 + (y0 + 4 * x2 + 16 * y1), xmask & ymask,
        eviction_policy='evict_last')
    tl.store(out_ptr0 + (x2 + 4 * y3), tmp0, xmask & ymask)


@triton.jit
def triton_per_fused_clone_convolution_native_layer_norm_1(in_out_ptr0,
    in_out_ptr1, in_ptr0, out_ptr0, out_ptr1, xnumel, rnumel, XBLOCK: tl.
    constexpr):
    xnumel = 4
    RBLOCK: tl.constexpr = 16
    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)
    r3 = rindex
    x0 = xindex
    r2 = rindex // 4
    tmp0 = tl.load(in_out_ptr0 + (r3 + 16 * x0), xmask, other=0.0)
    tmp1 = tl.load(in_ptr0 + r2, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = tl.broadcast_to(tmp2, [XBLOCK, RBLOCK])
    tl.where(xmask, tmp3, 0)
    tmp6 = tl.broadcast_to(tmp3, [XBLOCK, RBLOCK])
    tmp8 = tl.where(xmask, tmp6, 0)
    tmp9 = tl.sum(tmp8, 1)[:, None]
    tmp10 = tl.full([XBLOCK, 1], 16, tl.int32)
    tmp11 = tmp10.to(tl.float32)
    tmp12 = tmp9 / tmp11
    tmp13 = tmp3 - tmp12
    tmp14 = tmp13 * tmp13
    tmp15 = tl.broadcast_to(tmp14, [XBLOCK, RBLOCK])
    tmp17 = tl.where(xmask, tmp15, 0)
    tmp18 = tl.sum(tmp17, 1)[:, None]
    tmp19 = 16.0
    tmp20 = tmp18 / tmp19
    tmp21 = 1e-05
    tmp22 = tmp20 + tmp21
    tmp23 = libdevice.rsqrt(tmp22)
    tmp24 = tmp2 - tmp12
    tmp25 = tmp24 * tmp23
    tl.store(in_out_ptr0 + (r3 + 16 * x0), tmp2, xmask)
    tl.debug_barrier()
    tl.store(in_out_ptr1 + x0, tmp23, xmask)
    tl.store(out_ptr1 + (r3 + 16 * x0), tmp25, xmask)
    tl.store(out_ptr0 + x0, tmp12, xmask)


@triton.jit
def triton_poi_fused_add_gelu_2(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK:
    tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 4
    tmp0 = tl.load(in_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr1 + x0, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = 0.5
    tmp4 = tmp2 * tmp3
    tmp5 = 0.7071067811865476
    tmp6 = tmp2 * tmp5
    tmp7 = libdevice.erf(tmp6)
    tmp8 = 1.0
    tmp9 = tmp7 + tmp8
    tmp10 = tmp4 * tmp9
    tl.store(out_ptr0 + x2, tmp10, xmask)


@triton.jit
def triton_per_fused_add_native_layer_norm_native_layer_norm_backward_3(in_ptr0
    , in_ptr1, in_ptr2, out_ptr0, out_ptr1, out_ptr2, xnumel, rnumel,
    XBLOCK: tl.constexpr):
    xnumel = 4
    RBLOCK: tl.constexpr = 16
    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)
    r3 = rindex
    x0 = xindex
    r1 = rindex % 4
    tmp0 = tl.load(in_ptr0 + (r3 + 16 * x0), xmask, other=0.0)
    tmp1 = tl.load(in_ptr1 + (r3 + 16 * x0), xmask, other=0.0)
    tmp2 = tl.load(in_ptr2 + r1, None, eviction_policy='evict_last')
    tmp3 = tmp1 + tmp2
    tmp4 = tmp0 + tmp3
    tmp5 = tl.broadcast_to(tmp4, [XBLOCK, RBLOCK])
    tl.where(xmask, tmp5, 0)
    tmp8 = tl.broadcast_to(tmp5, [XBLOCK, RBLOCK])
    tmp10 = tl.where(xmask, tmp8, 0)
    tmp11 = tl.sum(tmp10, 1)[:, None]
    tmp12 = tl.full([XBLOCK, 1], 16, tl.int32)
    tmp13 = tmp12.to(tl.float32)
    tmp14 = tmp11 / tmp13
    tmp15 = tmp5 - tmp14
    tmp16 = tmp15 * tmp15
    tmp17 = tl.broadcast_to(tmp16, [XBLOCK, RBLOCK])
    tmp19 = tl.where(xmask, tmp17, 0)
    tmp20 = tl.sum(tmp19, 1)[:, None]
    tmp21 = 16.0
    tmp22 = tmp20 / tmp21
    tmp23 = 1e-05
    tmp24 = tmp22 + tmp23
    tmp25 = libdevice.rsqrt(tmp24)
    tmp26 = 0.0625
    tmp27 = tmp25 * tmp26
    tl.store(out_ptr2 + x0, tmp27, xmask)
    tl.store(out_ptr0 + x0, tmp14, xmask)
    tl.store(out_ptr1 + x0, tmp20, xmask)


@triton.jit
def triton_poi_fused_add_native_layer_norm_4(in_ptr0, in_ptr1, in_ptr2,
    in_ptr3, in_ptr4, out_ptr0, ynumel, xnumel, YBLOCK: tl.constexpr,
    XBLOCK: tl.constexpr):
    ynumel = 16
    xnumel = 4
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    ymask = yindex < ynumel
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x2 = xindex
    y3 = yindex
    y1 = yindex // 4
    y0 = yindex % 4
    tmp0 = tl.load(in_ptr0 + (x2 + 4 * y3), xmask & ymask, eviction_policy=
        'evict_last')
    tmp1 = tl.load(in_ptr1 + (x2 + 4 * y3), xmask & ymask, eviction_policy=
        'evict_last')
    tmp2 = tl.load(in_ptr2 + x2, xmask, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr3 + y1, ymask, eviction_policy='evict_last')
    tmp7 = tl.load(in_ptr4 + y1, ymask, eviction_policy='evict_last')
    tmp3 = tmp1 + tmp2
    tmp4 = tmp0 + tmp3
    tmp6 = tmp4 - tmp5
    tmp8 = 16.0
    tmp9 = tmp7 / tmp8
    tmp10 = 1e-05
    tmp11 = tmp9 + tmp10
    tmp12 = libdevice.rsqrt(tmp11)
    tmp13 = tmp6 * tmp12
    tl.store(out_ptr0 + (y0 + 4 * x2 + 16 * y1), tmp13, xmask & ymask)


@triton.jit
def triton_poi_fused_gelu_5(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + x0, xmask)
    tmp1 = 0.5
    tmp2 = tmp0 * tmp1
    tmp3 = 0.7071067811865476
    tmp4 = tmp0 * tmp3
    tmp5 = libdevice.erf(tmp4)
    tmp6 = 1.0
    tmp7 = tmp5 + tmp6
    tmp8 = tmp2 * tmp7
    tl.store(out_ptr0 + x0, tmp8, xmask)


@triton.jit
def triton_poi_fused_add_6(in_ptr0, in_ptr1, in_ptr2, in_ptr3, in_ptr4,
    out_ptr0, ynumel, xnumel, YBLOCK: tl.constexpr, XBLOCK: tl.constexpr):
    ynumel = 16
    xnumel = 4
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    ymask = yindex < ynumel
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x2 = xindex
    y3 = yindex
    y0 = yindex % 4
    y1 = yindex // 4
    tmp0 = tl.load(in_ptr0 + (x2 + 4 * y3), xmask & ymask, eviction_policy=
        'evict_last')
    tmp1 = tl.load(in_ptr1 + (x2 + 4 * y3), xmask & ymask, eviction_policy=
        'evict_last')
    tmp2 = tl.load(in_ptr2 + x2, xmask, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr3 + (y0 + 4 * x2 + 16 * y1), xmask & ymask,
        eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr4 + y0, ymask, eviction_policy='evict_last')
    tmp3 = tmp1 + tmp2
    tmp4 = tmp0 + tmp3
    tmp7 = tmp5 + tmp6
    tmp8 = tmp4 + tmp7
    tl.store(out_ptr0 + (x2 + 4 * y3), tmp8, xmask & ymask)


@triton.jit
def triton_per_fused_native_layer_norm_native_layer_norm_backward_7(in_ptr0,
    out_ptr0, out_ptr1, out_ptr2, xnumel, rnumel, XBLOCK: tl.constexpr):
    xnumel = 4
    RBLOCK: tl.constexpr = 16
    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 + 16 * x0), xmask, other=0.0)
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK, RBLOCK])
    tl.where(xmask, tmp1, 0)
    tmp4 = tl.broadcast_to(tmp1, [XBLOCK, RBLOCK])
    tmp6 = tl.where(xmask, tmp4, 0)
    tmp7 = tl.sum(tmp6, 1)[:, None]
    tmp8 = tl.full([XBLOCK, 1], 16, tl.int32)
    tmp9 = tmp8.to(tl.float32)
    tmp10 = tmp7 / tmp9
    tmp11 = tmp1 - tmp10
    tmp12 = tmp11 * tmp11
    tmp13 = tl.broadcast_to(tmp12, [XBLOCK, RBLOCK])
    tmp15 = tl.where(xmask, tmp13, 0)
    tmp16 = tl.sum(tmp15, 1)[:, None]
    tmp17 = 16.0
    tmp18 = tmp16 / tmp17
    tmp19 = 1e-05
    tmp20 = tmp18 + tmp19
    tmp21 = libdevice.rsqrt(tmp20)
    tmp22 = 0.0625
    tmp23 = tmp21 * tmp22
    tl.store(out_ptr2 + x0, tmp23, xmask)
    tl.store(out_ptr0 + x0, tmp10, xmask)
    tl.store(out_ptr1 + x0, tmp16, xmask)


@triton.jit
def triton_poi_fused_native_layer_norm_8(in_ptr0, in_ptr1, in_ptr2,
    out_ptr0, ynumel, xnumel, YBLOCK: tl.constexpr, XBLOCK: tl.constexpr):
    ynumel = 16
    xnumel = 4
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    ymask = yindex < ynumel
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x2 = xindex
    y0 = yindex % 4
    y1 = yindex // 4
    y3 = yindex
    tmp0 = tl.load(in_ptr0 + (y0 + 4 * x2 + 16 * y1), xmask & ymask,
        eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr1 + y1, ymask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr2 + y1, ymask, eviction_policy='evict_last')
    tmp2 = tmp0 - tmp1
    tmp4 = 16.0
    tmp5 = tmp3 / tmp4
    tmp6 = 1e-05
    tmp7 = tmp5 + tmp6
    tmp8 = libdevice.rsqrt(tmp7)
    tmp9 = tmp2 * tmp8
    tl.store(out_ptr0 + (x2 + 4 * y3), tmp9, xmask & ymask)


@triton.jit
def triton_poi_fused_mean_9(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + 4 * x0, xmask, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr0 + (1 + 4 * x0), xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr0 + (2 + 4 * x0), xmask, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr0 + (3 + 4 * x0), xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp4 = tmp2 + tmp3
    tmp6 = tmp4 + tmp5
    tmp7 = 4.0
    tmp8 = tmp6 / tmp7
    tl.store(out_ptr0 + x0, tmp8, xmask)


def call(args):
    (primals_1, primals_2, primals_3, primals_4, primals_5, primals_6,
        primals_7, primals_8, primals_9, primals_10, primals_11, primals_12,
        primals_13, primals_14, primals_15, primals_16, primals_17,
        primals_18, primals_19, primals_20, primals_21, primals_22,
        primals_23, primals_24, primals_25, primals_26, primals_27,
        primals_28, primals_29, primals_30, primals_31, primals_32,
        primals_33, primals_34, primals_35, primals_36, primals_37) = args
    args.clear()
    assert_size_stride(primals_1, (4, 4, 4), (16, 4, 1))
    assert_size_stride(primals_2, (4, 4, 1), (4, 1, 1))
    assert_size_stride(primals_3, (4,), (1,))
    assert_size_stride(primals_4, (4, 4), (4, 1))
    assert_size_stride(primals_5, (4,), (1,))
    assert_size_stride(primals_6, (4, 4), (4, 1))
    assert_size_stride(primals_7, (4,), (1,))
    assert_size_stride(primals_8, (4, 4), (4, 1))
    assert_size_stride(primals_9, (4,), (1,))
    assert_size_stride(primals_10, (4, 4), (4, 1))
    assert_size_stride(primals_11, (4,), (1,))
    assert_size_stride(primals_12, (4, 4), (4, 1))
    assert_size_stride(primals_13, (4,), (1,))
    assert_size_stride(primals_14, (4, 4), (4, 1))
    assert_size_stride(primals_15, (4,), (1,))
    assert_size_stride(primals_16, (4, 4), (4, 1))
    assert_size_stride(primals_17, (4,), (1,))
    assert_size_stride(primals_18, (4, 4), (4, 1))
    assert_size_stride(primals_19, (4,), (1,))
    assert_size_stride(primals_20, (4, 4), (4, 1))
    assert_size_stride(primals_21, (4,), (1,))
    assert_size_stride(primals_22, (4, 4), (4, 1))
    assert_size_stride(primals_23, (4,), (1,))
    assert_size_stride(primals_24, (4, 4), (4, 1))
    assert_size_stride(primals_25, (4,), (1,))
    assert_size_stride(primals_26, (4, 4), (4, 1))
    assert_size_stride(primals_27, (4,), (1,))
    assert_size_stride(primals_28, (4, 4), (4, 1))
    assert_size_stride(primals_29, (4,), (1,))
    assert_size_stride(primals_30, (4, 4), (4, 1))
    assert_size_stride(primals_31, (4,), (1,))
    assert_size_stride(primals_32, (4, 4), (4, 1))
    assert_size_stride(primals_33, (4,), (1,))
    assert_size_stride(primals_34, (4, 4), (4, 1))
    assert_size_stride(primals_35, (4,), (1,))
    assert_size_stride(primals_36, (4, 4), (4, 1))
    assert_size_stride(primals_37, (4,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_convolution_0[grid(16, 4)](primals_1, buf0, 16, 4,
            XBLOCK=4, YBLOCK=16, num_warps=1, num_stages=1)
        buf1 = extern_kernels.convolution(buf0, primals_2, stride=(1,),
            padding=(0,), dilation=(1,), transposed=False, output_padding=(
            0,), groups=1, bias=None)
        assert_size_stride(buf1, (4, 4, 4), (16, 4, 1))
        buf2 = buf1
        del buf1
        buf3 = empty_strided_cuda((4, 1, 1), (1, 1, 1), torch.float32)
        buf4 = empty_strided_cuda((4, 1, 1), (1, 4, 4), torch.float32)
        buf6 = reinterpret_tensor(buf4, (4, 1, 1), (1, 1, 1), 0)
        del buf4
        buf7 = buf0
        del buf0
        triton_per_fused_clone_convolution_native_layer_norm_1[grid(4)](buf2,
            buf6, primals_3, buf3, buf7, 4, 16, XBLOCK=1, num_warps=2,
            num_stages=1)
        del primals_3
        buf8 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf7, (16, 4), (4, 1), 0),
            reinterpret_tensor(primals_4, (4, 4), (1, 4), 0), out=buf8)
        buf9 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused_add_gelu_2[grid(64)](buf8, primals_5, buf9, 64,
            XBLOCK=64, num_warps=1, num_stages=1)
        buf10 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf9, (16, 4), (4, 1), 0),
            reinterpret_tensor(primals_6, (4, 4), (1, 4), 0), out=buf10)
        buf11 = empty_strided_cuda((4, 1, 1), (1, 4, 4), torch.float32)
        buf12 = empty_strided_cuda((4, 1, 1), (1, 4, 4), torch.float32)
        buf80 = empty_strided_cuda((4, 1, 1), (1, 1, 1), torch.float32)
        triton_per_fused_add_native_layer_norm_native_layer_norm_backward_3[
            grid(4)](buf2, buf10, primals_7, buf11, buf12, buf80, 4, 16,
            XBLOCK=1, num_warps=2, num_stages=1)
        buf14 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused_add_native_layer_norm_4[grid(16, 4)](buf2, buf10,
            primals_7, buf11, buf12, buf14, 16, 4, XBLOCK=4, YBLOCK=8,
            num_warps=1, num_stages=1)
        buf15 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        extern_kernels.addmm(primals_9, reinterpret_tensor(buf14, (16, 4),
            (4, 1), 0), reinterpret_tensor(primals_8, (4, 4), (1, 4), 0),
            alpha=1, beta=1, out=buf15)
        del primals_9
        buf16 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused_gelu_5[grid(64)](buf15, buf16, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf17 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf16, (16, 4), (4, 1), 0),
            reinterpret_tensor(primals_10, (4, 4), (1, 4), 0), out=buf17)
        buf18 = empty_strided_cuda((4, 4, 4), (16, 1, 4), torch.float32)
        triton_poi_fused_add_6[grid(16, 4)](buf2, buf10, primals_7, buf17,
            primals_11, buf18, 16, 4, XBLOCK=4, YBLOCK=16, num_warps=1,
            num_stages=1)
        del primals_11
        del primals_7
        buf19 = buf12
        del buf12
        buf20 = buf11
        del buf11
        buf79 = empty_strided_cuda((4, 1, 1), (1, 1, 1), torch.float32)
        triton_per_fused_native_layer_norm_native_layer_norm_backward_7[grid(4)
            ](buf18, buf19, buf20, buf79, 4, 16, XBLOCK=1, num_warps=2,
            num_stages=1)
        buf22 = reinterpret_tensor(buf17, (4, 4, 4), (16, 4, 1), 0)
        del buf17
        triton_poi_fused_native_layer_norm_8[grid(16, 4)](buf18, buf19,
            buf20, buf22, 16, 4, XBLOCK=2, YBLOCK=16, num_warps=1, num_stages=1
            )
        buf23 = reinterpret_tensor(buf10, (4, 4, 4), (16, 4, 1), 0)
        del buf10
        triton_poi_fused_convolution_0[grid(16, 4)](buf22, buf23, 16, 4,
            XBLOCK=4, YBLOCK=16, num_warps=1, num_stages=1)
        buf24 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf23, (16, 4), (4, 1), 0),
            reinterpret_tensor(primals_12, (4, 4), (1, 4), 0), out=buf24)
        buf25 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused_add_gelu_2[grid(64)](buf24, primals_13, buf25, 64,
            XBLOCK=64, num_warps=1, num_stages=1)
        buf26 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf25, (16, 4), (4, 1), 0),
            reinterpret_tensor(primals_14, (4, 4), (1, 4), 0), out=buf26)
        buf27 = buf20
        del buf20
        buf28 = buf19
        del buf19
        buf78 = empty_strided_cuda((4, 1, 1), (1, 1, 1), torch.float32)
        triton_per_fused_add_native_layer_norm_native_layer_norm_backward_3[
            grid(4)](buf18, buf26, primals_15, buf27, buf28, buf78, 4, 16,
            XBLOCK=1, num_warps=2, num_stages=1)
        buf30 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused_add_native_layer_norm_4[grid(16, 4)](buf18, buf26,
            primals_15, buf27, buf28, buf30, 16, 4, XBLOCK=4, YBLOCK=8,
            num_warps=1, num_stages=1)
        buf31 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        extern_kernels.addmm(primals_17, reinterpret_tensor(buf30, (16, 4),
            (4, 1), 0), reinterpret_tensor(primals_16, (4, 4), (1, 4), 0),
            alpha=1, beta=1, out=buf31)
        del primals_17
        buf32 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused_gelu_5[grid(64)](buf31, buf32, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf33 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf32, (16, 4), (4, 1), 0),
            reinterpret_tensor(primals_18, (4, 4), (1, 4), 0), out=buf33)
        buf34 = empty_strided_cuda((4, 4, 4), (16, 1, 4), torch.float32)
        triton_poi_fused_add_6[grid(16, 4)](buf18, buf26, primals_15, buf33,
            primals_19, buf34, 16, 4, XBLOCK=4, YBLOCK=16, num_warps=1,
            num_stages=1)
        del primals_15
        del primals_19
        buf35 = buf28
        del buf28
        buf36 = buf27
        del buf27
        buf77 = empty_strided_cuda((4, 1, 1), (1, 1, 1), torch.float32)
        triton_per_fused_native_layer_norm_native_layer_norm_backward_7[grid(4)
            ](buf34, buf35, buf36, buf77, 4, 16, XBLOCK=1, num_warps=2,
            num_stages=1)
        buf38 = reinterpret_tensor(buf33, (4, 4, 4), (16, 4, 1), 0)
        del buf33
        triton_poi_fused_native_layer_norm_8[grid(16, 4)](buf34, buf35,
            buf36, buf38, 16, 4, XBLOCK=2, YBLOCK=16, num_warps=1, num_stages=1
            )
        buf39 = reinterpret_tensor(buf26, (4, 4, 4), (16, 4, 1), 0)
        del buf26
        triton_poi_fused_convolution_0[grid(16, 4)](buf38, buf39, 16, 4,
            XBLOCK=4, YBLOCK=16, num_warps=1, num_stages=1)
        buf40 = reinterpret_tensor(buf18, (16, 4), (4, 1), 0)
        del buf18
        extern_kernels.mm(reinterpret_tensor(buf39, (16, 4), (4, 1), 0),
            reinterpret_tensor(primals_20, (4, 4), (1, 4), 0), out=buf40)
        buf41 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused_add_gelu_2[grid(64)](buf40, primals_21, buf41, 64,
            XBLOCK=64, num_warps=1, num_stages=1)
        buf42 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf41, (16, 4), (4, 1), 0),
            reinterpret_tensor(primals_22, (4, 4), (1, 4), 0), out=buf42)
        buf43 = buf36
        del buf36
        buf44 = buf35
        del buf35
        buf76 = empty_strided_cuda((4, 1, 1), (1, 1, 1), torch.float32)
        triton_per_fused_add_native_layer_norm_native_layer_norm_backward_3[
            grid(4)](buf34, buf42, primals_23, buf43, buf44, buf76, 4, 16,
            XBLOCK=1, num_warps=2, num_stages=1)
        buf46 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused_add_native_layer_norm_4[grid(16, 4)](buf34, buf42,
            primals_23, buf43, buf44, buf46, 16, 4, XBLOCK=4, YBLOCK=8,
            num_warps=1, num_stages=1)
        buf47 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        extern_kernels.addmm(primals_25, reinterpret_tensor(buf46, (16, 4),
            (4, 1), 0), reinterpret_tensor(primals_24, (4, 4), (1, 4), 0),
            alpha=1, beta=1, out=buf47)
        del primals_25
        buf48 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused_gelu_5[grid(64)](buf47, buf48, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf49 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf48, (16, 4), (4, 1), 0),
            reinterpret_tensor(primals_26, (4, 4), (1, 4), 0), out=buf49)
        buf50 = empty_strided_cuda((4, 4, 4), (16, 1, 4), torch.float32)
        triton_poi_fused_add_6[grid(16, 4)](buf34, buf42, primals_23, buf49,
            primals_27, buf50, 16, 4, XBLOCK=4, YBLOCK=16, num_warps=1,
            num_stages=1)
        del primals_23
        del primals_27
        buf51 = buf44
        del buf44
        buf52 = buf43
        del buf43
        buf75 = empty_strided_cuda((4, 1, 1), (1, 1, 1), torch.float32)
        triton_per_fused_native_layer_norm_native_layer_norm_backward_7[grid(4)
            ](buf50, buf51, buf52, buf75, 4, 16, XBLOCK=1, num_warps=2,
            num_stages=1)
        buf54 = reinterpret_tensor(buf49, (4, 4, 4), (16, 4, 1), 0)
        del buf49
        triton_poi_fused_native_layer_norm_8[grid(16, 4)](buf50, buf51,
            buf52, buf54, 16, 4, XBLOCK=2, YBLOCK=16, num_warps=1, num_stages=1
            )
        buf55 = reinterpret_tensor(buf42, (4, 4, 4), (16, 4, 1), 0)
        del buf42
        triton_poi_fused_convolution_0[grid(16, 4)](buf54, buf55, 16, 4,
            XBLOCK=4, YBLOCK=16, num_warps=1, num_stages=1)
        buf56 = reinterpret_tensor(buf34, (16, 4), (4, 1), 0)
        del buf34
        extern_kernels.mm(reinterpret_tensor(buf55, (16, 4), (4, 1), 0),
            reinterpret_tensor(primals_28, (4, 4), (1, 4), 0), out=buf56)
        buf57 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused_add_gelu_2[grid(64)](buf56, primals_29, buf57, 64,
            XBLOCK=64, num_warps=1, num_stages=1)
        buf58 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf57, (16, 4), (4, 1), 0),
            reinterpret_tensor(primals_30, (4, 4), (1, 4), 0), out=buf58)
        buf59 = buf52
        del buf52
        buf60 = buf51
        del buf51
        buf74 = empty_strided_cuda((4, 1, 1), (1, 1, 1), torch.float32)
        triton_per_fused_add_native_layer_norm_native_layer_norm_backward_3[
            grid(4)](buf50, buf58, primals_31, buf59, buf60, buf74, 4, 16,
            XBLOCK=1, num_warps=2, num_stages=1)
        buf62 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused_add_native_layer_norm_4[grid(16, 4)](buf50, buf58,
            primals_31, buf59, buf60, buf62, 16, 4, XBLOCK=4, YBLOCK=8,
            num_warps=1, num_stages=1)
        buf63 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        extern_kernels.addmm(primals_33, reinterpret_tensor(buf62, (16, 4),
            (4, 1), 0), reinterpret_tensor(primals_32, (4, 4), (1, 4), 0),
            alpha=1, beta=1, out=buf63)
        del primals_33
        buf64 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused_gelu_5[grid(64)](buf63, buf64, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf65 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf64, (16, 4), (4, 1), 0),
            reinterpret_tensor(primals_34, (4, 4), (1, 4), 0), out=buf65)
        buf66 = empty_strided_cuda((4, 4, 4), (16, 1, 4), torch.float32)
        triton_poi_fused_add_6[grid(16, 4)](buf50, buf58, primals_31, buf65,
            primals_35, buf66, 16, 4, XBLOCK=4, YBLOCK=16, num_warps=1,
            num_stages=1)
        del buf50
        del buf58
        del primals_31
        del primals_35
        buf67 = buf60
        del buf60
        buf68 = buf59
        del buf59
        buf73 = empty_strided_cuda((4, 1, 1), (1, 1, 1), torch.float32)
        triton_per_fused_native_layer_norm_native_layer_norm_backward_7[grid(4)
            ](buf66, buf67, buf68, buf73, 4, 16, XBLOCK=1, num_warps=2,
            num_stages=1)
        buf70 = reinterpret_tensor(buf65, (4, 4, 4), (16, 4, 1), 0)
        del buf65
        triton_poi_fused_native_layer_norm_8[grid(16, 4)](buf66, buf67,
            buf68, buf70, 16, 4, XBLOCK=2, YBLOCK=16, num_warps=1, num_stages=1
            )
        del buf66
        del buf67
        del buf68
        buf71 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        triton_poi_fused_mean_9[grid(16)](buf70, buf71, 16, XBLOCK=16,
            num_warps=1, num_stages=1)
        buf72 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        extern_kernels.addmm(primals_37, buf71, reinterpret_tensor(
            primals_36, (4, 4), (1, 4), 0), alpha=1, beta=1, out=buf72)
        del primals_37
    return (buf72, primals_2, primals_5, primals_13, primals_21, primals_29,
        reinterpret_tensor(primals_1, (4, 4, 4), (16, 1, 4), 0), buf2, buf3,
        buf6, reinterpret_tensor(buf7, (16, 4), (4, 1), 0), buf8,
        reinterpret_tensor(buf9, (16, 4), (4, 1), 0), buf14, buf15,
        reinterpret_tensor(buf16, (16, 4), (4, 1), 0), buf22,
        reinterpret_tensor(buf23, (16, 4), (4, 1), 0), buf24,
        reinterpret_tensor(buf25, (16, 4), (4, 1), 0), buf30, buf31,
        reinterpret_tensor(buf32, (16, 4), (4, 1), 0), buf38,
        reinterpret_tensor(buf39, (16, 4), (4, 1), 0), buf40,
        reinterpret_tensor(buf41, (16, 4), (4, 1), 0), buf46, buf47,
        reinterpret_tensor(buf48, (16, 4), (4, 1), 0), buf54,
        reinterpret_tensor(buf55, (16, 4), (4, 1), 0), buf56,
        reinterpret_tensor(buf57, (16, 4), (4, 1), 0), buf62, buf63,
        reinterpret_tensor(buf64, (16, 4), (4, 1), 0), buf70, buf71,
        primals_36, buf73, primals_34, primals_32, buf74, primals_30,
        primals_28, buf75, primals_26, primals_24, buf76, primals_22,
        primals_20, buf77, primals_18, primals_16, buf78, primals_14,
        primals_12, buf79, primals_10, primals_8, buf80, primals_6, primals_4)


class MlpBlock(nn.Module):

    def __init__(self, features, hidden_dim):
        super().__init__()
        self.hidden_dim = hidden_dim
        self.features = features
        self.fc1 = nn.Linear(self.features, self.hidden_dim)
        self.fc2 = nn.Linear(self.hidden_dim, int(self.features))

    def forward(self, x):
        y = self.fc1(x)
        y = F.gelu(y)
        return self.fc2(y)


class MixerBlock(nn.Module):
    """Mixer block layer"""

    def __init__(self, tokens_dim, tokens_mlp_dim, channels_dim,
        channels_mlp_dim):
        super().__init__()
        self.tokens_mlp_dim = tokens_mlp_dim
        self.tokens_dim = tokens_dim
        self.channels_mlp_dim = channels_mlp_dim
        self.channels_dim = channels_dim
        self.token_mixer = MlpBlock(self.tokens_dim, self.tokens_mlp_dim)
        self.channel_mixer = MlpBlock(self.channels_dim, self.channels_mlp_dim)

    def forward(self, x):
        y = F.layer_norm(x, x.shape[1:])
        y = torch.transpose(y, 1, 2)
        y = self.token_mixer(y)
        y = torch.transpose(y, 1, 2)
        x = x + y
        y = F.layer_norm(x, x.shape[1:])
        return x + self.channel_mixer(y)


class MlpMixerNew(nn.Module):
    """Mixer architecture"""

    def __init__(self, patches, feature_length, num_classes, num_blocks,
        hidden_dim, tokens_mlp_dim, channels_mlp_dim):
        super().__init__()
        self.patches = patches
        self.feature_length = feature_length
        self.num_classes = num_classes
        self.num_blocks = num_blocks
        self.hidden_dim = hidden_dim
        self.tokens_mlp_dim = tokens_mlp_dim
        self.channels_mlp_dim = channels_mlp_dim
        self.conv = nn.Conv1d(in_channels=self.patches, out_channels=self.
            hidden_dim, kernel_size=1)
        for nb in range(self.num_blocks):
            setattr(self, 'mixerBlock_{}'.format(nb), MixerBlock(self.
                feature_length, self.tokens_mlp_dim, self.hidden_dim, self.
                channels_mlp_dim))
        self.fc = nn.Linear(in_features=self.feature_length, out_features=
            self.num_classes)

    def forward(self, input_0):
        primals_2 = self.conv.weight
        primals_3 = self.conv.bias
        primals_4 = self.mixerBlock_0.token_mixer.fc1.weight
        primals_5 = self.mixerBlock_0.token_mixer.fc1.bias
        primals_6 = self.mixerBlock_0.token_mixer.fc2.weight
        primals_7 = self.mixerBlock_0.token_mixer.fc2.bias
        primals_8 = self.mixerBlock_0.channel_mixer.fc1.weight
        primals_9 = self.mixerBlock_0.channel_mixer.fc1.bias
        primals_10 = self.mixerBlock_0.channel_mixer.fc2.weight
        primals_11 = self.mixerBlock_0.channel_mixer.fc2.bias
        primals_12 = self.mixerBlock_1.token_mixer.fc1.weight
        primals_13 = self.mixerBlock_1.token_mixer.fc1.bias
        primals_14 = self.mixerBlock_1.token_mixer.fc2.weight
        primals_15 = self.mixerBlock_1.token_mixer.fc2.bias
        primals_16 = self.mixerBlock_1.channel_mixer.fc1.weight
        primals_17 = self.mixerBlock_1.channel_mixer.fc1.bias
        primals_18 = self.mixerBlock_1.channel_mixer.fc2.weight
        primals_19 = self.mixerBlock_1.channel_mixer.fc2.bias
        primals_20 = self.mixerBlock_2.token_mixer.fc1.weight
        primals_21 = self.mixerBlock_2.token_mixer.fc1.bias
        primals_22 = self.mixerBlock_2.token_mixer.fc2.weight
        primals_23 = self.mixerBlock_2.token_mixer.fc2.bias
        primals_24 = self.mixerBlock_2.channel_mixer.fc1.weight
        primals_25 = self.mixerBlock_2.channel_mixer.fc1.bias
        primals_26 = self.mixerBlock_2.channel_mixer.fc2.weight
        primals_27 = self.mixerBlock_2.channel_mixer.fc2.bias
        primals_28 = self.mixerBlock_3.token_mixer.fc1.weight
        primals_29 = self.mixerBlock_3.token_mixer.fc1.bias
        primals_30 = self.mixerBlock_3.token_mixer.fc2.weight
        primals_31 = self.mixerBlock_3.token_mixer.fc2.bias
        primals_32 = self.mixerBlock_3.channel_mixer.fc1.weight
        primals_33 = self.mixerBlock_3.channel_mixer.fc1.bias
        primals_34 = self.mixerBlock_3.channel_mixer.fc2.weight
        primals_35 = self.mixerBlock_3.channel_mixer.fc2.bias
        primals_36 = self.fc.weight
        primals_37 = self.fc.bias
        primals_1 = input_0
        output = call([primals_1, primals_2, primals_3, primals_4,
            primals_5, primals_6, primals_7, primals_8, primals_9,
            primals_10, primals_11, primals_12, primals_13, primals_14,
            primals_15, primals_16, primals_17, primals_18, primals_19,
            primals_20, primals_21, primals_22, primals_23, primals_24,
            primals_25, primals_26, primals_27, primals_28, primals_29,
            primals_30, primals_31, primals_32, primals_33, primals_34,
            primals_35, primals_36, primals_37])
        return output[0]


Measured latency_ms: 0.091724