# AOT ID: ['0_forward']
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_6/inductor_cache/xj/cxjxsxuqu7utclzyuepnlpraugwu73em67oyrv7oapys5jwyvfsb.py
# Topologically Sorted Source Nodes: [x_1, out], Original ATen: [aten.repeat, aten._native_batch_norm_legit, aten.cat]
# Source node to ATen node mapping:
#   out => cat
#   x_1 => add, repeat, repeat_1, rsqrt, var_mean
# Graph fragment:
#   %repeat : [num_users=2] = call_function[target=torch.ops.aten.repeat.default](args = (%primals_3, [4]), kwargs = {})
#   %repeat_1 : [num_users=2] = call_function[target=torch.ops.aten.repeat.default](args = (%primals_4, [4]), kwargs = {})
#   %var_mean : [num_users=2] = call_function[target=torch.ops.aten.var_mean.correction](args = (%view, [0, 2, 3]), kwargs = {correction: 0, keepdim: True})
#   %add : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%getitem, 1e-05), kwargs = {})
#   %rsqrt : [num_users=2] = call_function[target=torch.ops.aten.rsqrt.default](args = (%add,), kwargs = {})
#   %cat : [num_users=1] = call_function[target=torch.ops.aten.cat.default](args = ([%view_3, %view_8, %view_13, %view_18], 1), kwargs = {})
triton_per_fused__native_batch_norm_legit_cat_repeat_0 = async_compile.triton('triton_per_fused__native_batch_norm_legit_cat_repeat_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=[4, 16],
    reduction_hint=ReductionHint.DEFAULT,
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: '*fp32', 5: '*fp32', 6: '*fp32', 7: '*fp32', 8: 'i32', 9: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4, 5, 6, 7, 9), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused__native_batch_norm_legit_cat_repeat_0', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 3, 'num_reduction': 4, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', '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__native_batch_norm_legit_cat_repeat_0(in_out_ptr0, in_ptr0, in_ptr1, in_ptr2, out_ptr0, out_ptr1, out_ptr2, out_ptr3, xnumel, rnumel, XBLOCK : tl.constexpr):
    xnumel = 4
    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)
    x0 = xindex
    r1 = rindex
    tmp0 = tl.load(in_ptr0 + (0))
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK, 1])
    tmp2 = tl.load(in_ptr1 + (0))
    tmp3 = tl.broadcast_to(tmp2, [XBLOCK, 1])
    tmp4 = tl.load(in_ptr2 + (r1 + (16*x0)), xmask, other=0.0)
    tmp5 = tl.broadcast_to(tmp4, [XBLOCK, RBLOCK])
    tmp7 = tl.where(xmask, tmp5, 0)
    tmp8 = tl.broadcast_to(tmp5, [XBLOCK, RBLOCK])
    tmp10 = tl.where(xmask, tmp8, 0)
    tmp11 = tl.sum(tmp10, 1)[:, None]
    tmp12 = tl.full([XBLOCK, 1], 16, tl.int32)
    tmp13 = tmp12.to(tl.float32)
    tmp14 = tmp11 / tmp13
    tmp15 = tmp5 - tmp14
    tmp16 = tmp15 * tmp15
    tmp17 = tl.broadcast_to(tmp16, [XBLOCK, RBLOCK])
    tmp19 = tl.where(xmask, tmp17, 0)
    tmp20 = tl.sum(tmp19, 1)[:, None]
    tmp21 = 16.0
    tmp22 = tmp20 / tmp21
    tmp23 = 1e-05
    tmp24 = tmp22 + tmp23
    tmp25 = libdevice.rsqrt(tmp24)
    tmp26 = tmp4 - tmp14
    tmp27 = tmp26 * tmp25
    tmp28 = tmp27 * tmp1
    tmp29 = tmp28 + tmp3
    tmp30 = tl.full([1, 1], 0, tl.int32)
    tmp31 = triton_helpers.maximum(tmp30, tmp29)
    tl.store(out_ptr0 + (x0), tmp1, xmask)
    tl.store(out_ptr1 + (x0), tmp3, xmask)
    tl.debug_barrier()
    tl.store(in_out_ptr0 + (x0), tmp25, xmask)
    tl.store(out_ptr3 + ((4*r1) + (64*x0)), tmp31, xmask)
    tl.store(out_ptr2 + (x0), tmp14, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_6/inductor_cache/tm/ctmmtqrsskonejfnwca4me77icl4owmomtvtjun27tsomvqer26c.py
# Topologically Sorted Source Nodes: [x_3, out], Original ATen: [aten.repeat, aten._native_batch_norm_legit, aten.cat]
# Source node to ATen node mapping:
#   out => cat
#   x_3 => add_2, repeat_2, repeat_3, rsqrt_1, var_mean_1
# Graph fragment:
#   %repeat_2 : [num_users=2] = call_function[target=torch.ops.aten.repeat.default](args = (%primals_6, [4]), kwargs = {})
#   %repeat_3 : [num_users=2] = call_function[target=torch.ops.aten.repeat.default](args = (%primals_7, [4]), kwargs = {})
#   %var_mean_1 : [num_users=2] = call_function[target=torch.ops.aten.var_mean.correction](args = (%view_5, [0, 2, 3]), kwargs = {correction: 0, keepdim: True})
#   %add_2 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%getitem_2, 1e-05), kwargs = {})
#   %rsqrt_1 : [num_users=2] = call_function[target=torch.ops.aten.rsqrt.default](args = (%add_2,), kwargs = {})
#   %cat : [num_users=1] = call_function[target=torch.ops.aten.cat.default](args = ([%view_3, %view_8, %view_13, %view_18], 1), kwargs = {})
triton_per_fused__native_batch_norm_legit_cat_repeat_1 = async_compile.triton('triton_per_fused__native_batch_norm_legit_cat_repeat_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.persistent_reduction(
    size_hints=[4, 16],
    reduction_hint=ReductionHint.DEFAULT,
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: '*fp32', 5: '*fp32', 6: '*fp32', 7: '*fp32', 8: 'i32', 9: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4, 5, 6, 9), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused__native_batch_norm_legit_cat_repeat_1', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 3, 'num_reduction': 4, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', '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__native_batch_norm_legit_cat_repeat_1(in_out_ptr0, in_ptr0, in_ptr1, in_ptr2, out_ptr0, out_ptr1, out_ptr2, out_ptr3, xnumel, rnumel, XBLOCK : tl.constexpr):
    xnumel = 4
    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)
    x0 = xindex
    r1 = rindex
    tmp0 = tl.load(in_ptr0 + (0))
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK, 1])
    tmp2 = tl.load(in_ptr1 + (0))
    tmp3 = tl.broadcast_to(tmp2, [XBLOCK, 1])
    tmp4 = tl.load(in_ptr2 + (r1 + (16*x0)), xmask, other=0.0)
    tmp5 = tl.broadcast_to(tmp4, [XBLOCK, RBLOCK])
    tmp7 = tl.where(xmask, tmp5, 0)
    tmp8 = tl.broadcast_to(tmp5, [XBLOCK, RBLOCK])
    tmp10 = tl.where(xmask, tmp8, 0)
    tmp11 = tl.sum(tmp10, 1)[:, None]
    tmp12 = tl.full([XBLOCK, 1], 16, tl.int32)
    tmp13 = tmp12.to(tl.float32)
    tmp14 = tmp11 / tmp13
    tmp15 = tmp5 - tmp14
    tmp16 = tmp15 * tmp15
    tmp17 = tl.broadcast_to(tmp16, [XBLOCK, RBLOCK])
    tmp19 = tl.where(xmask, tmp17, 0)
    tmp20 = tl.sum(tmp19, 1)[:, None]
    tmp21 = 16.0
    tmp22 = tmp20 / tmp21
    tmp23 = 1e-05
    tmp24 = tmp22 + tmp23
    tmp25 = libdevice.rsqrt(tmp24)
    tmp26 = tmp4 - tmp14
    tmp27 = tmp26 * tmp25
    tmp28 = tmp27 * tmp1
    tmp29 = tmp28 + tmp3
    tmp30 = tl.full([1, 1], 0, tl.int32)
    tmp31 = triton_helpers.maximum(tmp30, tmp29)
    tl.store(out_ptr0 + (x0), tmp1, xmask)
    tl.store(out_ptr1 + (x0), tmp3, xmask)
    tl.debug_barrier()
    tl.store(in_out_ptr0 + (x0), tmp25, xmask)
    tl.store(out_ptr3 + ((4*r1) + (64*x0)), tmp31, xmask)
    tl.store(out_ptr2 + (x0), tmp14, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_6/inductor_cache/yh/cyhjdw2dcue5if5ifsjdpd4bkhwx2l6kbamh4nhxjksmiwxcrllp.py
# Topologically Sorted Source Nodes: [out], Original ATen: [aten.cat]
# Source node to ATen node mapping:
#   out => cat
# Graph fragment:
#   %cat : [num_users=1] = call_function[target=torch.ops.aten.cat.default](args = ([%view_3, %view_8, %view_13, %view_18], 1), kwargs = {})
triton_poi_fused_cat_2 = async_compile.triton('triton_poi_fused_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=[16, 16], tile_hint=TileHint.SQUARE,
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: 'i32', 3: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_cat_2', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 1, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', '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_cat_2(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK : tl.constexpr, XBLOCK : tl.constexpr):
    ynumel = 16
    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
    y0 = yindex % 4
    y1 = (yindex // 4)
    y3 = yindex
    tmp0 = tl.load(in_ptr0 + (y0 + (4*x2) + (64*y1)), xmask & ymask)
    tl.store(out_ptr0 + (x2 + (16*y3)), tmp0, xmask & ymask)
''', device_str='cuda')


async_compile.wait(globals())
del async_compile

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, (1, 4, 1, 1), (4, 1, 1, 1))
    assert_size_stride(primals_2, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(primals_3, (1, ), (1, ))
    assert_size_stride(primals_4, (1, ), (1, ))
    assert_size_stride(primals_5, (1, 4, 3, 3), (36, 9, 3, 1))
    assert_size_stride(primals_6, (1, ), (1, ))
    assert_size_stride(primals_7, (1, ), (1, ))
    assert_size_stride(primals_8, (1, 4, 5, 5), (100, 25, 5, 1))
    assert_size_stride(primals_9, (1, ), (1, ))
    assert_size_stride(primals_10, (1, ), (1, ))
    assert_size_stride(primals_11, (1, 4, 7, 7), (196, 49, 7, 1))
    assert_size_stride(primals_12, (1, ), (1, ))
    assert_size_stride(primals_13, (1, ), (1, ))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        # Topologically Sorted Source Nodes: [x], Original ATen: [aten.convolution]
        buf0 = extern_kernels.convolution(primals_2, 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, 1, 4, 4), (16, 16, 4, 1))
        buf1 = empty_strided_cuda((4, ), (1, ), torch.float32)
        buf2 = empty_strided_cuda((4, ), (1, ), torch.float32)
        buf3 = empty_strided_cuda((1, 4, 1, 1), (4, 1, 1, 1), torch.float32)
        buf4 = empty_strided_cuda((1, 4, 1, 1), (4, 1, 4, 4), torch.float32)
        buf6 = reinterpret_tensor(buf4, (1, 4, 1, 1), (4, 1, 1, 1), 0); del buf4  # reuse
        buf32 = empty_strided_cuda((4, 4, 4, 4), (64, 1, 16, 4), torch.float32)
        buf28 = reinterpret_tensor(buf32, (4, 1, 4, 4), (64, 1, 16, 4), 0)  # alias
        # Topologically Sorted Source Nodes: [x_1, out], Original ATen: [aten.repeat, aten._native_batch_norm_legit, aten.cat]
        stream0 = get_raw_stream(0)
        triton_per_fused__native_batch_norm_legit_cat_repeat_0.run(buf6, primals_3, primals_4, buf0, buf1, buf2, buf3, buf28, 4, 16, grid=grid(4), stream=stream0)
        del primals_3
        del primals_4
        # Topologically Sorted Source Nodes: [x_2], Original ATen: [aten.convolution]
        buf7 = extern_kernels.convolution(primals_2, primals_5, stride=(1, 1), padding=(1, 1), dilation=(1, 1), transposed=False, output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf7, (4, 1, 4, 4), (16, 16, 4, 1))
        buf8 = empty_strided_cuda((4, ), (1, ), torch.float32)
        buf9 = empty_strided_cuda((4, ), (1, ), torch.float32)
        buf10 = empty_strided_cuda((1, 4, 1, 1), (4, 1, 1, 1), torch.float32)
        buf11 = empty_strided_cuda((1, 4, 1, 1), (4, 1, 4, 4), torch.float32)
        buf13 = reinterpret_tensor(buf11, (1, 4, 1, 1), (4, 1, 1, 1), 0); del buf11  # reuse
        buf29 = reinterpret_tensor(buf32, (4, 1, 4, 4), (64, 1, 16, 4), 1)  # alias
        # Topologically Sorted Source Nodes: [x_3, out], Original ATen: [aten.repeat, aten._native_batch_norm_legit, aten.cat]
        triton_per_fused__native_batch_norm_legit_cat_repeat_1.run(buf13, primals_6, primals_7, buf7, buf8, buf9, buf10, buf29, 4, 16, grid=grid(4), stream=stream0)
        del primals_6
        del primals_7
        # Topologically Sorted Source Nodes: [x_4], Original ATen: [aten.convolution]
        buf14 = extern_kernels.convolution(primals_2, primals_8, stride=(1, 1), padding=(2, 2), dilation=(1, 1), transposed=False, output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf14, (4, 1, 4, 4), (16, 16, 4, 1))
        buf15 = empty_strided_cuda((4, ), (1, ), torch.float32)
        buf16 = empty_strided_cuda((4, ), (1, ), torch.float32)
        buf17 = empty_strided_cuda((1, 4, 1, 1), (4, 1, 1, 1), torch.float32)
        buf18 = empty_strided_cuda((1, 4, 1, 1), (4, 1, 4, 4), torch.float32)
        buf20 = reinterpret_tensor(buf18, (1, 4, 1, 1), (4, 1, 1, 1), 0); del buf18  # reuse
        buf30 = reinterpret_tensor(buf32, (4, 1, 4, 4), (64, 1, 16, 4), 2)  # alias
        # Topologically Sorted Source Nodes: [x_5, out], Original ATen: [aten.repeat, aten._native_batch_norm_legit, aten.cat]
        triton_per_fused__native_batch_norm_legit_cat_repeat_1.run(buf20, primals_9, primals_10, buf14, buf15, buf16, buf17, buf30, 4, 16, grid=grid(4), stream=stream0)
        del primals_10
        del primals_9
        # Topologically Sorted Source Nodes: [x_6], Original ATen: [aten.convolution]
        buf21 = extern_kernels.convolution(primals_2, primals_11, stride=(1, 1), padding=(3, 3), dilation=(1, 1), transposed=False, output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf21, (4, 1, 4, 4), (16, 16, 4, 1))
        buf22 = empty_strided_cuda((4, ), (1, ), torch.float32)
        buf23 = empty_strided_cuda((4, ), (1, ), torch.float32)
        buf24 = empty_strided_cuda((1, 4, 1, 1), (4, 1, 1, 1), torch.float32)
        buf25 = empty_strided_cuda((1, 4, 1, 1), (4, 1, 4, 4), torch.float32)
        buf27 = reinterpret_tensor(buf25, (1, 4, 1, 1), (4, 1, 1, 1), 0); del buf25  # reuse
        buf31 = reinterpret_tensor(buf32, (4, 1, 4, 4), (64, 1, 16, 4), 3)  # alias
        # Topologically Sorted Source Nodes: [x_7, out], Original ATen: [aten.repeat, aten._native_batch_norm_legit, aten.cat]
        triton_per_fused__native_batch_norm_legit_cat_repeat_1.run(buf27, primals_12, primals_13, buf21, buf22, buf23, buf24, buf31, 4, 16, grid=grid(4), stream=stream0)
        del primals_12
        del primals_13
        buf33 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [out], Original ATen: [aten.cat]
        triton_poi_fused_cat_2.run(buf32, buf33, 16, 16, grid=grid(16, 16), stream=stream0)
        del buf28
        del buf29
        del buf30
        del buf31
        del buf32
    return (buf33, primals_1, primals_2, primals_5, primals_8, primals_11, buf0, buf1, buf2, buf3, buf6, buf7, buf8, buf9, buf10, buf13, buf14, buf15, buf16, buf17, buf20, buf21, buf22, buf23, buf24, buf27, )


def benchmark_compiled_module(times=10, repeat=10):
    from torch._dynamo.testing import rand_strided
    from torch._inductor.utils import print_performance
    primals_1 = rand_strided((1, 4, 1, 1), (4, 1, 1, 1), device='cuda:0', dtype=torch.float32)
    primals_2 = rand_strided((4, 4, 4, 4), (64, 16, 4, 1), device='cuda:0', dtype=torch.float32)
    primals_3 = rand_strided((1, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_4 = rand_strided((1, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_5 = rand_strided((1, 4, 3, 3), (36, 9, 3, 1), device='cuda:0', dtype=torch.float32)
    primals_6 = rand_strided((1, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_7 = rand_strided((1, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_8 = rand_strided((1, 4, 5, 5), (100, 25, 5, 1), device='cuda:0', dtype=torch.float32)
    primals_9 = rand_strided((1, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_10 = rand_strided((1, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_11 = rand_strided((1, 4, 7, 7), (196, 49, 7, 1), device='cuda:0', dtype=torch.float32)
    primals_12 = rand_strided((1, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_13 = rand_strided((1, ), (1, ), device='cuda:0', dtype=torch.float32)
    fn = lambda: 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 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.nn.functional as F


class BasicConv(nn.Module):

    def __init__(self, in_channels, out_channels, use_bn=False, **kwargs):
        super(BasicConv, self).__init__()
        self.use_bn = use_bn
        self.conv = nn.Conv2d(in_channels, out_channels, bias=not self.
            use_bn, **kwargs)
        self.bn = nn.InstanceNorm2d(out_channels, affine=True
            ) if self.use_bn else None

    def forward(self, x):
        x = self.conv(x)
        if self.use_bn:
            x = self.bn(x)
        return F.relu(x, inplace=True)


class SAModule_Head(nn.Module):

    def __init__(self, in_channels, out_channels, use_bn):
        super(SAModule_Head, self).__init__()
        branch_out = out_channels // 4
        self.branch1x1 = BasicConv(in_channels, branch_out, use_bn=use_bn,
            kernel_size=1)
        self.branch3x3 = BasicConv(in_channels, branch_out, use_bn=use_bn,
            kernel_size=3, padding=1)
        self.branch5x5 = BasicConv(in_channels, branch_out, use_bn=use_bn,
            kernel_size=5, padding=2)
        self.branch7x7 = BasicConv(in_channels, branch_out, use_bn=use_bn,
            kernel_size=7, padding=3)

    def forward(self, x):
        branch1x1 = self.branch1x1(x)
        branch3x3 = self.branch3x3(x)
        branch5x5 = self.branch5x5(x)
        branch7x7 = self.branch7x7(x)
        out = torch.cat([branch1x1, branch3x3, branch5x5, branch7x7], 1)
        return out


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


def get_init_inputs():
    return [[], {'in_channels': 4, 'out_channels': 4, 'use_bn': 4}]

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
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as nn
import torch.nn.functional as F
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__native_batch_norm_legit_cat_repeat_0(in_out_ptr0,
    in_ptr0, in_ptr1, in_ptr2, out_ptr0, out_ptr1, out_ptr2, out_ptr3,
    xnumel, rnumel, XBLOCK: tl.constexpr):
    xnumel = 4
    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)
    x0 = xindex
    r1 = rindex
    tmp0 = tl.load(in_ptr0 + 0)
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK, 1])
    tmp2 = tl.load(in_ptr1 + 0)
    tmp3 = tl.broadcast_to(tmp2, [XBLOCK, 1])
    tmp4 = tl.load(in_ptr2 + (r1 + 16 * x0), xmask, other=0.0)
    tmp5 = tl.broadcast_to(tmp4, [XBLOCK, RBLOCK])
    tl.where(xmask, tmp5, 0)
    tmp8 = tl.broadcast_to(tmp5, [XBLOCK, RBLOCK])
    tmp10 = tl.where(xmask, tmp8, 0)
    tmp11 = tl.sum(tmp10, 1)[:, None]
    tmp12 = tl.full([XBLOCK, 1], 16, tl.int32)
    tmp13 = tmp12.to(tl.float32)
    tmp14 = tmp11 / tmp13
    tmp15 = tmp5 - tmp14
    tmp16 = tmp15 * tmp15
    tmp17 = tl.broadcast_to(tmp16, [XBLOCK, RBLOCK])
    tmp19 = tl.where(xmask, tmp17, 0)
    tmp20 = tl.sum(tmp19, 1)[:, None]
    tmp21 = 16.0
    tmp22 = tmp20 / tmp21
    tmp23 = 1e-05
    tmp24 = tmp22 + tmp23
    tmp25 = libdevice.rsqrt(tmp24)
    tmp26 = tmp4 - tmp14
    tmp27 = tmp26 * tmp25
    tmp28 = tmp27 * tmp1
    tmp29 = tmp28 + tmp3
    tmp30 = tl.full([1, 1], 0, tl.int32)
    tmp31 = triton_helpers.maximum(tmp30, tmp29)
    tl.store(out_ptr0 + x0, tmp1, xmask)
    tl.store(out_ptr1 + x0, tmp3, xmask)
    tl.debug_barrier()
    tl.store(in_out_ptr0 + x0, tmp25, xmask)
    tl.store(out_ptr3 + (4 * r1 + 64 * x0), tmp31, xmask)
    tl.store(out_ptr2 + x0, tmp14, xmask)


@triton.jit
def triton_per_fused__native_batch_norm_legit_cat_repeat_1(in_out_ptr0,
    in_ptr0, in_ptr1, in_ptr2, out_ptr0, out_ptr1, out_ptr2, out_ptr3,
    xnumel, rnumel, XBLOCK: tl.constexpr):
    xnumel = 4
    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)
    x0 = xindex
    r1 = rindex
    tmp0 = tl.load(in_ptr0 + 0)
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK, 1])
    tmp2 = tl.load(in_ptr1 + 0)
    tmp3 = tl.broadcast_to(tmp2, [XBLOCK, 1])
    tmp4 = tl.load(in_ptr2 + (r1 + 16 * x0), xmask, other=0.0)
    tmp5 = tl.broadcast_to(tmp4, [XBLOCK, RBLOCK])
    tl.where(xmask, tmp5, 0)
    tmp8 = tl.broadcast_to(tmp5, [XBLOCK, RBLOCK])
    tmp10 = tl.where(xmask, tmp8, 0)
    tmp11 = tl.sum(tmp10, 1)[:, None]
    tmp12 = tl.full([XBLOCK, 1], 16, tl.int32)
    tmp13 = tmp12.to(tl.float32)
    tmp14 = tmp11 / tmp13
    tmp15 = tmp5 - tmp14
    tmp16 = tmp15 * tmp15
    tmp17 = tl.broadcast_to(tmp16, [XBLOCK, RBLOCK])
    tmp19 = tl.where(xmask, tmp17, 0)
    tmp20 = tl.sum(tmp19, 1)[:, None]
    tmp21 = 16.0
    tmp22 = tmp20 / tmp21
    tmp23 = 1e-05
    tmp24 = tmp22 + tmp23
    tmp25 = libdevice.rsqrt(tmp24)
    tmp26 = tmp4 - tmp14
    tmp27 = tmp26 * tmp25
    tmp28 = tmp27 * tmp1
    tmp29 = tmp28 + tmp3
    tmp30 = tl.full([1, 1], 0, tl.int32)
    tmp31 = triton_helpers.maximum(tmp30, tmp29)
    tl.store(out_ptr0 + x0, tmp1, xmask)
    tl.store(out_ptr1 + x0, tmp3, xmask)
    tl.debug_barrier()
    tl.store(in_out_ptr0 + x0, tmp25, xmask)
    tl.store(out_ptr3 + (4 * r1 + 64 * x0), tmp31, xmask)
    tl.store(out_ptr2 + x0, tmp14, xmask)


@triton.jit
def triton_poi_fused_cat_2(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK: tl.
    constexpr, XBLOCK: tl.constexpr):
    ynumel = 16
    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
    y0 = yindex % 4
    y1 = yindex // 4
    y3 = yindex
    tmp0 = tl.load(in_ptr0 + (y0 + 4 * x2 + 64 * y1), xmask & ymask)
    tl.store(out_ptr0 + (x2 + 16 * y3), tmp0, xmask & ymask)


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, (1, 4, 1, 1), (4, 1, 1, 1))
    assert_size_stride(primals_2, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(primals_3, (1,), (1,))
    assert_size_stride(primals_4, (1,), (1,))
    assert_size_stride(primals_5, (1, 4, 3, 3), (36, 9, 3, 1))
    assert_size_stride(primals_6, (1,), (1,))
    assert_size_stride(primals_7, (1,), (1,))
    assert_size_stride(primals_8, (1, 4, 5, 5), (100, 25, 5, 1))
    assert_size_stride(primals_9, (1,), (1,))
    assert_size_stride(primals_10, (1,), (1,))
    assert_size_stride(primals_11, (1, 4, 7, 7), (196, 49, 7, 1))
    assert_size_stride(primals_12, (1,), (1,))
    assert_size_stride(primals_13, (1,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = extern_kernels.convolution(primals_2, 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, 1, 4, 4), (16, 16, 4, 1))
        buf1 = empty_strided_cuda((4,), (1,), torch.float32)
        buf2 = empty_strided_cuda((4,), (1,), torch.float32)
        buf3 = empty_strided_cuda((1, 4, 1, 1), (4, 1, 1, 1), torch.float32)
        buf4 = empty_strided_cuda((1, 4, 1, 1), (4, 1, 4, 4), torch.float32)
        buf6 = reinterpret_tensor(buf4, (1, 4, 1, 1), (4, 1, 1, 1), 0)
        del buf4
        buf32 = empty_strided_cuda((4, 4, 4, 4), (64, 1, 16, 4), torch.float32)
        buf28 = reinterpret_tensor(buf32, (4, 1, 4, 4), (64, 1, 16, 4), 0)
        get_raw_stream(0)
        triton_per_fused__native_batch_norm_legit_cat_repeat_0[grid(4)](buf6,
            primals_3, primals_4, buf0, buf1, buf2, buf3, buf28, 4, 16,
            XBLOCK=1, num_warps=2, num_stages=1)
        del primals_3
        del primals_4
        buf7 = extern_kernels.convolution(primals_2, primals_5, stride=(1, 
            1), padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf7, (4, 1, 4, 4), (16, 16, 4, 1))
        buf8 = empty_strided_cuda((4,), (1,), torch.float32)
        buf9 = empty_strided_cuda((4,), (1,), torch.float32)
        buf10 = empty_strided_cuda((1, 4, 1, 1), (4, 1, 1, 1), torch.float32)
        buf11 = empty_strided_cuda((1, 4, 1, 1), (4, 1, 4, 4), torch.float32)
        buf13 = reinterpret_tensor(buf11, (1, 4, 1, 1), (4, 1, 1, 1), 0)
        del buf11
        buf29 = reinterpret_tensor(buf32, (4, 1, 4, 4), (64, 1, 16, 4), 1)
        triton_per_fused__native_batch_norm_legit_cat_repeat_1[grid(4)](buf13,
            primals_6, primals_7, buf7, buf8, buf9, buf10, buf29, 4, 16,
            XBLOCK=1, num_warps=2, num_stages=1)
        del primals_6
        del primals_7
        buf14 = extern_kernels.convolution(primals_2, primals_8, stride=(1,
            1), padding=(2, 2), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf14, (4, 1, 4, 4), (16, 16, 4, 1))
        buf15 = empty_strided_cuda((4,), (1,), torch.float32)
        buf16 = empty_strided_cuda((4,), (1,), torch.float32)
        buf17 = empty_strided_cuda((1, 4, 1, 1), (4, 1, 1, 1), torch.float32)
        buf18 = empty_strided_cuda((1, 4, 1, 1), (4, 1, 4, 4), torch.float32)
        buf20 = reinterpret_tensor(buf18, (1, 4, 1, 1), (4, 1, 1, 1), 0)
        del buf18
        buf30 = reinterpret_tensor(buf32, (4, 1, 4, 4), (64, 1, 16, 4), 2)
        triton_per_fused__native_batch_norm_legit_cat_repeat_1[grid(4)](buf20,
            primals_9, primals_10, buf14, buf15, buf16, buf17, buf30, 4, 16,
            XBLOCK=1, num_warps=2, num_stages=1)
        del primals_10
        del primals_9
        buf21 = extern_kernels.convolution(primals_2, primals_11, stride=(1,
            1), padding=(3, 3), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf21, (4, 1, 4, 4), (16, 16, 4, 1))
        buf22 = empty_strided_cuda((4,), (1,), torch.float32)
        buf23 = empty_strided_cuda((4,), (1,), torch.float32)
        buf24 = empty_strided_cuda((1, 4, 1, 1), (4, 1, 1, 1), torch.float32)
        buf25 = empty_strided_cuda((1, 4, 1, 1), (4, 1, 4, 4), torch.float32)
        buf27 = reinterpret_tensor(buf25, (1, 4, 1, 1), (4, 1, 1, 1), 0)
        del buf25
        buf31 = reinterpret_tensor(buf32, (4, 1, 4, 4), (64, 1, 16, 4), 3)
        triton_per_fused__native_batch_norm_legit_cat_repeat_1[grid(4)](buf27,
            primals_12, primals_13, buf21, buf22, buf23, buf24, buf31, 4, 
            16, XBLOCK=1, num_warps=2, num_stages=1)
        del primals_12
        del primals_13
        buf33 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        triton_poi_fused_cat_2[grid(16, 16)](buf32, buf33, 16, 16, XBLOCK=
            16, YBLOCK=16, num_warps=4, num_stages=1)
        del buf28
        del buf29
        del buf30
        del buf31
        del buf32
    return (buf33, primals_1, primals_2, primals_5, primals_8, primals_11,
        buf0, buf1, buf2, buf3, buf6, buf7, buf8, buf9, buf10, buf13, buf14,
        buf15, buf16, buf17, buf20, buf21, buf22, buf23, buf24, buf27)


class BasicConv(nn.Module):

    def __init__(self, in_channels, out_channels, use_bn=False, **kwargs):
        super(BasicConv, self).__init__()
        self.use_bn = use_bn
        self.conv = nn.Conv2d(in_channels, out_channels, bias=not self.
            use_bn, **kwargs)
        self.bn = nn.InstanceNorm2d(out_channels, affine=True
            ) if self.use_bn else None

    def forward(self, x):
        x = self.conv(x)
        if self.use_bn:
            x = self.bn(x)
        return F.relu(x, inplace=True)


class SAModule_HeadNew(nn.Module):

    def __init__(self, in_channels, out_channels, use_bn):
        super(SAModule_HeadNew, self).__init__()
        branch_out = out_channels // 4
        self.branch1x1 = BasicConv(in_channels, branch_out, use_bn=use_bn,
            kernel_size=1)
        self.branch3x3 = BasicConv(in_channels, branch_out, use_bn=use_bn,
            kernel_size=3, padding=1)
        self.branch5x5 = BasicConv(in_channels, branch_out, use_bn=use_bn,
            kernel_size=5, padding=2)
        self.branch7x7 = BasicConv(in_channels, branch_out, use_bn=use_bn,
            kernel_size=7, padding=3)

    def forward(self, input_0):
        primals_1 = self.branch1x1.conv.weight
        primals_3 = self.branch1x1.bn.weight
        primals_4 = self.branch1x1.bn.bias
        primals_5 = self.branch3x3.conv.weight
        primals_6 = self.branch3x3.bn.weight
        primals_7 = self.branch3x3.bn.bias
        primals_8 = self.branch5x5.conv.weight
        primals_9 = self.branch5x5.bn.weight
        primals_10 = self.branch5x5.bn.bias
        primals_11 = self.branch7x7.conv.weight
        primals_12 = self.branch7x7.bn.weight
        primals_13 = self.branch7x7.bn.bias
        primals_2 = 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]
