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 import Tensor
from typing import Optional
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_stack_0(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
    x0 = xindex % 4
    x1 = xindex // 4 % 4
    x2 = xindex // 16
    x3 = xindex
    tmp0 = x0
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 1, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (x1 + 16 * x2), tmp4 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp6 = tl.load(in_ptr0 + (8 + x1 + 16 * x2), tmp4 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp7 = tmp6 - tmp5
    tmp8 = 0.5
    tmp9 = tmp7 * tmp8
    tmp10 = tmp5 + tmp9
    tmp11 = tl.load(in_ptr1 + (x1 + 16 * x2), tmp4 & xmask, eviction_policy
        ='evict_last', other=0.0)
    tmp12 = tmp11 * tmp7
    tmp13 = tmp10 + tmp12
    tmp14 = tl.load(in_ptr1 + (8 + x1 + 16 * x2), tmp4 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp15 = tmp14 * tmp7
    tmp16 = tmp15 * tmp8
    tmp17 = tmp13 - tmp16
    tmp18 = tl.full(tmp17.shape, 0.0, tmp17.dtype)
    tmp19 = tl.where(tmp4, tmp17, tmp18)
    tmp20 = tmp0 >= tmp3
    tmp21 = tl.full([1], 2, tl.int64)
    tmp22 = tmp0 < tmp21
    tmp23 = tmp20 & tmp22
    tmp24 = tl.load(in_ptr0 + (4 + x1 + 16 * x2), tmp23 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp25 = tl.load(in_ptr0 + (12 + x1 + 16 * x2), tmp23 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp26 = tmp25 - tmp24
    tmp27 = tmp26 * tmp8
    tmp28 = tmp24 + tmp27
    tmp29 = tl.load(in_ptr1 + (4 + x1 + 16 * x2), tmp23 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp30 = tmp29 * tmp26
    tmp31 = tmp28 + tmp30
    tmp32 = tl.load(in_ptr1 + (12 + x1 + 16 * x2), tmp23 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp33 = tmp32 * tmp26
    tmp34 = tmp33 * tmp8
    tmp35 = tmp31 - tmp34
    tmp36 = tl.full(tmp35.shape, 0.0, tmp35.dtype)
    tmp37 = tl.where(tmp23, tmp35, tmp36)
    tmp38 = tmp0 >= tmp21
    tmp39 = tl.full([1], 3, tl.int64)
    tmp40 = tmp0 < tmp39
    tmp41 = tmp38 & tmp40
    tmp42 = tl.load(in_ptr0 + (x1 + 16 * x2), tmp41 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp43 = tl.load(in_ptr0 + (8 + x1 + 16 * x2), tmp41 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp44 = tmp43 - tmp42
    tmp45 = tmp44 * tmp8
    tmp46 = tmp42 + tmp45
    tmp47 = tl.load(in_ptr1 + (x1 + 16 * x2), tmp41 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp48 = tmp47 * tmp44
    tmp49 = tmp46 + tmp48
    tmp50 = tl.load(in_ptr1 + (8 + x1 + 16 * x2), tmp41 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp51 = tmp50 * tmp44
    tmp52 = tmp51 * tmp8
    tmp53 = tmp49 + tmp52
    tmp54 = tl.full(tmp53.shape, 0.0, tmp53.dtype)
    tmp55 = tl.where(tmp41, tmp53, tmp54)
    tmp56 = tmp0 >= tmp39
    tl.full([1], 4, tl.int64)
    tmp59 = tl.load(in_ptr0 + (4 + x1 + 16 * x2), tmp56 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp60 = tl.load(in_ptr0 + (12 + x1 + 16 * x2), tmp56 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp61 = tmp60 - tmp59
    tmp62 = tmp61 * tmp8
    tmp63 = tmp59 + tmp62
    tmp64 = tl.load(in_ptr1 + (4 + x1 + 16 * x2), tmp56 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp65 = tmp64 * tmp61
    tmp66 = tmp63 + tmp65
    tmp67 = tl.load(in_ptr1 + (12 + x1 + 16 * x2), tmp56 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp68 = tmp67 * tmp61
    tmp69 = tmp68 * tmp8
    tmp70 = tmp66 + tmp69
    tmp71 = tl.full(tmp70.shape, 0.0, tmp70.dtype)
    tmp72 = tl.where(tmp56, tmp70, tmp71)
    tmp73 = tl.where(tmp41, tmp55, tmp72)
    tmp74 = tl.where(tmp23, tmp37, tmp73)
    tmp75 = tl.where(tmp4, tmp19, tmp74)
    tl.store(out_ptr0 + x3, tmp75, 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)
        buf0 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_stack_0[grid(256)](arg0_1, arg1_1, buf0, 256,
            XBLOCK=128, num_warps=4, num_stages=1)
        del arg0_1
        del arg1_1
    return buf0,


class AnchorBoxTransformNew(nn.Module):

    def __init__(self, mean: 'Optional[Tensor]'=None, std:
        'Optional[Tensor]'=None, log_length: 'bool'=False):
        super(AnchorBoxTransformNew, self).__init__()
        self.mean = mean
        self.std = std
        self.log_length = log_length

    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.015279