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
import torch.optim
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_relu_0(in_out_ptr0, in_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 984064
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x1 = xindex // 3844 % 64
    tmp0 = tl.load(in_out_ptr0 + x3, xmask)
    tmp1 = tl.load(in_ptr0 + x1, 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 + x3, tmp4, xmask)


@triton.jit
def triton_poi_fused_convolution_1(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 // 3600 % 32
    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__adaptive_avg_pool2d_2(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)
    x1 = xindex // 16 % 16
    x0 = xindex % 16
    x2 = xindex // 256
    x4 = xindex
    tmp0 = 15 * x1 // 4
    tmp1 = (75 + 60 * x1) // 16
    tmp2 = tmp0 < tmp1
    tmp3 = 15 * x0 // 4
    tmp4 = (75 + 60 * x0) // 16
    tmp5 = tmp3 < tmp4
    tmp6 = tmp2 & tmp5
    tmp7 = tl.load(in_ptr0 + (60 * (15 * x1 // 4) + 3600 * x2 + 15 * x0 // 
        4), tmp6, eviction_policy='evict_last', other=0.0)
    tmp8 = 1 + 15 * x0 // 4
    tmp9 = tmp8 < tmp4
    tmp10 = tmp2 & tmp9
    tmp11 = tl.load(in_ptr0 + (1 + 60 * (15 * x1 // 4) + 3600 * x2 + 15 *
        x0 // 4), tmp10, eviction_policy='evict_last', other=0.0)
    tmp12 = tmp11 + tmp7
    tmp13 = 2 + 15 * x0 // 4
    tmp14 = tmp13 < tmp4
    tmp15 = tmp2 & tmp14
    tmp16 = tl.load(in_ptr0 + (2 + 60 * (15 * x1 // 4) + 3600 * x2 + 15 *
        x0 // 4), tmp15, eviction_policy='evict_last', other=0.0)
    tmp17 = tmp16 + tmp12
    tmp18 = 3 + 15 * x0 // 4
    tmp19 = tmp18 < tmp4
    tmp20 = tmp2 & tmp19
    tmp21 = tl.load(in_ptr0 + (3 + 60 * (15 * x1 // 4) + 3600 * x2 + 15 *
        x0 // 4), tmp20, eviction_policy='evict_last', other=0.0)
    tmp22 = tmp21 + tmp17
    tmp23 = 4 + 15 * x0 // 4
    tmp24 = tmp23 < tmp4
    tmp25 = tmp2 & tmp24
    tmp26 = tl.load(in_ptr0 + (4 + 60 * (15 * x1 // 4) + 3600 * x2 + 15 *
        x0 // 4), tmp25, eviction_policy='evict_last', other=0.0)
    tmp27 = tmp26 + tmp22
    tmp28 = 1 + 15 * x1 // 4
    tmp29 = tmp28 < tmp1
    tmp30 = tmp29 & tmp5
    tmp31 = tl.load(in_ptr0 + (60 + 60 * (15 * x1 // 4) + 3600 * x2 + 15 *
        x0 // 4), tmp30, eviction_policy='evict_last', other=0.0)
    tmp32 = tmp31 + tmp27
    tmp33 = tmp29 & tmp9
    tmp34 = tl.load(in_ptr0 + (61 + 60 * (15 * x1 // 4) + 3600 * x2 + 15 *
        x0 // 4), tmp33, eviction_policy='evict_last', other=0.0)
    tmp35 = tmp34 + tmp32
    tmp36 = tmp29 & tmp14
    tmp37 = tl.load(in_ptr0 + (62 + 60 * (15 * x1 // 4) + 3600 * x2 + 15 *
        x0 // 4), tmp36, eviction_policy='evict_last', other=0.0)
    tmp38 = tmp37 + tmp35
    tmp39 = tmp29 & tmp19
    tmp40 = tl.load(in_ptr0 + (63 + 60 * (15 * x1 // 4) + 3600 * x2 + 15 *
        x0 // 4), tmp39, eviction_policy='evict_last', other=0.0)
    tmp41 = tmp40 + tmp38
    tmp42 = tmp29 & tmp24
    tmp43 = tl.load(in_ptr0 + (64 + 60 * (15 * x1 // 4) + 3600 * x2 + 15 *
        x0 // 4), tmp42, eviction_policy='evict_last', other=0.0)
    tmp44 = tmp43 + tmp41
    tmp45 = 2 + 15 * x1 // 4
    tmp46 = tmp45 < tmp1
    tmp47 = tmp46 & tmp5
    tmp48 = tl.load(in_ptr0 + (120 + 60 * (15 * x1 // 4) + 3600 * x2 + 15 *
        x0 // 4), tmp47, eviction_policy='evict_last', other=0.0)
    tmp49 = tmp48 + tmp44
    tmp50 = tmp46 & tmp9
    tmp51 = tl.load(in_ptr0 + (121 + 60 * (15 * x1 // 4) + 3600 * x2 + 15 *
        x0 // 4), tmp50, eviction_policy='evict_last', other=0.0)
    tmp52 = tmp51 + tmp49
    tmp53 = tmp46 & tmp14
    tmp54 = tl.load(in_ptr0 + (122 + 60 * (15 * x1 // 4) + 3600 * x2 + 15 *
        x0 // 4), tmp53, eviction_policy='evict_last', other=0.0)
    tmp55 = tmp54 + tmp52
    tmp56 = tmp46 & tmp19
    tmp57 = tl.load(in_ptr0 + (123 + 60 * (15 * x1 // 4) + 3600 * x2 + 15 *
        x0 // 4), tmp56, eviction_policy='evict_last', other=0.0)
    tmp58 = tmp57 + tmp55
    tmp59 = tmp46 & tmp24
    tmp60 = tl.load(in_ptr0 + (124 + 60 * (15 * x1 // 4) + 3600 * x2 + 15 *
        x0 // 4), tmp59, eviction_policy='evict_last', other=0.0)
    tmp61 = tmp60 + tmp58
    tmp62 = 3 + 15 * x1 // 4
    tmp63 = tmp62 < tmp1
    tmp64 = tmp63 & tmp5
    tmp65 = tl.load(in_ptr0 + (180 + 60 * (15 * x1 // 4) + 3600 * x2 + 15 *
        x0 // 4), tmp64, eviction_policy='evict_last', other=0.0)
    tmp66 = tmp65 + tmp61
    tmp67 = tmp63 & tmp9
    tmp68 = tl.load(in_ptr0 + (181 + 60 * (15 * x1 // 4) + 3600 * x2 + 15 *
        x0 // 4), tmp67, eviction_policy='evict_last', other=0.0)
    tmp69 = tmp68 + tmp66
    tmp70 = tmp63 & tmp14
    tmp71 = tl.load(in_ptr0 + (182 + 60 * (15 * x1 // 4) + 3600 * x2 + 15 *
        x0 // 4), tmp70, eviction_policy='evict_last', other=0.0)
    tmp72 = tmp71 + tmp69
    tmp73 = tmp63 & tmp19
    tmp74 = tl.load(in_ptr0 + (183 + 60 * (15 * x1 // 4) + 3600 * x2 + 15 *
        x0 // 4), tmp73, eviction_policy='evict_last', other=0.0)
    tmp75 = tmp74 + tmp72
    tmp76 = tmp63 & tmp24
    tmp77 = tl.load(in_ptr0 + (184 + 60 * (15 * x1 // 4) + 3600 * x2 + 15 *
        x0 // 4), tmp76, eviction_policy='evict_last', other=0.0)
    tmp78 = tmp77 + tmp75
    tmp79 = 4 + 15 * x1 // 4
    tmp80 = tmp79 < tmp1
    tmp81 = tmp80 & tmp5
    tmp82 = tl.load(in_ptr0 + (240 + 60 * (15 * x1 // 4) + 3600 * x2 + 15 *
        x0 // 4), tmp81, eviction_policy='evict_last', other=0.0)
    tmp83 = tmp82 + tmp78
    tmp84 = tmp80 & tmp9
    tmp85 = tl.load(in_ptr0 + (241 + 60 * (15 * x1 // 4) + 3600 * x2 + 15 *
        x0 // 4), tmp84, eviction_policy='evict_last', other=0.0)
    tmp86 = tmp85 + tmp83
    tmp87 = tmp80 & tmp14
    tmp88 = tl.load(in_ptr0 + (242 + 60 * (15 * x1 // 4) + 3600 * x2 + 15 *
        x0 // 4), tmp87, eviction_policy='evict_last', other=0.0)
    tmp89 = tmp88 + tmp86
    tmp90 = tmp80 & tmp19
    tmp91 = tl.load(in_ptr0 + (243 + 60 * (15 * x1 // 4) + 3600 * x2 + 15 *
        x0 // 4), tmp90, eviction_policy='evict_last', other=0.0)
    tmp92 = tmp91 + tmp89
    tmp93 = tmp80 & tmp24
    tmp94 = tl.load(in_ptr0 + (244 + 60 * (15 * x1 // 4) + 3600 * x2 + 15 *
        x0 // 4), tmp93, eviction_policy='evict_last', other=0.0)
    tmp95 = tmp94 + tmp92
    tmp96 = 1.0
    tmp97 = tl.full(tmp96.shape, 0.0, tmp96.dtype)
    tmp98 = tl.where(tmp6, tmp96, tmp97)
    tmp99 = tl.where(tmp10, tmp96, tmp97)
    tmp100 = tmp99 + tmp98
    tmp101 = tl.where(tmp15, tmp96, tmp97)
    tmp102 = tmp101 + tmp100
    tmp103 = tl.where(tmp20, tmp96, tmp97)
    tmp104 = tmp103 + tmp102
    tmp105 = tl.where(tmp25, tmp96, tmp97)
    tmp106 = tmp105 + tmp104
    tmp107 = tl.where(tmp30, tmp96, tmp97)
    tmp108 = tmp107 + tmp106
    tmp109 = tl.where(tmp33, tmp96, tmp97)
    tmp110 = tmp109 + tmp108
    tmp111 = tl.where(tmp36, tmp96, tmp97)
    tmp112 = tmp111 + tmp110
    tmp113 = tl.where(tmp39, tmp96, tmp97)
    tmp114 = tmp113 + tmp112
    tmp115 = tl.where(tmp42, tmp96, tmp97)
    tmp116 = tmp115 + tmp114
    tmp117 = tl.where(tmp47, tmp96, tmp97)
    tmp118 = tmp117 + tmp116
    tmp119 = tl.where(tmp50, tmp96, tmp97)
    tmp120 = tmp119 + tmp118
    tmp121 = tl.where(tmp53, tmp96, tmp97)
    tmp122 = tmp121 + tmp120
    tmp123 = tl.where(tmp56, tmp96, tmp97)
    tmp124 = tmp123 + tmp122
    tmp125 = tl.where(tmp59, tmp96, tmp97)
    tmp126 = tmp125 + tmp124
    tmp127 = tl.where(tmp64, tmp96, tmp97)
    tmp128 = tmp127 + tmp126
    tmp129 = tl.where(tmp67, tmp96, tmp97)
    tmp130 = tmp129 + tmp128
    tmp131 = tl.where(tmp70, tmp96, tmp97)
    tmp132 = tmp131 + tmp130
    tmp133 = tl.where(tmp73, tmp96, tmp97)
    tmp134 = tmp133 + tmp132
    tmp135 = tl.where(tmp76, tmp96, tmp97)
    tmp136 = tmp135 + tmp134
    tmp137 = tl.where(tmp81, tmp96, tmp97)
    tmp138 = tmp137 + tmp136
    tmp139 = tl.where(tmp84, tmp96, tmp97)
    tmp140 = tmp139 + tmp138
    tmp141 = tl.where(tmp87, tmp96, tmp97)
    tmp142 = tmp141 + tmp140
    tmp143 = tl.where(tmp90, tmp96, tmp97)
    tmp144 = tmp143 + tmp142
    tmp145 = tl.where(tmp93, tmp96, tmp97)
    tmp146 = tmp145 + tmp144
    tmp147 = tmp95 / tmp146
    tl.store(out_ptr0 + x4, tmp147, None)


@triton.jit
def triton_poi_fused_cat_3(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK: tl.
    constexpr):
    xnumel = 32784
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 8196
    x1 = xindex // 8196
    tmp0 = x0
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 4, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (4 * x1 + x0), tmp4 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp6 = tmp0 >= tmp3
    tl.full([1], 8196, tl.int64)
    tmp9 = tl.load(in_ptr1 + (8192 * x1 + (-4 + x0)), tmp6 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp10 = tl.where(tmp4, tmp5, tmp9)
    tl.store(out_ptr0 + (x0 + 8224 * x1), tmp10, xmask)


@triton.jit
def triton_poi_fused_relu_4(in_out_ptr0, in_ptr0, xnumel, XBLOCK: tl.constexpr
    ):
    xnumel = 1024
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 256
    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)


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
        ) = args
    args.clear()
    assert_size_stride(primals_1, (64, 4, 3, 3), (36, 9, 3, 1))
    assert_size_stride(primals_2, (64,), (1,))
    assert_size_stride(primals_3, (4, 4, 64, 64), (16384, 4096, 64, 1))
    assert_size_stride(primals_4, (32, 64, 3, 3), (576, 9, 3, 1))
    assert_size_stride(primals_5, (32,), (1,))
    assert_size_stride(primals_6, (4, 4), (4, 1))
    assert_size_stride(primals_7, (256, 8196), (8196, 1))
    assert_size_stride(primals_8, (256,), (1,))
    assert_size_stride(primals_9, (256, 256), (256, 1))
    assert_size_stride(primals_10, (256,), (1,))
    assert_size_stride(primals_11, (1, 256), (256, 1))
    assert_size_stride(primals_12, (1,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = extern_kernels.convolution(primals_3, primals_1, stride=(1, 
            1), padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf0, (4, 64, 62, 62), (246016, 3844, 62, 1))
        buf1 = buf0
        del buf0
        get_raw_stream(0)
        triton_poi_fused_convolution_relu_0[grid(984064)](buf1, primals_2, 
            984064, XBLOCK=1024, num_warps=4, num_stages=1)
        del primals_2
        buf2 = extern_kernels.convolution(buf1, 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, 60, 60), (115200, 3600, 60, 1))
        buf3 = buf2
        del buf2
        triton_poi_fused_convolution_1[grid(460800)](buf3, primals_5, 
            460800, XBLOCK=512, num_warps=8, num_stages=1)
        del primals_5
        buf4 = empty_strided_cuda((4, 32, 16, 16), (8192, 256, 16, 1),
            torch.float32)
        triton_poi_fused__adaptive_avg_pool2d_2[grid(32768)](buf3, buf4, 
            32768, XBLOCK=128, num_warps=4, num_stages=1)
        buf5 = empty_strided_cuda((4, 8196), (8224, 1), torch.float32)
        triton_poi_fused_cat_3[grid(32784)](primals_6, buf4, buf5, 32784,
            XBLOCK=512, num_warps=4, num_stages=1)
        del buf4
        del primals_6
        buf6 = empty_strided_cuda((4, 256), (256, 1), torch.float32)
        extern_kernels.mm(buf5, reinterpret_tensor(primals_7, (8196, 256),
            (1, 8196), 0), out=buf6)
        buf7 = buf6
        del buf6
        triton_poi_fused_relu_4[grid(1024)](buf7, primals_8, 1024, XBLOCK=
            256, num_warps=4, num_stages=1)
        del primals_8
        buf8 = empty_strided_cuda((4, 256), (256, 1), torch.float32)
        extern_kernels.mm(buf7, reinterpret_tensor(primals_9, (256, 256), (
            1, 256), 0), out=buf8)
        buf9 = buf8
        del buf8
        triton_poi_fused_relu_4[grid(1024)](buf9, primals_10, 1024, XBLOCK=
            256, num_warps=4, num_stages=1)
        del primals_10
        buf11 = empty_strided_cuda((4, 1), (1, 1), torch.float32)
        extern_kernels.addmm(primals_12, buf9, reinterpret_tensor(
            primals_11, (256, 1), (1, 256), 0), alpha=1, beta=1, out=buf11)
        del primals_12
    return (buf11, primals_1, primals_3, primals_4, buf1, buf3, buf5, buf7,
        buf9, primals_11, primals_9, primals_7)


class GlobalDiscriminatorNew(nn.Module):

    def __init__(self, y_size, M_channels):
        super().__init__()
        self.c0 = nn.Conv2d(M_channels, 64, kernel_size=3)
        self.c1 = nn.Conv2d(64, 32, kernel_size=3)
        self.avgpool = nn.AdaptiveAvgPool2d(16)
        self.l0 = nn.Linear(32 * 16 * 16 + y_size, 256)
        self.l1 = nn.Linear(256, 256)
        self.l2 = nn.Linear(256, 1)

    def forward(self, input_0, input_1):
        primals_1 = self.c0.weight
        primals_2 = self.c0.bias
        primals_4 = self.c1.weight
        primals_5 = self.c1.bias
        primals_7 = self.l0.weight
        primals_8 = self.l0.bias
        primals_9 = self.l1.weight
        primals_10 = self.l1.bias
        primals_11 = self.l2.weight
        primals_12 = self.l2.bias
        primals_6 = input_0
        primals_3 = input_1
        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])
        return output[0]


Measured latency_ms: 0.015148