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
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_0(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK: tl.
    constexpr, XBLOCK: tl.constexpr):
    ynumel = 12
    xnumel = 16
    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 % 3
    y1 = yindex // 3
    tmp0 = tl.load(in_ptr0 + (x2 + 16 * y3), xmask & ymask, eviction_policy
        ='evict_last')
    tl.store(out_ptr0 + (y0 + 3 * x2 + 48 * y1), tmp0, xmask & ymask)


@triton.jit
def triton_poi_fused_1(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK: tl.
    constexpr, XBLOCK: tl.constexpr):
    ynumel = 384
    xnumel = 9
    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 % 3
    y1 = yindex // 3
    tmp0 = tl.load(in_ptr0 + (x2 + 9 * y3), xmask & ymask, eviction_policy=
        'evict_last')
    tl.store(out_ptr0 + (y0 + 3 * x2 + 27 * y1), tmp0, xmask & ymask)


@triton.jit
def triton_poi_fused_2(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK: tl.
    constexpr, XBLOCK: tl.constexpr):
    xnumel = 9
    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 % 128
    y1 = yindex // 128
    tmp0 = tl.load(in_ptr0 + (x2 + 9 * y3), xmask, eviction_policy='evict_last'
        )
    tl.store(out_ptr0 + (y0 + 128 * x2 + 1152 * y1), tmp0, xmask)


@triton.jit
def triton_poi_fused_add_div_3(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr
    ):
    xnumel = 48
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 3
    x1 = xindex // 3 % 2
    x2 = xindex // 6
    x3 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 + 6 * x1 + 24 * x2), xmask)
    tmp1 = tl.load(in_ptr0 + (12 + x0 + 6 * x1 + 24 * x2), xmask)
    tmp3 = tl.load(in_ptr0 + (3 + x0 + 6 * x1 + 24 * x2), xmask)
    tmp5 = tl.load(in_ptr0 + (15 + x0 + 6 * x1 + 24 * x2), xmask)
    tmp2 = tmp0 + tmp1
    tmp4 = tmp2 + tmp3
    tmp6 = tmp4 + tmp5
    tmp7 = 0.25
    tmp8 = tmp6 * tmp7
    tl.store(out_ptr0 + x3, tmp8, xmask)


