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.parallel
import torch.optim
import torch
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
reinterpret_tensor = torch._C._dynamo.guards._reinterpret_tensor


@triton.jit
def triton_poi_fused_convolution_0(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.
    constexpr):
    xnumel = 128
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 16
    x1 = xindex // 16 % 4
    x2 = xindex // 64
    x3 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 + 16 * x2 + 64 * x1), xmask)
    tl.store(out_ptr0 + x3, tmp0, xmask)


@triton.jit
def triton_poi_fused_clone_1(in_ptr0, in_ptr1, in_ptr2, out_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = xindex // 16 % 4
    x3 = xindex
    x0 = xindex % 16
    x2 = xindex // 64
    tmp0 = x1
    tmp1 = tl.full([1], 2, tl.int64)
    tmp2 = tmp0 >= tmp1
    tmp3 = tl.load(in_ptr0 + x3, tmp2 & xmask, other=0.0)
    tmp4 = tmp0 < tmp1
    tmp5 = tl.load(in_ptr1 + (x0 + 16 * x2 + 64 * x1), tmp4 & xmask, other=0.0)
    tmp6 = tl.load(in_ptr2 + x1, tmp4 & xmask, eviction_policy='evict_last',
        other=0.0)
    tmp7 = tmp5 + tmp6
    tmp8 = tl.full(tmp7.shape, 0.0, tmp7.dtype)
    tmp9 = tl.where(tmp4, tmp7, tmp8)
    tmp10 = 0.0
    tmp11 = tl.where(tmp4, tmp9, tmp10)
    tmp12 = tl.where(tmp2, tmp3, tmp11)
    tl.store(out_ptr0 + x3, tmp12, xmask)


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


class CONV1d_FusionBlockNew(nn.Module):

    def __init__(self, in_channels, n_segment, n_div):
        super(CONV1d_FusionBlockNew, self).__init__()
        self.n_div = n_div
        self.fold = in_channels // n_div
        self.n_segment = n_segment
        self.temporal_conv = nn.Conv3d(in_channels=2 * self.fold,
            out_channels=2 * self.fold, kernel_size=(3, 1, 1), padding=(1, 
            0, 0), stride=1, bias=True)
        nn.init.constant_(self.temporal_conv.weight, 0)
        nn.init.constant_(self.temporal_conv.bias, 0)

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


Measured latency_ms: 0.044705