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


class DWTNew(nn.Module):
    """
    2D Discrete Wavelet Transform as implemented in [1]_.

    References
    ----------

    .. [1] Liu, Pengju, et al. “Multi-Level Wavelet-CNN for Image Restoration.” ArXiv:1805.07071 [Cs], May 2018.
    arXiv.org, http://arxiv.org/abs/1805.07071.

    """

    def __init__(self):
        super().__init__()
        self.requires_grad = False

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


Measured latency_ms: 0.014074