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

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


# kernel path: runs/run_shard_7/inductor_cache/eq/ceqd4v2pibbxxx65uo2foiehgfuw64kx77b4cfkmooflc3b45zik.py
# Topologically Sorted Source Nodes: [resizing_layer], Original ATen: [aten._to_copy, aten.arange, aten.add, aten.mul, aten.sub, aten.clamp, aten._unsafe_index]
# Source node to ATen node mapping:
#   resizing_layer => _unsafe_index, _unsafe_index_1, _unsafe_index_2, _unsafe_index_3, _unsafe_index_4, _unsafe_index_5, _unsafe_index_6, _unsafe_index_7, add_10, add_11, add_4, add_6, add_7, add_8, add_9, clamp_max_3, clamp_max_4, clamp_max_5, clamp_min_2, clamp_min_3, clamp_min_4, clamp_min_5, convert_element_type_1, convert_element_type_3, convert_element_type_4, convert_element_type_5, iota_2, mul_2, mul_3, mul_4, mul_5, mul_6, mul_7, mul_8, mul_9, sub_10, sub_11, sub_12, sub_2, sub_3, sub_4, sub_5, sub_6, sub_7, sub_8, sub_9
# Graph fragment:
#   %convert_element_type_1 : [num_users=6] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%view, torch.int64), kwargs = {})
#   %convert_element_type_3 : [num_users=6] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%view_1, torch.int64), kwargs = {})
#   %iota_2 : [num_users=1] = call_function[target=torch.ops.prims.iota.default](args = (4,), kwargs = {start: 0, step: 1, dtype: torch.int64, device: cuda:0, requires_grad: False})
#   %convert_element_type_4 : [num_users=1] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%iota_2, torch.float32), kwargs = {})
#   %add_4 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%convert_element_type_4, 0.5), kwargs = {})
#   %mul_2 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%add_4, 1.0), kwargs = {})
#   %sub_2 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%mul_2, 0.5), kwargs = {})
#   %clamp_min_2 : [num_users=2] = call_function[target=torch.ops.aten.clamp_min.default](args = (%sub_2, 0.0), kwargs = {})
#   %convert_element_type_5 : [num_users=6] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%clamp_min_2, torch.int64), kwargs = {})
#   %_unsafe_index_7 : [num_users=1] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%arg0_1, [None, None, %clamp_max, %clamp_max_1, %clamp_max_2]), kwargs = {})
#   %_unsafe_index_6 : [num_users=2] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%arg0_1, [None, None, %clamp_max, %clamp_max_1, %convert_element_type_5]), kwargs = {})
#   %sub_7 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%_unsafe_index_7, %_unsafe_index_6), kwargs = {})
#   %sub_3 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%clamp_min_2, %convert_element_type_5), kwargs = {})
#   %clamp_min_3 : [num_users=1] = call_function[target=torch.ops.aten.clamp_min.default](args = (%sub_3, 0.0), kwargs = {})
#   %clamp_max_3 : [num_users=4] = call_function[target=torch.ops.aten.clamp_max.default](args = (%clamp_min_3, 1.0), kwargs = {})
#   %mul_6 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_7, %clamp_max_3), kwargs = {})
#   %add_9 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%_unsafe_index_6, %mul_6), kwargs = {})
#   %_unsafe_index_5 : [num_users=1] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%arg0_1, [None, None, %clamp_max, %convert_element_type_3, %clamp_max_2]), kwargs = {})
#   %_unsafe_index_4 : [num_users=2] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%arg0_1, [None, None, %clamp_max, %convert_element_type_3, %convert_element_type_5]), kwargs = {})
#   %sub_6 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%_unsafe_index_5, %_unsafe_index_4), kwargs = {})
#   %mul_5 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_6, %clamp_max_3), kwargs = {})
#   %add_8 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%_unsafe_index_4, %mul_5), kwargs = {})
#   %sub_10 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%add_9, %add_8), kwargs = {})
#   %sub_8 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%view_1, %convert_element_type_3), kwargs = {})
#   %clamp_min_4 : [num_users=1] = call_function[target=torch.ops.aten.clamp_min.default](args = (%sub_8, 0.0), kwargs = {})
#   %clamp_max_4 : [num_users=2] = call_function[target=torch.ops.aten.clamp_max.default](args = (%clamp_min_4, 1.0), kwargs = {})
#   %mul_8 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_10, %clamp_max_4), kwargs = {})
#   %add_11 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%add_8, %mul_8), kwargs = {})
#   %_unsafe_index_3 : [num_users=1] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%arg0_1, [None, None, %convert_element_type_1, %clamp_max_1, %clamp_max_2]), kwargs = {})
#   %_unsafe_index_2 : [num_users=2] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%arg0_1, [None, None, %convert_element_type_1, %clamp_max_1, %convert_element_type_5]), kwargs = {})
#   %sub_5 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%_unsafe_index_3, %_unsafe_index_2), kwargs = {})
#   %mul_4 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_5, %clamp_max_3), kwargs = {})
#   %add_7 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%_unsafe_index_2, %mul_4), kwargs = {})
#   %_unsafe_index_1 : [num_users=1] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%arg0_1, [None, None, %convert_element_type_1, %convert_element_type_3, %clamp_max_2]), kwargs = {})
#   %_unsafe_index : [num_users=2] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%arg0_1, [None, None, %convert_element_type_1, %convert_element_type_3, %convert_element_type_5]), kwargs = {})
#   %sub_4 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%_unsafe_index_1, %_unsafe_index), kwargs = {})
#   %mul_3 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_4, %clamp_max_3), kwargs = {})
#   %add_6 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%_unsafe_index, %mul_3), kwargs = {})
#   %sub_9 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%add_7, %add_6), kwargs = {})
#   %mul_7 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_9, %clamp_max_4), kwargs = {})
#   %add_10 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%add_6, %mul_7), kwargs = {})
#   %sub_12 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%add_11, %add_10), kwargs = {})
#   %sub_11 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%view, %convert_element_type_1), kwargs = {})
#   %clamp_min_5 : [num_users=1] = call_function[target=torch.ops.aten.clamp_min.default](args = (%sub_11, 0.0), kwargs = {})
#   %clamp_max_5 : [num_users=1] = call_function[target=torch.ops.aten.clamp_max.default](args = (%clamp_min_5, 1.0), kwargs = {})
#   %mul_9 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_12, %clamp_max_5), kwargs = {})
triton_poi_fused__to_copy__unsafe_index_add_arange_clamp_mul_sub_0 = async_compile.triton('triton_poi_fused__to_copy__unsafe_index_add_arange_clamp_mul_sub_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.pointwise(
    size_hints=[1024], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 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_poi_fused__to_copy__unsafe_index_add_arange_clamp_mul_sub_0', 'mutated_arg_names': ['in_out_ptr0', 'in_out_ptr1', 'in_out_ptr3'], '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__unsafe_index_add_arange_clamp_mul_sub_0(in_out_ptr0, in_out_ptr1, in_out_ptr3, in_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 1024
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = (xindex // 16) % 4
    x1 = (xindex // 4) % 4
    x0 = xindex % 4
    x3 = (xindex // 64)
    x6 = xindex
    tmp0 = x2
    tmp1 = tmp0.to(tl.float32)
    tmp2 = 0.5
    tmp3 = tmp1 + tmp2
    tmp4 = 1.0
    tmp5 = tmp3 * tmp4
    tmp6 = tmp5 - tmp2
    tmp7 = 0.0
    tmp8 = triton_helpers.maximum(tmp6, tmp7)
    tmp9 = tmp8.to(tl.int32)
    tmp10 = x1
    tmp11 = tmp10.to(tl.float32)
    tmp12 = tmp11 + tmp2
    tmp13 = tmp12 * tmp4
    tmp14 = tmp13 - tmp2
    tmp15 = triton_helpers.maximum(tmp14, tmp7)
    tmp16 = tmp15.to(tl.int32)
    tmp17 = tl.full([1], 1, tl.int64)
    tmp18 = tmp16 + tmp17
    tmp19 = tl.full([1], 3, tl.int64)
    tmp20 = triton_helpers.minimum(tmp18, tmp19)
    tmp21 = x0
    tmp22 = tmp21.to(tl.float32)
    tmp23 = tmp22 + tmp2
    tmp24 = tmp23 * tmp4
    tmp25 = tmp24 - tmp2
    tmp26 = triton_helpers.maximum(tmp25, tmp7)
    tmp27 = tmp26.to(tl.int32)
    tmp28 = tmp27 + tmp17
    tmp29 = triton_helpers.minimum(tmp28, tmp19)
    tmp30 = tl.load(in_ptr0 + (tmp29 + (4*tmp20) + (16*tmp9) + (64*x3)), xmask, eviction_policy='evict_last')
    tmp31 = tl.load(in_ptr0 + (tmp27 + (4*tmp20) + (16*tmp9) + (64*x3)), xmask, eviction_policy='evict_last')
    tmp32 = tmp30 - tmp31
    tmp33 = tmp27.to(tl.float32)
    tmp34 = tmp26 - tmp33
    tmp35 = triton_helpers.maximum(tmp34, tmp7)
    tmp36 = triton_helpers.minimum(tmp35, tmp4)
    tmp37 = tmp32 * tmp36
    tmp38 = tmp31 + tmp37
    tmp39 = tl.load(in_ptr0 + (tmp29 + (4*tmp16) + (16*tmp9) + (64*x3)), xmask, eviction_policy='evict_last')
    tmp40 = tl.load(in_ptr0 + (tmp27 + (4*tmp16) + (16*tmp9) + (64*x3)), xmask, eviction_policy='evict_last')
    tmp41 = tmp39 - tmp40
    tmp42 = tmp41 * tmp36
    tmp43 = tmp40 + tmp42
    tmp44 = tmp9 + tmp17
    tmp45 = triton_helpers.minimum(tmp44, tmp19)
    tmp46 = tl.load(in_ptr0 + (tmp29 + (4*tmp20) + (16*tmp45) + (64*x3)), xmask, eviction_policy='evict_last')
    tmp47 = tl.load(in_ptr0 + (tmp27 + (4*tmp20) + (16*tmp45) + (64*x3)), xmask, eviction_policy='evict_last')
    tmp48 = tl.load(in_ptr0 + (tmp29 + (4*tmp16) + (16*tmp45) + (64*x3)), xmask, eviction_policy='evict_last')
    tmp49 = tl.load(in_ptr0 + (tmp27 + (4*tmp16) + (16*tmp45) + (64*x3)), xmask, eviction_policy='evict_last')
    tmp50 = tmp48 - tmp49
    tmp51 = tmp50 * tmp36
    tmp52 = tmp49 + tmp51
    tmp53 = tmp46 - tmp47
    tmp54 = tmp53 * tmp36
    tmp55 = tmp47 + tmp54
    tmp56 = tmp55 - tmp52
    tmp57 = tmp16.to(tl.float32)
    tmp58 = tmp15 - tmp57
    tmp59 = triton_helpers.maximum(tmp58, tmp7)
    tmp60 = triton_helpers.minimum(tmp59, tmp4)
    tmp61 = tmp56 * tmp60
    tmp62 = tmp52 + tmp61
    tmp63 = tmp38 - tmp43
    tmp64 = tmp63 * tmp60
    tmp65 = tmp43 + tmp64
    tmp66 = tmp62 - tmp65
    tmp67 = tmp9.to(tl.float32)
    tmp68 = tmp8 - tmp67
    tmp69 = triton_helpers.maximum(tmp68, tmp7)
    tmp70 = triton_helpers.minimum(tmp69, tmp4)
    tmp71 = tmp66 * tmp70
    tl.store(in_out_ptr0 + (x6), tmp38, xmask)
    tl.store(in_out_ptr1 + (x6), tmp43, xmask)
    tl.store(in_out_ptr3 + (x6), tmp71, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/q7/cq7a57jaykep2rn5amyxkdznm2ecmdbkbyxbbpppwdsky6lbmylr.py
# Topologically Sorted Source Nodes: [output_tensor], Original ATen: [aten.sum]
# Source node to ATen node mapping:
#   output_tensor => sum_1
# Graph fragment:
#   %sum_1 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%view_3, [2]), kwargs = {})
triton_poi_fused_sum_1 = async_compile.triton('triton_poi_fused_sum_1', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

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

@triton_heuristics.pointwise(
    size_hints=[256], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 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_poi_fused_sum_1', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 12, '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_sum_1(in_ptr0, in_ptr1, in_ptr2, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = (xindex // 64)
    x4 = xindex % 64
    x1 = (xindex // 4) % 4
    x5 = xindex
    tmp0 = tl.load(in_ptr0 + (x4 + (256*x3)), xmask)
    tmp1 = tl.load(in_ptr1 + (x4 + (256*x3)), xmask)
    tmp19 = tl.load(in_ptr2 + (x4 + (256*x3)), xmask)
    tmp21 = tl.load(in_ptr0 + (64 + x4 + (256*x3)), xmask)
    tmp22 = tl.load(in_ptr1 + (64 + x4 + (256*x3)), xmask)
    tmp26 = tl.load(in_ptr2 + (64 + x4 + (256*x3)), xmask)
    tmp29 = tl.load(in_ptr0 + (128 + x4 + (256*x3)), xmask)
    tmp30 = tl.load(in_ptr1 + (128 + x4 + (256*x3)), xmask)
    tmp34 = tl.load(in_ptr2 + (128 + x4 + (256*x3)), xmask)
    tmp37 = tl.load(in_ptr0 + (192 + x4 + (256*x3)), xmask)
    tmp38 = tl.load(in_ptr1 + (192 + x4 + (256*x3)), xmask)
    tmp42 = tl.load(in_ptr2 + (192 + x4 + (256*x3)), xmask)
    tmp2 = tmp1 - tmp0
    tmp3 = x1
    tmp4 = tmp3.to(tl.float32)
    tmp5 = 0.5
    tmp6 = tmp4 + tmp5
    tmp7 = 1.0
    tmp8 = tmp6 * tmp7
    tmp9 = tmp8 - tmp5
    tmp10 = 0.0
    tmp11 = triton_helpers.maximum(tmp9, tmp10)
    tmp12 = tmp11.to(tl.int32)
    tmp13 = tmp12.to(tl.float32)
    tmp14 = tmp11 - tmp13
    tmp15 = triton_helpers.maximum(tmp14, tmp10)
    tmp16 = triton_helpers.minimum(tmp15, tmp7)
    tmp17 = tmp2 * tmp16
    tmp18 = tmp0 + tmp17
    tmp20 = tmp18 + tmp19
    tmp23 = tmp22 - tmp21
    tmp24 = tmp23 * tmp16
    tmp25 = tmp21 + tmp24
    tmp27 = tmp25 + tmp26
    tmp28 = tmp20 + tmp27
    tmp31 = tmp30 - tmp29
    tmp32 = tmp31 * tmp16
    tmp33 = tmp29 + tmp32
    tmp35 = tmp33 + tmp34
    tmp36 = tmp28 + tmp35
    tmp39 = tmp38 - tmp37
    tmp40 = tmp39 * tmp16
    tmp41 = tmp37 + tmp40
    tmp43 = tmp41 + tmp42
    tmp44 = tmp36 + tmp43
    tl.store(out_ptr0 + (x5), tmp44, xmask)
''', device_str='cuda')


async_compile.wait(globals())
del async_compile

def call(args):
    arg0_1, = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4, 4, 4, 4), (256, 64, 16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf6 = empty_strided_cuda((4, 4, 4, 4, 4), (256, 64, 16, 4, 1), torch.float32)
        buf7 = buf6; del buf6  # reuse
        buf8 = buf7; del buf7  # reuse
        buf9 = empty_strided_cuda((4, 4, 4, 4, 4), (256, 64, 16, 4, 1), torch.float32)
        buf10 = buf9; del buf9  # reuse
        buf0 = empty_strided_cuda((4, 4, 4, 4, 4), (256, 64, 16, 4, 1), torch.float32)
        buf5 = buf0; del buf0  # reuse
        buf11 = buf5; del buf5  # reuse
        # Topologically Sorted Source Nodes: [resizing_layer], Original ATen: [aten._to_copy, aten.arange, aten.add, aten.mul, aten.sub, aten.clamp, aten._unsafe_index]
        stream0 = get_raw_stream(0)
        triton_poi_fused__to_copy__unsafe_index_add_arange_clamp_mul_sub_0.run(buf8, buf10, buf11, arg0_1, 1024, grid=grid(1024), stream=stream0)
        del arg0_1
        buf12 = empty_strided_cuda((4, 1, 4, 4, 4), (64, 64, 16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [output_tensor], Original ATen: [aten.sum]
        triton_poi_fused_sum_1.run(buf10, buf8, buf11, buf12, 256, grid=grid(256), stream=stream0)
        del buf10
        del buf11
        del buf8
    return (buf12, )


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


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

import torch
import torch.utils.data
import torch
import torch.nn as nn


class LinearAdditiveUpsample(nn.Module):
    """Bi/Trilinear Additive Upsample

    Upsampling strategy described in Wojna et al (https://doi.org/10.1007/s11263-019-01170-8) to avoid checkerboard
    patterns while keeping a better performance for the convolution.

    Parameters:
        scale_factor (int)  -- the factor for the upsampling operation
        n_splits (float)    -- the channel reduction factor
        threed (bool)       -- 3D (true) or 2D (false) network

    """

    def __init__(self, scale_factor, n_splits, threed):
        super(LinearAdditiveUpsample, self).__init__()
        self.scale_factor = scale_factor
        self.n_splits = n_splits
        if threed:
            self.mode = 'trilinear'
        else:
            self.mode = 'bilinear'

    def forward(self, input_tensor):
        n_channels = input_tensor.shape[1]
        assert self.n_splits > 0 and n_channels % self.n_splits == 0, 'Number of feature channels should be divisible by n_splits'
        resizing_layer = nn.functional.interpolate(input_tensor,
            scale_factor=self.scale_factor, mode=self.mode, align_corners=False
            )
        split = torch.split(resizing_layer, self.n_splits, dim=1)
        split_tensor = torch.stack(split, dim=1)
        output_tensor = torch.sum(split_tensor, dim=2)
        return output_tensor


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


def get_init_inputs():
    return [[], {'scale_factor': 1.0, 'n_splits': 4, 'threed': 4}]

import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.utils.data
import torch
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda


@triton.jit
def triton_poi_fused__to_copy__unsafe_index_add_arange_clamp_mul_sub_0(
    in_out_ptr0, in_out_ptr1, in_out_ptr3, in_ptr0, xnumel, XBLOCK: tl.
    constexpr):
    xnumel = 1024
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex // 16 % 4
    x1 = xindex // 4 % 4
    x0 = xindex % 4
    x3 = xindex // 64
    x6 = xindex
    tmp0 = x2
    tmp1 = tmp0.to(tl.float32)
    tmp2 = 0.5
    tmp3 = tmp1 + tmp2
    tmp4 = 1.0
    tmp5 = tmp3 * tmp4
    tmp6 = tmp5 - tmp2
    tmp7 = 0.0
    tmp8 = triton_helpers.maximum(tmp6, tmp7)
    tmp9 = tmp8.to(tl.int32)
    tmp10 = x1
    tmp11 = tmp10.to(tl.float32)
    tmp12 = tmp11 + tmp2
    tmp13 = tmp12 * tmp4
    tmp14 = tmp13 - tmp2
    tmp15 = triton_helpers.maximum(tmp14, tmp7)
    tmp16 = tmp15.to(tl.int32)
    tmp17 = tl.full([1], 1, tl.int64)
    tmp18 = tmp16 + tmp17
    tmp19 = tl.full([1], 3, tl.int64)
    tmp20 = triton_helpers.minimum(tmp18, tmp19)
    tmp21 = x0
    tmp22 = tmp21.to(tl.float32)
    tmp23 = tmp22 + tmp2
    tmp24 = tmp23 * tmp4
    tmp25 = tmp24 - tmp2
    tmp26 = triton_helpers.maximum(tmp25, tmp7)
    tmp27 = tmp26.to(tl.int32)
    tmp28 = tmp27 + tmp17
    tmp29 = triton_helpers.minimum(tmp28, tmp19)
    tmp30 = tl.load(in_ptr0 + (tmp29 + 4 * tmp20 + 16 * tmp9 + 64 * x3),
        xmask, eviction_policy='evict_last')
    tmp31 = tl.load(in_ptr0 + (tmp27 + 4 * tmp20 + 16 * tmp9 + 64 * x3),
        xmask, eviction_policy='evict_last')
    tmp32 = tmp30 - tmp31
    tmp33 = tmp27.to(tl.float32)
    tmp34 = tmp26 - tmp33
    tmp35 = triton_helpers.maximum(tmp34, tmp7)
    tmp36 = triton_helpers.minimum(tmp35, tmp4)
    tmp37 = tmp32 * tmp36
    tmp38 = tmp31 + tmp37
    tmp39 = tl.load(in_ptr0 + (tmp29 + 4 * tmp16 + 16 * tmp9 + 64 * x3),
        xmask, eviction_policy='evict_last')
    tmp40 = tl.load(in_ptr0 + (tmp27 + 4 * tmp16 + 16 * tmp9 + 64 * x3),
        xmask, eviction_policy='evict_last')
    tmp41 = tmp39 - tmp40
    tmp42 = tmp41 * tmp36
    tmp43 = tmp40 + tmp42
    tmp44 = tmp9 + tmp17
    tmp45 = triton_helpers.minimum(tmp44, tmp19)
    tmp46 = tl.load(in_ptr0 + (tmp29 + 4 * tmp20 + 16 * tmp45 + 64 * x3),
        xmask, eviction_policy='evict_last')
    tmp47 = tl.load(in_ptr0 + (tmp27 + 4 * tmp20 + 16 * tmp45 + 64 * x3),
        xmask, eviction_policy='evict_last')
    tmp48 = tl.load(in_ptr0 + (tmp29 + 4 * tmp16 + 16 * tmp45 + 64 * x3),
        xmask, eviction_policy='evict_last')
    tmp49 = tl.load(in_ptr0 + (tmp27 + 4 * tmp16 + 16 * tmp45 + 64 * x3),
        xmask, eviction_policy='evict_last')
    tmp50 = tmp48 - tmp49
    tmp51 = tmp50 * tmp36
    tmp52 = tmp49 + tmp51
    tmp53 = tmp46 - tmp47
    tmp54 = tmp53 * tmp36
    tmp55 = tmp47 + tmp54
    tmp56 = tmp55 - tmp52
    tmp57 = tmp16.to(tl.float32)
    tmp58 = tmp15 - tmp57
    tmp59 = triton_helpers.maximum(tmp58, tmp7)
    tmp60 = triton_helpers.minimum(tmp59, tmp4)
    tmp61 = tmp56 * tmp60
    tmp62 = tmp52 + tmp61
    tmp63 = tmp38 - tmp43
    tmp64 = tmp63 * tmp60
    tmp65 = tmp43 + tmp64
    tmp66 = tmp62 - tmp65
    tmp67 = tmp9.to(tl.float32)
    tmp68 = tmp8 - tmp67
    tmp69 = triton_helpers.maximum(tmp68, tmp7)
    tmp70 = triton_helpers.minimum(tmp69, tmp4)
    tmp71 = tmp66 * tmp70
    tl.store(in_out_ptr0 + x6, tmp38, xmask)
    tl.store(in_out_ptr1 + x6, tmp43, xmask)
    tl.store(in_out_ptr3 + x6, tmp71, xmask)


@triton.jit
def triton_poi_fused_sum_1(in_ptr0, in_ptr1, in_ptr2, out_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex // 64
    x4 = xindex % 64
    x1 = xindex // 4 % 4
    x5 = xindex
    tmp0 = tl.load(in_ptr0 + (x4 + 256 * x3), xmask)
    tmp1 = tl.load(in_ptr1 + (x4 + 256 * x3), xmask)
    tmp19 = tl.load(in_ptr2 + (x4 + 256 * x3), xmask)
    tmp21 = tl.load(in_ptr0 + (64 + x4 + 256 * x3), xmask)
    tmp22 = tl.load(in_ptr1 + (64 + x4 + 256 * x3), xmask)
    tmp26 = tl.load(in_ptr2 + (64 + x4 + 256 * x3), xmask)
    tmp29 = tl.load(in_ptr0 + (128 + x4 + 256 * x3), xmask)
    tmp30 = tl.load(in_ptr1 + (128 + x4 + 256 * x3), xmask)
    tmp34 = tl.load(in_ptr2 + (128 + x4 + 256 * x3), xmask)
    tmp37 = tl.load(in_ptr0 + (192 + x4 + 256 * x3), xmask)
    tmp38 = tl.load(in_ptr1 + (192 + x4 + 256 * x3), xmask)
    tmp42 = tl.load(in_ptr2 + (192 + x4 + 256 * x3), xmask)
    tmp2 = tmp1 - tmp0
    tmp3 = x1
    tmp4 = tmp3.to(tl.float32)
    tmp5 = 0.5
    tmp6 = tmp4 + tmp5
    tmp7 = 1.0
    tmp8 = tmp6 * tmp7
    tmp9 = tmp8 - tmp5
    tmp10 = 0.0
    tmp11 = triton_helpers.maximum(tmp9, tmp10)
    tmp12 = tmp11.to(tl.int32)
    tmp13 = tmp12.to(tl.float32)
    tmp14 = tmp11 - tmp13
    tmp15 = triton_helpers.maximum(tmp14, tmp10)
    tmp16 = triton_helpers.minimum(tmp15, tmp7)
    tmp17 = tmp2 * tmp16
    tmp18 = tmp0 + tmp17
    tmp20 = tmp18 + tmp19
    tmp23 = tmp22 - tmp21
    tmp24 = tmp23 * tmp16
    tmp25 = tmp21 + tmp24
    tmp27 = tmp25 + tmp26
    tmp28 = tmp20 + tmp27
    tmp31 = tmp30 - tmp29
    tmp32 = tmp31 * tmp16
    tmp33 = tmp29 + tmp32
    tmp35 = tmp33 + tmp34
    tmp36 = tmp28 + tmp35
    tmp39 = tmp38 - tmp37
    tmp40 = tmp39 * tmp16
    tmp41 = tmp37 + tmp40
    tmp43 = tmp41 + tmp42
    tmp44 = tmp36 + tmp43
    tl.store(out_ptr0 + x5, tmp44, xmask)


def call(args):
    arg0_1, = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4, 4, 4, 4), (256, 64, 16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf6 = empty_strided_cuda((4, 4, 4, 4, 4), (256, 64, 16, 4, 1),
            torch.float32)
        buf7 = buf6
        del buf6
        buf8 = buf7
        del buf7
        buf9 = empty_strided_cuda((4, 4, 4, 4, 4), (256, 64, 16, 4, 1),
            torch.float32)
        buf10 = buf9
        del buf9
        buf0 = empty_strided_cuda((4, 4, 4, 4, 4), (256, 64, 16, 4, 1),
            torch.float32)
        buf5 = buf0
        del buf0
        buf11 = buf5
        del buf5
        get_raw_stream(0)
        triton_poi_fused__to_copy__unsafe_index_add_arange_clamp_mul_sub_0[grid
            (1024)](buf8, buf10, buf11, arg0_1, 1024, XBLOCK=256, num_warps
            =4, num_stages=1)
        del arg0_1
        buf12 = empty_strided_cuda((4, 1, 4, 4, 4), (64, 64, 16, 4, 1),
            torch.float32)
        triton_poi_fused_sum_1[grid(256)](buf10, buf8, buf11, buf12, 256,
            XBLOCK=128, num_warps=4, num_stages=1)
        del buf10
        del buf11
        del buf8
    return buf12,


class LinearAdditiveUpsampleNew(nn.Module):
    """Bi/Trilinear Additive Upsample

    Upsampling strategy described in Wojna et al (https://doi.org/10.1007/s11263-019-01170-8) to avoid checkerboard
    patterns while keeping a better performance for the convolution.

    Parameters:
        scale_factor (int)  -- the factor for the upsampling operation
        n_splits (float)    -- the channel reduction factor
        threed (bool)       -- 3D (true) or 2D (false) network

    """

    def __init__(self, scale_factor, n_splits, threed):
        super(LinearAdditiveUpsampleNew, self).__init__()
        self.scale_factor = scale_factor
        self.n_splits = n_splits
        if threed:
            self.mode = 'trilinear'
        else:
            self.mode = 'bilinear'

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