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.nn.parallel
import torch.nn as nn
import torch.utils.data
import torch.backends.cudnn
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_new_zeros_0(out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = 0.0
    tl.store(out_ptr0 + x0, tmp0, xmask)


@triton.jit
def triton_poi_fused_index_put_new_zeros_1(in_ptr0, 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 % 4
    x2 = xindex
    x1 = xindex // 4
    tmp11 = tl.load(in_ptr0 + x2, xmask)
    tmp0 = x0
    tmp1 = tl.full([1], 2, tl.int64)
    tmp2 = tmp0 < tmp1
    tmp3 = tl.full([1], 1, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.full([1], 0, tl.int64)
    tmp6 = tl.where(tmp4, tmp5, tmp3)
    tmp7 = tl.full([1], 3, tl.int64)
    tmp8 = tmp0 < tmp7
    tmp9 = tl.where(tmp8, tmp1, tmp7)
    tmp10 = tl.where(tmp2, tmp6, tmp9)
    tl.store(out_ptr0 + (5 * tmp10 + 16 * x1), tmp11, xmask)


@triton.jit
def triton_poi_fused_index_put_max_pool2d_with_indices_2(in_ptr0, out_ptr0,
    out_ptr1, xnumel, XBLOCK: tl.constexpr):
    xnumel = 48
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 3
    x1 = xindex // 3
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 + 4 * x1), xmask)
    tmp1 = tl.load(in_ptr0 + (1 + x0 + 4 * x1), xmask)
    tmp2 = triton_helpers.maximum(tmp1, tmp0)
    tmp3 = x0
    tmp4 = tl.full([1], 1, tl.int64)
    tmp5 = tmp3 < tmp4
    tmp6 = tl.full([1], 2, tl.int64)
    tmp7 = tmp3 < tmp6
    tmp8 = tl.where(tmp7, tmp4, tmp6)
    tmp9 = tl.full([1], 0, tl.int64)
    tmp10 = tl.where(tmp5, tmp9, tmp8)
    tmp11 = tl.full([1], 3, tl.int64)
    tmp12 = tl.where(tmp7, tmp6, tmp11)
    tmp13 = tl.where(tmp5, tmp4, tmp12)
    tl.store(out_ptr0 + x2, tmp2, xmask)
    tl.store(out_ptr1 + (tmp13 + 4 * tmp10 + 16 * x1), tmp2, xmask)


@triton.jit
def triton_poi_fused_index_put_max_pool2d_with_indices_3(in_ptr0, out_ptr0,
    out_ptr1, xnumel, XBLOCK: tl.constexpr):
    xnumel = 32
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 2
    x1 = xindex // 2
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 + 3 * x1), xmask)
    tmp1 = tl.load(in_ptr0 + (1 + x0 + 3 * x1), xmask)
    tmp2 = triton_helpers.maximum(tmp1, tmp0)
    tmp3 = x0
    tmp4 = tl.full([1], 1, tl.int64)
    tmp5 = tmp3 < tmp4
    tmp6 = tl.full([1], 0, tl.int64)
    tmp7 = tl.where(tmp5, tmp6, tmp4)
    tmp8 = tl.full([1], 2, tl.int64)
    tmp9 = tl.full([1], 3, tl.int64)
    tmp10 = tl.where(tmp5, tmp8, tmp9)
    tl.store(out_ptr0 + x2, tmp2, xmask)
    tl.store(out_ptr1 + (tmp10 + 4 * tmp7 + 16 * x1), tmp2, xmask)


@triton.jit
def triton_poi_fused_index_put_4(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 + 2 * x0, xmask, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr0 + (1 + 2 * x0), xmask, eviction_policy='evict_last')
    tmp2 = triton_helpers.maximum(tmp1, tmp0)
    tl.store(out_ptr0 + (3 + 16 * x0), tmp2, xmask)


