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
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_cat_0(in_ptr0, in_ptr1, in_ptr2, out_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = xindex // 16 % 4
    x0 = xindex % 16
    x2 = xindex // 64
    x3 = xindex
    tmp0 = x1
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 1, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (x0 + 64 * x2), tmp4 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp6 = tl.load(in_ptr1 + (x0 + 16 * x2), tmp4 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp7 = tmp5 - tmp6
    tmp8 = tl.load(in_ptr2 + (x0 + 16 * x2), tmp4 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp9 = tmp7 / tmp8
    tmp10 = tl.full(tmp9.shape, 0.0, tmp9.dtype)
    tmp11 = tl.where(tmp4, tmp9, tmp10)
    tmp12 = tmp0 >= tmp3
    tmp13 = tl.full([1], 2, tl.int64)
    tmp14 = tmp0 < tmp13
    tmp15 = tmp12 & tmp14
    tmp16 = tl.load(in_ptr0 + (16 + x0 + 64 * x2), tmp15 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp17 = tl.load(in_ptr1 + (64 + x0 + 16 * x2), tmp15 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp18 = tmp16 - tmp17
    tmp19 = tl.load(in_ptr2 + (64 + x0 + 16 * x2), tmp15 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp20 = tmp18 / tmp19
    tmp21 = tl.full(tmp20.shape, 0.0, tmp20.dtype)
    tmp22 = tl.where(tmp15, tmp20, tmp21)
    tmp23 = tmp0 >= tmp13
    tmp24 = tl.full([1], 3, tl.int64)
    tmp25 = tmp0 < tmp24
    tmp26 = tmp23 & tmp25
    tmp27 = tl.load(in_ptr0 + (32 + x0 + 64 * x2), tmp26 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp28 = tl.load(in_ptr1 + (128 + x0 + 16 * x2), tmp26 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp29 = tmp27 - tmp28
    tmp30 = tl.load(in_ptr2 + (128 + x0 + 16 * x2), tmp26 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp31 = tmp29 / tmp30
    tmp32 = tl.full(tmp31.shape, 0.0, tmp31.dtype)
    tmp33 = tl.where(tmp26, tmp31, tmp32)
    tmp34 = tmp0 >= tmp24
    tl.full([1], 4, tl.int64)
    tmp37 = tl.load(in_ptr0 + (48 + x0 + 64 * x2), tmp34 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp38 = tl.load(in_ptr1 + (192 + x0 + 16 * x2), tmp34 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp39 = tmp37 - tmp38
    tmp40 = tl.load(in_ptr2 + (192 + x0 + 16 * x2), tmp34 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp41 = tmp39 / tmp40
    tmp42 = tl.full(tmp41.shape, 0.0, tmp41.dtype)
    tmp43 = tl.where(tmp34, tmp41, tmp42)
    tmp44 = tl.where(tmp26, tmp33, tmp43)
    tmp45 = tl.where(tmp15, tmp22, tmp44)
    tmp46 = tl.where(tmp4, tmp11, tmp45)
    tl.store(out_ptr0 + x3, tmp46, xmask)


def call(args):
    arg0_1, arg1_1, arg2_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))
    assert_size_stride(arg2_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_cat_0[grid(256)](arg1_1, arg0_1, arg2_1, buf0, 256,
            XBLOCK=128, num_warps=4, num_stages=1)
        del arg0_1
        del arg1_1
        del arg2_1
    return buf0,


class std_normNew(nn.Module):

    def __init__(self, inverse=False):
        super(std_normNew, self).__init__()
        self.inverse = inverse

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


Measured latency_ms: 0.015829