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


@triton.jit
def triton_poi_fused__to_copy_ceil_div_1(in_ptr0, 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
    tmp0 = tl.load(in_ptr0 + x0, xmask)
    tmp1 = 0.25
    tmp2 = tmp0 * tmp1
    tmp3 = libdevice.ceil(tmp2)
    tmp4 = tmp3.to(tl.int32)
    tl.store(out_ptr0 + x0, tmp4, 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, 16, 4), (256, 64, 4, 1), torch.float32
            )
        get_raw_stream(0)
        triton_poi_fused_cat_0[grid(1024)](arg0_1, buf0, 1024, XBLOCK=256,
            num_warps=4, num_stages=1)
        del arg0_1
        buf1 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.int32)
        triton_poi_fused__to_copy_ceil_div_1[grid(256)](arg1_1, buf1, 256,
            XBLOCK=128, num_warps=4, num_stages=1)
        del arg1_1
    return reinterpret_tensor(buf0, (1, 4, 16, 4), (1024, 64, 4, 1), 0), buf1


class StackTimeNew(torch.nn.Module):
    __constants__ = ['factor']

    def __init__(self, factor):
        super().__init__()
        self.factor = int(factor)

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


Measured latency_ms: 0.027313