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, math as tl_math
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_clone_0(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK: tl.
    constexpr, XBLOCK: tl.constexpr):
    xnumel = 4
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    tl.full([XBLOCK, YBLOCK], True, tl.int1)
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x2 = xindex
    y0 = yindex % 4096
    y1 = yindex // 4096
    y3 = yindex
    tmp0 = tl.load(in_ptr0 + (y0 + 4096 * x2 + 16384 * y1), xmask,
        eviction_policy='evict_last')
    tl.store(out_ptr0 + (x2 + 4 * y3), tmp0, xmask)


@triton.jit
def triton_poi_fused_add_convolution_gelu_1(in_out_ptr0, in_ptr0, in_ptr1,
    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
    x1 = xindex // 4096 % 4
    tmp0 = tl.load(in_out_ptr0 + x3, None)
    tmp1 = tl.load(in_ptr0 + x1, None, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr1 + x3, None)
    tmp2 = tmp0 + tmp1
    tmp4 = tmp2 + tmp3
    tmp5 = 0.5
    tmp6 = tmp4 * tmp5
    tmp7 = 0.7071067811865476
    tmp8 = tmp4 * tmp7
    tmp9 = libdevice.erf(tmp8)
    tmp10 = 1.0
    tmp11 = tmp9 + tmp10
    tmp12 = tmp6 * tmp11
    tl.store(in_out_ptr0 + x3, tmp2, None)
    tl.store(out_ptr0 + x3, tmp12, None)


@triton.jit
def triton_poi_fused_add_convolution_gelu_gelu_backward_2(in_ptr0, in_ptr1,
    in_ptr2, out_ptr0, out_ptr1, xnumel, XBLOCK: tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x3 = xindex
    x1 = xindex // 4096 % 4
    tmp0 = tl.load(in_ptr0 + x3, None)
    tmp1 = tl.load(in_ptr1 + x1, None, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr2 + x3, None)
    tmp2 = tmp0 + tmp1
    tmp4 = tmp2 + tmp3
    tmp5 = 0.5
    tmp6 = tmp4 * tmp5
    tmp7 = 0.7071067811865476
    tmp8 = tmp4 * tmp7
    tmp9 = libdevice.erf(tmp8)
    tmp10 = 1.0
    tmp11 = tmp9 + tmp10
    tmp12 = tmp6 * tmp11
    tmp13 = tmp11 * tmp5
    tmp14 = tmp4 * tmp4
    tmp15 = -0.5
    tmp16 = tmp14 * tmp15
    tmp17 = tl_math.exp(tmp16)
    tmp18 = 0.3989422804014327
    tmp19 = tmp17 * tmp18
    tmp20 = tmp4 * tmp19
    tmp21 = tmp13 + tmp20
    tl.store(out_ptr0 + x3, tmp12, None)
    tl.store(out_ptr1 + x3, tmp21, None)


@triton.jit
def triton_poi_fused_convolution_3(in_out_ptr0, in_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
    x1 = xindex // 4096 % 4
    tmp0 = tl.load(in_out_ptr0 + x3, None)
    tmp1 = tl.load(in_ptr0 + x1, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tl.store(in_out_ptr0 + x3, tmp2, None)


@triton.jit
def triton_poi_fused_add_gelu_mul_4(in_out_ptr0, in_ptr0, in_ptr1, in_ptr2,
    in_ptr3, in_ptr4, in_ptr5, in_ptr6, in_ptr7, in_ptr8, in_ptr9, in_ptr10,
    ynumel, xnumel, YBLOCK: tl.constexpr, XBLOCK: tl.constexpr):
    xnumel = 4
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    tl.full([XBLOCK, YBLOCK], True, tl.int1)
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x1 = xindex
    y0 = yindex
    y2 = yindex % 4096
    y3 = yindex // 4096
    tmp0 = tl.load(in_ptr0 + (x1 + 4 * y0), xmask, eviction_policy='evict_last'
        )
    tmp1 = tl.load(in_ptr1 + x1, xmask, eviction_policy='evict_last')
    tmp11 = tl.load(in_ptr2 + x1, xmask, eviction_policy='evict_last')
    tmp13 = tl.load(in_ptr3 + (x1 + 4 * y0), xmask, eviction_policy=
        'evict_last')
    tmp14 = tl.load(in_ptr4 + x1, xmask, eviction_policy='evict_last')
    tmp21 = tl.load(in_ptr5 + x1, xmask, eviction_policy='evict_last')
    tmp24 = tl.load(in_ptr6 + (x1 + 4 * y0), xmask, eviction_policy=
        'evict_last')
    tmp25 = tl.load(in_ptr7 + x1, xmask, eviction_policy='evict_last')
    tmp32 = tl.load(in_ptr8 + x1, xmask, eviction_policy='evict_last')
    tmp35 = tl.load(in_ptr9 + (y2 + 4096 * x1 + 16384 * y3), xmask,
        eviction_policy='evict_last')
    tmp41 = tl.load(in_ptr10 + x1, 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
    tmp12 = tmp10 * tmp11
    tmp15 = tmp13 + tmp14
    tmp16 = tmp15 * tmp3
    tmp17 = tmp15 * tmp5
    tmp18 = libdevice.erf(tmp17)
    tmp19 = tmp18 + tmp8
    tmp20 = tmp16 * tmp19
    tmp22 = tmp20 * tmp21
    tmp23 = tmp12 + tmp22
    tmp26 = tmp24 + tmp25
    tmp27 = tmp26 * tmp3
    tmp28 = tmp26 * tmp5
    tmp29 = libdevice.erf(tmp28)
    tmp30 = tmp29 + tmp8
    tmp31 = tmp27 * tmp30
    tmp33 = tmp31 * tmp32
    tmp34 = tmp23 + tmp33
    tmp36 = tmp35 * tmp3
    tmp37 = tmp35 * tmp5
    tmp38 = libdevice.erf(tmp37)
    tmp39 = tmp38 + tmp8
    tmp40 = tmp36 * tmp39
    tmp42 = tmp40 * tmp41
    tmp43 = tmp34 + tmp42
    tl.debug_barrier()
    tl.store(in_out_ptr0 + (x1 + 4 * y0), tmp43, xmask)


@triton.jit
def triton_poi_fused_convolution_5(in_out_ptr0, in_ptr0, xnumel, XBLOCK: tl
    .constexpr):
    xnumel = 3844
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = tl.load(in_out_ptr0 + x0, xmask)
    tmp1 = tl.load(in_ptr0 + 0)
    tmp2 = tl.broadcast_to(tmp1, [XBLOCK])
    tmp3 = tmp0 + tmp2
    tl.store(in_out_ptr0 + x0, tmp3, xmask)


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


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


@triton.jit
def triton_poi_fused__to_copy_8(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 = x0
    tmp1 = tmp0.to(tl.float32)
    tmp2 = 0.5
    tmp3 = tmp1 + tmp2
    tmp4 = 0.046875
    tmp5 = tmp3 * tmp4
    tmp6 = tmp5 - tmp2
    tmp7 = 0.0
    tmp8 = triton_helpers.maximum(tmp6, tmp7)
    tmp9 = tmp8.to(tl.int32)
    tl.store(out_ptr0 + x0, tmp9, xmask)


@triton.jit
def triton_poi_fused_add_clamp_9(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 = x0
    tmp1 = tmp0.to(tl.float32)
    tmp2 = 0.5
    tmp3 = tmp1 + tmp2
    tmp4 = 0.046875
    tmp5 = tmp3 * tmp4
    tmp6 = tmp5 - tmp2
    tmp7 = 0.0
    tmp8 = triton_helpers.maximum(tmp6, tmp7)
    tmp9 = tmp8.to(tl.int32)
    tmp10 = tl.full([1], 1, tl.int64)
    tmp11 = tmp9 + tmp10
    tmp12 = tl.full([1], 2, tl.int64)
    tmp13 = triton_helpers.minimum(tmp11, tmp12)
    tl.store(out_ptr0 + x0, tmp13, xmask)


@triton.jit
def triton_poi_fused__to_copy_add_arange_clamp_mul_sub_10(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 = x0
    tmp1 = tmp0.to(tl.float32)
    tmp2 = 0.5
    tmp3 = tmp1 + tmp2
    tmp4 = 0.046875
    tmp5 = tmp3 * tmp4
    tmp6 = tmp5 - tmp2
    tmp7 = 0.0
    tmp8 = triton_helpers.maximum(tmp6, tmp7)
    tmp9 = tmp8.to(tl.int32)
    tmp10 = tmp9.to(tl.float32)
    tmp11 = tmp8 - tmp10
    tmp12 = triton_helpers.maximum(tmp11, tmp7)
    tmp13 = 1.0
    tmp14 = triton_helpers.minimum(tmp12, tmp13)
    tl.store(out_ptr0 + x0, tmp14, xmask)


@triton.jit
def triton_poi_fused__unsafe_index_add_convolution_mul_sub_11(in_out_ptr0,
    in_ptr0, in_ptr1, in_ptr2, in_ptr3, in_ptr4, in_ptr5, in_ptr6, in_ptr7,
    in_ptr8, in_ptr9, xnumel, XBLOCK: tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x1 = xindex // 64 % 64
    x0 = xindex % 64
    x2 = xindex // 4096
    x3 = xindex
    tmp0 = tl.load(in_ptr0 + x1, None, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr1 + x0, None, eviction_policy='evict_last')
    tmp10 = tl.load(in_ptr3 + 0)
    tmp11 = tl.broadcast_to(tmp10, [XBLOCK])
    tmp13 = tl.load(in_ptr4 + x0, None, eviction_policy='evict_last')
    tmp20 = tl.load(in_ptr5 + x0, None, eviction_policy='evict_last')
    tmp23 = tl.load(in_ptr6 + x1, None, eviction_policy='evict_last')
    tmp35 = tl.load(in_ptr7 + x1, None, eviction_policy='evict_last')
    tmp38 = tl.load(in_ptr8 + x3, None)
    tmp39 = tl.load(in_ptr9 + 0)
    tmp40 = tl.broadcast_to(tmp39, [XBLOCK])
    tmp1 = tl.full([XBLOCK], 3, tl.int32)
    tmp2 = tmp0 + tmp1
    tmp3 = tmp0 < 0
    tmp4 = tl.where(tmp3, tmp2, tmp0)
    tmp6 = tmp5 + tmp1
    tmp7 = tmp5 < 0
    tmp8 = tl.where(tmp7, tmp6, tmp5)
    tmp9 = tl.load(in_ptr2 + (tmp8 + 3 * tmp4 + 9 * x2), None,
        eviction_policy='evict_last')
    tmp12 = tmp9 + tmp11
    tmp14 = tmp13 + tmp1
    tmp15 = tmp13 < 0
    tmp16 = tl.where(tmp15, tmp14, tmp13)
    tmp17 = tl.load(in_ptr2 + (tmp16 + 3 * tmp4 + 9 * x2), None,
        eviction_policy='evict_last')
    tmp18 = tmp17 + tmp11
    tmp19 = tmp18 - tmp12
    tmp21 = tmp19 * tmp20
    tmp22 = tmp12 + tmp21
    tmp24 = tmp23 + tmp1
    tmp25 = tmp23 < 0
    tmp26 = tl.where(tmp25, tmp24, tmp23)
    tmp27 = tl.load(in_ptr2 + (tmp8 + 3 * tmp26 + 9 * x2), None,
        eviction_policy='evict_last')
    tmp28 = tmp27 + tmp11
    tmp29 = tl.load(in_ptr2 + (tmp16 + 3 * tmp26 + 9 * x2), None,
        eviction_policy='evict_last')
    tmp30 = tmp29 + tmp11
    tmp31 = tmp30 - tmp28
    tmp32 = tmp31 * tmp20
    tmp33 = tmp28 + tmp32
    tmp34 = tmp33 - tmp22
    tmp36 = tmp34 * tmp35
    tmp37 = tmp22 + tmp36
    tmp41 = tmp38 + tmp40
    tmp42 = tmp37 + tmp41
    tl.store(in_out_ptr0 + x3, tmp42, None)


@triton.jit
def triton_poi_fused_mul_sigmoid_12(in_ptr0, in_ptr1, 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
    tmp0 = tl.load(in_ptr0 + x0, None)
    tmp1 = tl.load(in_ptr1 + x0, None)
    tmp2 = tl.sigmoid(tmp1)
    tmp3 = tmp0 * tmp2
    tl.store(out_ptr0 + x0, tmp3, None)


@triton.jit
def triton_poi_fused_add_13(in_out_ptr0, in_ptr0, in_ptr1, ynumel, xnumel,
    YBLOCK: tl.constexpr, XBLOCK: tl.constexpr):
    xnumel = 4
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    tl.full([XBLOCK, YBLOCK], True, tl.int1)
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x2 = xindex
    y3 = yindex
    y0 = yindex % 4096
    y1 = yindex // 4096
    tmp0 = tl.load(in_out_ptr0 + (x2 + 4 * y3), xmask, eviction_policy=
        'evict_last')
    tmp1 = tl.load(in_ptr0 + x2, xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr1 + (y0 + 4096 * x2 + 16384 * y1), xmask,
        eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp4 = tmp2 + tmp3
    tl.debug_barrier()
    tl.store(in_out_ptr0 + (x2 + 4 * y3), tmp4, 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) = args
    args.clear()
    assert_size_stride(primals_1, (4, 4, 64, 64), (16384, 4096, 64, 1))
    assert_size_stride(primals_2, (4, 4), (4, 1))
    assert_size_stride(primals_3, (4,), (1,))
    assert_size_stride(primals_4, (4, 4, 3, 3), (36, 9, 3, 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, 3, 3), (36, 9, 3, 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, 3, 3), (36, 9, 3, 1))
    assert_size_stride(primals_13, (4,), (1,))
    assert_size_stride(primals_14, (4, 4, 3, 3), (36, 9, 3, 1))
    assert_size_stride(primals_15, (4,), (1,))
    assert_size_stride(primals_16, (1, 4), (4, 1))
    assert_size_stride(primals_17, (1, 4), (4, 1))
    assert_size_stride(primals_18, (1, 4), (4, 1))
    assert_size_stride(primals_19, (1, 4), (4, 1))
    assert_size_stride(primals_20, (1, 4), (4, 1))
    assert_size_stride(primals_21, (1,), (1,))
    assert_size_stride(primals_22, (1, 1, 3, 3), (9, 9, 3, 1))
    assert_size_stride(primals_23, (1,), (1,))
    assert_size_stride(primals_24, (1, 1, 3, 3), (9, 9, 3, 1))
    assert_size_stride(primals_25, (1,), (1,))
    assert_size_stride(primals_26, (1, 1, 3, 3), (9, 9, 3, 1))
    assert_size_stride(primals_27, (1,), (1,))
    assert_size_stride(primals_28, (1, 1, 3, 3), (9, 9, 3, 1))
    assert_size_stride(primals_29, (1,), (1,))
    assert_size_stride(primals_30, (1, 1), (1, 1))
    assert_size_stride(primals_31, (1,), (1,))
    assert_size_stride(primals_32, (4, 1), (1, 1))
    assert_size_stride(primals_33, (4,), (1,))
    assert_size_stride(primals_34, (4, 4), (4, 1))
    assert_size_stride(primals_35, (4,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 64, 64, 4), (16384, 256, 4, 1), torch
            .float32)
        get_raw_stream(0)
        triton_poi_fused_clone_0[grid(16384, 4)](primals_1, buf0, 16384, 4,
            XBLOCK=4, YBLOCK=256, num_warps=4, num_stages=1)
        buf1 = empty_strided_cuda((16384, 4), (4, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf0, (16384, 4), (4, 1), 0),
            reinterpret_tensor(primals_2, (4, 4), (1, 4), 0), out=buf1)
        del primals_2
        buf2 = extern_kernels.convolution(primals_1, primals_4, stride=(1, 
            1), padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf2, (4, 4, 64, 64), (16384, 4096, 64, 1))
        buf3 = buf2
        del buf2
        buf4 = empty_strided_cuda((4, 4, 64, 64), (16384, 4096, 64, 1),
            torch.float32)
        triton_poi_fused_add_convolution_gelu_1[grid(65536)](buf3,
            primals_5, primals_1, buf4, 65536, XBLOCK=256, num_warps=4,
            num_stages=1)
        del primals_5
        buf5 = empty_strided_cuda((4, 64, 64, 4), (16384, 256, 4, 1), torch
            .float32)
        triton_poi_fused_clone_0[grid(16384, 4)](buf4, buf5, 16384, 4,
            XBLOCK=4, YBLOCK=256, num_warps=4, num_stages=1)
        buf6 = empty_strided_cuda((16384, 4), (4, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf5, (16384, 4), (4, 1), 0),
            reinterpret_tensor(primals_6, (4, 4), (1, 4), 0), out=buf6)
        buf7 = extern_kernels.convolution(buf4, primals_8, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf7, (4, 4, 64, 64), (16384, 4096, 64, 1))
        buf8 = empty_strided_cuda((4, 4, 64, 64), (16384, 4096, 64, 1),
            torch.float32)
        buf46 = empty_strided_cuda((4, 4, 64, 64), (16384, 4096, 64, 1),
            torch.float32)
        triton_poi_fused_add_convolution_gelu_gelu_backward_2[grid(65536)](buf7
            , primals_9, buf4, buf8, buf46, 65536, XBLOCK=256, num_warps=4,
            num_stages=1)
        del primals_9
        buf9 = reinterpret_tensor(buf7, (4, 64, 64, 4), (16384, 256, 4, 1), 0)
        del buf7
        triton_poi_fused_clone_0[grid(16384, 4)](buf8, buf9, 16384, 4,
            XBLOCK=4, YBLOCK=256, num_warps=4, num_stages=1)
        buf10 = empty_strided_cuda((16384, 4), (4, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf9, (16384, 4), (4, 1), 0),
            reinterpret_tensor(primals_10, (4, 4), (1, 4), 0), out=buf10)
        buf11 = extern_kernels.convolution(buf8, primals_12, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf11, (4, 4, 64, 64), (16384, 4096, 64, 1))
        buf12 = empty_strided_cuda((4, 4, 64, 64), (16384, 4096, 64, 1),
            torch.float32)
        buf45 = empty_strided_cuda((4, 4, 64, 64), (16384, 4096, 64, 1),
            torch.float32)
        triton_poi_fused_add_convolution_gelu_gelu_backward_2[grid(65536)](
            buf11, primals_13, buf8, buf12, buf45, 65536, XBLOCK=256,
            num_warps=4, num_stages=1)
        del primals_13
        buf13 = extern_kernels.convolution(buf12, primals_14, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf13, (4, 4, 64, 64), (16384, 4096, 64, 1))
        buf14 = buf13
        del buf13
        triton_poi_fused_convolution_3[grid(65536)](buf14, primals_15, 
            65536, XBLOCK=256, num_warps=4, num_stages=1)
        del primals_15
        buf15 = reinterpret_tensor(buf11, (4, 64, 64, 4), (16384, 256, 4, 1), 0
            )
        del buf11
        buf16 = buf15
        del buf15
        triton_poi_fused_add_gelu_mul_4[grid(16384, 4)](buf16, buf1,
            primals_3, primals_16, buf6, primals_7, primals_17, buf10,
            primals_11, primals_18, buf14, primals_19, 16384, 4, XBLOCK=4,
            YBLOCK=256, num_warps=4, num_stages=1)
        buf18 = empty_strided_cuda((16384, 1), (1, 1), torch.float32)
        extern_kernels.addmm(primals_21, reinterpret_tensor(buf16, (16384, 
            4), (4, 1), 0), reinterpret_tensor(primals_20, (4, 1), (1, 4), 
            0), alpha=1, beta=1, out=buf18)
        del primals_21
        buf19 = extern_kernels.convolution(reinterpret_tensor(buf18, (4, 1,
            64, 64), (4096, 1, 64, 1), 0), primals_22, stride=(2, 2),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf19, (4, 1, 31, 31), (961, 1, 31, 1))
        buf20 = buf19
        del buf19
        triton_poi_fused_convolution_5[grid(3844)](buf20, primals_23, 3844,
            XBLOCK=256, num_warps=4, num_stages=1)
        del primals_23
        buf21 = torch.ops.aten.max_pool2d_with_indices.default(buf20, [7, 7
            ], [3, 3])
        buf22 = buf21[0]
        buf23 = buf21[1]
        del buf21
        buf24 = extern_kernels.convolution(buf22, primals_24, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf24, (4, 1, 7, 7), (49, 1, 7, 1))
        buf25 = buf24
        del buf24
        buf26 = empty_strided_cuda((4, 1, 7, 7), (49, 1, 7, 1), torch.float32)
        triton_poi_fused_convolution_gelu_6[grid(196)](buf25, primals_25,
            buf26, 196, XBLOCK=256, num_warps=4, num_stages=1)
        del primals_25
        buf27 = extern_kernels.convolution(buf26, primals_26, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf27, (4, 1, 5, 5), (25, 1, 5, 1))
        buf28 = buf27
        del buf27
        buf29 = empty_strided_cuda((4, 1, 5, 5), (25, 1, 5, 1), torch.float32)
        triton_poi_fused_convolution_gelu_7[grid(100)](buf28, primals_27,
            buf29, 100, XBLOCK=128, num_warps=4, num_stages=1)
        del primals_27
        buf30 = extern_kernels.convolution(buf29, primals_28, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf30, (4, 1, 3, 3), (9, 1, 3, 1))
        buf31 = empty_strided_cuda((64, 1), (1, 1), torch.int64)
        triton_poi_fused__to_copy_8[grid(64)](buf31, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf32 = empty_strided_cuda((64, 1), (1, 1), torch.int64)
        triton_poi_fused_add_clamp_9[grid(64)](buf32, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf33 = empty_strided_cuda((64,), (1,), torch.int64)
        triton_poi_fused__to_copy_8[grid(64)](buf33, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf34 = empty_strided_cuda((64,), (1,), torch.int64)
        triton_poi_fused_add_clamp_9[grid(64)](buf34, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf35 = empty_strided_cuda((64,), (1,), torch.float32)
        triton_poi_fused__to_copy_add_arange_clamp_mul_sub_10[grid(64)](buf35,
            64, XBLOCK=64, num_warps=1, num_stages=1)
        buf37 = empty_strided_cuda((64, 1), (1, 1), torch.float32)
        triton_poi_fused__to_copy_add_arange_clamp_mul_sub_10[grid(64)](buf37,
            64, XBLOCK=64, num_warps=1, num_stages=1)
        buf39 = empty_strided_cuda((16384, 1), (1, 1), torch.float32)
        extern_kernels.mm(buf18, primals_30, out=buf39)
        buf38 = empty_strided_cuda((4, 1, 64, 64), (4096, 16384, 64, 1),
            torch.float32)
        buf40 = reinterpret_tensor(buf38, (4, 64, 64, 1), (4096, 64, 1, 1), 0)
        del buf38
        triton_poi_fused__unsafe_index_add_convolution_mul_sub_11[grid(16384)](
            buf40, buf31, buf33, buf30, primals_29, buf34, buf35, buf32,
            buf37, buf39, primals_31, 16384, XBLOCK=256, num_warps=4,
            num_stages=1)
        del buf30
        del buf39
        del primals_29
        del primals_31
        buf41 = empty_strided_cuda((16384, 4), (4, 1), torch.float32)
        extern_kernels.addmm(primals_33, reinterpret_tensor(buf40, (16384, 
            1), (1, 0), 0), reinterpret_tensor(primals_32, (1, 4), (1, 1), 
            0), alpha=1, beta=1, out=buf41)
        del primals_33
        buf42 = empty_strided_cuda((4, 4, 64, 64), (16384, 1, 256, 4),
            torch.float32)
        triton_poi_fused_mul_sigmoid_12[grid(65536)](buf16, buf41, buf42, 
            65536, XBLOCK=256, num_warps=4, num_stages=1)
        buf43 = empty_strided_cuda((16384, 4), (4, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf42, (16384, 4), (4, 1), 0),
            reinterpret_tensor(primals_34, (4, 4), (1, 4), 0), out=buf43)
        buf44 = reinterpret_tensor(buf43, (4, 4, 64, 64), (16384, 1, 256, 4), 0
            )
        del buf43
        triton_poi_fused_add_13[grid(16384, 4)](buf44, primals_35,
            primals_1, 16384, 4, XBLOCK=4, YBLOCK=128, num_warps=4,
            num_stages=1)
        del primals_35
    return (buf44, primals_1, primals_3, primals_4, primals_7, primals_8,
        primals_11, primals_12, primals_14, primals_16, primals_17,
        primals_18, primals_19, primals_22, primals_24, primals_26,
        primals_28, reinterpret_tensor(buf0, (16384, 4), (4, 1), 0), buf1,
        buf3, buf4, reinterpret_tensor(buf5, (16384, 4), (4, 1), 0), buf6,
        buf8, reinterpret_tensor(buf9, (16384, 4), (4, 1), 0), buf10, buf12,
        buf14, reinterpret_tensor(buf16, (4, 4, 64, 64), (16384, 1, 256, 4),
        0), buf18, buf20, buf22, buf23, buf25, buf26, buf28, buf29, buf31,
        buf32, buf33, buf34, buf35, buf37, reinterpret_tensor(buf40, (16384,
        1), (1, 1), 0), buf41, reinterpret_tensor(buf42, (16384, 4), (4, 1),
        0), primals_34, primals_32, primals_30, primals_20, buf45,
        primals_10, buf46, primals_6)


class ESA(nn.Module):

    def __init__(self, num_feat=50, conv=nn.Conv2d, p=0.25):
        super(ESA, self).__init__()
        f = num_feat // 4
        BSConvS_kwargs = {}
        if conv.__name__ == 'BSConvS':
            BSConvS_kwargs = {'p': p}
        self.conv1 = nn.Linear(num_feat, f)
        self.conv_f = nn.Linear(f, f)
        self.maxPooling = nn.MaxPool2d(kernel_size=7, stride=3)
        self.conv_max = conv(f, f, kernel_size=3, **BSConvS_kwargs)
        self.conv2 = nn.Conv2d(f, f, 3, 2, 0)
        self.conv3 = conv(f, f, kernel_size=3, **BSConvS_kwargs)
        self.conv3_ = conv(f, f, kernel_size=3, **BSConvS_kwargs)
        self.conv4 = nn.Linear(f, num_feat)
        self.sigmoid = nn.Sigmoid()
        self.GELU = nn.GELU()

    def forward(self, input):
        x = input.permute(0, 2, 3, 1)
        c1_ = self.conv1(x)
        c1 = self.conv2(c1_.permute(0, 3, 1, 2))
        v_max = self.maxPooling(c1)
        v_range = self.GELU(self.conv_max(v_max))
        c3 = self.GELU(self.conv3(v_range))
        c3 = self.conv3_(c3)
        c3 = F.interpolate(c3, (input.size(2), input.size(3)), mode=
            'bilinear', align_corners=False)
        cf = self.conv_f(c1_)
        c4 = self.conv4(c3.permute(0, 2, 3, 1) + cf)
        m = self.sigmoid(c4.permute(0, 3, 1, 2))
        return input * m


class RFDBNew(nn.Module):

    def __init__(self, in_channels, out_channels, distillation_rate=0.25,
        conv=nn.Conv2d, p=0.25):
        super(RFDBNew, self).__init__()
        kwargs = {'padding': 1}
        if conv.__name__ == 'BSConvS':
            kwargs = {'p': p}
        self.dc = self.distilled_channels = in_channels // 2
        self.rc = self.remaining_channels = in_channels
        self.c1_d = nn.Linear(in_channels, self.rc)
        self.c1_r = conv(in_channels, self.rc, kernel_size=3, **kwargs)
        self.c2_d = nn.Linear(self.remaining_channels, self.rc)
        self.c2_r = conv(self.remaining_channels, self.rc, kernel_size=3,
            **kwargs)
        self.c3_d = nn.Linear(self.remaining_channels, self.rc)
        self.c3_r = conv(self.remaining_channels, self.rc, kernel_size=3,
            **kwargs)
        self.c4 = conv(self.remaining_channels, in_channels, kernel_size=3,
            **kwargs)
        self.act = nn.GELU()
        self.alpha1 = nn.Parameter(torch.ones(1, in_channels))
        self.alpha2 = nn.Parameter(torch.ones(1, in_channels))
        self.alpha3 = nn.Parameter(torch.ones(1, in_channels))
        self.alpha4 = nn.Parameter(torch.ones(1, in_channels))
        self.esa = ESA(in_channels, conv)
        self.conv_out = nn.Linear(in_channels, out_channels)

    def forward(self, input_0):
        primals_16 = self.alpha1
        primals_17 = self.alpha2
        primals_18 = self.alpha3
        primals_19 = self.alpha4
        primals_2 = self.c1_d.weight
        primals_3 = self.c1_d.bias
        primals_4 = self.c1_r.weight
        primals_5 = self.c1_r.bias
        primals_6 = self.c2_d.weight
        primals_7 = self.c2_d.bias
        primals_8 = self.c2_r.weight
        primals_9 = self.c2_r.bias
        primals_10 = self.c3_d.weight
        primals_11 = self.c3_d.bias
        primals_12 = self.c3_r.weight
        primals_13 = self.c3_r.bias
        primals_14 = self.c4.weight
        primals_15 = self.c4.bias
        primals_20 = self.esa.conv1.weight
        primals_21 = self.esa.conv1.bias
        primals_30 = self.esa.conv_f.weight
        primals_23 = self.esa.conv_f.bias
        primals_22 = self.esa.conv_max.weight
        primals_25 = self.esa.conv_max.bias
        primals_24 = self.esa.conv2.weight
        primals_27 = self.esa.conv2.bias
        primals_26 = self.esa.conv3.weight
        primals_29 = self.esa.conv3.bias
        primals_28 = self.esa.conv3_.weight
        primals_31 = self.esa.conv3_.bias
        primals_32 = self.esa.conv4.weight
        primals_33 = self.esa.conv4.bias
        primals_34 = self.conv_out.weight
        primals_35 = self.conv_out.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])
        return output[0]


Measured latency_ms: 0.066123