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
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch import 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_add_clamp_min_logsumexp_mul_neg_softplus_sub_0(in_out_ptr0
    , in_ptr0, in_ptr1, 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 + x0, xmask)
    tmp8 = tl.load(in_ptr0 + (64 + x0), xmask)
    tmp15 = tl.load(in_ptr0 + (128 + x0), xmask)
    tmp22 = tl.load(in_ptr0 + (192 + x0), xmask)
    tmp44 = tl.load(in_ptr1 + x0, xmask)
    tmp55 = tl.load(in_ptr1 + (64 + x0), xmask)
    tmp65 = tl.load(in_ptr1 + (128 + x0), xmask)
    tmp75 = tl.load(in_ptr1 + (192 + x0), xmask)
    tmp1 = 4.0
    tmp2 = tmp0 + tmp1
    tmp3 = 0.0
    tmp4 = triton_helpers.maximum(tmp2, tmp3)
    tmp5 = tmp0 - tmp1
    tmp6 = tmp4 * tmp5
    tmp7 = tmp6 * tmp1
    tmp9 = tmp8 + tmp1
    tmp10 = triton_helpers.maximum(tmp9, tmp3)
    tmp11 = tmp8 - tmp1
    tmp12 = tmp10 * tmp11
    tmp13 = tmp12 * tmp1
    tmp14 = triton_helpers.maximum(tmp7, tmp13)
    tmp16 = tmp15 + tmp1
    tmp17 = triton_helpers.maximum(tmp16, tmp3)
    tmp18 = tmp15 - tmp1
    tmp19 = tmp17 * tmp18
    tmp20 = tmp19 * tmp1
    tmp21 = triton_helpers.maximum(tmp14, tmp20)
    tmp23 = tmp22 + tmp1
    tmp24 = triton_helpers.maximum(tmp23, tmp3)
    tmp25 = tmp22 - tmp1
    tmp26 = tmp24 * tmp25
    tmp27 = tmp26 * tmp1
    tmp28 = triton_helpers.maximum(tmp21, tmp27)
    tmp29 = tl_math.abs(tmp28)
    tmp30 = float('inf')
    tmp31 = tmp29 == tmp30
    tmp32 = tl.where(tmp31, tmp3, tmp28)
    tmp33 = tmp7 - tmp32
    tmp34 = tl_math.exp(tmp33)
    tmp35 = tmp13 - tmp32
    tmp36 = tl_math.exp(tmp35)
    tmp37 = tmp34 + tmp36
    tmp38 = tmp20 - tmp32
    tmp39 = tl_math.exp(tmp38)
    tmp40 = tmp37 + tmp39
    tmp41 = tmp27 - tmp32
    tmp42 = tl_math.exp(tmp41)
    tmp43 = tmp40 + tmp42
    tmp45 = -tmp44
    tmp46 = 1.0
    tmp47 = tmp45 + tmp46
    tmp48 = tmp47 + tmp1
    tmp49 = triton_helpers.maximum(tmp48, tmp3)
    tmp50 = -tmp49
    tmp51 = -3.0
    tmp52 = tmp44 - tmp51
    tmp53 = tmp50 * tmp52
    tmp54 = tmp53 * tmp1
    tmp56 = -tmp55
    tmp57 = tmp56 + tmp46
    tmp58 = tmp57 + tmp1
    tmp59 = triton_helpers.maximum(tmp58, tmp3)
    tmp60 = -tmp59
    tmp61 = tmp55 - tmp51
    tmp62 = tmp60 * tmp61
    tmp63 = tmp62 * tmp1
    tmp64 = triton_helpers.maximum(tmp54, tmp63)
    tmp66 = -tmp65
    tmp67 = tmp66 + tmp46
    tmp68 = tmp67 + tmp1
    tmp69 = triton_helpers.maximum(tmp68, tmp3)
    tmp70 = -tmp69
    tmp71 = tmp65 - tmp51
    tmp72 = tmp70 * tmp71
    tmp73 = tmp72 * tmp1
    tmp74 = triton_helpers.maximum(tmp64, tmp73)
    tmp76 = -tmp75
    tmp77 = tmp76 + tmp46
    tmp78 = tmp77 + tmp1
    tmp79 = triton_helpers.maximum(tmp78, tmp3)
    tmp80 = -tmp79
    tmp81 = tmp75 - tmp51
    tmp82 = tmp80 * tmp81
    tmp83 = tmp82 * tmp1
    tmp84 = triton_helpers.maximum(tmp74, tmp83)
    tmp85 = tl_math.abs(tmp84)
    tmp86 = tmp85 == tmp30
    tmp87 = tl.where(tmp86, tmp3, tmp84)
    tmp88 = tmp54 - tmp87
    tmp89 = tl_math.exp(tmp88)
    tmp90 = tmp63 - tmp87
    tmp91 = tl_math.exp(tmp90)
    tmp92 = tmp89 + tmp91
    tmp93 = tmp73 - tmp87
    tmp94 = tl_math.exp(tmp93)
    tmp95 = tmp92 + tmp94
    tmp96 = tmp83 - tmp87
    tmp97 = tl_math.exp(tmp96)
    tmp98 = tmp95 + tmp97
    tmp99 = tl_math.log(tmp43)
    tmp100 = tmp99 + tmp32
    tmp101 = tl_math.log(tmp98)
    tmp102 = tmp101 + tmp87
    tmp103 = tmp100 + tmp102
    tmp104 = tmp103 * tmp46
    tmp105 = 20.0
    tmp106 = tmp104 > tmp105
    tmp107 = tl_math.exp(tmp104)
    tmp108 = libdevice.log1p(tmp107)
    tmp109 = tmp108 * tmp46
    tmp110 = tl.where(tmp106, tmp103, tmp109)
    tl.store(in_out_ptr0 + x0, tmp110, xmask)


def call(args):
    arg0_1, arg1_1 = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(arg1_1, (4, 4, 4, 4), (64, 16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf2 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        buf5 = buf2
        del buf2
        get_raw_stream(0)
        triton_poi_fused_add_clamp_min_logsumexp_mul_neg_softplus_sub_0[grid
            (64)](buf5, arg1_1, arg0_1, 64, XBLOCK=64, num_warps=1,
            num_stages=1)
        del arg0_1
        del arg1_1
    return buf5,


class CircleLossNew(nn.Module):

    def __init__(self, m: 'float', gamma: 'float') ->None:
        super(CircleLossNew, self).__init__()
        self.m = m
        self.gamma = gamma
        self.soft_plus = nn.Softplus()

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


Measured latency_ms: 0.015223