# 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_7/inductor_cache/l6/cl6777b5oo4mtwbmmrb56fzsbooogvalisfatsqsvwdxxvj3qtm3.py
# Topologically Sorted Source Nodes: [output, output_1], Original ATen: [aten.convolution, aten._native_batch_norm_legit]
# Source node to ATen node mapping:
#   output => convolution
#   output_1 => var_mean
# Graph fragment:
#   %convolution : [num_users=2] = call_function[target=torch.ops.aten.convolution.default](args = (%primals_3, %primals_1, %primals_2, [1, 1, 1], [0, 0, 0], [1, 1, 1], False, [0, 0, 0], 1), kwargs = {})
#   %var_mean : [num_users=2] = call_function[target=torch.ops.aten.var_mean.correction](args = (%view, [0, 2, 3, 4]), kwargs = {correction: 0, keepdim: True})
triton_red_fused__native_batch_norm_legit_convolution_0 = async_compile.triton('triton_red_fused__native_batch_norm_legit_convolution_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=[256, 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__native_batch_norm_legit_convolution_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__native_batch_norm_legit_convolution_0(in_out_ptr0, in_ptr0, out_ptr0, out_ptr1, out_ptr2, xnumel, rnumel, XBLOCK : tl.constexpr, RBLOCK : tl.constexpr):
    xnumel = 256
    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
    x1 = (xindex // 32) % 2
    tmp1 = tl.load(in_ptr0 + (x1), xmask, eviction_policy='evict_last')
    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
        r3 = rindex
        tmp0 = tl.load(in_out_ptr0 + (r3 + (8192*x4)), rmask & xmask, eviction_policy='evict_first', 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 + (r3 + (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_7/inductor_cache/n4/cn4kzmqi736xyk336mpk7353ywgjx3ahbcpi5uxs5a4wumlctiqf.py
# Topologically Sorted Source Nodes: [output_1], Original ATen: [aten.repeat]
# Source node to ATen node mapping:
#   output_1 => repeat
# Graph fragment:
#   %repeat : [num_users=2] = call_function[target=torch.ops.aten.repeat.default](args = (%primals_4, [4]), kwargs = {})
triton_poi_fused_repeat_1 = async_compile.triton('triton_poi_fused_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.pointwise(
    size_hints=[8], 
    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), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_repeat_1', '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_repeat_1(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 8
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 % 2), xmask)
    tl.store(out_ptr0 + (x0), tmp0, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/3i/c3i5gjzqzfthfrw3wdjs55c2r64csamkhn3dhjmenthah5zeqbf4.py
# Topologically Sorted Source Nodes: [output_1], Original ATen: [aten._native_batch_norm_legit]
# Source node to ATen node mapping:
#   output_1 => add, rsqrt, var_mean
# Graph fragment:
#   %var_mean : [num_users=2] = call_function[target=torch.ops.aten.var_mean.correction](args = (%view, [0, 2, 3, 4]), 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_batch_norm_legit_2 = async_compile.triton('triton_per_fused__native_batch_norm_legit_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.persistent_reduction(
    size_hints=[8, 32],
    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, 7), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused__native_batch_norm_legit_2', '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_batch_norm_legit_2(in_ptr0, in_ptr1, in_ptr2, out_ptr0, out_ptr1, out_ptr2, xnumel, rnumel, XBLOCK : tl.constexpr):
    xnumel = 8
    rnumel = 32
    RBLOCK: tl.constexpr = 32
    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 + (32*x0)), xmask, other=0.0)
    tmp1 = tl.load(in_ptr1 + (r1 + (32*x0)), xmask, other=0.0)
    tmp2 = tl.load(in_ptr2 + (r1 + (32*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 = 262144.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_7/inductor_cache/4w/c4wucv4kdxkjlqe3aggek2cygacn5abqdwr2pb3snbbdjfio2wkt.py
# Topologically Sorted Source Nodes: [output_2], Original ATen: [aten.relu]
# Source node to ATen node mapping:
#   output_2 => relu
# Graph fragment:
#   %relu : [num_users=2] = call_function[target=torch.ops.aten.relu.default](args = (%view_1,), kwargs = {})
triton_poi_fused_relu_3 = async_compile.triton('triton_poi_fused_relu_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=[2097152], 
    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_relu_3', '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_relu_3(in_ptr0, in_ptr1, in_ptr2, in_ptr3, in_ptr4, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 2097152
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = tl.full([XBLOCK], True, tl.int1)
    x3 = xindex
    x4 = (xindex // 262144)
    x1 = (xindex // 262144) % 2
    tmp0 = tl.load(in_ptr0 + (x3), None)
    tmp1 = tl.load(in_ptr1 + (x4), None, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr2 + (x4), None, eviction_policy='evict_last')
    tmp10 = tl.load(in_ptr3 + (x4), None, eviction_policy='evict_last')
    tmp12 = tl.load(in_ptr4 + (x1), None, eviction_policy='evict_last')
    tmp2 = tmp0 - tmp1
    tmp4 = 262144.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_7/inductor_cache/r2/cr2gusnlwfmg2roftivwxqzr6sryb527df57v66vp3fasortqoiv.py
# Topologically Sorted Source Nodes: [output_5], Original ATen: [aten.arange, aten.add, aten.mul, aten._to_copy]
# Source node to ATen node mapping:
#   output_5 => add_2, add_3, convert_element_type, convert_element_type_1, iota, mul_2, mul_3
# Graph fragment:
#   %iota : [num_users=1] = call_function[target=torch.ops.prims.iota.default](args = (64,), kwargs = {start: 0, step: 1, dtype: torch.int64, device: cuda:0, requires_grad: False})
#   %mul_2 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%iota, 1), kwargs = {})
#   %add_2 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_2, 0), kwargs = {})
#   %convert_element_type : [num_users=1] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%add_2, torch.float32), kwargs = {})
#   %add_3 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%convert_element_type, 0.0), kwargs = {})
#   %mul_3 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%add_3, 0.5), kwargs = {})
#   %convert_element_type_1 : [num_users=3] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%mul_3, torch.int64), kwargs = {})
triton_poi_fused__to_copy_add_arange_mul_4 = async_compile.triton('triton_poi_fused__to_copy_add_arange_mul_4', '''
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=[64], 
    filename=__file__,
    triton_meta={'signature': {0: '*i64', 1: '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), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__to_copy_add_arange_mul_4', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 0, '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__to_copy_add_arange_mul_4(out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = x0
    tmp1 = tmp0.to(tl.float32)
    tmp2 = 0.5
    tmp3 = tmp1 * tmp2
    tmp4 = tmp3.to(tl.int32)
    tl.store(out_ptr0 + (x0), tmp4, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/or/cornkii7keqevhdsfvavlhdtdcj3mu5qnsobbrjri3s37szjjarh.py
# Topologically Sorted Source Nodes: [output_4, output_5, output_6], Original ATen: [aten.avg_pool3d, aten._unsafe_index, aten.mean]
# Source node to ATen node mapping:
#   output_4 => avg_pool3d
#   output_5 => _unsafe_index
#   output_6 => mean
# Graph fragment:
#   %avg_pool3d : [num_users=1] = call_function[target=torch.ops.aten.avg_pool3d.default](args = (%relu, [2, 2, 2], [2, 2, 2]), kwargs = {})
#   %_unsafe_index : [num_users=1] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%avg_pool3d, [None, None, %unsqueeze_7, %unsqueeze_6, %convert_element_type_1]), kwargs = {})
#   %mean : [num_users=1] = call_function[target=torch.ops.aten.mean.dim](args = (%_unsafe_index, [-1, -2, -3], True), kwargs = {})
triton_red_fused__unsafe_index_avg_pool3d_mean_5 = async_compile.triton('triton_red_fused__unsafe_index_avg_pool3d_mean_5', '''
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=[256, 8192],
    reduction_hint=ReductionHint.DEFAULT,
    filename=__file__,
    triton_meta={'signature': {0: '*i64', 1: '*fp32', 2: '*fp32', 3: 'i32', 4: '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), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_red_fused__unsafe_index_avg_pool3d_mean_5', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 3, 'num_reduction': 1, '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__unsafe_index_avg_pool3d_mean_5(in_ptr0, in_ptr1, out_ptr1, xnumel, rnumel, XBLOCK : tl.constexpr, RBLOCK : tl.constexpr):
    xnumel = 256
    rnumel = 8192
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    rbase = tl.arange(0, RBLOCK)[None, :]
    x0 = xindex % 32
    x1 = (xindex // 32)
    x5 = xindex
    _tmp31 = tl.full([XBLOCK, RBLOCK], 0, tl.float32)
    for roffset in range(0, rnumel, RBLOCK):
        rindex = roffset + rbase
        rmask = rindex < rnumel
        r4 = (rindex // 4096)
        r3 = (rindex // 64) % 64
        r2 = rindex % 64
        r6 = rindex
        tmp0 = tl.load(in_ptr0 + (r4 + (2*x0)), rmask & xmask, eviction_policy='evict_last', other=0.0)
        tmp5 = tl.load(in_ptr0 + (r3), rmask, eviction_policy='evict_last', other=0.0)
        tmp9 = tl.load(in_ptr0 + (r2), rmask, eviction_policy='evict_last', other=0.0)
        tmp1 = tl.full([XBLOCK, RBLOCK], 32, tl.int32)
        tmp2 = tmp0 + tmp1
        tmp3 = tmp0 < 0
        tmp4 = tl.where(tmp3, tmp2, tmp0)
        tmp6 = tmp5 + tmp1
        tmp7 = tmp5 < 0
        tmp8 = tl.where(tmp7, tmp6, tmp5)
        tmp10 = tmp9 + tmp1
        tmp11 = tmp9 < 0
        tmp12 = tl.where(tmp11, tmp10, tmp9)
        tmp13 = tl.load(in_ptr1 + ((2*tmp12) + (128*tmp8) + (8192*tmp4) + (262144*x1)), rmask & xmask, eviction_policy='evict_last')
        tmp14 = tl.load(in_ptr1 + (1 + (2*tmp12) + (128*tmp8) + (8192*tmp4) + (262144*x1)), rmask & xmask, eviction_policy='evict_last')
        tmp15 = tmp14 + tmp13
        tmp16 = tl.load(in_ptr1 + (64 + (2*tmp12) + (128*tmp8) + (8192*tmp4) + (262144*x1)), rmask & xmask, eviction_policy='evict_last')
        tmp17 = tmp16 + tmp15
        tmp18 = tl.load(in_ptr1 + (65 + (2*tmp12) + (128*tmp8) + (8192*tmp4) + (262144*x1)), rmask & xmask, eviction_policy='evict_last')
        tmp19 = tmp18 + tmp17
        tmp20 = tl.load(in_ptr1 + (4096 + (2*tmp12) + (128*tmp8) + (8192*tmp4) + (262144*x1)), rmask & xmask, eviction_policy='evict_last')
        tmp21 = tmp20 + tmp19
        tmp22 = tl.load(in_ptr1 + (4097 + (2*tmp12) + (128*tmp8) + (8192*tmp4) + (262144*x1)), rmask & xmask, eviction_policy='evict_last')
        tmp23 = tmp22 + tmp21
        tmp24 = tl.load(in_ptr1 + (4160 + (2*tmp12) + (128*tmp8) + (8192*tmp4) + (262144*x1)), rmask & xmask, eviction_policy='evict_last')
        tmp25 = tmp24 + tmp23
        tmp26 = tl.load(in_ptr1 + (4161 + (2*tmp12) + (128*tmp8) + (8192*tmp4) + (262144*x1)), rmask & xmask, eviction_policy='evict_last')
        tmp27 = tmp26 + tmp25
        tmp28 = 0.125
        tmp29 = tmp27 * tmp28
        tmp30 = tl.broadcast_to(tmp29, [XBLOCK, RBLOCK])
        tmp32 = _tmp31 + tmp30
        _tmp31 = tl.where(rmask & xmask, tmp32, _tmp31)
    tmp31 = tl.sum(_tmp31, 1)[:, None]
    tl.store(out_ptr1 + (x5), tmp31, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/vy/cvyohxn2kuwdzd4cn3xjjpoopixuttlh7p53eodyip5jjlpbejt2.py
# Topologically Sorted Source Nodes: [output_6], Original ATen: [aten.mean]
# Source node to ATen node mapping:
#   output_6 => mean
# Graph fragment:
#   %mean : [num_users=1] = call_function[target=torch.ops.aten.mean.dim](args = (%_unsafe_index, [-1, -2, -3], True), kwargs = {})
triton_per_fused_mean_6 = async_compile.triton('triton_per_fused_mean_6', '''
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=[8, 32],
    reduction_hint=ReductionHint.INNER,
    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, 3), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused_mean_6', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 1, 'num_reduction': 1, '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_mean_6(in_out_ptr0, in_ptr0, xnumel, rnumel, XBLOCK : tl.constexpr):
    xnumel = 8
    rnumel = 32
    RBLOCK: tl.constexpr = 32
    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 + (32*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 = 262144.0
    tmp6 = tmp4 / tmp5
    tl.debug_barrier()
    tl.store(in_out_ptr0 + (x0), tmp6, xmask)
''', device_str='cuda')


async_compile.wait(globals())
del async_compile

def call(args):
    primals_1, primals_2, primals_3, primals_4, primals_5 = args
    args.clear()
    assert_size_stride(primals_1, (2, 2, 1, 1, 1), (2, 1, 1, 1, 1))
    assert_size_stride(primals_2, (2, ), (1, ))
    assert_size_stride(primals_3, (4, 2, 64, 64, 64), (524288, 262144, 4096, 64, 1))
    assert_size_stride(primals_4, (2, ), (1, ))
    assert_size_stride(primals_5, (2, ), (1, ))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        # Topologically Sorted Source Nodes: [output], Original ATen: [aten.convolution]
        buf0 = extern_kernels.convolution(primals_3, primals_1, stride=(1, 1, 1), padding=(0, 0, 0), dilation=(1, 1, 1), transposed=False, output_padding=(0, 0, 0), groups=1, bias=None)
        assert_size_stride(buf0, (4, 2, 64, 64, 64), (524288, 262144, 4096, 64, 1))
        buf1 = buf0; del buf0  # reuse
        buf3 = empty_strided_cuda((1, 8, 1, 1, 1, 32), (256, 32, 256, 256, 256, 1), torch.float32)
        buf4 = empty_strided_cuda((1, 8, 1, 1, 1, 32), (256, 32, 256, 256, 256, 1), torch.float32)
        buf5 = empty_strided_cuda((1, 8, 1, 1, 1, 32), (256, 32, 256, 256, 256, 1), torch.float32)
        # Topologically Sorted Source Nodes: [output, output_1], Original ATen: [aten.convolution, aten._native_batch_norm_legit]
        stream0 = get_raw_stream(0)
        triton_red_fused__native_batch_norm_legit_convolution_0.run(buf1, primals_2, buf3, buf4, buf5, 256, 8192, grid=grid(256), stream=stream0)
        del primals_2
        buf2 = empty_strided_cuda((8, ), (1, ), torch.float32)
        # Topologically Sorted Source Nodes: [output_1], Original ATen: [aten.repeat]
        triton_poi_fused_repeat_1.run(primals_4, buf2, 8, grid=grid(8), stream=stream0)
        del primals_4
        buf6 = empty_strided_cuda((1, 8, 1, 1, 1), (8, 1, 8, 8, 8), torch.float32)
        buf7 = empty_strided_cuda((1, 8, 1, 1, 1), (8, 1, 8, 8, 8), torch.float32)
        buf9 = empty_strided_cuda((1, 8, 1, 1, 1), (8, 1, 8, 8, 8), torch.float32)
        # Topologically Sorted Source Nodes: [output_1], Original ATen: [aten._native_batch_norm_legit]
        triton_per_fused__native_batch_norm_legit_2.run(buf3, buf4, buf5, buf6, buf7, buf9, 8, 32, grid=grid(8), stream=stream0)
        del buf3
        del buf4
        buf10 = empty_strided_cuda((4, 2, 64, 64, 64), (524288, 262144, 4096, 64, 1), torch.float32)
        # Topologically Sorted Source Nodes: [output_2], Original ATen: [aten.relu]
        triton_poi_fused_relu_3.run(buf1, buf6, buf7, buf2, primals_5, buf10, 2097152, grid=grid(2097152), stream=stream0)
        del primals_5
        buf11 = empty_strided_cuda((64, ), (1, ), torch.int64)
        # Topologically Sorted Source Nodes: [output_5], Original ATen: [aten.arange, aten.add, aten.mul, aten._to_copy]
        triton_poi_fused__to_copy_add_arange_mul_4.run(buf11, 64, grid=grid(64), stream=stream0)
        buf13 = reinterpret_tensor(buf5, (4, 2, 1, 1, 1, 32), (64, 32, 256, 256, 256, 1), 0); del buf5  # reuse
        # Topologically Sorted Source Nodes: [output_4, output_5, output_6], Original ATen: [aten.avg_pool3d, aten._unsafe_index, aten.mean]
        triton_red_fused__unsafe_index_avg_pool3d_mean_5.run(buf11, buf10, buf13, 256, 8192, grid=grid(256), stream=stream0)
        buf14 = reinterpret_tensor(buf7, (4, 2, 1, 1, 1), (2, 1, 8, 8, 8), 0); del buf7  # reuse
        buf15 = reinterpret_tensor(buf14, (4, 2, 1, 1, 1), (2, 1, 1, 1, 1), 0); del buf14  # reuse
        # Topologically Sorted Source Nodes: [output_6], Original ATen: [aten.mean]
        triton_per_fused_mean_6.run(buf15, buf13, 8, 32, grid=grid(8), stream=stream0)
        del buf13
    return (buf15, primals_1, primals_3, buf1, buf2, reinterpret_tensor(buf9, (8, ), (1, ), 0), buf10, buf11, reinterpret_tensor(buf6, (1, 8, 1, 1, 1), (8, 1, 1, 1, 1), 0), )


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((2, 2, 1, 1, 1), (2, 1, 1, 1, 1), device='cuda:0', dtype=torch.float32)
    primals_2 = rand_strided((2, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_3 = rand_strided((4, 2, 64, 64, 64), (524288, 262144, 4096, 64, 1), device='cuda:0', dtype=torch.float32)
    primals_4 = rand_strided((2, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_5 = rand_strided((2, ), (1, ), device='cuda:0', dtype=torch.float32)
    fn = lambda: call([primals_1, primals_2, primals_3, primals_4, primals_5])
    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.functional as F


class RefModel3d(torch.nn.Module):
    """The 3D reference model."""

    def __init__(self):
        super().__init__()
        self.l1 = torch.nn.Conv3d(2, 2, 1, bias=True)
        self.l2 = torch.nn.InstanceNorm3d(2, affine=True)
        self.l3 = torch.nn.ReLU()
        self.l4 = torch.nn.Dropout3d(0.2)
        self.l5 = torch.nn.AvgPool3d(2)
        self.l7 = torch.nn.AdaptiveAvgPool3d(1)

    def forward(self, x):
        output = self.l1(x)
        output = self.l2(output)
        output = self.l3(output)
        output = self.l4(output)
        output = self.l5(output)
        output = F.interpolate(output, mode='nearest', scale_factor=2)
        output = self.l7(output)
        return output


def get_inputs():
    return [torch.rand([4, 2, 64, 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
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__native_batch_norm_legit_convolution_0(in_out_ptr0,
    in_ptr0, out_ptr0, out_ptr1, out_ptr2, xnumel, rnumel, XBLOCK: tl.
    constexpr, RBLOCK: tl.constexpr):
    xnumel = 256
    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
    x1 = xindex // 32 % 2
    tmp1 = tl.load(in_ptr0 + x1, xmask, eviction_policy='evict_last')
    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
        r3 = rindex
        tmp0 = tl.load(in_out_ptr0 + (r3 + 8192 * x4), rmask & xmask,
            eviction_policy='evict_first', 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 + (r3 + 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_poi_fused_repeat_1(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 8
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + x0 % 2, xmask)
    tl.store(out_ptr0 + x0, tmp0, xmask)


@triton.jit
def triton_per_fused__native_batch_norm_legit_2(in_ptr0, in_ptr1, in_ptr2,
    out_ptr0, out_ptr1, out_ptr2, xnumel, rnumel, XBLOCK: tl.constexpr):
    xnumel = 8
    RBLOCK: tl.constexpr = 32
    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 + 32 * x0), xmask, other=0.0)
    tmp1 = tl.load(in_ptr1 + (r1 + 32 * x0), xmask, other=0.0)
    tmp2 = tl.load(in_ptr2 + (r1 + 32 * 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 = 262144.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_relu_3(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 // 262144
    x1 = xindex // 262144 % 2
    tmp0 = tl.load(in_ptr0 + x3, None)
    tmp1 = tl.load(in_ptr1 + x4, None, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr2 + x4, None, eviction_policy='evict_last')
    tmp10 = tl.load(in_ptr3 + x4, None, eviction_policy='evict_last')
    tmp12 = tl.load(in_ptr4 + x1, None, eviction_policy='evict_last')
    tmp2 = tmp0 - tmp1
    tmp4 = 262144.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__to_copy_add_arange_mul_4(out_ptr0, xnumel, XBLOCK: tl
    .constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = x0
    tmp1 = tmp0.to(tl.float32)
    tmp2 = 0.5
    tmp3 = tmp1 * tmp2
    tmp4 = tmp3.to(tl.int32)
    tl.store(out_ptr0 + x0, tmp4, xmask)


@triton.jit
def triton_red_fused__unsafe_index_avg_pool3d_mean_5(in_ptr0, in_ptr1,
    out_ptr1, xnumel, rnumel, XBLOCK: tl.constexpr, RBLOCK: tl.constexpr):
    xnumel = 256
    rnumel = 8192
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    rbase = tl.arange(0, RBLOCK)[None, :]
    x0 = xindex % 32
    x1 = xindex // 32
    x5 = xindex
    _tmp31 = tl.full([XBLOCK, RBLOCK], 0, tl.float32)
    for roffset in range(0, rnumel, RBLOCK):
        rindex = roffset + rbase
        rmask = rindex < rnumel
        r4 = rindex // 4096
        r3 = rindex // 64 % 64
        r2 = rindex % 64
        tmp0 = tl.load(in_ptr0 + (r4 + 2 * x0), rmask & xmask,
            eviction_policy='evict_last', other=0.0)
        tmp5 = tl.load(in_ptr0 + r3, rmask, eviction_policy='evict_last',
            other=0.0)
        tmp9 = tl.load(in_ptr0 + r2, rmask, eviction_policy='evict_last',
            other=0.0)
        tmp1 = tl.full([XBLOCK, RBLOCK], 32, tl.int32)
        tmp2 = tmp0 + tmp1
        tmp3 = tmp0 < 0
        tmp4 = tl.where(tmp3, tmp2, tmp0)
        tmp6 = tmp5 + tmp1
        tmp7 = tmp5 < 0
        tmp8 = tl.where(tmp7, tmp6, tmp5)
        tmp10 = tmp9 + tmp1
        tmp11 = tmp9 < 0
        tmp12 = tl.where(tmp11, tmp10, tmp9)
        tmp13 = tl.load(in_ptr1 + (2 * tmp12 + 128 * tmp8 + 8192 * tmp4 + 
            262144 * x1), rmask & xmask, eviction_policy='evict_last')
        tmp14 = tl.load(in_ptr1 + (1 + 2 * tmp12 + 128 * tmp8 + 8192 * tmp4 +
            262144 * x1), rmask & xmask, eviction_policy='evict_last')
        tmp15 = tmp14 + tmp13
        tmp16 = tl.load(in_ptr1 + (64 + 2 * tmp12 + 128 * tmp8 + 8192 *
            tmp4 + 262144 * x1), rmask & xmask, eviction_policy='evict_last')
        tmp17 = tmp16 + tmp15
        tmp18 = tl.load(in_ptr1 + (65 + 2 * tmp12 + 128 * tmp8 + 8192 *
            tmp4 + 262144 * x1), rmask & xmask, eviction_policy='evict_last')
        tmp19 = tmp18 + tmp17
        tmp20 = tl.load(in_ptr1 + (4096 + 2 * tmp12 + 128 * tmp8 + 8192 *
            tmp4 + 262144 * x1), rmask & xmask, eviction_policy='evict_last')
        tmp21 = tmp20 + tmp19
        tmp22 = tl.load(in_ptr1 + (4097 + 2 * tmp12 + 128 * tmp8 + 8192 *
            tmp4 + 262144 * x1), rmask & xmask, eviction_policy='evict_last')
        tmp23 = tmp22 + tmp21
        tmp24 = tl.load(in_ptr1 + (4160 + 2 * tmp12 + 128 * tmp8 + 8192 *
            tmp4 + 262144 * x1), rmask & xmask, eviction_policy='evict_last')
        tmp25 = tmp24 + tmp23
        tmp26 = tl.load(in_ptr1 + (4161 + 2 * tmp12 + 128 * tmp8 + 8192 *
            tmp4 + 262144 * x1), rmask & xmask, eviction_policy='evict_last')
        tmp27 = tmp26 + tmp25
        tmp28 = 0.125
        tmp29 = tmp27 * tmp28
        tmp30 = tl.broadcast_to(tmp29, [XBLOCK, RBLOCK])
        tmp32 = _tmp31 + tmp30
        _tmp31 = tl.where(rmask & xmask, tmp32, _tmp31)
    tmp31 = tl.sum(_tmp31, 1)[:, None]
    tl.store(out_ptr1 + x5, tmp31, xmask)


@triton.jit
def triton_per_fused_mean_6(in_out_ptr0, in_ptr0, xnumel, rnumel, XBLOCK:
    tl.constexpr):
    xnumel = 8
    RBLOCK: tl.constexpr = 32
    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 + 32 * 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 = 262144.0
    tmp6 = tmp4 / tmp5
    tl.debug_barrier()
    tl.store(in_out_ptr0 + x0, tmp6, xmask)


def call(args):
    primals_1, primals_2, primals_3, primals_4, primals_5 = args
    args.clear()
    assert_size_stride(primals_1, (2, 2, 1, 1, 1), (2, 1, 1, 1, 1))
    assert_size_stride(primals_2, (2,), (1,))
    assert_size_stride(primals_3, (4, 2, 64, 64, 64), (524288, 262144, 4096,
        64, 1))
    assert_size_stride(primals_4, (2,), (1,))
    assert_size_stride(primals_5, (2,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = extern_kernels.convolution(primals_3, primals_1, stride=(1, 
            1, 1), padding=(0, 0, 0), dilation=(1, 1, 1), transposed=False,
            output_padding=(0, 0, 0), groups=1, bias=None)
        assert_size_stride(buf0, (4, 2, 64, 64, 64), (524288, 262144, 4096,
            64, 1))
        buf1 = buf0
        del buf0
        buf3 = empty_strided_cuda((1, 8, 1, 1, 1, 32), (256, 32, 256, 256, 
            256, 1), torch.float32)
        buf4 = empty_strided_cuda((1, 8, 1, 1, 1, 32), (256, 32, 256, 256, 
            256, 1), torch.float32)
        buf5 = empty_strided_cuda((1, 8, 1, 1, 1, 32), (256, 32, 256, 256, 
            256, 1), torch.float32)
        get_raw_stream(0)
        triton_red_fused__native_batch_norm_legit_convolution_0[grid(256)](buf1
            , primals_2, buf3, buf4, buf5, 256, 8192, XBLOCK=1, RBLOCK=2048,
            num_warps=16, num_stages=1)
        del primals_2
        buf2 = empty_strided_cuda((8,), (1,), torch.float32)
        triton_poi_fused_repeat_1[grid(8)](primals_4, buf2, 8, XBLOCK=8,
            num_warps=1, num_stages=1)
        del primals_4
        buf6 = empty_strided_cuda((1, 8, 1, 1, 1), (8, 1, 8, 8, 8), torch.
            float32)
        buf7 = empty_strided_cuda((1, 8, 1, 1, 1), (8, 1, 8, 8, 8), torch.
            float32)
        buf9 = empty_strided_cuda((1, 8, 1, 1, 1), (8, 1, 8, 8, 8), torch.
            float32)
        triton_per_fused__native_batch_norm_legit_2[grid(8)](buf3, buf4,
            buf5, buf6, buf7, buf9, 8, 32, XBLOCK=8, num_warps=2, num_stages=1)
        del buf3
        del buf4
        buf10 = empty_strided_cuda((4, 2, 64, 64, 64), (524288, 262144, 
            4096, 64, 1), torch.float32)
        triton_poi_fused_relu_3[grid(2097152)](buf1, buf6, buf7, buf2,
            primals_5, buf10, 2097152, XBLOCK=512, num_warps=8, num_stages=1)
        del primals_5
        buf11 = empty_strided_cuda((64,), (1,), torch.int64)
        triton_poi_fused__to_copy_add_arange_mul_4[grid(64)](buf11, 64,
            XBLOCK=64, num_warps=1, num_stages=1)
        buf13 = reinterpret_tensor(buf5, (4, 2, 1, 1, 1, 32), (64, 32, 256,
            256, 256, 1), 0)
        del buf5
        triton_red_fused__unsafe_index_avg_pool3d_mean_5[grid(256)](buf11,
            buf10, buf13, 256, 8192, XBLOCK=1, RBLOCK=1024, num_warps=16,
            num_stages=1)
        buf14 = reinterpret_tensor(buf7, (4, 2, 1, 1, 1), (2, 1, 8, 8, 8), 0)
        del buf7
        buf15 = reinterpret_tensor(buf14, (4, 2, 1, 1, 1), (2, 1, 1, 1, 1), 0)
        del buf14
        triton_per_fused_mean_6[grid(8)](buf15, buf13, 8, 32, XBLOCK=8,
            num_warps=2, num_stages=1)
        del buf13
    return buf15, primals_1, primals_3, buf1, buf2, reinterpret_tensor(buf9,
        (8,), (1,), 0), buf10, buf11, reinterpret_tensor(buf6, (1, 8, 1, 1,
        1), (8, 1, 1, 1, 1), 0)


class RefModel3dNew(torch.nn.Module):
    """The 3D reference model."""

    def __init__(self):
        super().__init__()
        self.l1 = torch.nn.Conv3d(2, 2, 1, bias=True)
        self.l2 = torch.nn.InstanceNorm3d(2, affine=True)
        self.l3 = torch.nn.ReLU()
        self.l4 = torch.nn.Dropout3d(0.2)
        self.l5 = torch.nn.AvgPool3d(2)
        self.l7 = torch.nn.AdaptiveAvgPool3d(1)

    def forward(self, input_0):
        primals_1 = self.l1.weight
        primals_2 = self.l1.bias
        primals_4 = self.l2.weight
        primals_5 = self.l2.bias
        primals_3 = input_0
        output = call([primals_1, primals_2, primals_3, primals_4, primals_5])
        return output[0]