@triton.jit
def triton_poi_fused_new_zeros_5(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 = 0.0
    tl.store(out_ptr0 + x0, tmp0, xmask)


@triton.jit
def triton_poi_fused_add_index_index_put_new_zeros_6(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 % 4
    x1 = xindex // 4
    tmp0 = x0
    tmp1 = tl.full([1], 2, tl.int64)
    tmp2 = tmp0 < tmp1
    tmp3 = tl.full([1], 1, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.full([1], 0, tl.int64)
    tmp6 = tl.where(tmp4, tmp5, tmp3)
    tmp7 = tl.full([1], 3, tl.int64)
    tmp8 = tmp0 < tmp7
    tmp9 = tl.where(tmp8, tmp1, tmp7)
    tmp10 = tl.where(tmp2, tmp6, tmp9)
    tmp11 = 1.0
    tl.store(out_ptr0 + (5 * tmp10 + 16 * x1), tmp11, xmask)


@triton.jit
def triton_poi_fused_add_index_index_put_7(in_ptr0, out_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 12
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 3
    x1 = xindex // 3
    tmp0 = x0
    tmp1 = tl.full([1], 1, tl.int64)
    tmp2 = tmp0 < tmp1
    tmp3 = tl.full([1], 2, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.where(tmp4, tmp1, tmp3)
    tmp6 = tl.full([1], 0, tl.int64)
    tmp7 = tl.where(tmp2, tmp6, tmp5)
    tmp8 = tl.full([1], 3, tl.int64)
    tmp9 = tl.where(tmp4, tmp3, tmp8)
    tmp10 = tl.where(tmp2, tmp1, tmp9)
    tmp11 = tl.load(in_ptr0 + (tmp10 + 4 * tmp7 + 16 * x1), xmask,
        eviction_policy='evict_last')
    tmp12 = 1.0
    tmp13 = tmp11 + tmp12
    tl.store(out_ptr0 + (tmp10 + 4 * tmp7 + 16 * x1), tmp13, xmask)


@triton.jit
def triton_poi_fused_add_index_index_put_8(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 % 2
    x1 = xindex // 2
    tmp0 = x0
    tmp1 = tl.full([1], 1, tl.int64)
    tmp2 = tmp0 < tmp1
    tmp3 = tl.full([1], 0, tl.int64)
    tmp4 = tl.where(tmp2, tmp3, tmp1)
    tmp5 = tl.full([1], 2, tl.int64)
    tmp6 = tl.full([1], 3, tl.int64)
    tmp7 = tl.where(tmp2, tmp5, tmp6)
    tmp8 = tl.load(in_ptr0 + (tmp7 + 4 * tmp4 + 16 * x1), xmask,
        eviction_policy='evict_last')
    tmp9 = 1.0
    tmp10 = tmp8 + tmp9
    tl.store(out_ptr0 + (tmp7 + 4 * tmp4 + 16 * x1), tmp10, xmask)


@triton.jit
def triton_poi_fused_add_index_index_put_9(in_ptr0, out_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 4
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + (3 + 16 * x0), xmask, eviction_policy='evict_last'
        )
    tmp1 = 1.0
    tmp2 = tmp0 + tmp1
    tl.store(out_ptr0 + (3 + 16 * x0), tmp2, xmask)


def call(args):
    arg0_1, = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4, 4), (16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf2 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_new_zeros_0[grid(256)](buf2, 256, XBLOCK=256,
            num_warps=4, num_stages=1)
        triton_poi_fused_index_put_new_zeros_1[grid(64)](arg0_1, buf2, 64,
            XBLOCK=64, num_warps=1, num_stages=1)
        buf0 = empty_strided_cuda((4, 4, 1, 3), (12, 3, 48, 1), torch.float32)
        triton_poi_fused_index_put_max_pool2d_with_indices_2[grid(48)](arg0_1,
            buf0, buf2, 48, XBLOCK=64, num_warps=1, num_stages=1)
        del arg0_1
        buf1 = empty_strided_cuda((4, 4, 1, 2), (8, 2, 32, 1), torch.float32)
        triton_poi_fused_index_put_max_pool2d_with_indices_3[grid(32)](buf0,
            buf1, buf2, 32, XBLOCK=32, num_warps=1, num_stages=1)
        del buf0
        triton_poi_fused_index_put_4[grid(16)](buf1, buf2, 16, XBLOCK=16,
            num_warps=1, num_stages=1)
        del buf1
        buf7 = empty_strided_cuda((4, 1, 4, 4), (16, 16, 4, 1), torch.float32)
        triton_poi_fused_new_zeros_5[grid(64)](buf7, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        triton_poi_fused_add_index_index_put_new_zeros_6[grid(16)](buf7, 16,
            XBLOCK=16, num_warps=1, num_stages=1)
        triton_poi_fused_add_index_index_put_7[grid(12)](buf7, buf7, 12,
            XBLOCK=16, num_warps=1, num_stages=1)
        triton_poi_fused_add_index_index_put_8[grid(8)](buf7, buf7, 8,
            XBLOCK=8, num_warps=1, num_stages=1)
        triton_poi_fused_add_index_index_put_9[grid(4)](buf7, buf7, 4,
            XBLOCK=4, num_warps=1, num_stages=1)
    return buf2, buf7


class PropMaxPoolNew(nn.Module):

    def __init__(self, cfg):
        super(PropMaxPoolNew, self).__init__()
        num_layers = cfg.NUM_LAYERS
        self.layers = nn.ModuleList([nn.Identity()] + [nn.MaxPool1d(2,
            stride=1) for _ in range(num_layers - 1)])
        self.num_layers = num_layers

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


Measured latency_ms: 0.060674