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


@triton.jit
def triton_poi_fused_leaky_relu_0(in_ptr0, 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)
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + x0, None)
    tmp1 = 0.0
    tmp2 = tmp0 > tmp1
    tmp3 = 0.2
    tmp4 = tmp0 * tmp3
    tmp5 = tl.where(tmp2, tmp0, tmp4)
    tl.store(out_ptr0 + x0, tmp2, None)
    tl.store(out_ptr1 + x0, tmp5, None)


@triton.jit
def triton_poi_fused_leaky_relu_1(in_ptr0, 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)
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + x0, None)
    tmp1 = 0.0
    tmp2 = tmp0 > tmp1
    tmp3 = 0.2
    tmp4 = tmp0 * tmp3
    tmp5 = tl.where(tmp2, tmp0, tmp4)
    tl.store(out_ptr0 + x0, tmp2, None)
    tl.store(out_ptr1 + x0, tmp5, None)


@triton.jit
def triton_poi_fused_leaky_relu_2(in_ptr0, 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)
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + x0, None)
    tmp1 = 0.0
    tmp2 = tmp0 > tmp1
    tmp3 = 0.2
    tmp4 = tmp0 * tmp3
    tmp5 = tl.where(tmp2, tmp0, tmp4)
    tl.store(out_ptr0 + x0, tmp2, None)
    tl.store(out_ptr1 + x0, tmp5, None)


@triton.jit
def triton_poi_fused_leaky_relu_3(in_ptr0, 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)
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + x0, None)
    tmp1 = 0.0
    tmp2 = tmp0 > tmp1
    tmp3 = 0.2
    tmp4 = tmp0 * tmp3
    tmp5 = tl.where(tmp2, tmp0, tmp4)
    tl.store(out_ptr0 + x0, tmp2, None)
    tl.store(out_ptr1 + x0, tmp5, None)


@triton.jit
def triton_poi_fused_leaky_relu_4(in_ptr0, 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)
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + x0, None)
    tmp1 = 0.0
    tmp2 = tmp0 > tmp1
    tmp3 = 0.2
    tmp4 = tmp0 * tmp3
    tmp5 = tl.where(tmp2, tmp0, tmp4)
    tl.store(out_ptr0 + x0, tmp2, None)
    tl.store(out_ptr1 + x0, tmp5, None)


@triton.jit
def triton_poi_fused_leaky_relu_5(in_ptr0, 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)
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + x0, None)
    tmp1 = 0.0
    tmp2 = tmp0 > tmp1
    tmp3 = 0.2
    tmp4 = tmp0 * tmp3
    tmp5 = tl.where(tmp2, tmp0, tmp4)
    tl.store(out_ptr0 + x0, tmp2, None)
    tl.store(out_ptr1 + x0, tmp5, None)


@triton.jit
def triton_poi_fused_max_pool2d_with_indices_sigmoid_6(in_ptr0, out_ptr0,
    out_ptr1, xnumel, XBLOCK: tl.constexpr):
    xnumel = 8
    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')
    tmp7 = tl.load(in_ptr0 + (2 + 4 * x0), xmask, eviction_policy='evict_last')
    tmp12 = tl.load(in_ptr0 + (3 + 4 * x0), xmask, eviction_policy='evict_last'
        )
    tmp2 = tmp1 > tmp0
    tmp3 = tl.full([1], 1, tl.int8)
    tmp4 = tl.full([1], 0, tl.int8)
    tmp5 = tl.where(tmp2, tmp3, tmp4)
    tmp6 = triton_helpers.maximum(tmp1, tmp0)
    tmp8 = tmp7 > tmp6
    tmp9 = tl.full([1], 2, tl.int8)
    tmp10 = tl.where(tmp8, tmp9, tmp5)
    tmp11 = triton_helpers.maximum(tmp7, tmp6)
    tmp13 = tmp12 > tmp11
    tmp14 = tl.full([1], 3, tl.int8)
    tmp15 = tl.where(tmp13, tmp14, tmp10)
    tmp16 = triton_helpers.maximum(tmp12, tmp11)
    tmp17 = tl.sigmoid(tmp16)
    tl.store(out_ptr0 + x0, tmp15, xmask)
    tl.store(out_ptr1 + x0, tmp17, xmask)


