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 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_adaptive_max_pool2d_relu_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')
    tmp3 = tl.load(in_ptr0 + (1 + 16 * x0), xmask, eviction_policy='evict_last'
        )
    tmp6 = tl.load(in_ptr0 + (2 + 16 * x0), xmask, eviction_policy='evict_last'
        )
    tmp9 = tl.load(in_ptr0 + (3 + 16 * x0), xmask, eviction_policy='evict_last'
        )
    tmp12 = tl.load(in_ptr0 + (4 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp15 = tl.load(in_ptr0 + (5 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp18 = tl.load(in_ptr0 + (6 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp21 = tl.load(in_ptr0 + (7 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp24 = tl.load(in_ptr0 + (8 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp27 = tl.load(in_ptr0 + (9 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp30 = tl.load(in_ptr0 + (10 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp33 = tl.load(in_ptr0 + (11 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp36 = tl.load(in_ptr0 + (12 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp39 = tl.load(in_ptr0 + (13 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp42 = tl.load(in_ptr0 + (14 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp45 = tl.load(in_ptr0 + (15 + 16 * x0), xmask, eviction_policy=
        'evict_last')
    tmp1 = tl.full([1], 0, tl.int32)
    tmp2 = triton_helpers.maximum(tmp1, tmp0)
    tmp4 = triton_helpers.maximum(tmp1, tmp3)
    tmp5 = triton_helpers.maximum(tmp4, tmp2)
    tmp7 = triton_helpers.maximum(tmp1, tmp6)
    tmp8 = triton_helpers.maximum(tmp7, tmp5)
    tmp10 = triton_helpers.maximum(tmp1, tmp9)
    tmp11 = triton_helpers.maximum(tmp10, tmp8)
    tmp13 = triton_helpers.maximum(tmp1, tmp12)
    tmp14 = triton_helpers.maximum(tmp13, tmp11)
    tmp16 = triton_helpers.maximum(tmp1, tmp15)
    tmp17 = triton_helpers.maximum(tmp16, tmp14)
    tmp19 = triton_helpers.maximum(tmp1, tmp18)
    tmp20 = triton_helpers.maximum(tmp19, tmp17)
    tmp22 = triton_helpers.maximum(tmp1, tmp21)
    tmp23 = triton_helpers.maximum(tmp22, tmp20)
    tmp25 = triton_helpers.maximum(tmp1, tmp24)
    tmp26 = triton_helpers.maximum(tmp25, tmp23)
    tmp28 = triton_helpers.maximum(tmp1, tmp27)
    tmp29 = triton_helpers.maximum(tmp28, tmp26)
    tmp31 = triton_helpers.maximum(tmp1, tmp30)
    tmp32 = triton_helpers.maximum(tmp31, tmp29)
    tmp34 = triton_helpers.maximum(tmp1, tmp33)
    tmp35 = triton_helpers.maximum(tmp34, tmp32)
    tmp37 = triton_helpers.maximum(tmp1, tmp36)
    tmp38 = triton_helpers.maximum(tmp37, tmp35)
    tmp40 = triton_helpers.maximum(tmp1, tmp39)
    tmp41 = triton_helpers.maximum(tmp40, tmp38)
    tmp43 = triton_helpers.maximum(tmp1, tmp42)
    tmp44 = triton_helpers.maximum(tmp43, tmp41)
    tmp46 = triton_helpers.maximum(tmp1, tmp45)
    tmp47 = triton_helpers.maximum(tmp46, tmp44)
    tl.store(out_ptr0 + x0, tmp47, xmask)


@triton.jit
def triton_poi_fused_minimum_mul_relu_1(in_ptr0, in_ptr1, out_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x1 = xindex // 16
    tmp0 = tl.load(in_ptr0 + x2, xmask)
    tmp3 = tl.load(in_ptr1 + x1, xmask, eviction_policy='evict_last')
    tmp1 = tl.full([1], 0, tl.int32)
    tmp2 = triton_helpers.maximum(tmp1, tmp0)
    tmp4 = 4.0
    tmp5 = tmp3 * tmp4
    tmp6 = triton_helpers.minimum(tmp2, tmp5)
    tl.store(out_ptr0 + x2, tmp6, xmask)


def call(args):
    arg0_1, = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4, 4, 4), (64, 16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 4, 1, 1), (4, 1, 16, 16), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_adaptive_max_pool2d_relu_0[grid(16)](arg0_1, buf0,
            16, XBLOCK=16, num_warps=1, num_stages=1)
        buf1 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        triton_poi_fused_minimum_mul_relu_1[grid(256)](arg0_1, buf0, buf1, 
            256, XBLOCK=128, num_warps=4, num_stages=1)
        del arg0_1
        del buf0
    return buf1,


class DRSNew(nn.Module):
    """ 
    DRS non-learnable setting
    hyperparameter O , additional training paramters X
    """

    def __init__(self, delta):
        super(DRSNew, self).__init__()
        self.relu = nn.ReLU()
        self.delta = delta
        self.global_max_pool = nn.AdaptiveMaxPool2d(1)

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


Measured latency_ms: 0.027183