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.functional
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_convolution_0(in_out_ptr0, in_ptr0, xnumel, XBLOCK: tl
    .constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x3 = xindex
    x1 = xindex // 4096 % 3
    tmp0 = tl.load(in_out_ptr0 + x3, None)
    tmp1 = tl.load(in_ptr0 + x1, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tl.store(in_out_ptr0 + x3, tmp2, None)


@triton.jit
def triton_poi_fused_mul_sub_1(in_ptr0, out_ptr0, out_ptr1, xnumel, XBLOCK:
    tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x0 = xindex % 4096
    x1 = xindex // 4096
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + (8192 + x0 + 12288 * x1), None)
    tmp1 = tl.load(in_ptr0 + (x0 + 12288 * x1), None)
    tmp3 = tl.load(in_ptr0 + (4096 + x0 + 12288 * x1), None)
    tmp2 = tmp0 - tmp1
    tmp4 = tmp2 * tmp3
    tl.store(out_ptr0 + x2, tmp2, None)
    tl.store(out_ptr1 + x2, tmp4, None)


@triton.jit
def triton_poi_fused_cat_sub_2(in_ptr0, in_ptr1, in_ptr2, out_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x1 = xindex // 4096 % 2
    x0 = xindex % 4096
    x2 = xindex // 8192
    x3 = xindex
    tmp0 = x1
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 1, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (4096 + x0 + 12288 * x2), tmp4,
        eviction_policy='evict_last', other=0.0)
    tmp6 = tmp0 >= tmp3
    tl.full([1], 2, tl.int64)
    tmp9 = tl.load(in_ptr1 + (4096 + x0 + 4096 * (-1 + x1) + 12288 * x2),
        tmp6, other=0.0)
    tmp10 = tl.load(in_ptr2 + (1 + (-1 + x1)), tmp6, eviction_policy=
        'evict_last', other=0.0)
    tmp11 = tmp9 + tmp10
    tmp12 = tl.full(tmp11.shape, 0.0, tmp11.dtype)
    tmp13 = tl.where(tmp6, tmp11, tmp12)
    tmp14 = tl.where(tmp4, tmp5, tmp13)
    tmp15 = tl.load(in_ptr0 + (x0 + 4096 * x1 + 12288 * x2), tmp4, other=0.0)
    tmp16 = tl.load(in_ptr1 + (8192 + x0 + 4096 * (-1 + x1) + 12288 * x2),
        tmp6, other=0.0)
    tmp17 = tl.load(in_ptr2 + (2 + (-1 + x1)), tmp6, eviction_policy=
        'evict_last', other=0.0)
    tmp18 = tmp16 + tmp17
    tmp19 = tl.full(tmp18.shape, 0.0, tmp18.dtype)
    tmp20 = tl.where(tmp6, tmp18, tmp19)
    tmp21 = tl.where(tmp4, tmp15, tmp20)
    tmp22 = tmp14 - tmp21
    tl.store(out_ptr0 + x3, tmp22, None)


def call(args):
    (primals_1, primals_2, primals_3, primals_4, primals_5, primals_6,
        primals_7, primals_8) = args
    args.clear()
    assert_size_stride(primals_1, (3, 3, 1, 1), (3, 1, 1, 1))
    assert_size_stride(primals_2, (3,), (1,))
    assert_size_stride(primals_3, (4, 3, 64, 64), (12288, 4096, 64, 1))
    assert_size_stride(primals_4, (4, 3, 64, 64), (12288, 4096, 64, 1))
    assert_size_stride(primals_5, (3, 1, 1, 1), (1, 1, 1, 1))
    assert_size_stride(primals_6, (3,), (1,))
    assert_size_stride(primals_7, (3, 1, 1, 1), (1, 1, 1, 1))
    assert_size_stride(primals_8, (3,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = extern_kernels.convolution(primals_3, primals_1, stride=(1, 
            1), padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf0, (4, 3, 64, 64), (12288, 4096, 64, 1))
        buf1 = extern_kernels.convolution(primals_4, primals_1, stride=(1, 
            1), padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf1, (4, 3, 64, 64), (12288, 4096, 64, 1))
        buf2 = buf0
        del buf0
        get_raw_stream(0)
        triton_poi_fused_convolution_0[grid(49152)](buf2, primals_2, 49152,
            XBLOCK=512, num_warps=4, num_stages=1)
        buf3 = empty_strided_cuda((4, 1, 64, 64), (4096, 4096, 64, 1),
            torch.float32)
        buf4 = empty_strided_cuda((4, 1, 64, 64), (4096, 4096, 64, 1),
            torch.float32)
        triton_poi_fused_mul_sub_1[grid(16384)](buf2, buf3, buf4, 16384,
            XBLOCK=128, num_warps=4, num_stages=1)
        buf5 = extern_kernels.convolution(reinterpret_tensor(buf2, (4, 1, 
            64, 64), (12288, 0, 64, 1), 8192), primals_5, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf5, (4, 3, 64, 64), (12288, 4096, 64, 1))
        buf6 = buf5
        del buf5
        triton_poi_fused_convolution_0[grid(49152)](buf6, primals_6, 49152,
            XBLOCK=512, num_warps=4, num_stages=1)
        del primals_6
        buf7 = extern_kernels.convolution(reinterpret_tensor(buf2, (4, 1, 
            64, 64), (12288, 0, 64, 1), 4096), primals_7, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf7, (4, 3, 64, 64), (12288, 4096, 64, 1))
        buf8 = buf7
        del buf7
        triton_poi_fused_convolution_0[grid(49152)](buf8, primals_8, 49152,
            XBLOCK=512, num_warps=4, num_stages=1)
        del primals_8
        buf9 = empty_strided_cuda((4, 2, 64, 64), (8192, 4096, 64, 1),
            torch.float32)
        triton_poi_fused_cat_sub_2[grid(32768)](buf2, buf1, primals_2, buf9,
            32768, XBLOCK=256, num_warps=4, num_stages=1)
        del buf1
        del primals_2
    return (buf6, buf8, buf4, buf9, primals_1, primals_3, primals_4,
        primals_5, primals_7, reinterpret_tensor(buf2, (4, 1, 64, 64), (
        12288, 4096, 64, 1), 4096), reinterpret_tensor(buf2, (4, 1, 64, 64),
        (12288, 4096, 64, 1), 8192), buf3)


class SplitConcatNetNew(torch.nn.Module):

    def __init__(self):
        super(SplitConcatNetNew, self).__init__()
        self.conv1 = torch.nn.Conv2d(3, 3, kernel_size=1, stride=1)
        self.conv2 = torch.nn.Conv2d(1, 3, kernel_size=1, stride=1)
        self.conv3 = torch.nn.Conv2d(1, 3, kernel_size=1, stride=1)

    def forward(self, input_0, input_1):
        primals_1 = self.conv1.weight
        primals_2 = self.conv1.bias
        primals_5 = self.conv2.weight
        primals_6 = self.conv2.bias
        primals_7 = self.conv3.weight
        primals_8 = self.conv3.bias
        primals_3 = input_0
        primals_4 = input_1
        output = call([primals_1, primals_2, primals_3, primals_4,
            primals_5, primals_6, primals_7, primals_8])
        return output[0], output[1], output[2], output[3]


Measured latency_ms: 0.014867