def call(args):
    (primals_1, primals_2, primals_3, primals_4, primals_5, primals_6,
        primals_7, primals_8) = args
    args.clear()
    assert_size_stride(primals_1, (16, 2, 4, 4), (32, 16, 4, 1))
    assert_size_stride(primals_2, (4, 2, 256, 256), (131072, 65536, 256, 1))
    assert_size_stride(primals_3, (32, 16, 4, 4), (256, 16, 4, 1))
    assert_size_stride(primals_4, (64, 32, 4, 4), (512, 16, 4, 1))
    assert_size_stride(primals_5, (128, 64, 4, 4), (1024, 16, 4, 1))
    assert_size_stride(primals_6, (128, 128, 4, 4), (2048, 16, 4, 1))
    assert_size_stride(primals_7, (128, 128, 4, 4), (2048, 16, 4, 1))
    assert_size_stride(primals_8, (2, 128, 3, 3), (1152, 9, 3, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = extern_kernels.convolution(primals_2, primals_1, stride=(2, 
            2), padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf0, (4, 16, 128, 128), (262144, 16384, 128, 1))
        buf1 = empty_strided_cuda((4, 16, 128, 128), (262144, 16384, 128, 1
            ), torch.bool)
        buf2 = empty_strided_cuda((4, 16, 128, 128), (262144, 16384, 128, 1
            ), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_leaky_relu_0[grid(1048576)](buf0, buf1, buf2, 
            1048576, XBLOCK=1024, num_warps=4, num_stages=1)
        del buf0
        buf3 = extern_kernels.convolution(buf2, primals_3, stride=(2, 2),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf3, (4, 32, 64, 64), (131072, 4096, 64, 1))
        buf4 = empty_strided_cuda((4, 32, 64, 64), (131072, 4096, 64, 1),
            torch.bool)
        buf5 = empty_strided_cuda((4, 32, 64, 64), (131072, 4096, 64, 1),
            torch.float32)
        triton_poi_fused_leaky_relu_1[grid(524288)](buf3, buf4, buf5, 
            524288, XBLOCK=512, num_warps=8, num_stages=1)
        del buf3
        buf6 = extern_kernels.convolution(buf5, primals_4, stride=(2, 2),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf6, (4, 64, 32, 32), (65536, 1024, 32, 1))
        buf7 = empty_strided_cuda((4, 64, 32, 32), (65536, 1024, 32, 1),
            torch.bool)
        buf8 = empty_strided_cuda((4, 64, 32, 32), (65536, 1024, 32, 1),
            torch.float32)
        triton_poi_fused_leaky_relu_2[grid(262144)](buf6, buf7, buf8, 
            262144, XBLOCK=1024, num_warps=4, num_stages=1)
        del buf6
        buf9 = extern_kernels.convolution(buf8, primals_5, stride=(2, 2),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf9, (4, 128, 16, 16), (32768, 256, 16, 1))
        buf10 = empty_strided_cuda((4, 128, 16, 16), (32768, 256, 16, 1),
            torch.bool)
        buf11 = empty_strided_cuda((4, 128, 16, 16), (32768, 256, 16, 1),
            torch.float32)
        triton_poi_fused_leaky_relu_3[grid(131072)](buf9, buf10, buf11, 
            131072, XBLOCK=1024, num_warps=4, num_stages=1)
        del buf9
        buf12 = extern_kernels.convolution(buf11, primals_6, stride=(2, 2),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf12, (4, 128, 8, 8), (8192, 64, 8, 1))
        buf13 = empty_strided_cuda((4, 128, 8, 8), (8192, 64, 8, 1), torch.bool
            )
        buf14 = empty_strided_cuda((4, 128, 8, 8), (8192, 64, 8, 1), torch.
            float32)
        triton_poi_fused_leaky_relu_4[grid(32768)](buf12, buf13, buf14, 
            32768, XBLOCK=256, num_warps=4, num_stages=1)
        del buf12
        buf15 = extern_kernels.convolution(buf14, primals_7, stride=(2, 2),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf15, (4, 128, 4, 4), (2048, 16, 4, 1))
        buf16 = empty_strided_cuda((4, 128, 4, 4), (2048, 16, 4, 1), torch.bool
            )
        buf17 = empty_strided_cuda((4, 128, 4, 4), (2048, 16, 4, 1), torch.
            float32)
        triton_poi_fused_leaky_relu_5[grid(8192)](buf15, buf16, buf17, 8192,
            XBLOCK=256, num_warps=4, num_stages=1)
        del buf15
        buf18 = extern_kernels.convolution(buf17, primals_8, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf18, (4, 2, 2, 2), (8, 4, 2, 1))
        buf19 = empty_strided_cuda((4, 2, 1, 1), (2, 1, 1, 1), torch.int8)
        buf20 = empty_strided_cuda((4, 2, 1, 1), (2, 1, 1, 1), torch.float32)
        triton_poi_fused_max_pool2d_with_indices_sigmoid_6[grid(8)](buf18,
            buf19, buf20, 8, XBLOCK=8, num_warps=1, num_stages=1)
    return (buf20, primals_1, primals_2, primals_3, primals_4, primals_5,
        primals_6, primals_7, primals_8, buf1, buf2, buf4, buf5, buf7, buf8,
        buf10, buf11, buf13, buf14, buf16, buf17, buf18, buf19, buf20)


class DiscriminatorNew(nn.Module):

    def __init__(self):
        super(DiscriminatorNew, self).__init__()
        self.conv1 = nn.Conv2d(2, 16, 4, 2, 1, bias=False)
        self.act1 = nn.LeakyReLU(0.2, inplace=False)
        self.conv2 = nn.Conv2d(16, 32, 4, 2, 1, bias=False)
        self.act2 = nn.LeakyReLU(0.2, inplace=False)
        self.conv3 = nn.Conv2d(32, 64, 4, 2, 1, bias=False)
        self.act3 = nn.LeakyReLU(0.2, inplace=False)
        self.conv4 = nn.Conv2d(64, 128, 4, 2, 1, bias=False)
        self.act4 = nn.LeakyReLU(0.2, inplace=False)
        self.conv5 = nn.Conv2d(128, 128, 4, 2, 1, bias=False)
        self.act5 = nn.LeakyReLU(0.2, inplace=False)
        self.conv6 = nn.Conv2d(128, 128, 4, 2, 1, bias=False)
        self.act6 = nn.LeakyReLU(0.2, inplace=False)
        self.conv7 = nn.Conv2d(128, 2, 3, 1, bias=False)
        self.pool7 = nn.MaxPool2d(2, stride=2)

    def forward(self, input_0):
        primals_1 = self.conv1.weight
        primals_3 = self.conv2.weight
        primals_4 = self.conv3.weight
        primals_5 = self.conv4.weight
        primals_6 = self.conv5.weight
        primals_7 = self.conv6.weight
        primals_8 = self.conv7.weight
        primals_2 = input_0
        output = call([primals_1, primals_2, primals_3, primals_4,
            primals_5, primals_6, primals_7, primals_8])
        return output[0]


Measured latency_ms: 0.213233