import torch
from torch._inductor.select_algorithm import extern_kernels
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 = 512
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex // 16 % 8
    x1 = xindex // 4 % 4
    x0 = xindex % 4
    x3 = xindex // 128
    x6 = xindex % 16
    x7 = xindex
    tmp0 = x2
    tmp1 = tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 4, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = 2 + x1
    tmp6 = tmp5 >= tmp1
    tmp7 = tl.full([1], 8, tl.int64)
    tmp8 = tmp5 < tmp7
    tmp9 = 2 + x0
    tmp10 = tmp9 >= tmp1
    tmp11 = tmp9 < tmp7
    tmp12 = tmp6 & tmp8
    tmp13 = tmp12 & tmp10
    tmp14 = tmp13 & tmp11
    tmp15 = tmp14 & tmp4
    tmp16 = tl.load(in_ptr0 + (18 + x0 + 8 * x1 + 64 * x2 + 256 * x3), 
        tmp15 & xmask, other=0.0)
    tmp17 = tl.load(in_ptr1 + x2, tmp15 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp18 = tmp16 + tmp17
    tmp19 = tl.full(tmp18.shape, 0.0, tmp18.dtype)
    tmp20 = tl.where(tmp15, tmp18, tmp19)
    tmp21 = tl.full(tmp20.shape, 0.0, tmp20.dtype)
    tmp22 = tl.where(tmp4, tmp20, tmp21)
    tmp23 = tmp0 >= tmp3
    tmp25 = tl.load(in_ptr2 + (x6 + 16 * (-4 + x2) + 64 * x3), tmp23 &
        xmask, other=0.0)
    tmp26 = tl.where(tmp4, tmp22, tmp25)
    tl.store(out_ptr0 + x7, tmp26, xmask)


def call(args):
    primals_1, primals_2, primals_3, primals_4 = args
    args.clear()
    assert_size_stride(primals_1, (4, 4, 2, 2), (16, 4, 2, 1))
    assert_size_stride(primals_2, (4,), (1,))
    assert_size_stride(primals_3, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(primals_4, (4, 4, 4, 4), (64, 16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = extern_kernels.convolution(primals_3, primals_1, stride=(2, 
            2), padding=(0, 0), dilation=(1, 1), transposed=True,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf0, (4, 4, 8, 8), (256, 64, 8, 1))
        buf1 = empty_strided_cuda((4, 8, 4, 4), (128, 16, 4, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_cat_0[grid(512)](buf0, primals_2, primals_4, buf1,
            512, XBLOCK=256, num_warps=4, num_stages=1)
        del buf0
        del primals_2
        del primals_4
    return buf1, primals_1, primals_3


class upNew(nn.Module):

    def __init__(self, in_ch, out_ch):
        super(upNew, self).__init__()
        self.up_scale = nn.ConvTranspose2d(in_ch, out_ch, 2, stride=2)

    def forward(self, input_0, input_1):
        primals_1 = self.up_scale.weight
        primals_2 = self.up_scale.bias
        primals_3 = input_0
        primals_4 = input_1
        output = call([primals_1, primals_2, primals_3, primals_4])
        return output[0]


Measured latency_ms: 0.025883