# AOT ID: ['0_inference']
from ctypes import c_void_p, c_long, c_int
import torch
import math
import random
import os
import tempfile
from math import inf, nan
from torch._inductor.hooks import run_intermediate_hooks
from torch._inductor.utils import maybe_profile
from torch._inductor.codegen.memory_planning import _align as align
from torch import device, empty_strided
from torch._inductor.async_compile import AsyncCompile
from torch._inductor.select_algorithm import extern_kernels
from torch._inductor.codegen.multi_kernel import MultiKernelCall
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid, split_scan_grid, grid_combo_kernels, start_graph, end_graph
from torch._C import _cuda_getCurrentRawStream as get_raw_stream

aten = torch.ops.aten
inductor_ops = torch.ops.inductor
_quantized = torch.ops._quantized
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cpu = torch._C._dynamo.guards._empty_strided_cpu
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda
empty_strided_xpu = torch._C._dynamo.guards._empty_strided_xpu
reinterpret_tensor = torch._C._dynamo.guards._reinterpret_tensor
alloc_from_pool = torch.ops.inductor._alloc_from_pool
async_compile = AsyncCompile()


# kernel path: runs/run_shard_1/inductor_cache/es/cesbyftzmx6nihksezicupvshq2xyblkjexqxqoylrpjygihfjdz.py
# Topologically Sorted Source Nodes: [ppm_out, concat_outs], Original ATen: [aten.mean, aten.cat]
# Source node to ATen node mapping:
#   concat_outs => cat
#   ppm_out => mean
# Graph fragment:
#   %mean : [num_users=1] = call_function[target=torch.ops.aten.mean.dim](args = (%arg0_1, [-1, -2], True), kwargs = {})
#   %cat : [num_users=1] = call_function[target=torch.ops.aten.cat.default](args = ([%view, %view_1, %view_2, %view_3], 2), kwargs = {})
triton_per_fused_cat_mean_0 = async_compile.triton('triton_per_fused_cat_mean_0', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.persistent_reduction(
    size_hints=[16, 16],
    reduction_hint=ReductionHint.INNER,
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: 'i32', 3: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=90, major=9, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=132), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused_cat_mean_0', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 1, 'num_reduction': 1, 'backend_hash': 'B098E03CDA7B8ADC90DAFFDF24A2956451D1B13F297756A5DCC209498AA53705', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False}
)
@triton.jit
def triton_per_fused_cat_mean_0(in_ptr0, out_ptr1, xnumel, rnumel, XBLOCK : tl.constexpr):
    xnumel = 16
    rnumel = 16
    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, :]
    roffset = 0
    rmask = tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r1 = rindex
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + (r1 + (16*x0)), 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_ptr1 + (110*x0), tmp6, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_1/inductor_cache/oh/coh2rjc7ysofithbtyrxhduve5pwmgaqug6ae2bbcwowgrsbrawa.py
# Topologically Sorted Source Nodes: [ppm_out_1, concat_outs], Original ATen: [aten._adaptive_avg_pool2d, aten.cat]
# Source node to ATen node mapping:
#   concat_outs => cat
#   ppm_out_1 => _adaptive_avg_pool2d
# Graph fragment:
#   %_adaptive_avg_pool2d : [num_users=1] = call_function[target=torch.ops.aten._adaptive_avg_pool2d.default](args = (%arg0_1, [3, 3]), kwargs = {})
#   %cat : [num_users=1] = call_function[target=torch.ops.aten.cat.default](args = ([%view, %view_1, %view_2, %view_3], 2), kwargs = {})
triton_poi_fused__adaptive_avg_pool2d_cat_1 = async_compile.triton('triton_poi_fused__adaptive_avg_pool2d_cat_1', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.pointwise(
    size_hints=[256], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=90, major=9, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=132), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 2), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__adaptive_avg_pool2d_cat_1', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 4, 'num_reduction': 0, 'backend_hash': 'B098E03CDA7B8ADC90DAFFDF24A2956451D1B13F297756A5DCC209498AA53705', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused__adaptive_avg_pool2d_cat_1(in_ptr0, out_ptr1, xnumel, XBLOCK : tl.constexpr):
    xnumel = 144
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = (xindex // 3) % 3
    x0 = xindex % 3
    x2 = (xindex // 9)
    x5 = xindex
    x3 = xindex % 9
    tmp0 = ((4*x1) // 3)
    tmp1 = 2 + ((4*x1) // 3)
    tmp2 = tmp0 < tmp1
    tmp3 = ((4*x0) // 3)
    tmp4 = 2 + ((4*x0) // 3)
    tmp5 = tmp3 < tmp4
    tmp6 = tmp2 & tmp5
    tmp7 = tl.load(in_ptr0 + ((4*((4*x1) // 3)) + (16*x2) + ((4*x0) // 3)), tmp6 & xmask, other=0.0)
    tmp8 = 1 + ((4*x0) // 3)
    tmp9 = tmp8 < tmp4
    tmp10 = tmp2 & tmp9
    tmp11 = tl.load(in_ptr0 + (1 + (4*((4*x1) // 3)) + (16*x2) + ((4*x0) // 3)), tmp10 & xmask, other=0.0)
    tmp12 = tmp11 + tmp7
    tmp13 = 1 + ((4*x1) // 3)
    tmp14 = tmp13 < tmp1
    tmp15 = tmp14 & tmp5
    tmp16 = tl.load(in_ptr0 + (4 + (4*((4*x1) // 3)) + (16*x2) + ((4*x0) // 3)), tmp15 & xmask, other=0.0)
    tmp17 = tmp16 + tmp12
    tmp18 = tmp14 & tmp9
    tmp19 = tl.load(in_ptr0 + (5 + (4*((4*x1) // 3)) + (16*x2) + ((4*x0) // 3)), tmp18 & xmask, other=0.0)
    tmp20 = tmp19 + tmp17
    tmp21 = 1.0
    tmp22 = tl.full(tmp21.shape, 0.0, tmp21.dtype)
    tmp23 = tl.where(tmp6, tmp21, tmp22)
    tmp24 = tl.where(tmp10, tmp21, tmp22)
    tmp25 = tmp24 + tmp23
    tmp26 = tl.where(tmp15, tmp21, tmp22)
    tmp27 = tmp26 + tmp25
    tmp28 = tl.where(tmp18, tmp21, tmp22)
    tmp29 = tmp28 + tmp27
    tmp30 = tmp20 / tmp29
    tl.store(out_ptr1 + (x3 + (110*x2)), tmp30, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_1/inductor_cache/jy/cjy2z2qozy7p5rvfa2cmcd7vro5eiexgv3zo6z2l2f5bormgizrg.py
# Topologically Sorted Source Nodes: [ppm_out_2, concat_outs], Original ATen: [aten._adaptive_avg_pool2d, aten.cat]
# Source node to ATen node mapping:
#   concat_outs => cat
#   ppm_out_2 => _adaptive_avg_pool2d_1
# Graph fragment:
#   %_adaptive_avg_pool2d_1 : [num_users=1] = call_function[target=torch.ops.aten._adaptive_avg_pool2d.default](args = (%arg0_1, [6, 6]), kwargs = {})
#   %cat : [num_users=1] = call_function[target=torch.ops.aten.cat.default](args = ([%view, %view_1, %view_2, %view_3], 2), kwargs = {})
triton_poi_fused__adaptive_avg_pool2d_cat_2 = async_compile.triton('triton_poi_fused__adaptive_avg_pool2d_cat_2', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.pointwise(
    size_hints=[1024], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=90, major=9, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=132), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 2), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__adaptive_avg_pool2d_cat_2', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 4, 'num_reduction': 0, 'backend_hash': 'B098E03CDA7B8ADC90DAFFDF24A2956451D1B13F297756A5DCC209498AA53705', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused__adaptive_avg_pool2d_cat_2(in_ptr0, out_ptr1, xnumel, XBLOCK : tl.constexpr):
    xnumel = 576
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = (xindex // 6) % 6
    x0 = xindex % 6
    x2 = (xindex // 36)
    x5 = xindex
    x3 = xindex % 36
    tmp0 = ((2*x1) // 3)
    tmp1 = ((9 + (4*x1)) // 6)
    tmp2 = tmp0 < tmp1
    tmp3 = ((2*x0) // 3)
    tmp4 = ((9 + (4*x0)) // 6)
    tmp5 = tmp3 < tmp4
    tmp6 = tmp2 & tmp5
    tmp7 = tl.load(in_ptr0 + ((4*((2*x1) // 3)) + (16*x2) + ((2*x0) // 3)), tmp6 & xmask, eviction_policy='evict_last', other=0.0)
    tmp8 = 1 + ((2*x0) // 3)
    tmp9 = tmp8 < tmp4
    tmp10 = tmp2 & tmp9
    tmp11 = tl.load(in_ptr0 + (1 + (4*((2*x1) // 3)) + (16*x2) + ((2*x0) // 3)), tmp10 & xmask, eviction_policy='evict_last', other=0.0)
    tmp12 = tmp11 + tmp7
    tmp13 = 1 + ((2*x1) // 3)
    tmp14 = tmp13 < tmp1
    tmp15 = tmp14 & tmp5
    tmp16 = tl.load(in_ptr0 + (4 + (4*((2*x1) // 3)) + (16*x2) + ((2*x0) // 3)), tmp15 & xmask, eviction_policy='evict_last', other=0.0)
    tmp17 = tmp16 + tmp12
    tmp18 = tmp14 & tmp9
    tmp19 = tl.load(in_ptr0 + (5 + (4*((2*x1) // 3)) + (16*x2) + ((2*x0) // 3)), tmp18 & xmask, eviction_policy='evict_last', other=0.0)
    tmp20 = tmp19 + tmp17
    tmp21 = 1.0
    tmp22 = tl.full(tmp21.shape, 0.0, tmp21.dtype)
    tmp23 = tl.where(tmp6, tmp21, tmp22)
    tmp24 = tl.where(tmp10, tmp21, tmp22)
    tmp25 = tmp24 + tmp23
    tmp26 = tl.where(tmp15, tmp21, tmp22)
    tmp27 = tmp26 + tmp25
    tmp28 = tl.where(tmp18, tmp21, tmp22)
    tmp29 = tmp28 + tmp27
    tmp30 = tmp20 / tmp29
    tl.store(out_ptr1 + (x3 + (110*x2)), tmp30, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_1/inductor_cache/zy/czyis5hozxekviztp7azz4aojsoxvkf2xug7exwmraxf3o2ntuzw.py
# Topologically Sorted Source Nodes: [ppm_out_3, concat_outs], Original ATen: [aten._adaptive_avg_pool2d, aten.cat]
# Source node to ATen node mapping:
#   concat_outs => cat
#   ppm_out_3 => _adaptive_avg_pool2d_2
# Graph fragment:
#   %_adaptive_avg_pool2d_2 : [num_users=1] = call_function[target=torch.ops.aten._adaptive_avg_pool2d.default](args = (%arg0_1, [8, 8]), kwargs = {})
#   %cat : [num_users=1] = call_function[target=torch.ops.aten.cat.default](args = ([%view, %view_1, %view_2, %view_3], 2), kwargs = {})
triton_poi_fused__adaptive_avg_pool2d_cat_3 = async_compile.triton('triton_poi_fused__adaptive_avg_pool2d_cat_3', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.pointwise(
    size_hints=[1024], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=90, major=9, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=132), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 2), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__adaptive_avg_pool2d_cat_3', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 4, 'num_reduction': 0, 'backend_hash': 'B098E03CDA7B8ADC90DAFFDF24A2956451D1B13F297756A5DCC209498AA53705', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused__adaptive_avg_pool2d_cat_3(in_ptr0, out_ptr1, xnumel, XBLOCK : tl.constexpr):
    xnumel = 1024
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = (xindex // 8) % 8
    x0 = xindex % 8
    x2 = (xindex // 64)
    x5 = xindex
    x3 = xindex % 64
    tmp0 = (x1 // 2)
    tmp1 = ((11 + (4*x1)) // 8)
    tmp2 = tmp0 < tmp1
    tmp3 = (x0 // 2)
    tmp4 = ((11 + (4*x0)) // 8)
    tmp5 = tmp3 < tmp4
    tmp6 = tmp2 & tmp5
    tmp7 = tl.load(in_ptr0 + ((4*(x1 // 2)) + (16*x2) + (x0 // 2)), tmp6 & xmask, eviction_policy='evict_last', other=0.0)
    tmp8 = 1 + (x0 // 2)
    tmp9 = tmp8 < tmp4
    tmp10 = tmp2 & tmp9
    tmp11 = tl.load(in_ptr0 + (1 + (4*(x1 // 2)) + (16*x2) + (x0 // 2)), tmp10 & xmask, eviction_policy='evict_last', other=0.0)
    tmp12 = tmp11 + tmp7
    tmp13 = 1 + (x1 // 2)
    tmp14 = tmp13 < tmp1
    tmp15 = tmp14 & tmp5
    tmp16 = tl.load(in_ptr0 + (4 + (4*(x1 // 2)) + (16*x2) + (x0 // 2)), tmp15 & xmask, eviction_policy='evict_last', other=0.0)
    tmp17 = tmp16 + tmp12
    tmp18 = tmp14 & tmp9
    tmp19 = tl.load(in_ptr0 + (5 + (4*(x1 // 2)) + (16*x2) + (x0 // 2)), tmp18 & xmask, eviction_policy='evict_last', other=0.0)
    tmp20 = tmp19 + tmp17
    tmp21 = 1.0
    tmp22 = tl.full(tmp21.shape, 0.0, tmp21.dtype)
    tmp23 = tl.where(tmp6, tmp21, tmp22)
    tmp24 = tl.where(tmp10, tmp21, tmp22)
    tmp25 = tmp24 + tmp23
    tmp26 = tl.where(tmp15, tmp21, tmp22)
    tmp27 = tmp26 + tmp25
    tmp28 = tl.where(tmp18, tmp21, tmp22)
    tmp29 = tmp28 + tmp27
    tmp30 = tmp20 / tmp29
    tl.store(out_ptr1 + (x3 + (110*x2)), tmp30, xmask)
''', device_str='cuda')


async_compile.wait(globals())
del async_compile

def call(args):
    arg0_1, = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4, 4, 4), (64, 16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf8 = empty_strided_cuda((4, 4, 110), (440, 110, 1), torch.float32)
        buf4 = reinterpret_tensor(buf8, (4, 4, 1), (440, 110, 1), 0)  # alias
        # Topologically Sorted Source Nodes: [ppm_out, concat_outs], Original ATen: [aten.mean, aten.cat]
        stream0 = get_raw_stream(0)
        triton_per_fused_cat_mean_0.run(arg0_1, buf4, 16, 16, grid=grid(16), stream=stream0)
        buf5 = reinterpret_tensor(buf8, (4, 4, 9), (440, 110, 1), 1)  # alias
        # Topologically Sorted Source Nodes: [ppm_out_1, concat_outs], Original ATen: [aten._adaptive_avg_pool2d, aten.cat]
        triton_poi_fused__adaptive_avg_pool2d_cat_1.run(arg0_1, buf5, 144, grid=grid(144), stream=stream0)
        buf6 = reinterpret_tensor(buf8, (4, 4, 36), (440, 110, 1), 10)  # alias
        # Topologically Sorted Source Nodes: [ppm_out_2, concat_outs], Original ATen: [aten._adaptive_avg_pool2d, aten.cat]
        triton_poi_fused__adaptive_avg_pool2d_cat_2.run(arg0_1, buf6, 576, grid=grid(576), stream=stream0)
        buf7 = reinterpret_tensor(buf8, (4, 4, 64), (440, 110, 1), 46)  # alias
        # Topologically Sorted Source Nodes: [ppm_out_3, concat_outs], Original ATen: [aten._adaptive_avg_pool2d, aten.cat]
        triton_poi_fused__adaptive_avg_pool2d_cat_3.run(arg0_1, buf7, 1024, grid=grid(1024), stream=stream0)
        del arg0_1
    return (buf8, )


def benchmark_compiled_module(times=10, repeat=10):
    from torch._dynamo.testing import rand_strided
    from torch._inductor.utils import print_performance
    arg0_1 = rand_strided((4, 4, 4, 4), (64, 16, 4, 1), device='cuda:0', dtype=torch.float32)
    fn = lambda: call([arg0_1])
    return print_performance(fn, times=times, repeat=repeat)


if __name__ == "__main__":
    from torch._inductor.wrapper_benchmark import compiled_module_main
    compiled_module_main('None', benchmark_compiled_module)

import torch
import torch.nn as nn
import torch._C
import torch.serialization


class PPMConcat(nn.ModuleList):
    """Pyramid Pooling Module that only concat the features of each layer.

    Args:
        pool_scales (tuple[int]): Pooling scales used in Pooling Pyramid
            Module.
    """

    def __init__(self, pool_scales=(1, 3, 6, 8)):
        super(PPMConcat, self).__init__([nn.AdaptiveAvgPool2d(pool_scale) for
            pool_scale in pool_scales])

    def forward(self, feats):
        """Forward function."""
        ppm_outs = []
        for ppm in self:
            ppm_out = ppm(feats)
            ppm_outs.append(ppm_out.view(*feats.shape[:2], -1))
        concat_outs = torch.cat(ppm_outs, dim=2)
        return concat_outs


def get_inputs():
    return [torch.rand([4, 4, 4, 4])]


def get_init_inputs():
    return [[], {}]

import torch
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
import torch._C
import torch.serialization
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_cat_mean_0(in_ptr0, out_ptr1, xnumel, rnumel, XBLOCK:
    tl.constexpr):
    xnumel = 16
    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)
    r1 = rindex
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + (r1 + 16 * x0), 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_ptr1 + 110 * x0, tmp6, xmask)


@triton.jit
def triton_poi_fused__adaptive_avg_pool2d_cat_1(in_ptr0, out_ptr1, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 144
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = xindex // 3 % 3
    x0 = xindex % 3
    x2 = xindex // 9
    x3 = xindex % 9
    tmp0 = 4 * x1 // 3
    tmp1 = 2 + 4 * x1 // 3
    tmp2 = tmp0 < tmp1
    tmp3 = 4 * x0 // 3
    tmp4 = 2 + 4 * x0 // 3
    tmp5 = tmp3 < tmp4
    tmp6 = tmp2 & tmp5
    tmp7 = tl.load(in_ptr0 + (4 * (4 * x1 // 3) + 16 * x2 + 4 * x0 // 3), 
        tmp6 & xmask, other=0.0)
    tmp8 = 1 + 4 * x0 // 3
    tmp9 = tmp8 < tmp4
    tmp10 = tmp2 & tmp9
    tmp11 = tl.load(in_ptr0 + (1 + 4 * (4 * x1 // 3) + 16 * x2 + 4 * x0 // 
        3), tmp10 & xmask, other=0.0)
    tmp12 = tmp11 + tmp7
    tmp13 = 1 + 4 * x1 // 3
    tmp14 = tmp13 < tmp1
    tmp15 = tmp14 & tmp5
    tmp16 = tl.load(in_ptr0 + (4 + 4 * (4 * x1 // 3) + 16 * x2 + 4 * x0 // 
        3), tmp15 & xmask, other=0.0)
    tmp17 = tmp16 + tmp12
    tmp18 = tmp14 & tmp9
    tmp19 = tl.load(in_ptr0 + (5 + 4 * (4 * x1 // 3) + 16 * x2 + 4 * x0 // 
        3), tmp18 & xmask, other=0.0)
    tmp20 = tmp19 + tmp17
    tmp21 = 1.0
    tmp22 = tl.full(tmp21.shape, 0.0, tmp21.dtype)
    tmp23 = tl.where(tmp6, tmp21, tmp22)
    tmp24 = tl.where(tmp10, tmp21, tmp22)
    tmp25 = tmp24 + tmp23
    tmp26 = tl.where(tmp15, tmp21, tmp22)
    tmp27 = tmp26 + tmp25
    tmp28 = tl.where(tmp18, tmp21, tmp22)
    tmp29 = tmp28 + tmp27
    tmp30 = tmp20 / tmp29
    tl.store(out_ptr1 + (x3 + 110 * x2), tmp30, xmask)


@triton.jit
def triton_poi_fused__adaptive_avg_pool2d_cat_2(in_ptr0, out_ptr1, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 576
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = xindex // 6 % 6
    x0 = xindex % 6
    x2 = xindex // 36
    x3 = xindex % 36
    tmp0 = 2 * x1 // 3
    tmp1 = (9 + 4 * x1) // 6
    tmp2 = tmp0 < tmp1
    tmp3 = 2 * x0 // 3
    tmp4 = (9 + 4 * x0) // 6
    tmp5 = tmp3 < tmp4
    tmp6 = tmp2 & tmp5
    tmp7 = tl.load(in_ptr0 + (4 * (2 * x1 // 3) + 16 * x2 + 2 * x0 // 3), 
        tmp6 & xmask, eviction_policy='evict_last', other=0.0)
    tmp8 = 1 + 2 * x0 // 3
    tmp9 = tmp8 < tmp4
    tmp10 = tmp2 & tmp9
    tmp11 = tl.load(in_ptr0 + (1 + 4 * (2 * x1 // 3) + 16 * x2 + 2 * x0 // 
        3), tmp10 & xmask, eviction_policy='evict_last', other=0.0)
    tmp12 = tmp11 + tmp7
    tmp13 = 1 + 2 * x1 // 3
    tmp14 = tmp13 < tmp1
    tmp15 = tmp14 & tmp5
    tmp16 = tl.load(in_ptr0 + (4 + 4 * (2 * x1 // 3) + 16 * x2 + 2 * x0 // 
        3), tmp15 & xmask, eviction_policy='evict_last', other=0.0)
    tmp17 = tmp16 + tmp12
    tmp18 = tmp14 & tmp9
    tmp19 = tl.load(in_ptr0 + (5 + 4 * (2 * x1 // 3) + 16 * x2 + 2 * x0 // 
        3), tmp18 & xmask, eviction_policy='evict_last', other=0.0)
    tmp20 = tmp19 + tmp17
    tmp21 = 1.0
    tmp22 = tl.full(tmp21.shape, 0.0, tmp21.dtype)
    tmp23 = tl.where(tmp6, tmp21, tmp22)
    tmp24 = tl.where(tmp10, tmp21, tmp22)
    tmp25 = tmp24 + tmp23
    tmp26 = tl.where(tmp15, tmp21, tmp22)
    tmp27 = tmp26 + tmp25
    tmp28 = tl.where(tmp18, tmp21, tmp22)
    tmp29 = tmp28 + tmp27
    tmp30 = tmp20 / tmp29
    tl.store(out_ptr1 + (x3 + 110 * x2), tmp30, xmask)


@triton.jit
def triton_poi_fused__adaptive_avg_pool2d_cat_3(in_ptr0, out_ptr1, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 1024
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = xindex // 8 % 8
    x0 = xindex % 8
    x2 = xindex // 64
    x3 = xindex % 64
    tmp0 = x1 // 2
    tmp1 = (11 + 4 * x1) // 8
    tmp2 = tmp0 < tmp1
    tmp3 = x0 // 2
    tmp4 = (11 + 4 * x0) // 8
    tmp5 = tmp3 < tmp4
    tmp6 = tmp2 & tmp5
    tmp7 = tl.load(in_ptr0 + (4 * (x1 // 2) + 16 * x2 + x0 // 2), tmp6 &
        xmask, eviction_policy='evict_last', other=0.0)
    tmp8 = 1 + x0 // 2
    tmp9 = tmp8 < tmp4
    tmp10 = tmp2 & tmp9
    tmp11 = tl.load(in_ptr0 + (1 + 4 * (x1 // 2) + 16 * x2 + x0 // 2), 
        tmp10 & xmask, eviction_policy='evict_last', other=0.0)
    tmp12 = tmp11 + tmp7
    tmp13 = 1 + x1 // 2
    tmp14 = tmp13 < tmp1
    tmp15 = tmp14 & tmp5
    tmp16 = tl.load(in_ptr0 + (4 + 4 * (x1 // 2) + 16 * x2 + x0 // 2), 
        tmp15 & xmask, eviction_policy='evict_last', other=0.0)
    tmp17 = tmp16 + tmp12
    tmp18 = tmp14 & tmp9
    tmp19 = tl.load(in_ptr0 + (5 + 4 * (x1 // 2) + 16 * x2 + x0 // 2), 
        tmp18 & xmask, eviction_policy='evict_last', other=0.0)
    tmp20 = tmp19 + tmp17
    tmp21 = 1.0
    tmp22 = tl.full(tmp21.shape, 0.0, tmp21.dtype)
    tmp23 = tl.where(tmp6, tmp21, tmp22)
    tmp24 = tl.where(tmp10, tmp21, tmp22)
    tmp25 = tmp24 + tmp23
    tmp26 = tl.where(tmp15, tmp21, tmp22)
    tmp27 = tmp26 + tmp25
    tmp28 = tl.where(tmp18, tmp21, tmp22)
    tmp29 = tmp28 + tmp27
    tmp30 = tmp20 / tmp29
    tl.store(out_ptr1 + (x3 + 110 * x2), tmp30, xmask)


def call(args):
    arg0_1, = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4, 4, 4), (64, 16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf8 = empty_strided_cuda((4, 4, 110), (440, 110, 1), torch.float32)
        buf4 = reinterpret_tensor(buf8, (4, 4, 1), (440, 110, 1), 0)
        get_raw_stream(0)
        triton_per_fused_cat_mean_0[grid(16)](arg0_1, buf4, 16, 16, XBLOCK=
            8, num_warps=2, num_stages=1)
        buf5 = reinterpret_tensor(buf8, (4, 4, 9), (440, 110, 1), 1)
        triton_poi_fused__adaptive_avg_pool2d_cat_1[grid(144)](arg0_1, buf5,
            144, XBLOCK=256, num_warps=4, num_stages=1)
        buf6 = reinterpret_tensor(buf8, (4, 4, 36), (440, 110, 1), 10)
        triton_poi_fused__adaptive_avg_pool2d_cat_2[grid(576)](arg0_1, buf6,
            576, XBLOCK=128, num_warps=4, num_stages=1)
        buf7 = reinterpret_tensor(buf8, (4, 4, 64), (440, 110, 1), 46)
        triton_poi_fused__adaptive_avg_pool2d_cat_3[grid(1024)](arg0_1,
            buf7, 1024, XBLOCK=128, num_warps=4, num_stages=1)
        del arg0_1
    return buf8,


class PPMConcatNew(nn.ModuleList):
    """Pyramid Pooling Module that only concat the features of each layer.

    Args:
        pool_scales (tuple[int]): Pooling scales used in Pooling Pyramid
            Module.
    """

    def __init__(self, pool_scales=(1, 3, 6, 8)):
        super(PPMConcatNew, self).__init__([nn.AdaptiveAvgPool2d(pool_scale
            ) for pool_scale in pool_scales])

    def forward(self, input_0):
        arg0_1 = input_0
        output = call([arg0_1])
        return output[0]
