# 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_8/inductor_cache/2n/c2ng6n7nv7j6ot5s3l65cjcbcom4k45g6xz2sxctmom3kjfu2yje.py
# Topologically Sorted Source Nodes: [x, norm], Original ATen: [aten.convolution, aten.native_group_norm]
# Source node to ATen node mapping:
#   norm => var_mean
#   x => convolution
# Graph fragment:
#   %convolution : [num_users=2] = call_function[target=torch.ops.aten.convolution.default](args = (%primals_3, %primals_1, %primals_2, [1, 1], [1, 1], [1, 1], False, [0, 0], 1), kwargs = {})
#   %var_mean : [num_users=2] = call_function[target=torch.ops.aten.var_mean.correction](args = (%view, [2, 3]), kwargs = {correction: 0, keepdim: True})
triton_red_fused_convolution_native_group_norm_0 = async_compile.triton('triton_red_fused_convolution_native_group_norm_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.reduction(
    size_hints=[512, 8192],
    reduction_hint=ReductionHint.INNER,
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: '*fp32', 5: 'i32', 6: '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), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_red_fused_convolution_native_group_norm_0', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 2, 'num_reduction': 3, '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_red_fused_convolution_native_group_norm_0(in_out_ptr0, in_ptr0, out_ptr0, out_ptr1, out_ptr2, xnumel, rnumel, XBLOCK : tl.constexpr, RBLOCK : tl.constexpr):
    xnumel = 512
    rnumel = 8192
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    rbase = tl.arange(0, RBLOCK)[None, :]
    x4 = xindex
    x0 = xindex % 128
    tmp4_mean = tl.zeros([XBLOCK, RBLOCK], tl.float32)
    tmp4_m2 = tl.zeros([XBLOCK, RBLOCK], tl.float32)
    tmp4_weight = tl.zeros([XBLOCK, RBLOCK], tl.float32)
    for roffset in range(0, rnumel, RBLOCK):
        rindex = roffset + rbase
        rmask = rindex < rnumel
        r5 = rindex
        r3 = (rindex // 4096)
        tmp0 = tl.load(in_out_ptr0 + (r5 + (8192*x4)), rmask & xmask, eviction_policy='evict_first', other=0.0)
        tmp1 = tl.load(in_ptr0 + (r3 + (2*x0)), rmask & xmask, eviction_policy='evict_last', other=0.0)
        tmp2 = tmp0 + tmp1
        tmp3 = tl.broadcast_to(tmp2, [XBLOCK, RBLOCK])
        tmp4_mean_next, tmp4_m2_next, tmp4_weight_next = triton_helpers.welford_reduce(
            tmp3, tmp4_mean, tmp4_m2, tmp4_weight, roffset == 0
        )
        tmp4_mean = tl.where(rmask & xmask, tmp4_mean_next, tmp4_mean)
        tmp4_m2 = tl.where(rmask & xmask, tmp4_m2_next, tmp4_m2)
        tmp4_weight = tl.where(rmask & xmask, tmp4_weight_next, tmp4_weight)
        tl.store(in_out_ptr0 + (r5 + (8192*x4)), tmp2, rmask & xmask)
    tmp4_tmp, tmp5_tmp, tmp6_tmp = triton_helpers.welford(
        tmp4_mean, tmp4_m2, tmp4_weight, 1
    )
    tmp4 = tmp4_tmp[:, None]
    tmp5 = tmp5_tmp[:, None]
    tmp6 = tmp6_tmp[:, None]
    tl.store(out_ptr0 + (x4), tmp4, xmask)
    tl.store(out_ptr1 + (x4), tmp5, xmask)
    tl.store(out_ptr2 + (x4), tmp6, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_8/inductor_cache/hq/chqhykjsbqdit7w6q4wokmaxashjyx3mcvrb5eht7rghwqiaatcf.py
# Topologically Sorted Source Nodes: [norm], Original ATen: [aten.native_group_norm]
# Source node to ATen node mapping:
#   norm => add, rsqrt, var_mean
# Graph fragment:
#   %var_mean : [num_users=2] = call_function[target=torch.ops.aten.var_mean.correction](args = (%view, [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 = {})
triton_per_fused_native_group_norm_1 = async_compile.triton('triton_per_fused_native_group_norm_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=[128, 4],
    reduction_hint=ReductionHint.INNER,
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: '*fp32', 5: '*fp32', 6: 'i32', 7: '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), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused_native_group_norm_1', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 3, 'num_reduction': 2, '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_group_norm_1(in_ptr0, in_ptr1, in_ptr2, out_ptr0, out_ptr1, out_ptr2, xnumel, rnumel, XBLOCK : tl.constexpr):
    xnumel = 128
    rnumel = 4
    RBLOCK: tl.constexpr = 4
    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 + (4*x0)), xmask, other=0.0)
    tmp1 = tl.load(in_ptr1 + (r1 + (4*x0)), xmask, other=0.0)
    tmp2 = tl.load(in_ptr2 + (r1 + (4*x0)), xmask, other=0.0)
    tmp3 = tl.broadcast_to(tmp0, [XBLOCK, RBLOCK])
    tmp4 = tl.broadcast_to(tmp1, [XBLOCK, RBLOCK])
    tmp5 = tl.broadcast_to(tmp2, [XBLOCK, RBLOCK])
    tmp7 = tl.where(xmask, tmp3, 0)
    tmp8 = tl.where(xmask, tmp4, 0)
    tmp9 = tl.where(xmask, tmp5, 0)
    tmp10, tmp11, tmp12 = triton_helpers.welford(tmp7, tmp8, tmp9, 1)
    tmp13 = tmp10[:, None]
    tmp14 = tmp11[:, None]
    tmp15 = tmp12[:, None]
    tmp16 = 32768.0
    tmp17 = tmp14 / tmp16
    tmp18 = 1e-05
    tmp19 = tmp17 + tmp18
    tmp20 = libdevice.rsqrt(tmp19)
    tl.store(out_ptr2 + (x0), tmp20, xmask)
    tl.store(out_ptr0 + (x0), tmp13, xmask)
    tl.store(out_ptr1 + (x0), tmp14, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_8/inductor_cache/q3/cq32fxmy5x7yle33r4ilakwezapd2xehsgje6if3o5knnssz3adi.py
# Topologically Sorted Source Nodes: [norm, relu], Original ATen: [aten.native_group_norm, aten.relu]
# Source node to ATen node mapping:
#   norm => add_1, mul_1
#   relu => relu
# Graph fragment:
#   %mul_1 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%view_1, %unsqueeze_5), kwargs = {})
#   %add_1 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_1, %unsqueeze_2), kwargs = {})
#   %relu : [num_users=2] = call_function[target=torch.ops.aten.relu.default](args = (%add_1,), kwargs = {})
triton_poi_fused_native_group_norm_relu_2 = async_compile.triton('triton_poi_fused_native_group_norm_relu_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=[4194304], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: '*fp32', 5: '*fp32', 6: '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), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_native_group_norm_relu_2', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 5, '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_native_group_norm_relu_2(in_ptr0, in_ptr1, in_ptr2, in_ptr3, in_ptr4, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 4194304
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = tl.full([XBLOCK], True, tl.int1)
    x3 = xindex
    x4 = (xindex // 4096)
    x1 = (xindex // 4096) % 256
    tmp0 = tl.load(in_ptr0 + (x3), None)
    tmp1 = tl.load(in_ptr1 + ((x4 // 8)), None, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr2 + ((x4 // 8)), None, eviction_policy='evict_last')
    tmp10 = tl.load(in_ptr3 + (x1), None, eviction_policy='evict_last')
    tmp12 = tl.load(in_ptr4 + (x1), None, eviction_policy='evict_last')
    tmp2 = tmp0 - tmp1
    tmp4 = 32768.0
    tmp5 = tmp3 / tmp4
    tmp6 = 1e-05
    tmp7 = tmp5 + tmp6
    tmp8 = libdevice.rsqrt(tmp7)
    tmp9 = tmp2 * tmp8
    tmp11 = tmp9 * tmp10
    tmp13 = tmp11 + tmp12
    tmp14 = tl.full([1], 0, tl.int32)
    tmp15 = triton_helpers.maximum(tmp14, tmp13)
    tl.store(out_ptr0 + (x3), tmp15, None)
''', device_str='cuda')


# kernel path: runs/run_shard_8/inductor_cache/ob/cobe3cs3zdr4g3svcyqtxtcc4l4ckot56hsytcz47nu3sggotrlx.py
# Topologically Sorted Source Nodes: [input_1], Original ATen: [aten.convolution]
# Source node to ATen node mapping:
#   input_1 => convolution_4
# Graph fragment:
#   %convolution_4 : [num_users=1] = call_function[target=torch.ops.aten.convolution.default](args = (%relu_3, %primals_18, %primals_19, [1, 1], [1, 1], [1, 1], False, [0, 0], 1), kwargs = {})
triton_poi_fused_convolution_3 = async_compile.triton('triton_poi_fused_convolution_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=[16384], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '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), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_convolution_3', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 2, '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_convolution_3(in_out_ptr0, in_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 16384
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = tl.full([XBLOCK], True, tl.int1)
    x0 = xindex
    tmp0 = tl.load(in_out_ptr0 + (x0), None)
    tmp1 = tl.load(in_ptr0 + (0))
    tmp2 = tl.broadcast_to(tmp1, [XBLOCK])
    tmp3 = tmp0 + tmp2
    tl.store(in_out_ptr0 + (x0), tmp3, None)
''', 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, primals_14, primals_15, primals_16, primals_17, primals_18, primals_19 = args
    args.clear()
    assert_size_stride(primals_1, (256, 256, 3, 3), (2304, 9, 3, 1))
    assert_size_stride(primals_2, (256, ), (1, ))
    assert_size_stride(primals_3, (4, 256, 64, 64), (1048576, 4096, 64, 1))
    assert_size_stride(primals_4, (256, ), (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, ), (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, ), (1, ))
    assert_size_stride(primals_13, (256, ), (1, ))
    assert_size_stride(primals_14, (256, 256, 3, 3), (2304, 9, 3, 1))
    assert_size_stride(primals_15, (256, ), (1, ))
    assert_size_stride(primals_16, (256, ), (1, ))
    assert_size_stride(primals_17, (256, ), (1, ))
    assert_size_stride(primals_18, (1, 256, 3, 3), (2304, 9, 3, 1))
    assert_size_stride(primals_19, (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_3, primals_1, stride=(1, 1), padding=(1, 1), dilation=(1, 1), transposed=False, output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf0, (4, 256, 64, 64), (1048576, 4096, 64, 1))
        buf1 = buf0; del buf0  # reuse
        buf2 = empty_strided_cuda((4, 32, 1, 1, 4), (128, 4, 512, 512, 1), torch.float32)
        buf3 = empty_strided_cuda((4, 32, 1, 1, 4), (128, 4, 512, 512, 1), torch.float32)
        buf4 = empty_strided_cuda((4, 32, 1, 1, 4), (128, 4, 512, 512, 1), torch.float32)
        # Topologically Sorted Source Nodes: [x, norm], Original ATen: [aten.convolution, aten.native_group_norm]
        stream0 = get_raw_stream(0)
        triton_red_fused_convolution_native_group_norm_0.run(buf1, primals_2, buf2, buf3, buf4, 512, 8192, grid=grid(512), stream=stream0)
        del primals_2
        buf5 = empty_strided_cuda((4, 32, 1, 1), (32, 1, 128, 128), torch.float32)
        buf6 = empty_strided_cuda((4, 32, 1, 1), (32, 1, 128, 128), torch.float32)
        buf8 = empty_strided_cuda((4, 32, 1, 1), (32, 1, 128, 128), torch.float32)
        # Topologically Sorted Source Nodes: [norm], Original ATen: [aten.native_group_norm]
        triton_per_fused_native_group_norm_1.run(buf2, buf3, buf4, buf5, buf6, buf8, 128, 4, grid=grid(128), stream=stream0)
        buf9 = empty_strided_cuda((4, 256, 64, 64), (1048576, 4096, 64, 1), torch.float32)
        # Topologically Sorted Source Nodes: [norm, relu], Original ATen: [aten.native_group_norm, aten.relu]
        triton_poi_fused_native_group_norm_relu_2.run(buf1, buf5, buf6, primals_4, primals_5, buf9, 4194304, grid=grid(4194304), stream=stream0)
        del primals_5
        # Topologically Sorted Source Nodes: [x_1], Original ATen: [aten.convolution]
        buf10 = extern_kernels.convolution(buf9, primals_6, stride=(1, 1), padding=(1, 1), dilation=(1, 1), transposed=False, output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf10, (4, 256, 64, 64), (1048576, 4096, 64, 1))
        buf11 = buf10; del buf10  # reuse
        buf12 = buf4; del buf4  # reuse
        buf13 = buf3; del buf3  # reuse
        buf14 = buf2; del buf2  # reuse
        # Topologically Sorted Source Nodes: [x_1, norm_1], Original ATen: [aten.convolution, aten.native_group_norm]
        triton_red_fused_convolution_native_group_norm_0.run(buf11, primals_7, buf12, buf13, buf14, 512, 8192, grid=grid(512), stream=stream0)
        del primals_7
        buf15 = buf6; del buf6  # reuse
        buf16 = empty_strided_cuda((4, 32, 1, 1), (32, 1, 128, 128), torch.float32)
        buf18 = empty_strided_cuda((4, 32, 1, 1), (32, 1, 128, 128), torch.float32)
        # Topologically Sorted Source Nodes: [norm_1], Original ATen: [aten.native_group_norm]
        triton_per_fused_native_group_norm_1.run(buf12, buf13, buf14, buf15, buf16, buf18, 128, 4, grid=grid(128), stream=stream0)
        buf19 = empty_strided_cuda((4, 256, 64, 64), (1048576, 4096, 64, 1), torch.float32)
        # Topologically Sorted Source Nodes: [norm_1, relu_2], Original ATen: [aten.native_group_norm, aten.relu]
        triton_poi_fused_native_group_norm_relu_2.run(buf11, buf15, buf16, primals_8, primals_9, buf19, 4194304, grid=grid(4194304), stream=stream0)
        del primals_9
        # Topologically Sorted Source Nodes: [x_2], Original ATen: [aten.convolution]
        buf20 = extern_kernels.convolution(buf19, primals_10, stride=(1, 1), padding=(1, 1), dilation=(1, 1), transposed=False, output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf20, (4, 256, 64, 64), (1048576, 4096, 64, 1))
        buf21 = buf20; del buf20  # reuse
        buf22 = buf14; del buf14  # reuse
        buf23 = buf13; del buf13  # reuse
        buf24 = buf12; del buf12  # reuse
        # Topologically Sorted Source Nodes: [x_2, norm_2], Original ATen: [aten.convolution, aten.native_group_norm]
        triton_red_fused_convolution_native_group_norm_0.run(buf21, primals_11, buf22, buf23, buf24, 512, 8192, grid=grid(512), stream=stream0)
        del primals_11
        buf25 = buf16; del buf16  # reuse
        buf26 = empty_strided_cuda((4, 32, 1, 1), (32, 1, 128, 128), torch.float32)
        buf28 = empty_strided_cuda((4, 32, 1, 1), (32, 1, 128, 128), torch.float32)
        # Topologically Sorted Source Nodes: [norm_2], Original ATen: [aten.native_group_norm]
        triton_per_fused_native_group_norm_1.run(buf22, buf23, buf24, buf25, buf26, buf28, 128, 4, grid=grid(128), stream=stream0)
        buf29 = empty_strided_cuda((4, 256, 64, 64), (1048576, 4096, 64, 1), torch.float32)
        # Topologically Sorted Source Nodes: [norm_2, relu_4], Original ATen: [aten.native_group_norm, aten.relu]
        triton_poi_fused_native_group_norm_relu_2.run(buf21, buf25, buf26, primals_12, primals_13, buf29, 4194304, grid=grid(4194304), stream=stream0)
        del primals_13
        # Topologically Sorted Source Nodes: [x_3], Original ATen: [aten.convolution]
        buf30 = extern_kernels.convolution(buf29, primals_14, stride=(1, 1), padding=(1, 1), dilation=(1, 1), transposed=False, output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf30, (4, 256, 64, 64), (1048576, 4096, 64, 1))
        buf31 = buf30; del buf30  # reuse
        buf32 = buf24; del buf24  # reuse
        buf33 = buf23; del buf23  # reuse
        buf34 = buf22; del buf22  # reuse
        # Topologically Sorted Source Nodes: [x_3, norm_3], Original ATen: [aten.convolution, aten.native_group_norm]
        triton_red_fused_convolution_native_group_norm_0.run(buf31, primals_15, buf32, buf33, buf34, 512, 8192, grid=grid(512), stream=stream0)
        del primals_15
        buf35 = buf26; del buf26  # reuse
        buf36 = empty_strided_cuda((4, 32, 1, 1), (32, 1, 128, 128), torch.float32)
        buf38 = empty_strided_cuda((4, 32, 1, 1), (32, 1, 128, 128), torch.float32)
        # Topologically Sorted Source Nodes: [norm_3], Original ATen: [aten.native_group_norm]
        triton_per_fused_native_group_norm_1.run(buf32, buf33, buf34, buf35, buf36, buf38, 128, 4, grid=grid(128), stream=stream0)
        del buf32
        del buf33
        del buf34
        buf39 = empty_strided_cuda((4, 256, 64, 64), (1048576, 4096, 64, 1), torch.float32)
        # Topologically Sorted Source Nodes: [norm_3, relu_6], Original ATen: [aten.native_group_norm, aten.relu]
        triton_poi_fused_native_group_norm_relu_2.run(buf31, buf35, buf36, primals_16, primals_17, buf39, 4194304, grid=grid(4194304), stream=stream0)
        del buf36
        del primals_17
        # Topologically Sorted Source Nodes: [input_1], Original ATen: [aten.convolution]
        buf40 = extern_kernels.convolution(buf39, primals_18, stride=(1, 1), padding=(1, 1), dilation=(1, 1), transposed=False, output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf40, (4, 1, 64, 64), (4096, 4096, 64, 1))
        buf41 = buf40; del buf40  # reuse
        # Topologically Sorted Source Nodes: [input_1], Original ATen: [aten.convolution]
        triton_poi_fused_convolution_3.run(buf41, primals_19, 16384, grid=grid(16384), stream=stream0)
        del primals_19
    return (buf41, primals_1, primals_3, primals_4, primals_6, primals_8, primals_10, primals_12, primals_14, primals_16, primals_18, buf1, reinterpret_tensor(buf5, (4, 32), (32, 1), 0), reinterpret_tensor(buf8, (4, 32), (32, 1), 0), buf9, buf11, reinterpret_tensor(buf15, (4, 32), (32, 1), 0), reinterpret_tensor(buf18, (4, 32), (32, 1), 0), buf19, buf21, reinterpret_tensor(buf25, (4, 32), (32, 1), 0), reinterpret_tensor(buf28, (4, 32), (32, 1), 0), buf29, buf31, reinterpret_tensor(buf35, (4, 32), (32, 1), 0), reinterpret_tensor(buf38, (4, 32), (32, 1), 0), buf39, )


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((256, 256, 3, 3), (2304, 9, 3, 1), device='cuda:0', dtype=torch.float32)
    primals_2 = rand_strided((256, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_3 = rand_strided((4, 256, 64, 64), (1048576, 4096, 64, 1), device='cuda:0', dtype=torch.float32)
    primals_4 = rand_strided((256, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_5 = rand_strided((256, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_6 = rand_strided((256, 256, 3, 3), (2304, 9, 3, 1), device='cuda:0', dtype=torch.float32)
    primals_7 = rand_strided((256, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_8 = rand_strided((256, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_9 = rand_strided((256, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_10 = rand_strided((256, 256, 3, 3), (2304, 9, 3, 1), device='cuda:0', dtype=torch.float32)
    primals_11 = rand_strided((256, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_12 = rand_strided((256, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_13 = rand_strided((256, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_14 = rand_strided((256, 256, 3, 3), (2304, 9, 3, 1), device='cuda:0', dtype=torch.float32)
    primals_15 = rand_strided((256, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_16 = rand_strided((256, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_17 = rand_strided((256, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_18 = rand_strided((1, 256, 3, 3), (2304, 9, 3, 1), device='cuda:0', dtype=torch.float32)
    primals_19 = 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, primals_14, primals_15, primals_16, primals_17, primals_18, primals_19])
    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 math
import torch
import torch.nn as nn
from torch.nn.modules.utils import _pair


class BasicBlock(nn.Module):

    def __init__(self, in_channels, out_channels, kernel_size, stride=1,
        padding=0):
        super(BasicBlock, self).__init__()
        self.conv = nn.Conv2d(in_channels, out_channels, kernel_size,
            stride, padding)
        self.norm = nn.GroupNorm(num_groups=32, num_channels=256)
        self.relu = nn.ReLU(inplace=True)

    def forward(self, x):
        x = self.conv(x)
        norm = self.norm(x)
        relu = self.relu(norm)
        return relu


class DCNv2(nn.Module):

    def __init__(self, in_channels, out_channels, kernel_size, stride,
        padding, dilation=1, deformable_groups=1):
        super(DCNv2, self).__init__()
        self.in_channels = in_channels
        self.out_channels = out_channels
        self.kernel_size = _pair(kernel_size)
        self.stride = _pair(stride)
        self.padding = _pair(padding)
        self.dilation = _pair(dilation)
        self.deformable_groups = deformable_groups
        self.weight = nn.Parameter(torch.Tensor(out_channels, in_channels,
            *self.kernel_size))
        self.bias = nn.Parameter(torch.Tensor(out_channels))
        self.reset_parameters()

    def reset_parameters(self):
        n = self.in_channels
        for k in self.kernel_size:
            n *= k
        stdv = 1.0 / math.sqrt(n)
        self.weight.data.uniform_(-stdv, stdv)
        self.bias.data.zero_()

    def forward(self, input, offset, mask):
        assert 2 * self.deformable_groups * self.kernel_size[0
            ] * self.kernel_size[1] == offset.shape[1]
        assert self.deformable_groups * self.kernel_size[0] * self.kernel_size[
            1] == mask.shape[1]
        return dcn_v2_conv(input, offset, mask, self.weight, self.bias,
            self.stride, self.padding, self.dilation, self.deformable_groups)


class DCN(DCNv2):

    def __init__(self, in_channels, out_channels, kernel_size, stride,
        padding, dilation=1, deformable_groups=1):
        super(DCN, self).__init__(in_channels, out_channels, kernel_size,
            stride, padding, dilation, deformable_groups)
        channels_ = self.deformable_groups * 3 * self.kernel_size[0
            ] * self.kernel_size[1]
        self.conv_offset_mask = nn.Conv2d(self.in_channels, channels_,
            kernel_size=self.kernel_size, stride=self.stride, padding=self.
            padding, bias=True)
        self.init_offset()

    def init_offset(self):
        self.conv_offset_mask.weight.data.zero_()
        self.conv_offset_mask.bias.data.zero_()

    def forward(self, input):
        out = self.conv_offset_mask(input)
        o1, o2, mask = torch.chunk(out, 3, dim=1)
        offset = torch.cat((o1, o2), dim=1)
        mask = torch.sigmoid(mask)
        return dcn_v2_conv(input, offset, mask, self.weight, self.bias,
            self.stride, self.padding, self.dilation, self.deformable_groups)


class CenterNessNet(nn.Module):

    def __init__(self, in_channels=256, feat_channels=256, stacked_convs=4,
        dcn_on_last_conv=False):
        super(CenterNessNet, self).__init__()
        self.stacked_convs = stacked_convs
        self.dcn_on_last_conv = dcn_on_last_conv
        self.in_channels = in_channels
        self.feat_channels = feat_channels
        self._init_layers()
        self.init_weight()

    def _init_layers(self):
        self._init_centerness_convs()
        self._init_centerness_predict()

    def normal_init(self, module, mean=0, std=1, bias=0):
        nn.init.normal_(module.weight, mean, std)
        if hasattr(module, 'bias') and module.bias is not None:
            nn.init.constant_(module.bias, bias)

    def init_weight(self):
        for m in self.centerness_convs.modules():
            if isinstance(m, nn.Conv2d):
                torch.nn.init.xavier_normal_(m.weight.data)
                if m.bias is not None:
                    m.bias.data.zero_()
                elif isinstance(m, nn.GroupNorm):
                    m.weight.data.fill_(1)
                    m.bias.data.zero_()
                elif isinstance(m, nn.Linear):
                    torch.nn.normal(m.weight.data, 0, 0.01)
                    m.bias.zero_()
        for m in self.centerness_predict.modules():
            if isinstance(m, nn.Conv2d):
                torch.nn.init.xavier_normal_(m.weight.data)
                if m.bias is not None:
                    m.bias.data.zero_()

    def _init_centerness_convs(self):
        self.centerness_convs = nn.Sequential()
        for i in range(self.stacked_convs):
            chn = self.in_channels if i == 0 else self.feat_channels
            if self.dcn_on_last_conv and i == self.stacked_convs - 1:
                conv_cfg = DCN(chn, self.feat_channels, kernel_size=(3, 3),
                    stride=1, padding=1, deformable_groups=1)
            else:
                conv_cfg = BasicBlock(chn, self.feat_channels, 3, 1, 1)
            self.centerness_convs.add_module(('centerness_' + str({0})).
                format(i), conv_cfg)

    def _init_centerness_predict(self):
        self.centerness_predict = nn.Sequential()
        predict = nn.Conv2d(self.feat_channels, 1, 3, padding=1)
        self.centerness_predict.add_module('centerness_predict', predict)

    def forward(self, x):
        convs = self.centerness_convs(x)
        predict = self.centerness_predict(convs)
        return predict


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


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

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 math
import torch.nn as nn
from torch.nn.modules.utils import _pair
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_red_fused_convolution_native_group_norm_0(in_out_ptr0, in_ptr0,
    out_ptr0, out_ptr1, out_ptr2, xnumel, rnumel, XBLOCK: tl.constexpr,
    RBLOCK: tl.constexpr):
    xnumel = 512
    rnumel = 8192
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    rbase = tl.arange(0, RBLOCK)[None, :]
    x4 = xindex
    x0 = xindex % 128
    tmp4_mean = tl.zeros([XBLOCK, RBLOCK], tl.float32)
    tmp4_m2 = tl.zeros([XBLOCK, RBLOCK], tl.float32)
    tmp4_weight = tl.zeros([XBLOCK, RBLOCK], tl.float32)
    for roffset in range(0, rnumel, RBLOCK):
        rindex = roffset + rbase
        rmask = rindex < rnumel
        r5 = rindex
        r3 = rindex // 4096
        tmp0 = tl.load(in_out_ptr0 + (r5 + 8192 * x4), rmask & xmask,
            eviction_policy='evict_first', other=0.0)
        tmp1 = tl.load(in_ptr0 + (r3 + 2 * x0), rmask & xmask,
            eviction_policy='evict_last', other=0.0)
        tmp2 = tmp0 + tmp1
        tmp3 = tl.broadcast_to(tmp2, [XBLOCK, RBLOCK])
        tmp4_mean_next, tmp4_m2_next, tmp4_weight_next = (triton_helpers.
            welford_reduce(tmp3, tmp4_mean, tmp4_m2, tmp4_weight, roffset == 0)
            )
        tmp4_mean = tl.where(rmask & xmask, tmp4_mean_next, tmp4_mean)
        tmp4_m2 = tl.where(rmask & xmask, tmp4_m2_next, tmp4_m2)
        tmp4_weight = tl.where(rmask & xmask, tmp4_weight_next, tmp4_weight)
        tl.store(in_out_ptr0 + (r5 + 8192 * x4), tmp2, rmask & xmask)
    tmp4_tmp, tmp5_tmp, tmp6_tmp = triton_helpers.welford(tmp4_mean,
        tmp4_m2, tmp4_weight, 1)
    tmp4 = tmp4_tmp[:, None]
    tmp5 = tmp5_tmp[:, None]
    tmp6 = tmp6_tmp[:, None]
    tl.store(out_ptr0 + x4, tmp4, xmask)
    tl.store(out_ptr1 + x4, tmp5, xmask)
    tl.store(out_ptr2 + x4, tmp6, xmask)


@triton.jit
def triton_per_fused_native_group_norm_1(in_ptr0, in_ptr1, in_ptr2,
    out_ptr0, out_ptr1, out_ptr2, xnumel, rnumel, XBLOCK: tl.constexpr):
    xnumel = 128
    RBLOCK: tl.constexpr = 4
    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 + 4 * x0), xmask, other=0.0)
    tmp1 = tl.load(in_ptr1 + (r1 + 4 * x0), xmask, other=0.0)
    tmp2 = tl.load(in_ptr2 + (r1 + 4 * x0), xmask, other=0.0)
    tmp3 = tl.broadcast_to(tmp0, [XBLOCK, RBLOCK])
    tmp4 = tl.broadcast_to(tmp1, [XBLOCK, RBLOCK])
    tmp5 = tl.broadcast_to(tmp2, [XBLOCK, RBLOCK])
    tmp7 = tl.where(xmask, tmp3, 0)
    tmp8 = tl.where(xmask, tmp4, 0)
    tmp9 = tl.where(xmask, tmp5, 0)
    tmp10, tmp11, tmp12 = triton_helpers.welford(tmp7, tmp8, tmp9, 1)
    tmp13 = tmp10[:, None]
    tmp14 = tmp11[:, None]
    tmp12[:, None]
    tmp16 = 32768.0
    tmp17 = tmp14 / tmp16
    tmp18 = 1e-05
    tmp19 = tmp17 + tmp18
    tmp20 = libdevice.rsqrt(tmp19)
    tl.store(out_ptr2 + x0, tmp20, xmask)
    tl.store(out_ptr0 + x0, tmp13, xmask)
    tl.store(out_ptr1 + x0, tmp14, xmask)


@triton.jit
def triton_poi_fused_native_group_norm_relu_2(in_ptr0, in_ptr1, in_ptr2,
    in_ptr3, in_ptr4, out_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
    x4 = xindex // 4096
    x1 = xindex // 4096 % 256
    tmp0 = tl.load(in_ptr0 + x3, None)
    tmp1 = tl.load(in_ptr1 + x4 // 8, None, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr2 + x4 // 8, None, eviction_policy='evict_last')
    tmp10 = tl.load(in_ptr3 + x1, None, eviction_policy='evict_last')
    tmp12 = tl.load(in_ptr4 + x1, None, eviction_policy='evict_last')
    tmp2 = tmp0 - tmp1
    tmp4 = 32768.0
    tmp5 = tmp3 / tmp4
    tmp6 = 1e-05
    tmp7 = tmp5 + tmp6
    tmp8 = libdevice.rsqrt(tmp7)
    tmp9 = tmp2 * tmp8
    tmp11 = tmp9 * tmp10
    tmp13 = tmp11 + tmp12
    tmp14 = tl.full([1], 0, tl.int32)
    tmp15 = triton_helpers.maximum(tmp14, tmp13)
    tl.store(out_ptr0 + x3, tmp15, None)


@triton.jit
def triton_poi_fused_convolution_3(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)
    x0 = xindex
    tmp0 = tl.load(in_out_ptr0 + x0, None)
    tmp1 = tl.load(in_ptr0 + 0)
    tmp2 = tl.broadcast_to(tmp1, [XBLOCK])
    tmp3 = tmp0 + tmp2
    tl.store(in_out_ptr0 + x0, tmp3, None)


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, primals_14, primals_15, primals_16, primals_17,
        primals_18, primals_19) = args
    args.clear()
    assert_size_stride(primals_1, (256, 256, 3, 3), (2304, 9, 3, 1))
    assert_size_stride(primals_2, (256,), (1,))
    assert_size_stride(primals_3, (4, 256, 64, 64), (1048576, 4096, 64, 1))
    assert_size_stride(primals_4, (256,), (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,), (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,), (1,))
    assert_size_stride(primals_13, (256,), (1,))
    assert_size_stride(primals_14, (256, 256, 3, 3), (2304, 9, 3, 1))
    assert_size_stride(primals_15, (256,), (1,))
    assert_size_stride(primals_16, (256,), (1,))
    assert_size_stride(primals_17, (256,), (1,))
    assert_size_stride(primals_18, (1, 256, 3, 3), (2304, 9, 3, 1))
    assert_size_stride(primals_19, (1,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = extern_kernels.convolution(primals_3, primals_1, stride=(1, 
            1), padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf0, (4, 256, 64, 64), (1048576, 4096, 64, 1))
        buf1 = buf0
        del buf0
        buf2 = empty_strided_cuda((4, 32, 1, 1, 4), (128, 4, 512, 512, 1),
            torch.float32)
        buf3 = empty_strided_cuda((4, 32, 1, 1, 4), (128, 4, 512, 512, 1),
            torch.float32)
        buf4 = empty_strided_cuda((4, 32, 1, 1, 4), (128, 4, 512, 512, 1),
            torch.float32)
        get_raw_stream(0)
        triton_red_fused_convolution_native_group_norm_0[grid(512)](buf1,
            primals_2, buf2, buf3, buf4, 512, 8192, XBLOCK=1, RBLOCK=1024,
            num_warps=16, num_stages=1)
        del primals_2
        buf5 = empty_strided_cuda((4, 32, 1, 1), (32, 1, 128, 128), torch.
            float32)
        buf6 = empty_strided_cuda((4, 32, 1, 1), (32, 1, 128, 128), torch.
            float32)
        buf8 = empty_strided_cuda((4, 32, 1, 1), (32, 1, 128, 128), torch.
            float32)
        triton_per_fused_native_group_norm_1[grid(128)](buf2, buf3, buf4,
            buf5, buf6, buf8, 128, 4, XBLOCK=8, num_warps=2, num_stages=1)
        buf9 = empty_strided_cuda((4, 256, 64, 64), (1048576, 4096, 64, 1),
            torch.float32)
        triton_poi_fused_native_group_norm_relu_2[grid(4194304)](buf1, buf5,
            buf6, primals_4, primals_5, buf9, 4194304, XBLOCK=1024,
            num_warps=4, num_stages=1)
        del primals_5
        buf10 = extern_kernels.convolution(buf9, primals_6, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf10, (4, 256, 64, 64), (1048576, 4096, 64, 1))
        buf11 = buf10
        del buf10
        buf12 = buf4
        del buf4
        buf13 = buf3
        del buf3
        buf14 = buf2
        del buf2
        triton_red_fused_convolution_native_group_norm_0[grid(512)](buf11,
            primals_7, buf12, buf13, buf14, 512, 8192, XBLOCK=1, RBLOCK=
            1024, num_warps=16, num_stages=1)
        del primals_7
        buf15 = buf6
        del buf6
        buf16 = empty_strided_cuda((4, 32, 1, 1), (32, 1, 128, 128), torch.
            float32)
        buf18 = empty_strided_cuda((4, 32, 1, 1), (32, 1, 128, 128), torch.
            float32)
        triton_per_fused_native_group_norm_1[grid(128)](buf12, buf13, buf14,
            buf15, buf16, buf18, 128, 4, XBLOCK=8, num_warps=2, num_stages=1)
        buf19 = empty_strided_cuda((4, 256, 64, 64), (1048576, 4096, 64, 1),
            torch.float32)
        triton_poi_fused_native_group_norm_relu_2[grid(4194304)](buf11,
            buf15, buf16, primals_8, primals_9, buf19, 4194304, XBLOCK=1024,
            num_warps=4, num_stages=1)
        del primals_9
        buf20 = extern_kernels.convolution(buf19, primals_10, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf20, (4, 256, 64, 64), (1048576, 4096, 64, 1))
        buf21 = buf20
        del buf20
        buf22 = buf14
        del buf14
        buf23 = buf13
        del buf13
        buf24 = buf12
        del buf12
        triton_red_fused_convolution_native_group_norm_0[grid(512)](buf21,
            primals_11, buf22, buf23, buf24, 512, 8192, XBLOCK=1, RBLOCK=
            1024, num_warps=16, num_stages=1)
        del primals_11
        buf25 = buf16
        del buf16
        buf26 = empty_strided_cuda((4, 32, 1, 1), (32, 1, 128, 128), torch.
            float32)
        buf28 = empty_strided_cuda((4, 32, 1, 1), (32, 1, 128, 128), torch.
            float32)
        triton_per_fused_native_group_norm_1[grid(128)](buf22, buf23, buf24,
            buf25, buf26, buf28, 128, 4, XBLOCK=8, num_warps=2, num_stages=1)
        buf29 = empty_strided_cuda((4, 256, 64, 64), (1048576, 4096, 64, 1),
            torch.float32)
        triton_poi_fused_native_group_norm_relu_2[grid(4194304)](buf21,
            buf25, buf26, primals_12, primals_13, buf29, 4194304, XBLOCK=
            1024, num_warps=4, num_stages=1)
        del primals_13
        buf30 = extern_kernels.convolution(buf29, primals_14, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf30, (4, 256, 64, 64), (1048576, 4096, 64, 1))
        buf31 = buf30
        del buf30
        buf32 = buf24
        del buf24
        buf33 = buf23
        del buf23
        buf34 = buf22
        del buf22
        triton_red_fused_convolution_native_group_norm_0[grid(512)](buf31,
            primals_15, buf32, buf33, buf34, 512, 8192, XBLOCK=1, RBLOCK=
            1024, num_warps=16, num_stages=1)
        del primals_15
        buf35 = buf26
        del buf26
        buf36 = empty_strided_cuda((4, 32, 1, 1), (32, 1, 128, 128), torch.
            float32)
        buf38 = empty_strided_cuda((4, 32, 1, 1), (32, 1, 128, 128), torch.
            float32)
        triton_per_fused_native_group_norm_1[grid(128)](buf32, buf33, buf34,
            buf35, buf36, buf38, 128, 4, XBLOCK=8, num_warps=2, num_stages=1)
        del buf32
        del buf33
        del buf34
        buf39 = empty_strided_cuda((4, 256, 64, 64), (1048576, 4096, 64, 1),
            torch.float32)
        triton_poi_fused_native_group_norm_relu_2[grid(4194304)](buf31,
            buf35, buf36, primals_16, primals_17, buf39, 4194304, XBLOCK=
            1024, num_warps=4, num_stages=1)
        del buf36
        del primals_17
        buf40 = extern_kernels.convolution(buf39, primals_18, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf40, (4, 1, 64, 64), (4096, 4096, 64, 1))
        buf41 = buf40
        del buf40
        triton_poi_fused_convolution_3[grid(16384)](buf41, primals_19, 
            16384, XBLOCK=256, num_warps=4, num_stages=1)
        del primals_19
    return (buf41, primals_1, primals_3, primals_4, primals_6, primals_8,
        primals_10, primals_12, primals_14, primals_16, primals_18, buf1,
        reinterpret_tensor(buf5, (4, 32), (32, 1), 0), reinterpret_tensor(
        buf8, (4, 32), (32, 1), 0), buf9, buf11, reinterpret_tensor(buf15,
        (4, 32), (32, 1), 0), reinterpret_tensor(buf18, (4, 32), (32, 1), 0
        ), buf19, buf21, reinterpret_tensor(buf25, (4, 32), (32, 1), 0),
        reinterpret_tensor(buf28, (4, 32), (32, 1), 0), buf29, buf31,
        reinterpret_tensor(buf35, (4, 32), (32, 1), 0), reinterpret_tensor(
        buf38, (4, 32), (32, 1), 0), buf39)


class BasicBlock(nn.Module):

    def __init__(self, in_channels, out_channels, kernel_size, stride=1,
        padding=0):
        super(BasicBlock, self).__init__()
        self.conv = nn.Conv2d(in_channels, out_channels, kernel_size,
            stride, padding)
        self.norm = nn.GroupNorm(num_groups=32, num_channels=256)
        self.relu = nn.ReLU(inplace=True)

    def forward(self, x):
        x = self.conv(x)
        norm = self.norm(x)
        relu = self.relu(norm)
        return relu


class DCNv2(nn.Module):

    def __init__(self, in_channels, out_channels, kernel_size, stride,
        padding, dilation=1, deformable_groups=1):
        super(DCNv2, self).__init__()
        self.in_channels = in_channels
        self.out_channels = out_channels
        self.kernel_size = _pair(kernel_size)
        self.stride = _pair(stride)
        self.padding = _pair(padding)
        self.dilation = _pair(dilation)
        self.deformable_groups = deformable_groups
        self.weight = nn.Parameter(torch.Tensor(out_channels, in_channels,
            *self.kernel_size))
        self.bias = nn.Parameter(torch.Tensor(out_channels))
        self.reset_parameters()

    def reset_parameters(self):
        n = self.in_channels
        for k in self.kernel_size:
            n *= k
        stdv = 1.0 / math.sqrt(n)
        self.weight.data.uniform_(-stdv, stdv)
        self.bias.data.zero_()

    def forward(self, input, offset, mask):
        assert 2 * self.deformable_groups * self.kernel_size[0
            ] * self.kernel_size[1] == offset.shape[1]
        assert self.deformable_groups * self.kernel_size[0] * self.kernel_size[
            1] == mask.shape[1]
        return dcn_v2_conv(input, offset, mask, self.weight, self.bias,
            self.stride, self.padding, self.dilation, self.deformable_groups)


class DCN(DCNv2):

    def __init__(self, in_channels, out_channels, kernel_size, stride,
        padding, dilation=1, deformable_groups=1):
        super(DCN, self).__init__(in_channels, out_channels, kernel_size,
            stride, padding, dilation, deformable_groups)
        channels_ = self.deformable_groups * 3 * self.kernel_size[0
            ] * self.kernel_size[1]
        self.conv_offset_mask = nn.Conv2d(self.in_channels, channels_,
            kernel_size=self.kernel_size, stride=self.stride, padding=self.
            padding, bias=True)
        self.init_offset()

    def init_offset(self):
        self.conv_offset_mask.weight.data.zero_()
        self.conv_offset_mask.bias.data.zero_()

    def forward(self, input):
        out = self.conv_offset_mask(input)
        o1, o2, mask = torch.chunk(out, 3, dim=1)
        offset = torch.cat((o1, o2), dim=1)
        mask = torch.sigmoid(mask)
        return dcn_v2_conv(input, offset, mask, self.weight, self.bias,
            self.stride, self.padding, self.dilation, self.deformable_groups)


class CenterNessNetNew(nn.Module):

    def __init__(self, in_channels=256, feat_channels=256, stacked_convs=4,
        dcn_on_last_conv=False):
        super(CenterNessNetNew, self).__init__()
        self.stacked_convs = stacked_convs
        self.dcn_on_last_conv = dcn_on_last_conv
        self.in_channels = in_channels
        self.feat_channels = feat_channels
        self._init_layers()
        self.init_weight()

    def _init_layers(self):
        self._init_centerness_convs()
        self._init_centerness_predict()

    def normal_init(self, module, mean=0, std=1, bias=0):
        nn.init.normal_(module.weight, mean, std)
        if hasattr(module, 'bias') and module.bias is not None:
            nn.init.constant_(module.bias, bias)

    def init_weight(self):
        for m in self.centerness_convs.modules():
            if isinstance(m, nn.Conv2d):
                torch.nn.init.xavier_normal_(m.weight.data)
                if m.bias is not None:
                    m.bias.data.zero_()
                elif isinstance(m, nn.GroupNorm):
                    m.weight.data.fill_(1)
                    m.bias.data.zero_()
                elif isinstance(m, nn.Linear):
                    torch.nn.normal(m.weight.data, 0, 0.01)
                    m.bias.zero_()
        for m in self.centerness_predict.modules():
            if isinstance(m, nn.Conv2d):
                torch.nn.init.xavier_normal_(m.weight.data)
                if m.bias is not None:
                    m.bias.data.zero_()

    def _init_centerness_convs(self):
        self.centerness_convs = nn.Sequential()
        for i in range(self.stacked_convs):
            chn = self.in_channels if i == 0 else self.feat_channels
            if self.dcn_on_last_conv and i == self.stacked_convs - 1:
                conv_cfg = DCN(chn, self.feat_channels, kernel_size=(3, 3),
                    stride=1, padding=1, deformable_groups=1)
            else:
                conv_cfg = BasicBlock(chn, self.feat_channels, 3, 1, 1)
            self.centerness_convs.add_module(('centerness_' + str({0})).
                format(i), conv_cfg)

    def _init_centerness_predict(self):
        self.centerness_predict = nn.Sequential()
        predict = nn.Conv2d(self.feat_channels, 1, 3, padding=1)
        self.centerness_predict.add_module('centerness_predict', predict)

    def forward(self, input_0):
        primals_1 = self.centerness_convs.centerness_0.conv.weight
        primals_2 = self.centerness_convs.centerness_0.conv.bias
        primals_4 = self.centerness_convs.centerness_0.norm.weight
        primals_5 = self.centerness_convs.centerness_0.norm.bias
        primals_6 = self.centerness_convs.centerness_1.conv.weight
        primals_7 = self.centerness_convs.centerness_1.conv.bias
        primals_8 = self.centerness_convs.centerness_1.norm.weight
        primals_9 = self.centerness_convs.centerness_1.norm.bias
        primals_10 = self.centerness_convs.centerness_2.conv.weight
        primals_11 = self.centerness_convs.centerness_2.conv.bias
        primals_12 = self.centerness_convs.centerness_2.norm.weight
        primals_13 = self.centerness_convs.centerness_2.norm.bias
        primals_14 = self.centerness_convs.centerness_3.conv.weight
        primals_15 = self.centerness_convs.centerness_3.conv.bias
        primals_16 = self.centerness_convs.centerness_3.norm.weight
        primals_17 = self.centerness_convs.centerness_3.norm.bias
        primals_18 = self.centerness_predict.centerness_predict.weight
        primals_19 = self.centerness_predict.centerness_predict.bias
        primals_3 = 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, primals_14,
            primals_15, primals_16, primals_17, primals_18, primals_19])
        return output[0]
