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.triton_helpers import libdevice, math as tl_math
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_abs_softplus_sum_0(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
    tmp0 = tl.load(in_ptr0 + 4 * x0, xmask, eviction_policy='evict_last')
    tmp10 = tl.load(in_ptr0 + (1 + 4 * x0), xmask, eviction_policy='evict_last'
        )
    tmp19 = tl.load(in_ptr0 + (2 + 4 * x0), xmask, eviction_policy='evict_last'
        )
    tmp28 = tl.load(in_ptr0 + (3 + 4 * x0), xmask, eviction_policy='evict_last'
        )
    tmp1 = 1.0
    tmp2 = tmp0 * tmp1
    tmp3 = 20.0
    tmp4 = tmp2 > tmp3
    tmp5 = tl_math.exp(tmp2)
    tmp6 = libdevice.log1p(tmp5)
    tmp7 = tmp6 * tmp1
    tmp8 = tl.where(tmp4, tmp0, tmp7)
    tmp9 = tl_math.abs(tmp8)
    tmp11 = tmp10 * tmp1
    tmp12 = tmp11 > tmp3
    tmp13 = tl_math.exp(tmp11)
    tmp14 = libdevice.log1p(tmp13)
    tmp15 = tmp14 * tmp1
    tmp16 = tl.where(tmp12, tmp10, tmp15)
    tmp17 = tl_math.abs(tmp16)
    tmp18 = tmp9 + tmp17
    tmp20 = tmp19 * tmp1
    tmp21 = tmp20 > tmp3
    tmp22 = tl_math.exp(tmp20)
    tmp23 = libdevice.log1p(tmp22)
    tmp24 = tmp23 * tmp1
    tmp25 = tl.where(tmp21, tmp19, tmp24)
    tmp26 = tl_math.abs(tmp25)
    tmp27 = tmp18 + tmp26
    tmp29 = tmp28 * tmp1
    tmp30 = tmp29 > tmp3
    tmp31 = tl_math.exp(tmp29)
    tmp32 = libdevice.log1p(tmp31)
    tmp33 = tmp32 * tmp1
    tmp34 = tl.where(tmp30, tmp28, tmp33)
    tmp35 = tl_math.abs(tmp34)
    tmp36 = tmp27 + tmp35
    tl.store(out_ptr0 + x0, tmp36, xmask)


@triton.jit
def triton_poi_fused_div_softplus_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 // 4
    tmp0 = tl.load(in_ptr0 + x2, xmask)
    tmp9 = tl.load(in_ptr1 + x1, xmask, eviction_policy='evict_last')
    tmp1 = 1.0
    tmp2 = tmp0 * tmp1
    tmp3 = 20.0
    tmp4 = tmp2 > tmp3
    tmp5 = tl_math.exp(tmp2)
    tmp6 = libdevice.log1p(tmp5)
    tmp7 = tmp6 * tmp1
    tmp8 = tl.where(tmp4, tmp0, tmp7)
    tmp10 = tmp8 / tmp9
    tl.store(out_ptr0 + x2, tmp10, 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, 4, 1), (16, 4, 1, 64), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_abs_softplus_sum_0[grid(64)](arg0_1, buf0, 64,
            XBLOCK=64, num_warps=1, num_stages=1)
        buf1 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        triton_poi_fused_div_softplus_1[grid(256)](arg0_1, buf0, buf1, 256,
            XBLOCK=256, num_warps=4, num_stages=1)
        del arg0_1
        del buf0
    return buf1,


class NormalizerNew(nn.Module):

    def __init__(self, dim=-1, norm=1.0):
        super().__init__()
        self.dim = dim
        self.norm = norm
        self.softplus = nn.Softplus()

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


Measured latency_ms: 0.025747