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
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_per_fused_mean_0(in_out_ptr0, in_ptr0, out_ptr0, xnumel, rnumel,
    XBLOCK: tl.constexpr):
    xnumel = 1024
    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)
    r2 = rindex
    x3 = xindex
    x0 = xindex % 256
    x1 = xindex // 256
    tmp0 = tl.load(in_ptr0 + (r2 + 16 * x3), xmask, other=0.0)
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK, RBLOCK])
    tmp3 = tl.where(xmask, tmp1, 0)
    tmp4 = tl.sum(tmp3, 1)[:, None]
    tmp5 = 16.0
    tmp6 = tmp4 / tmp5
    tl.store(out_ptr0 + (x0 + 256 * r2 + 4096 * x1), tmp0, xmask)
    tl.debug_barrier()
    tl.store(in_out_ptr0 + x3, tmp6, xmask)


@triton.jit
def triton_poi_fused_1(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK: tl.
    constexpr, XBLOCK: tl.constexpr):
    xnumel = 9
    yoffset = (tl.program_id(1) + tl.program_id(2) * tl.num_programs(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 % 256
    y1 = yindex // 256
    tmp0 = tl.load(in_ptr0 + (x2 + 9 * y3), xmask, eviction_policy='evict_last'
        )
    tl.store(out_ptr0 + (y0 + 256 * x2 + 2304 * y1), tmp0, xmask)


@triton.jit
def triton_poi_fused__to_copy_2(out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 4
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = tl.full([1], 0, tl.int64)
    tl.store(out_ptr0 + x0, tmp0, xmask)


@triton.jit
def triton_poi_fused__to_copy_arange_clamp_mul_sub_3(out_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 4
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = 0.0
    tl.store(out_ptr0 + x0, tmp0, xmask)


@triton.jit
def triton_poi_fused__unsafe_index_add_convolution_mul_sub_4(in_ptr0,
    in_ptr1, in_ptr2, in_ptr3, in_ptr4, in_ptr5, 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 // 4 % 4
    x0 = xindex % 4
    x5 = xindex // 16
    x2 = xindex // 16 % 256
    x6 = xindex
    tmp0 = tl.load(in_ptr0 + x1, None, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr1 + x0, None, eviction_policy='evict_last')
    tmp9 = tl.load(in_ptr2 + x5, None, eviction_policy='evict_last')
    tmp10 = tl.load(in_ptr3 + x2, None, eviction_policy='evict_last')
    tmp12 = tl.load(in_ptr4 + x0, None, eviction_policy='evict_last')
    tmp17 = tl.load(in_ptr5 + x0, None, eviction_policy='evict_last')
    tmp1 = tl.full([XBLOCK], 1, tl.int32)
    tmp2 = tmp0 + tmp1
    tmp3 = tmp0 < 0
    tl.where(tmp3, tmp2, tmp0)
    tmp6 = tmp5 + tmp1
    tmp7 = tmp5 < 0
    tl.where(tmp7, tmp6, tmp5)
    tmp11 = tmp9 + tmp10
    tmp13 = tmp12 + tmp1
    tmp14 = tmp12 < 0
    tl.where(tmp14, tmp13, tmp12)
    tmp16 = tmp11 - tmp11
    tmp18 = tmp16 * tmp17
    tmp19 = tmp11 + tmp18
    tl.store(out_ptr0 + x6, tmp19, None)


@triton.jit
def triton_poi_fused_cat_5(in_ptr0, in_ptr1, in_ptr2, in_ptr3, in_ptr4,
    in_ptr5, in_ptr6, in_ptr7, in_ptr8, in_ptr9, in_ptr10, in_ptr11,
    in_ptr12, in_ptr13, in_ptr14, in_ptr15, 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 % 1280
    x3 = xindex // 20480
    x4 = xindex // 1280 % 16
    x2 = xindex // 5120 % 4
    x1 = xindex // 1280 % 4
    x5 = xindex // 1280
    x6 = xindex
    tmp0 = x0
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 256, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (x4 + 16 * x0 + 4096 * x3), tmp4,
        eviction_policy='evict_last', other=0.0)
    tmp6 = tl.load(in_ptr1 + x2, tmp4, eviction_policy='evict_last', other=0.0)
    tmp7 = tl.full([XBLOCK], 1, tl.int32)
    tmp8 = tmp6 + tmp7
    tmp9 = tmp6 < 0
    tl.where(tmp9, tmp8, tmp6)
    tmp11 = tl.load(in_ptr2 + x1, tmp4, eviction_policy='evict_last', other=0.0
        )
    tmp12 = tmp11 + tmp7
    tmp13 = tmp11 < 0
    tl.where(tmp13, tmp12, tmp11)
    tmp15 = tl.load(in_ptr3 + (256 * x3 + x0), tmp4, eviction_policy=
        'evict_last', other=0.0)
    tmp16 = tl.load(in_ptr4 + x0, tmp4, eviction_policy='evict_last', other=0.0
        )
    tmp17 = tmp15 + tmp16
    tmp18 = tl.load(in_ptr5 + x1, tmp4, eviction_policy='evict_last', other=0.0
        )
    tmp19 = tmp18 + tmp7
    tmp20 = tmp18 < 0
    tl.where(tmp20, tmp19, tmp18)
    tmp22 = tmp17 - tmp17
    tmp23 = tl.load(in_ptr6 + x1, tmp4, eviction_policy='evict_last', other=0.0
        )
    tmp24 = tmp22 * tmp23
    tmp25 = tmp17 + tmp24
    tmp26 = tmp25 - tmp5
    tmp27 = tl.load(in_ptr7 + x2, tmp4, eviction_policy='evict_last', other=0.0
        )
    tmp28 = tmp26 * tmp27
    tmp29 = tmp5 + tmp28
    tmp30 = tl.full(tmp29.shape, 0.0, tmp29.dtype)
    tmp31 = tl.where(tmp4, tmp29, tmp30)
    tmp32 = tmp0 >= tmp3
    tmp33 = tl.full([1], 512, tl.int64)
    tmp34 = tmp0 < tmp33
    tmp35 = tmp32 & tmp34
    tmp36 = tl.load(in_ptr8 + (256 * x5 + (-256 + x0)), tmp35,
        eviction_policy='evict_last', other=0.0)
    tmp37 = tl.load(in_ptr9 + (-256 + x0), tmp35, eviction_policy=
        'evict_last', other=0.0)
    tmp38 = tmp36 + tmp37
    tmp39 = tl.full(tmp38.shape, 0.0, tmp38.dtype)
    tmp40 = tl.where(tmp35, tmp38, tmp39)
    tmp41 = tmp0 >= tmp33
    tmp42 = tl.full([1], 768, tl.int64)
    tmp43 = tmp0 < tmp42
    tmp44 = tmp41 & tmp43
    tmp45 = tl.load(in_ptr10 + (256 * x5 + (-512 + x0)), tmp44,
        eviction_policy='evict_last', other=0.0)
    tmp46 = tl.load(in_ptr11 + (-512 + x0), tmp44, eviction_policy=
        'evict_last', other=0.0)
    tmp47 = tmp45 + tmp46
    tmp48 = tl.full(tmp47.shape, 0.0, tmp47.dtype)
    tmp49 = tl.where(tmp44, tmp47, tmp48)
    tmp50 = tmp0 >= tmp42
    tmp51 = tl.full([1], 1024, tl.int64)
    tmp52 = tmp0 < tmp51
    tmp53 = tmp50 & tmp52
    tmp54 = tl.load(in_ptr12 + (256 * x5 + (-768 + x0)), tmp53,
        eviction_policy='evict_last', other=0.0)
    tmp55 = tl.load(in_ptr13 + (-768 + x0), tmp53, eviction_policy=
        'evict_last', other=0.0)
    tmp56 = tmp54 + tmp55
    tmp57 = tl.full(tmp56.shape, 0.0, tmp56.dtype)
    tmp58 = tl.where(tmp53, tmp56, tmp57)
    tmp59 = tmp0 >= tmp51
    tl.full([1], 1280, tl.int64)
    tmp62 = tl.load(in_ptr14 + (256 * x5 + (-1024 + x0)), tmp59,
        eviction_policy='evict_last', other=0.0)
    tmp63 = tl.load(in_ptr15 + (-1024 + x0), tmp59, eviction_policy=
        'evict_last', other=0.0)
    tmp64 = tmp62 + tmp63
    tmp65 = tl.full(tmp64.shape, 0.0, tmp64.dtype)
    tmp66 = tl.where(tmp59, tmp64, tmp65)
    tmp67 = tl.where(tmp53, tmp58, tmp66)
    tmp68 = tl.where(tmp44, tmp49, tmp67)
    tmp69 = tl.where(tmp35, tmp40, tmp68)
    tmp70 = tl.where(tmp4, tmp31, tmp69)
    tl.store(out_ptr0 + x6, tmp70, None)


@triton.jit
def triton_poi_fused_convolution_6(in_ptr0, in_ptr1, out_ptr0, ynumel,
    xnumel, YBLOCK: tl.constexpr, XBLOCK: tl.constexpr):
    xnumel = 16
    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 % 256
    y1 = yindex // 256
    y3 = yindex
    tmp0 = tl.load(in_ptr0 + (y0 + 256 * x2 + 4096 * y1), xmask,
        eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr1 + y0, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tl.store(out_ptr0 + (x2 + 16 * y3), tmp2, 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) = args
    args.clear()
    assert_size_stride(primals_1, (4, 256, 4, 4), (4096, 16, 4, 1))
    assert_size_stride(primals_2, (256, 256, 1, 1), (256, 1, 1, 1))
    assert_size_stride(primals_3, (256,), (1,))
    assert_size_stride(primals_4, (256, 256, 1, 1), (256, 1, 1, 1))
    assert_size_stride(primals_5, (256,), (1,))
    assert_size_stride(primals_6, (256, 256, 3, 3), (2304, 9, 3, 1))
    assert_size_stride(primals_7, (256,), (1,))
    assert_size_stride(primals_8, (256, 256, 3, 3), (2304, 9, 3, 1))
    assert_size_stride(primals_9, (256,), (1,))
    assert_size_stride(primals_10, (256, 256, 3, 3), (2304, 9, 3, 1))
    assert_size_stride(primals_11, (256,), (1,))
    assert_size_stride(primals_12, (256, 1280, 1, 1), (1280, 1, 1, 1))
    assert_size_stride(primals_13, (256,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 256, 4, 4), (4096, 1, 1024, 256),
            torch.float32)
        buf4 = empty_strided_cuda((4, 256, 1, 1), (256, 1, 1024, 1024),
            torch.float32)
        buf5 = reinterpret_tensor(buf4, (4, 256, 1, 1), (256, 1, 256, 256), 0)
        del buf4
        get_raw_stream(0)
        triton_per_fused_mean_0[grid(1024)](buf5, primals_1, buf0, 1024, 16,
            XBLOCK=32, num_warps=4, num_stages=1)
        del primals_1
        buf1 = empty_strided_cuda((256, 256, 3, 3), (2304, 1, 768, 256),
            torch.float32)
        triton_poi_fused_1[grid(65536, 9)](primals_6, buf1, 65536, 9,
            XBLOCK=16, YBLOCK=64, num_warps=4, num_stages=1)
        del primals_6
        buf2 = empty_strided_cuda((256, 256, 3, 3), (2304, 1, 768, 256),
            torch.float32)
        triton_poi_fused_1[grid(65536, 9)](primals_8, buf2, 65536, 9,
            XBLOCK=16, YBLOCK=64, num_warps=4, num_stages=1)
        del primals_8
        buf3 = empty_strided_cuda((256, 256, 3, 3), (2304, 1, 768, 256),
            torch.float32)
        triton_poi_fused_1[grid(65536, 9)](primals_10, buf3, 65536, 9,
            XBLOCK=16, YBLOCK=64, num_warps=4, num_stages=1)
        del primals_10
        buf6 = extern_kernels.convolution(buf5, primals_2, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf6, (4, 256, 1, 1), (256, 1, 256, 256))
        buf7 = empty_strided_cuda((4, 1), (1, 1), torch.int64)
        triton_poi_fused__to_copy_2[grid(4)](buf7, 4, XBLOCK=4, num_warps=1,
            num_stages=1)
        buf8 = empty_strided_cuda((4, 1), (1, 1), torch.int64)
        triton_poi_fused__to_copy_2[grid(4)](buf8, 4, XBLOCK=4, num_warps=1,
            num_stages=1)
        buf9 = empty_strided_cuda((4,), (1,), torch.int64)
        triton_poi_fused__to_copy_2[grid(4)](buf9, 4, XBLOCK=4, num_warps=1,
            num_stages=1)
        buf10 = empty_strided_cuda((4,), (1,), torch.int64)
        triton_poi_fused__to_copy_2[grid(4)](buf10, 4, XBLOCK=4, num_warps=
            1, num_stages=1)
        buf11 = empty_strided_cuda((4,), (1,), torch.float32)
        triton_poi_fused__to_copy_arange_clamp_mul_sub_3[grid(4)](buf11, 4,
            XBLOCK=4, num_warps=1, num_stages=1)
        buf12 = empty_strided_cuda((4, 256, 4, 4), (4096, 16, 4, 1), torch.
            float32)
        triton_poi_fused__unsafe_index_add_convolution_mul_sub_4[grid(16384)](
            buf7, buf9, buf6, primals_3, buf10, buf11, buf12, 16384, XBLOCK
            =256, num_warps=4, num_stages=1)
        buf13 = empty_strided_cuda((4, 1), (1, 1), torch.float32)
        triton_poi_fused__to_copy_arange_clamp_mul_sub_3[grid(4)](buf13, 4,
            XBLOCK=4, num_warps=1, num_stages=1)
        buf14 = extern_kernels.convolution(buf0, primals_4, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf14, (4, 256, 4, 4), (4096, 1, 1024, 256))
        buf15 = extern_kernels.convolution(buf0, buf1, stride=(1, 1),
            padding=(6, 6), dilation=(6, 6), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf15, (4, 256, 4, 4), (4096, 1, 1024, 256))
        buf16 = extern_kernels.convolution(buf0, buf2, stride=(1, 1),
            padding=(12, 12), dilation=(12, 12), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf16, (4, 256, 4, 4), (4096, 1, 1024, 256))
        buf17 = extern_kernels.convolution(buf0, buf3, stride=(1, 1),
            padding=(18, 18), dilation=(18, 18), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf17, (4, 256, 4, 4), (4096, 1, 1024, 256))
        buf18 = empty_strided_cuda((4, 1280, 4, 4), (20480, 1, 5120, 1280),
            torch.float32)
        triton_poi_fused_cat_5[grid(81920)](buf12, buf8, buf9, buf6,
            primals_3, buf10, buf11, buf13, buf14, primals_5, buf15,
            primals_7, buf16, primals_9, buf17, primals_11, buf18, 81920,
            XBLOCK=512, num_warps=8, num_stages=1)
        del buf12
        del buf14
        del buf15
        del buf16
        del buf6
        del primals_11
        del primals_3
        del primals_5
        del primals_7
        del primals_9
        buf19 = extern_kernels.convolution(buf18, primals_12, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf19, (4, 256, 4, 4), (4096, 1, 1024, 256))
        buf20 = reinterpret_tensor(buf17, (4, 256, 4, 4), (4096, 16, 4, 1), 0)
        del buf17
        triton_poi_fused_convolution_6[grid(1024, 16)](buf19, primals_13,
            buf20, 1024, 16, XBLOCK=16, YBLOCK=16, num_warps=4, num_stages=1)
        del buf19
        del primals_13
    return (buf20, buf0, primals_2, primals_4, buf1, buf2, buf3, primals_12,
        buf5, buf7, buf8, buf9, buf10, buf11, buf13, buf18)


class ASPPNew(nn.Module):

    def __init__(self, in_channel=256, depth=256):
        super(ASPPNew, self).__init__()
        self.mean = nn.AdaptiveAvgPool2d((1, 1))
        self.conv = nn.Conv2d(in_channel, depth, 1, 1)
        self.atrous_block1 = nn.Conv2d(in_channel, depth, 1, 1)
        self.atrous_block6 = nn.Conv2d(in_channel, depth, 3, 1, padding=6,
            dilation=6)
        self.atrous_block12 = nn.Conv2d(in_channel, depth, 3, 1, padding=12,
            dilation=12)
        self.atrous_block18 = nn.Conv2d(in_channel, depth, 3, 1, padding=18,
            dilation=18)
        self.conv_1x1_output = nn.Conv2d(depth * 5, depth, 1, 1)

    def forward(self, input_0):
        primals_2 = self.conv.weight
        primals_3 = self.conv.bias
        primals_4 = self.atrous_block1.weight
        primals_5 = self.atrous_block1.bias
        primals_6 = self.atrous_block6.weight
        primals_7 = self.atrous_block6.bias
        primals_8 = self.atrous_block12.weight
        primals_9 = self.atrous_block12.bias
        primals_10 = self.atrous_block18.weight
        primals_11 = self.atrous_block18.bias
        primals_12 = self.conv_1x1_output.weight
        primals_13 = self.conv_1x1_output.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])
        return output[0]


Measured latency_ms: 0.04095