@triton.jit
def triton_poi_fused_convolution_relu_4(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)
    x2 = xindex
    x0 = xindex % 128
    tmp0 = tl.load(in_out_ptr0 + x2, None)
    tmp1 = tl.load(in_ptr0 + x0, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = tl.full([1], 0, tl.int32)
    tmp4 = triton_helpers.maximum(tmp3, tmp2)
    tl.store(in_out_ptr0 + x2, tmp4, None)


@triton.jit
def triton_poi_fused_add_convolution_div_mul_relu_5(in_out_ptr0, in_ptr0,
    in_ptr1, in_ptr2, 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
    x0 = xindex % 128
    x1 = xindex // 128 % 2
    x2 = xindex // 256
    tmp0 = tl.load(in_out_ptr0 + x3, None)
    tmp1 = tl.load(in_ptr0 + x0, None, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr1 + (x0 + 256 * x1 + 1024 * x2), None)
    tmp4 = tl.load(in_ptr2 + x0, None, eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr1 + (512 + x0 + 256 * x1 + 1024 * x2), None)
    tmp9 = tl.load(in_ptr1 + (128 + x0 + 256 * x1 + 1024 * x2), None)
    tmp12 = tl.load(in_ptr1 + (640 + x0 + 256 * x1 + 1024 * x2), None)
    tmp2 = tmp0 + tmp1
    tmp5 = tmp3 + tmp4
    tmp7 = tmp6 + tmp4
    tmp8 = tmp5 + tmp7
    tmp10 = tmp9 + tmp4
    tmp11 = tmp8 + tmp10
    tmp13 = tmp12 + tmp4
    tmp14 = tmp11 + tmp13
    tmp15 = 0.25
    tmp16 = tmp14 * tmp15
    tmp17 = 0.1
    tmp18 = tmp16 * tmp17
    tmp19 = tmp2 + tmp18
    tmp20 = tl.full([1], 0, tl.int32)
    tmp21 = triton_helpers.maximum(tmp20, tmp19)
    tl.store(in_out_ptr0 + x3, tmp19, None)
    tl.store(out_ptr0 + x3, tmp21, None)


@triton.jit
def triton_poi_fused_convolution_relu_6(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)
    x2 = xindex
    x0 = xindex % 128
    tmp0 = tl.load(in_out_ptr0 + x2, None)
    tmp1 = tl.load(in_ptr0 + x0, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = tl.full([1], 0, tl.int32)
    tmp4 = triton_helpers.maximum(tmp3, tmp2)
    tl.store(in_out_ptr0 + x2, tmp4, None)


@triton.jit
def triton_poi_fused_add_div_mul_relu_7(in_ptr0, in_ptr1, in_ptr2, in_ptr3,
    out_ptr0, out_ptr1, xnumel, XBLOCK: tl.constexpr):
    xnumel = 512
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 128
    x1 = xindex // 128
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 + 512 * x1), xmask)
    tmp1 = tl.load(in_ptr1 + x0, xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr0 + (256 + x0 + 512 * x1), xmask)
    tmp6 = tl.load(in_ptr0 + (128 + x0 + 512 * x1), xmask)
    tmp9 = tl.load(in_ptr0 + (384 + x0 + 512 * x1), xmask)
    tmp14 = tl.load(in_ptr2 + (x0 + 512 * x1), xmask)
    tmp15 = tl.load(in_ptr3 + x0, xmask, eviction_policy='evict_last')
    tmp17 = tl.load(in_ptr2 + (256 + x0 + 512 * x1), xmask)
    tmp20 = tl.load(in_ptr2 + (128 + x0 + 512 * x1), xmask)
    tmp23 = tl.load(in_ptr2 + (384 + x0 + 512 * x1), xmask)
    tmp2 = tmp0 + tmp1
    tmp4 = tmp3 + tmp1
    tmp5 = tmp2 + tmp4
    tmp7 = tmp6 + tmp1
    tmp8 = tmp5 + tmp7
    tmp10 = tmp9 + tmp1
    tmp11 = tmp8 + tmp10
    tmp12 = 0.25
    tmp13 = tmp11 * tmp12
    tmp16 = tmp14 + tmp15
    tmp18 = tmp17 + tmp15
    tmp19 = tmp16 + tmp18
    tmp21 = tmp20 + tmp15
    tmp22 = tmp19 + tmp21
    tmp24 = tmp23 + tmp15
    tmp25 = tmp22 + tmp24
    tmp26 = tmp25 * tmp12
    tmp27 = 0.1
    tmp28 = tmp26 * tmp27
    tmp29 = tmp13 + tmp28
    tmp30 = tl.full([1], 0, tl.int32)
    tmp31 = triton_helpers.maximum(tmp30, tmp29)
    tl.store(out_ptr0 + x2, tmp29, xmask)
    tl.store(out_ptr1 + x2, tmp31, xmask)


@triton.jit
def triton_poi_fused_convolution_relu_8(in_out_ptr0, in_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 512
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 128
    tmp0 = tl.load(in_out_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr0 + x0, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = tl.full([1], 0, tl.int32)
    tmp4 = triton_helpers.maximum(tmp3, tmp2)
    tl.store(in_out_ptr0 + x2, tmp4, xmask)


@triton.jit
def triton_poi_fused_add_convolution_mul_relu_9(in_ptr0, in_ptr1, in_ptr2,
    out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 512
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 128
    tmp0 = tl.load(in_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr1 + x2, xmask)
    tmp2 = tl.load(in_ptr2 + x0, xmask, eviction_policy='evict_last')
    tmp3 = tmp1 + tmp2
    tmp4 = 0.1
    tmp5 = tmp3 * tmp4
    tmp6 = tmp0 + tmp5
    tmp7 = tl.full([1], 0, tl.int32)
    tmp8 = triton_helpers.maximum(tmp7, tmp6)
    tl.store(out_ptr0 + x2, tmp8, xmask)


@triton.jit
def triton_poi_fused_add_convolution_mean_mul_relu_threshold_backward_10(
    in_out_ptr0, in_ptr0, in_ptr1, in_ptr2, in_ptr3, out_ptr0, out_ptr1,
    xnumel, XBLOCK: tl.constexpr):
    xnumel = 512
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 128
    tmp0 = tl.load(in_out_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr0 + x2, xmask)
    tmp2 = tl.load(in_ptr1 + x0, xmask, eviction_policy='evict_last')
    tmp7 = tl.load(in_ptr2 + x2, xmask)
    tmp8 = tl.load(in_ptr3 + x0, xmask, eviction_policy='evict_last')
    tmp3 = tmp1 + tmp2
    tmp4 = 0.1
    tmp5 = tmp3 * tmp4
    tmp6 = tmp0 + tmp5
    tmp9 = tmp7 + tmp8
    tmp10 = tmp9 * tmp4
    tmp11 = tmp6 + tmp10
    tmp12 = tl.full([1], 0, tl.int32)
    tmp13 = triton_helpers.maximum(tmp12, tmp11)
    tmp14 = 1.0
    tmp15 = tmp13 / tmp14
    tmp16 = tmp15 / tmp14
    tmp17 = 0.0
    tmp18 = tmp13 <= tmp17
    tl.store(out_ptr0 + x2, tmp16, xmask)
    tl.store(out_ptr1 + x2, tmp18, 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
        ) = args
    args.clear()
    assert_size_stride(primals_1, (4, 3, 4, 4), (48, 16, 4, 1))
    assert_size_stride(primals_2, (128, 3, 1, 1), (3, 1, 1, 1))
    assert_size_stride(primals_3, (128,), (1,))
    assert_size_stride(primals_4, (128, 3, 3, 3), (27, 9, 3, 1))
    assert_size_stride(primals_5, (128,), (1,))
    assert_size_stride(primals_6, (128, 128, 3, 3), (1152, 9, 3, 1))
    assert_size_stride(primals_7, (128,), (1,))
    assert_size_stride(primals_8, (128, 128, 1, 1), (128, 1, 1, 1))
    assert_size_stride(primals_9, (128,), (1,))
    assert_size_stride(primals_10, (128, 128, 3, 3), (1152, 9, 3, 1))
    assert_size_stride(primals_11, (128,), (1,))
    assert_size_stride(primals_12, (128, 128, 3, 3), (1152, 9, 3, 1))
    assert_size_stride(primals_13, (128,), (1,))
    assert_size_stride(primals_14, (128, 128, 3, 3), (1152, 9, 3, 1))
    assert_size_stride(primals_15, (128,), (1,))
    assert_size_stride(primals_16, (128, 128, 3, 3), (1152, 9, 3, 1))
    assert_size_stride(primals_17, (128,), (1,))
    assert_size_stride(primals_18, (128, 128, 3, 3), (1152, 9, 3, 1))
    assert_size_stride(primals_19, (128,), (1,))
    assert_size_stride(primals_20, (128, 128, 3, 3), (1152, 9, 3, 1))
    assert_size_stride(primals_21, (128,), (1,))
    assert_size_stride(primals_22, (1, 128), (128, 1))
    assert_size_stride(primals_23, (1,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 3, 4, 4), (48, 1, 12, 3), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_0[grid(12, 16)](primals_1, buf0, 12, 16, XBLOCK=16,
            YBLOCK=16, num_warps=4, num_stages=1)
        del primals_1
        buf1 = empty_strided_cuda((128, 3, 3, 3), (27, 1, 9, 3), torch.float32)
        triton_poi_fused_1[grid(384, 9)](primals_4, buf1, 384, 9, XBLOCK=16,
            YBLOCK=64, num_warps=4, num_stages=1)
        del primals_4
        buf2 = empty_strided_cuda((128, 128, 3, 3), (1152, 1, 384, 128),
            torch.float32)
        triton_poi_fused_2[grid(16384, 9)](primals_6, buf2, 16384, 9,
            XBLOCK=16, YBLOCK=64, num_warps=4, num_stages=1)
        del primals_6
        buf3 = empty_strided_cuda((128, 128, 3, 3), (1152, 1, 384, 128),
            torch.float32)
        triton_poi_fused_2[grid(16384, 9)](primals_10, buf3, 16384, 9,
            XBLOCK=16, YBLOCK=64, num_warps=4, num_stages=1)
        del primals_10
        buf4 = empty_strided_cuda((128, 128, 3, 3), (1152, 1, 384, 128),
            torch.float32)
        triton_poi_fused_2[grid(16384, 9)](primals_12, buf4, 16384, 9,
            XBLOCK=16, YBLOCK=64, num_warps=4, num_stages=1)
        del primals_12
        buf5 = empty_strided_cuda((128, 128, 3, 3), (1152, 1, 384, 128),
            torch.float32)
        triton_poi_fused_2[grid(16384, 9)](primals_14, buf5, 16384, 9,
            XBLOCK=16, YBLOCK=64, num_warps=4, num_stages=1)
        del primals_14
        buf6 = empty_strided_cuda((128, 128, 3, 3), (1152, 1, 384, 128),
            torch.float32)
        triton_poi_fused_2[grid(16384, 9)](primals_16, buf6, 16384, 9,
            XBLOCK=16, YBLOCK=64, num_warps=4, num_stages=1)
        del primals_16
        buf7 = empty_strided_cuda((128, 128, 3, 3), (1152, 1, 384, 128),
            torch.float32)
        triton_poi_fused_2[grid(16384, 9)](primals_18, buf7, 16384, 9,
            XBLOCK=16, YBLOCK=64, num_warps=4, num_stages=1)
        del primals_18
        buf8 = empty_strided_cuda((128, 128, 3, 3), (1152, 1, 384, 128),
            torch.float32)
        triton_poi_fused_2[grid(16384, 9)](primals_20, buf8, 16384, 9,
            XBLOCK=16, YBLOCK=64, num_warps=4, num_stages=1)
        del primals_20
        buf9 = empty_strided_cuda((4, 3, 2, 2), (12, 1, 6, 3), torch.float32)
        triton_poi_fused_add_div_3[grid(48)](buf0, buf9, 48, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf10 = extern_kernels.convolution(buf9, primals_2, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf10, (4, 128, 2, 2), (512, 1, 256, 128))
        buf11 = extern_kernels.convolution(buf0, buf1, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf11, (4, 128, 4, 4), (2048, 1, 512, 128))
        buf12 = buf11
        del buf11
        triton_poi_fused_convolution_relu_4[grid(8192)](buf12, primals_5, 
            8192, XBLOCK=128, num_warps=4, num_stages=1)
        del primals_5
        buf13 = extern_kernels.convolution(buf12, buf2, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf13, (4, 128, 4, 4), (2048, 1, 512, 128))
        buf14 = buf10
        del buf10
        buf16 = empty_strided_cuda((4, 128, 2, 2), (512, 1, 256, 128),
            torch.float32)
        triton_poi_fused_add_convolution_div_mul_relu_5[grid(2048)](buf14,
            primals_3, buf13, primals_7, buf16, 2048, XBLOCK=256, num_warps
            =4, num_stages=1)
        del buf13
        del primals_3
        del primals_7
        buf15 = extern_kernels.convolution(buf14, primals_8, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf15, (4, 128, 2, 2), (512, 1, 256, 128))
        buf17 = extern_kernels.convolution(buf16, buf3, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf17, (4, 128, 2, 2), (512, 1, 256, 128))
        buf18 = buf17
        del buf17
        triton_poi_fused_convolution_relu_6[grid(2048)](buf18, primals_11, 
            2048, XBLOCK=256, num_warps=4, num_stages=1)
        del primals_11
        buf19 = extern_kernels.convolution(buf18, buf4, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf19, (4, 128, 2, 2), (512, 1, 256, 128))
        buf20 = empty_strided_cuda((4, 128, 1, 1), (128, 1, 512, 512),
            torch.float32)
        buf21 = empty_strided_cuda((4, 128, 1, 1), (128, 1, 128, 128),
            torch.float32)
        triton_poi_fused_add_div_mul_relu_7[grid(512)](buf15, primals_9,
            buf19, primals_13, buf20, buf21, 512, XBLOCK=256, num_warps=4,
            num_stages=1)
        del buf15
        del buf19
        del primals_13
        del primals_9
        buf22 = extern_kernels.convolution(buf21, buf5, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf22, (4, 128, 1, 1), (128, 1, 128, 128))
        buf23 = buf22
        del buf22
        triton_poi_fused_convolution_relu_8[grid(512)](buf23, primals_15, 
            512, XBLOCK=256, num_warps=4, num_stages=1)
        del primals_15
        buf24 = extern_kernels.convolution(buf23, buf6, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf24, (4, 128, 1, 1), (128, 1, 128, 128))
        buf25 = empty_strided_cuda((4, 128, 1, 1), (128, 1, 128, 128),
            torch.float32)
        triton_poi_fused_add_convolution_mul_relu_9[grid(512)](buf20, buf24,
            primals_17, buf25, 512, XBLOCK=256, num_warps=4, num_stages=1)
        buf26 = extern_kernels.convolution(buf25, buf7, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf26, (4, 128, 1, 1), (128, 1, 128, 128))
        buf27 = buf26
        del buf26
        triton_poi_fused_convolution_relu_8[grid(512)](buf27, primals_19, 
            512, XBLOCK=256, num_warps=4, num_stages=1)
        del primals_19
        buf28 = extern_kernels.convolution(buf27, buf8, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf28, (4, 128, 1, 1), (128, 1, 128, 128))
        buf29 = buf20
        del buf20
        buf30 = empty_strided_cuda((4, 128), (128, 1), torch.float32)
        buf33 = empty_strided_cuda((4, 128, 1, 1), (128, 1, 128, 128),
            torch.bool)
        triton_poi_fused_add_convolution_mean_mul_relu_threshold_backward_10[
            grid(512)](buf29, buf24, primals_17, buf28, primals_21, buf30,
            buf33, 512, XBLOCK=256, num_warps=4, num_stages=1)
        del buf24
        del buf28
        del buf29
        del primals_17
        del primals_21
        buf32 = empty_strided_cuda((4, 1), (1, 1), torch.float32)
        extern_kernels.addmm(primals_23, buf30, reinterpret_tensor(
            primals_22, (128, 1), (1, 128), 0), alpha=1, beta=1, out=buf32)
        del primals_23
    return (reinterpret_tensor(buf32, (4,), (1,), 0), buf0, primals_2, buf1,
        buf2, primals_8, buf3, buf4, buf5, buf6, buf7, buf8, buf9, buf12,
        buf14, buf16, buf18, buf21, buf23, buf25, buf27, buf30, primals_22,
        buf33)


def global_pooling(input, pooling='mean'):
    if pooling == 'mean':
        return input.mean(3).mean(2)
    elif pooling == 'sum':
        return input.sum(3).sum(2)
    else:
        raise NotImplementedError()


class CustomConv2d(nn.Module):

    def __init__(self, in_channels, out_channels, kernel_size, stride=1,
        padding=None, bias=True, residual_init=True):
        super(CustomConv2d, self).__init__()
        self.residual_init = residual_init
        if padding is None:
            padding = int((kernel_size - 1) / 2)
        self.conv = nn.Conv2d(in_channels, out_channels, kernel_size,
            stride=stride, padding=padding, bias=bias)

    def forward(self, input):
        return self.conv(input)


class ConvMeanPool(nn.Module):

    def __init__(self, in_channels, out_channels, kernel_size, bias=True,
        residual_init=True):
        super(ConvMeanPool, self).__init__()
        self.conv = CustomConv2d(in_channels, out_channels, kernel_size,
            bias=bias, residual_init=residual_init)

    def forward(self, input):
        output = input
        output = self.conv(output)
        output = (output[:, :, ::2, ::2] + output[:, :, 1::2, ::2] + output
            [:, :, ::2, 1::2] + output[:, :, 1::2, 1::2]) / 4
        return output


class MeanPoolConv(nn.Module):

    def __init__(self, in_channels, out_channels, kernel_size, bias=True,
        residual_init=True):
        super(MeanPoolConv, self).__init__()
        self.conv = CustomConv2d(in_channels, out_channels, kernel_size,
            bias=bias, residual_init=residual_init)

    def forward(self, input):
        output = input
        output = (output[:, :, ::2, ::2] + output[:, :, 1::2, ::2] + output
            [:, :, ::2, 1::2] + output[:, :, 1::2, 1::2]) / 4
        output = self.conv(output)
        return output


class DepthToSpace(nn.Module):

    def __init__(self, block_size):
        super(DepthToSpace, self).__init__()
        self.block_size = block_size
        self.block_size_square = block_size * block_size

    def forward(self, input):
        output = input.permute(0, 2, 3, 1)
        batch_size, in_height, in_width, in_depth = output.size()
        out_depth = int(in_depth / self.block_size_square)
        out_width = int(in_width * self.block_size)
        out_height = int(in_height * self.block_size)
        output = output.contiguous().view(batch_size, in_height, in_width,
            self.block_size_square, out_depth)
        output_list = output.split(self.block_size, 3)
        output_list = [output_element.contiguous().view(batch_size,
            in_height, out_width, out_depth) for output_element in output_list]
        output = torch.stack(output_list, 0).transpose(0, 1).permute(0, 2, 
            1, 3, 4).contiguous().view(batch_size, out_height, out_width,
            out_depth)
        output = output.permute(0, 3, 1, 2)
        return output


class UpSampleConv(nn.Module):

    def __init__(self, in_channels, out_channels, kernel_size, bias=True,
        residual_init=True):
        super(UpSampleConv, self).__init__()
        self.conv = CustomConv2d(in_channels, out_channels, kernel_size,
            bias=bias, residual_init=residual_init)
        self.depth_to_space = DepthToSpace(2)

    def forward(self, input):
        output = input
        output = torch.cat((output, output, output, output), 1)
        output = self.depth_to_space(output)
        output = self.conv(output)
        return output


class ResidualBlock(nn.Module):

    def __init__(self, in_channels, out_channels, kernel_size, resample=
        None, residual_factor=1.0):
        super(ResidualBlock, self).__init__()
        self.residual_factor = residual_factor
        if in_channels != out_channels or resample is not None:
            self.learnable_shortcut = True
        else:
            self.learnable_shortcut = False
        self.relu1 = nn.ReLU()
        self.relu2 = nn.ReLU()
        if resample == 'down':
            self.conv_shortcut = ConvMeanPool(in_channels, out_channels,
                kernel_size=1, residual_init=False)
            self.conv1 = CustomConv2d(in_channels, in_channels, kernel_size
                =kernel_size)
            self.conv2 = ConvMeanPool(in_channels, out_channels,
                kernel_size=kernel_size)
        elif resample == 'up':
            self.conv_shortcut = UpSampleConv(in_channels, out_channels,
                kernel_size=1, residual_init=False)
            self.conv1 = UpSampleConv(in_channels, out_channels,
                kernel_size=kernel_size)
            self.conv2 = CustomConv2d(out_channels, out_channels,
                kernel_size=kernel_size)
        elif resample is None:
            if self.learnable_shortcut:
                self.conv_shortcut = CustomConv2d(in_channels, out_channels,
                    kernel_size=1, residual_init=False)
            self.conv1 = CustomConv2d(in_channels, out_channels,
                kernel_size=kernel_size)
            self.conv2 = CustomConv2d(out_channels, out_channels,
                kernel_size=kernel_size)
        else:
            raise NotImplementedError()

    def forward(self, input):
        if self.learnable_shortcut:
            shortcut = self.conv_shortcut(input)
        else:
            shortcut = input
        output = input
        output = self.relu1(output)
        output = self.conv1(output)
        output = self.relu2(output)
        output = self.conv2(output)
        return shortcut + self.residual_factor * output


class OptimizedResidualBlock(nn.Module):

    def __init__(self, in_channels, out_channels, kernel_size,
        residual_factor=1.0):
        super(OptimizedResidualBlock, self).__init__()
        self.residual_factor = residual_factor
        self.conv1 = CustomConv2d(in_channels, out_channels, kernel_size=
            kernel_size)
        self.conv2 = ConvMeanPool(out_channels, out_channels, kernel_size=
            kernel_size)
        self.conv_shortcut = MeanPoolConv(in_channels, out_channels,
            kernel_size=1, residual_init=False)
        self.relu2 = nn.ReLU()

    def forward(self, input):
        shortcut = self.conv_shortcut(input)
        output = input
        output = self.conv1(output)
        output = self.relu2(output)
        output = self.conv2(output)
        return shortcut + self.residual_factor * output


class DiscriminatorNew(nn.Module):

    def __init__(self, image_channels=3, channels=128, residual_factor=0.1,
        pooling='mean'):
        super(DiscriminatorNew, self).__init__()
        self.channels = channels
        self.image_channels = image_channels
        self.residual_factor = residual_factor
        self.pooling = pooling
        self.block1 = OptimizedResidualBlock(image_channels, channels, 3,
            residual_factor=residual_factor)
        self.block2 = ResidualBlock(channels, channels, 3, resample='down',
            residual_factor=residual_factor)
        self.block3 = ResidualBlock(channels, channels, 3, resample=None,
            residual_factor=residual_factor)
        self.block4 = ResidualBlock(channels, channels, 3, resample=None,
            residual_factor=residual_factor)
        self.relu5 = nn.ReLU()
        self.linear5 = nn.Linear(channels, 1)

    def forward(self, input_0):
        primals_4 = self.block1.conv1.conv.weight
        primals_3 = self.block1.conv1.conv.bias
        primals_6 = self.block1.conv2.conv.conv.weight
        primals_5 = self.block1.conv2.conv.conv.bias
        primals_2 = self.block1.conv_shortcut.conv.conv.weight
        primals_7 = self.block1.conv_shortcut.conv.conv.bias
        primals_8 = self.block2.conv_shortcut.conv.conv.weight
        primals_9 = self.block2.conv_shortcut.conv.conv.bias
        primals_10 = self.block2.conv1.conv.weight
        primals_11 = self.block2.conv1.conv.bias
        primals_12 = self.block2.conv2.conv.conv.weight
        primals_13 = self.block2.conv2.conv.conv.bias
        primals_14 = self.block3.conv1.conv.weight
        primals_15 = self.block3.conv1.conv.bias
        primals_16 = self.block3.conv2.conv.weight
        primals_17 = self.block3.conv2.conv.bias
        primals_18 = self.block4.conv1.conv.weight
        primals_19 = self.block4.conv1.conv.bias
        primals_20 = self.block4.conv2.conv.weight
        primals_21 = self.block4.conv2.conv.bias
        primals_22 = self.linear5.weight
        primals_23 = self.linear5.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])
        return output[0]


Measured latency_ms: 0.049478