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 nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda
reinterpret_tensor = torch._C._dynamo.guards._reinterpret_tensor


@triton.jit
def triton_poi_fused_stack_sub_0(in_ptr0, out_ptr0, out_ptr1, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = xindex // 4 % 16
    x0 = xindex % 4
    x2 = xindex // 64
    x3 = xindex
    tmp54 = tl.load(in_ptr0 + x3, xmask)
    tmp0 = x1
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 4, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (x0 + 4 * x1 + 64 * x2), tmp4 & xmask, other=0.0)
    tmp6 = tl.load(in_ptr0 + (16 + x0 + 4 * x1 + 64 * x2), tmp4 & xmask,
        other=0.0)
    tmp7 = tmp5 + tmp6
    tmp8 = 0.5
    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], 8, tl.int64)
    tmp14 = tmp0 < tmp13
    tmp15 = tmp12 & tmp14
    tmp16 = tl.load(in_ptr0 + (x0 + 4 * (-4 + x1) + 64 * x2), tmp15 & xmask,
        other=0.0)
    tmp17 = tl.load(in_ptr0 + (16 + x0 + 4 * (-4 + x1) + 64 * x2), tmp15 &
        xmask, other=0.0)
    tmp18 = tmp16 + tmp17
    tmp19 = tl.load(in_ptr0 + (32 + x0 + 4 * (-4 + x1) + 64 * x2), tmp15 &
        xmask, other=0.0)
    tmp20 = tmp18 + tmp19
    tmp21 = 0.3333333333333333
    tmp22 = tmp20 * tmp21
    tmp23 = tl.full(tmp22.shape, 0.0, tmp22.dtype)
    tmp24 = tl.where(tmp15, tmp22, tmp23)
    tmp25 = tmp0 >= tmp13
    tmp26 = tl.full([1], 12, tl.int64)
    tmp27 = tmp0 < tmp26
    tmp28 = tmp25 & tmp27
    tmp29 = tl.load(in_ptr0 + (x0 + 4 * (-8 + x1) + 64 * x2), tmp28 & xmask,
        other=0.0)
    tmp30 = tl.load(in_ptr0 + (16 + x0 + 4 * (-8 + x1) + 64 * x2), tmp28 &
        xmask, other=0.0)
    tmp31 = tmp29 + tmp30
    tmp32 = tl.load(in_ptr0 + (32 + x0 + 4 * (-8 + x1) + 64 * x2), tmp28 &
        xmask, other=0.0)
    tmp33 = tmp31 + tmp32
    tmp34 = tl.load(in_ptr0 + (48 + x0 + 4 * (-8 + x1) + 64 * x2), tmp28 &
        xmask, other=0.0)
    tmp35 = tmp33 + tmp34
    tmp36 = 0.25
    tmp37 = tmp35 * tmp36
    tmp38 = tl.full(tmp37.shape, 0.0, tmp37.dtype)
    tmp39 = tl.where(tmp28, tmp37, tmp38)
    tmp40 = tmp0 >= tmp26
    tl.full([1], 16, tl.int64)
    tmp43 = tl.load(in_ptr0 + (16 + x0 + 4 * (-12 + x1) + 64 * x2), tmp40 &
        xmask, other=0.0)
    tmp44 = tl.load(in_ptr0 + (32 + x0 + 4 * (-12 + x1) + 64 * x2), tmp40 &
        xmask, other=0.0)
    tmp45 = tmp43 + tmp44
    tmp46 = tl.load(in_ptr0 + (48 + x0 + 4 * (-12 + x1) + 64 * x2), tmp40 &
        xmask, other=0.0)
    tmp47 = tmp45 + tmp46
    tmp48 = tmp47 * tmp21
    tmp49 = tl.full(tmp48.shape, 0.0, tmp48.dtype)
    tmp50 = tl.where(tmp40, tmp48, tmp49)
    tmp51 = tl.where(tmp28, tmp39, tmp50)
    tmp52 = tl.where(tmp15, tmp24, tmp51)
    tmp53 = tl.where(tmp4, tmp11, tmp52)
    tmp55 = tmp54 - tmp53
    tl.store(out_ptr0 + x3, tmp53, xmask)
    tl.store(out_ptr1 + x3, tmp55, 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, 16, 4), (64, 4, 1), torch.float32)
        buf1 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_stack_sub_0[grid(256)](arg0_1, buf0, buf1, 256,
            XBLOCK=256, num_warps=4, num_stages=1)
        del arg0_1
    return reinterpret_tensor(buf0, (4, 4, 4, 4), (64, 16, 4, 1), 0), buf1


class MovingAverageNew(nn.Module):

    def __init__(self, cond_size: 'int', pred_size: 'int') ->None:
        super().__init__()
        self.left_window = cond_size // 2
        self.right_window = cond_size - self.left_window

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


Measured latency_ms: 0.016828