# 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_4/inductor_cache/p5/cp5zogooiopkv5uuult2mrr7qjmdp7iv4fmoa5574usff6d364fk.py
# Topologically Sorted Source Nodes: [max_pool2d], Original ATen: [aten.max_pool2d_with_indices]
# Source node to ATen node mapping:
#   max_pool2d => _low_memory_max_pool2d_with_offsets
# Graph fragment:
#   %_low_memory_max_pool2d_with_offsets : [num_users=1] = call_function[target=torch.ops.prims._low_memory_max_pool2d_with_offsets.default](args = (%primals_1, [4, 4], [4, 4], [0, 0], [1, 1], False), kwargs = {})
triton_poi_fused_max_pool2d_with_indices_0 = async_compile.triton('triton_poi_fused_max_pool2d_with_indices_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=[16], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*i8', 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_max_pool2d_with_indices_0', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 16, '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_max_pool2d_with_indices_0(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + (16*x0), xmask, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr0 + (1 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp7 = tl.load(in_ptr0 + (2 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp12 = tl.load(in_ptr0 + (3 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp17 = tl.load(in_ptr0 + (4 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp22 = tl.load(in_ptr0 + (5 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp27 = tl.load(in_ptr0 + (6 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp32 = tl.load(in_ptr0 + (7 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp37 = tl.load(in_ptr0 + (8 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp42 = tl.load(in_ptr0 + (9 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp47 = tl.load(in_ptr0 + (10 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp52 = tl.load(in_ptr0 + (11 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp57 = tl.load(in_ptr0 + (12 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp62 = tl.load(in_ptr0 + (13 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp67 = tl.load(in_ptr0 + (14 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp72 = tl.load(in_ptr0 + (15 + (16*x0)), xmask, eviction_policy='evict_last')
    tmp2 = tmp1 > tmp0
    tmp3 = tl.full([1], 1, tl.int8)
    tmp4 = tl.full([1], 0, tl.int8)
    tmp5 = tl.where(tmp2, tmp3, tmp4)
    tmp6 = triton_helpers.maximum(tmp1, tmp0)
    tmp8 = tmp7 > tmp6
    tmp9 = tl.full([1], 2, tl.int8)
    tmp10 = tl.where(tmp8, tmp9, tmp5)
    tmp11 = triton_helpers.maximum(tmp7, tmp6)
    tmp13 = tmp12 > tmp11
    tmp14 = tl.full([1], 3, tl.int8)
    tmp15 = tl.where(tmp13, tmp14, tmp10)
    tmp16 = triton_helpers.maximum(tmp12, tmp11)
    tmp18 = tmp17 > tmp16
    tmp19 = tl.full([1], 4, tl.int8)
    tmp20 = tl.where(tmp18, tmp19, tmp15)
    tmp21 = triton_helpers.maximum(tmp17, tmp16)
    tmp23 = tmp22 > tmp21
    tmp24 = tl.full([1], 5, tl.int8)
    tmp25 = tl.where(tmp23, tmp24, tmp20)
    tmp26 = triton_helpers.maximum(tmp22, tmp21)
    tmp28 = tmp27 > tmp26
    tmp29 = tl.full([1], 6, tl.int8)
    tmp30 = tl.where(tmp28, tmp29, tmp25)
    tmp31 = triton_helpers.maximum(tmp27, tmp26)
    tmp33 = tmp32 > tmp31
    tmp34 = tl.full([1], 7, tl.int8)
    tmp35 = tl.where(tmp33, tmp34, tmp30)
    tmp36 = triton_helpers.maximum(tmp32, tmp31)
    tmp38 = tmp37 > tmp36
    tmp39 = tl.full([1], 8, tl.int8)
    tmp40 = tl.where(tmp38, tmp39, tmp35)
    tmp41 = triton_helpers.maximum(tmp37, tmp36)
    tmp43 = tmp42 > tmp41
    tmp44 = tl.full([1], 9, tl.int8)
    tmp45 = tl.where(tmp43, tmp44, tmp40)
    tmp46 = triton_helpers.maximum(tmp42, tmp41)
    tmp48 = tmp47 > tmp46
    tmp49 = tl.full([1], 10, tl.int8)
    tmp50 = tl.where(tmp48, tmp49, tmp45)
    tmp51 = triton_helpers.maximum(tmp47, tmp46)
    tmp53 = tmp52 > tmp51
    tmp54 = tl.full([1], 11, tl.int8)
    tmp55 = tl.where(tmp53, tmp54, tmp50)
    tmp56 = triton_helpers.maximum(tmp52, tmp51)
    tmp58 = tmp57 > tmp56
    tmp59 = tl.full([1], 12, tl.int8)
    tmp60 = tl.where(tmp58, tmp59, tmp55)
    tmp61 = triton_helpers.maximum(tmp57, tmp56)
    tmp63 = tmp62 > tmp61
    tmp64 = tl.full([1], 13, tl.int8)
    tmp65 = tl.where(tmp63, tmp64, tmp60)
    tmp66 = triton_helpers.maximum(tmp62, tmp61)
    tmp68 = tmp67 > tmp66
    tmp69 = tl.full([1], 14, tl.int8)
    tmp70 = tl.where(tmp68, tmp69, tmp65)
    tmp71 = triton_helpers.maximum(tmp67, tmp66)
    tmp73 = tmp72 > tmp71
    tmp74 = tl.full([1], 15, tl.int8)
    tmp75 = tl.where(tmp73, tmp74, tmp70)
    tmp76 = triton_helpers.maximum(tmp72, tmp71)
    tl.store(out_ptr0 + (x0), tmp75, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_4/inductor_cache/mh/cmhje4kzx2kzanf5cgc6ilsip7tzwbuvl4t5vfmwebu2blmwkv5c.py
# Topologically Sorted Source Nodes: [x_1], Original ATen: [aten.cat]
# Source node to ATen node mapping:
#   x_1 => cat
# Graph fragment:
#   %cat : [num_users=2] = call_function[target=torch.ops.aten.cat.default](args = ([%mul, %primals_1], 1), kwargs = {})
triton_poi_fused_cat_1 = async_compile.triton('triton_poi_fused_cat_1', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

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

@triton_heuristics.pointwise(
    size_hints=[512], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*i8', 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_cat_1', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 3, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused_cat_1(in_ptr0, in_ptr1, in_ptr2, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 320
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = (xindex // 16) % 5
    x0 = xindex % 16
    x2 = (xindex // 80)
    x4 = xindex
    tmp6 = tl.load(in_ptr1 + (0))
    tmp7 = tl.broadcast_to(tmp6, [XBLOCK])
    tmp0 = x1
    tmp1 = tl.full([1], 0, tl.int64)
    tmp2 = tmp0 >= tmp1
    tmp3 = tl.full([1], 1, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (x0 + (16*x2)), tmp4 & xmask, eviction_policy='evict_last', other=0.0)
    tmp8 = tl.full([1], 4, tl.int32)
    tmp9 = tl.where((tmp7 < 0) != (tmp8 < 0), tl.where(tmp7 % tmp8 != 0, tmp7 // tmp8 - 1, tmp7 // tmp8), tmp7 // tmp8)
    tmp10 = tmp9 * tmp8
    tmp11 = tmp7 - tmp10
    tmp12 = tmp1 + tmp9
    tmp13 = tmp1 + tmp11
    tmp14 = tl.full([1], 4, tl.int64)
    tmp15 = tmp12 * tmp14
    tmp16 = tmp15 + tmp13
    tmp17 = tmp16 % tmp14
    tmp18 = tl.full([1], 0, tl.int32)
    tmp19 = tmp17 != tmp18
    tmp20 = libdevice.signbit(tmp17) if (tmp17).dtype is tl.float32 else tmp17 < 0
    tmp21 = libdevice.signbit(tmp14) if (tmp14).dtype is tl.float32 else tmp14 < 0
    tmp22 = tmp20 != tmp21
    tmp23 = tmp19 & tmp22
    tmp24 = tmp17 + tmp14
    tmp25 = tl.where(tmp23, tmp24, tmp17)
    tmp26 = tl.full([XBLOCK], 4, tl.int32)
    tmp27 = tmp25 + tmp26
    tmp28 = tmp25 < 0
    tmp29 = tl.where(tmp28, tmp27, tmp25)
    tl.device_assert(((0 <= tl.broadcast_to(tmp29, [XBLOCK])) & (tl.broadcast_to(tmp29, [XBLOCK]) < 4)) | ~(tmp4 & xmask), "index out of bounds: 0 <= tl.broadcast_to(tmp29, [XBLOCK]) < 4")
    tmp31 = tl.where((tmp16 < 0) != (tmp14 < 0), tl.where(tmp16 % tmp14 != 0, tmp16 // tmp14 - 1, tmp16 // tmp14), tmp16 // tmp14)
    tmp32 = tmp31 + tmp26
    tmp33 = tmp31 < 0
    tmp34 = tl.where(tmp33, tmp32, tmp31)
    tl.device_assert(((0 <= tl.broadcast_to(tmp34, [XBLOCK])) & (tl.broadcast_to(tmp34, [XBLOCK]) < 4)) | ~(tmp4 & xmask), "index out of bounds: 0 <= tl.broadcast_to(tmp34, [XBLOCK]) < 4")
    tmp36 = tl.load(in_ptr0 + (tmp29 + (4*tmp34) + (16*x2)), tmp4 & xmask, eviction_policy='evict_last', other=0.0)
    tmp37 = tmp5 * tmp36
    tmp38 = tl.full(tmp37.shape, 0.0, tmp37.dtype)
    tmp39 = tl.where(tmp4, tmp37, tmp38)
    tmp40 = tmp0 >= tmp3
    tmp41 = tl.full([1], 5, tl.int64)
    tmp42 = tmp0 < tmp41
    tmp43 = tl.load(in_ptr2 + (x0 + (16*((-1) + x1)) + (64*x2)), tmp40 & xmask, other=0.0)
    tmp44 = tl.where(tmp4, tmp39, tmp43)
    tl.store(out_ptr0 + (x4), tmp44, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_4/inductor_cache/oc/cocfsjkcudwohj5ajxn73666nyu2k5qiltgioztutzryztik22ar.py
# Topologically Sorted Source Nodes: [conv2d, out], Original ATen: [aten.convolution, aten.sigmoid]
# Source node to ATen node mapping:
#   conv2d => convolution
#   out => sigmoid
# Graph fragment:
#   %convolution : [num_users=1] = call_function[target=torch.ops.aten.convolution.default](args = (%cat, %primals_3, %primals_4, [1, 1], [0, 0], [1, 1], False, [0, 0], 1), kwargs = {})
#   %sigmoid : [num_users=1] = call_function[target=torch.ops.aten.sigmoid.default](args = (%convolution,), kwargs = {})
triton_poi_fused_convolution_sigmoid_2 = async_compile.triton('triton_poi_fused_convolution_sigmoid_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=[64], 
    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_sigmoid_2', '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_sigmoid_2(in_out_ptr0, in_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 = tl.load(in_out_ptr0 + (x0), xmask)
    tmp1 = tl.load(in_ptr0 + (0))
    tmp2 = tl.broadcast_to(tmp1, [XBLOCK])
    tmp3 = tmp0 + tmp2
    tmp4 = tl.sigmoid(tmp3)
    tl.store(in_out_ptr0 + (x0), tmp4, xmask)
''', device_str='cuda')


async_compile.wait(globals())
del async_compile

def call(args):
    primals_1, primals_2, primals_3, primals_4 = args
    args.clear()
    assert_size_stride(primals_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(primals_2, (4, 1, 4, 4), (16, 16, 4, 1))
    assert_size_stride(primals_3, (1, 5, 1, 1), (5, 1, 1, 1))
    assert_size_stride(primals_4, (1, ), (1, ))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 4, 1, 1), (4, 1, 16, 16), torch.int8)
        # Topologically Sorted Source Nodes: [max_pool2d], Original ATen: [aten.max_pool2d_with_indices]
        stream0 = get_raw_stream(0)
        triton_poi_fused_max_pool2d_with_indices_0.run(primals_1, buf0, 16, grid=grid(16), stream=stream0)
        buf1 = empty_strided_cuda((4, 5, 4, 4), (80, 16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [x_1], Original ATen: [aten.cat]
        triton_poi_fused_cat_1.run(primals_2, buf0, primals_1, buf1, 320, grid=grid(320), stream=stream0)
        del buf0
        del primals_1
        del primals_2
        # Topologically Sorted Source Nodes: [conv2d], Original ATen: [aten.convolution]
        buf2 = extern_kernels.convolution(buf1, primals_3, stride=(1, 1), padding=(0, 0), dilation=(1, 1), transposed=False, output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf2, (4, 1, 4, 4), (16, 16, 4, 1))
        buf3 = buf2; del buf2  # reuse
        # Topologically Sorted Source Nodes: [conv2d, out], Original ATen: [aten.convolution, aten.sigmoid]
        triton_poi_fused_convolution_sigmoid_2.run(buf3, primals_4, 64, grid=grid(64), stream=stream0)
        del primals_4
    return (buf3, primals_3, buf1, buf3, )


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((4, 4, 4, 4), (64, 16, 4, 1), device='cuda:0', dtype=torch.float32)
    primals_2 = rand_strided((4, 1, 4, 4), (16, 16, 4, 1), device='cuda:0', dtype=torch.float32)
    primals_3 = rand_strided((1, 5, 1, 1), (5, 1, 1, 1), device='cuda:0', dtype=torch.float32)
    primals_4 = rand_strided((1, ), (1, ), device='cuda:0', dtype=torch.float32)
    fn = lambda: call([primals_1, primals_2, primals_3, primals_4])
    return print_performance(fn, times=times, repeat=repeat)


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

import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.nn


class SameModule(nn.Module):

    def __init__(self, dim):
        super().__init__()
        self.conv = nn.Conv2d(dim + 1, 1, kernel_size=(1, 1))
        torch.nn.init.kaiming_normal_(self.conv.weight)
        self.dim = dim

    def forward(self, feats, attn):
        size = attn.size()[2]
        _the_max, the_idx = F.max_pool2d(attn, size, return_indices=True)
        attended_feats = feats.index_select(2, torch.div(the_idx[0, 0, 0, 0
            ], size, rounding_mode='floor'))
        attended_feats = attended_feats.index_select(3, the_idx[0, 0, 0, 0] %
            size)
        x = torch.mul(feats, attended_feats.repeat(1, 1, size, size))
        x = torch.cat([x, attn], dim=1)
        out = torch.sigmoid(self.conv(x))
        return out


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


def get_init_inputs():
    return [[], {'dim': 4}]

import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as nn
import torch.nn
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_max_pool2d_with_indices_0(in_ptr0, out_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + 16 * x0, xmask, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr0 + (1 + 16 * x0), xmask, eviction_policy='evict_last'
        )
    tmp7 = tl.load(in_ptr0 + (2 + 16 * x0), xmask, eviction_policy='evict_last'
        )
    tmp12 = tl.load(in_ptr0 + (3 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp17 = tl.load(in_ptr0 + (4 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp22 = tl.load(in_ptr0 + (5 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp27 = tl.load(in_ptr0 + (6 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp32 = tl.load(in_ptr0 + (7 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp37 = tl.load(in_ptr0 + (8 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp42 = tl.load(in_ptr0 + (9 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp47 = tl.load(in_ptr0 + (10 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp52 = tl.load(in_ptr0 + (11 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp57 = tl.load(in_ptr0 + (12 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp62 = tl.load(in_ptr0 + (13 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp67 = tl.load(in_ptr0 + (14 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp72 = tl.load(in_ptr0 + (15 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp2 = tmp1 > tmp0
    tmp3 = tl.full([1], 1, tl.int8)
    tmp4 = tl.full([1], 0, tl.int8)
    tmp5 = tl.where(tmp2, tmp3, tmp4)
    tmp6 = triton_helpers.maximum(tmp1, tmp0)
    tmp8 = tmp7 > tmp6
    tmp9 = tl.full([1], 2, tl.int8)
    tmp10 = tl.where(tmp8, tmp9, tmp5)
    tmp11 = triton_helpers.maximum(tmp7, tmp6)
    tmp13 = tmp12 > tmp11
    tmp14 = tl.full([1], 3, tl.int8)
    tmp15 = tl.where(tmp13, tmp14, tmp10)
    tmp16 = triton_helpers.maximum(tmp12, tmp11)
    tmp18 = tmp17 > tmp16
    tmp19 = tl.full([1], 4, tl.int8)
    tmp20 = tl.where(tmp18, tmp19, tmp15)
    tmp21 = triton_helpers.maximum(tmp17, tmp16)
    tmp23 = tmp22 > tmp21
    tmp24 = tl.full([1], 5, tl.int8)
    tmp25 = tl.where(tmp23, tmp24, tmp20)
    tmp26 = triton_helpers.maximum(tmp22, tmp21)
    tmp28 = tmp27 > tmp26
    tmp29 = tl.full([1], 6, tl.int8)
    tmp30 = tl.where(tmp28, tmp29, tmp25)
    tmp31 = triton_helpers.maximum(tmp27, tmp26)
    tmp33 = tmp32 > tmp31
    tmp34 = tl.full([1], 7, tl.int8)
    tmp35 = tl.where(tmp33, tmp34, tmp30)
    tmp36 = triton_helpers.maximum(tmp32, tmp31)
    tmp38 = tmp37 > tmp36
    tmp39 = tl.full([1], 8, tl.int8)
    tmp40 = tl.where(tmp38, tmp39, tmp35)
    tmp41 = triton_helpers.maximum(tmp37, tmp36)
    tmp43 = tmp42 > tmp41
    tmp44 = tl.full([1], 9, tl.int8)
    tmp45 = tl.where(tmp43, tmp44, tmp40)
    tmp46 = triton_helpers.maximum(tmp42, tmp41)
    tmp48 = tmp47 > tmp46
    tmp49 = tl.full([1], 10, tl.int8)
    tmp50 = tl.where(tmp48, tmp49, tmp45)
    tmp51 = triton_helpers.maximum(tmp47, tmp46)
    tmp53 = tmp52 > tmp51
    tmp54 = tl.full([1], 11, tl.int8)
    tmp55 = tl.where(tmp53, tmp54, tmp50)
    tmp56 = triton_helpers.maximum(tmp52, tmp51)
    tmp58 = tmp57 > tmp56
    tmp59 = tl.full([1], 12, tl.int8)
    tmp60 = tl.where(tmp58, tmp59, tmp55)
    tmp61 = triton_helpers.maximum(tmp57, tmp56)
    tmp63 = tmp62 > tmp61
    tmp64 = tl.full([1], 13, tl.int8)
    tmp65 = tl.where(tmp63, tmp64, tmp60)
    tmp66 = triton_helpers.maximum(tmp62, tmp61)
    tmp68 = tmp67 > tmp66
    tmp69 = tl.full([1], 14, tl.int8)
    tmp70 = tl.where(tmp68, tmp69, tmp65)
    tmp71 = triton_helpers.maximum(tmp67, tmp66)
    tmp73 = tmp72 > tmp71
    tmp74 = tl.full([1], 15, tl.int8)
    tmp75 = tl.where(tmp73, tmp74, tmp70)
    triton_helpers.maximum(tmp72, tmp71)
    tl.store(out_ptr0 + x0, tmp75, xmask)


@triton.jit
def triton_poi_fused_cat_1(in_ptr0, in_ptr1, in_ptr2, out_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 320
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = xindex // 16 % 5
    x0 = xindex % 16
    x2 = xindex // 80
    x4 = xindex
    tmp6 = tl.load(in_ptr1 + 0)
    tmp7 = tl.broadcast_to(tmp6, [XBLOCK])
    tmp0 = x1
    tmp1 = tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 1, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (x0 + 16 * x2), tmp4 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp8 = tl.full([1], 4, tl.int32)
    tmp9 = tl.where((tmp7 < 0) != (tmp8 < 0), tl.where(tmp7 % tmp8 != 0, 
        tmp7 // tmp8 - 1, tmp7 // tmp8), tmp7 // tmp8)
    tmp10 = tmp9 * tmp8
    tmp11 = tmp7 - tmp10
    tmp12 = tmp1 + tmp9
    tmp13 = tmp1 + tmp11
    tmp14 = tl.full([1], 4, tl.int64)
    tmp15 = tmp12 * tmp14
    tmp16 = tmp15 + tmp13
    tmp17 = tmp16 % tmp14
    tmp18 = tl.full([1], 0, tl.int32)
    tmp19 = tmp17 != tmp18
    tmp20 = libdevice.signbit(tmp17
        ) if tmp17.dtype is tl.float32 else tmp17 < 0
    tmp21 = libdevice.signbit(tmp14
        ) if tmp14.dtype is tl.float32 else tmp14 < 0
    tmp22 = tmp20 != tmp21
    tmp23 = tmp19 & tmp22
    tmp24 = tmp17 + tmp14
    tmp25 = tl.where(tmp23, tmp24, tmp17)
    tmp26 = tl.full([XBLOCK], 4, tl.int32)
    tmp27 = tmp25 + tmp26
    tmp28 = tmp25 < 0
    tmp29 = tl.where(tmp28, tmp27, tmp25)
    tl.device_assert((0 <= tl.broadcast_to(tmp29, [XBLOCK])) & (tl.
        broadcast_to(tmp29, [XBLOCK]) < 4) | ~(tmp4 & xmask),
        'index out of bounds: 0 <= tl.broadcast_to(tmp29, [XBLOCK]) < 4')
    tmp31 = tl.where((tmp16 < 0) != (tmp14 < 0), tl.where(tmp16 % tmp14 != 
        0, tmp16 // tmp14 - 1, tmp16 // tmp14), tmp16 // tmp14)
    tmp32 = tmp31 + tmp26
    tmp33 = tmp31 < 0
    tmp34 = tl.where(tmp33, tmp32, tmp31)
    tl.device_assert((0 <= tl.broadcast_to(tmp34, [XBLOCK])) & (tl.
        broadcast_to(tmp34, [XBLOCK]) < 4) | ~(tmp4 & xmask),
        'index out of bounds: 0 <= tl.broadcast_to(tmp34, [XBLOCK]) < 4')
    tmp36 = tl.load(in_ptr0 + (tmp29 + 4 * tmp34 + 16 * x2), tmp4 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp37 = tmp5 * tmp36
    tmp38 = tl.full(tmp37.shape, 0.0, tmp37.dtype)
    tmp39 = tl.where(tmp4, tmp37, tmp38)
    tmp40 = tmp0 >= tmp3
    tl.full([1], 5, tl.int64)
    tmp43 = tl.load(in_ptr2 + (x0 + 16 * (-1 + x1) + 64 * x2), tmp40 &
        xmask, other=0.0)
    tmp44 = tl.where(tmp4, tmp39, tmp43)
    tl.store(out_ptr0 + x4, tmp44, xmask)


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


def call(args):
    primals_1, primals_2, primals_3, primals_4 = args
    args.clear()
    assert_size_stride(primals_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(primals_2, (4, 1, 4, 4), (16, 16, 4, 1))
    assert_size_stride(primals_3, (1, 5, 1, 1), (5, 1, 1, 1))
    assert_size_stride(primals_4, (1,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 4, 1, 1), (4, 1, 16, 16), torch.int8)
        get_raw_stream(0)
        triton_poi_fused_max_pool2d_with_indices_0[grid(16)](primals_1,
            buf0, 16, XBLOCK=16, num_warps=1, num_stages=1)
        buf1 = empty_strided_cuda((4, 5, 4, 4), (80, 16, 4, 1), torch.float32)
        triton_poi_fused_cat_1[grid(320)](primals_2, buf0, primals_1, buf1,
            320, XBLOCK=128, num_warps=4, num_stages=1)
        del buf0
        del primals_1
        del primals_2
        buf2 = extern_kernels.convolution(buf1, primals_3, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf2, (4, 1, 4, 4), (16, 16, 4, 1))
        buf3 = buf2
        del buf2
        triton_poi_fused_convolution_sigmoid_2[grid(64)](buf3, primals_4, 
            64, XBLOCK=64, num_warps=1, num_stages=1)
        del primals_4
    return buf3, primals_3, buf1, buf3


class SameModuleNew(nn.Module):

    def __init__(self, dim):
        super().__init__()
        self.conv = nn.Conv2d(dim + 1, 1, kernel_size=(1, 1))
        torch.nn.init.kaiming_normal_(self.conv.weight)
        self.dim = dim

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