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
import torch.utils.data
import torch.jit
import torch.optim
import torch.utils.collect_env
import torch.nn.parallel
import torch.utils.data.distributed
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_add_floor_divide_sub_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 = tmp0.to(tl.int32)
    tmp2 = tl.full([1], 4, tl.int32)
    tmp3 = tmp1 + tmp2
    tmp4 = tl.full([1], 1, tl.int32)
    tmp5 = tmp3 - tmp4
    tmp6 = tl.where((tmp5 < 0) != (tmp2 < 0), tl.where(tmp5 % tmp2 != 0, 
        tmp5 // tmp2 - 1, tmp5 // tmp2), tmp5 // tmp2)
    tl.store(out_ptr0 + x0, tmp6, 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=128,
            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_add_floor_divide_sub_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(nn.Module):

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