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_leaky_relu_0(in_ptr0, out_ptr0, out_ptr1, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 25088
    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 = 0.0
    tmp2 = tmp0 > tmp1
    tmp3 = 0.01
    tmp4 = tmp0 * tmp3
    tmp5 = tl.where(tmp2, tmp0, tmp4)
    tl.store(out_ptr0 + x0, tmp2, xmask)
    tl.store(out_ptr1 + x0, tmp5, xmask)


@triton.jit
def triton_poi_fused_leaky_relu_1(in_ptr0, out_ptr0, out_ptr1, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 50176
    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 = 0.0
    tmp2 = tmp0 > tmp1
    tmp3 = 0.01
    tmp4 = tmp0 * tmp3
    tmp5 = tl.where(tmp2, tmp0, tmp4)
    tl.store(out_ptr0 + x0, tmp2, xmask)
    tl.store(out_ptr1 + x0, tmp5, xmask)


def call(args):
    primals_1, primals_2, primals_3, primals_4 = args
    args.clear()
    assert_size_stride(primals_1, (4, 128, 4, 4), (2048, 16, 4, 1))
    assert_size_stride(primals_2, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(primals_3, (128, 64, 4, 4), (1024, 16, 4, 1))
    assert_size_stride(primals_4, (64, 1, 4, 4), (16, 16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = extern_kernels.convolution(primals_2, primals_1, stride=(1, 
            1), padding=(0, 0), dilation=(1, 1), transposed=True,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf0, (4, 128, 7, 7), (6272, 49, 7, 1))
        buf1 = empty_strided_cuda((4, 128, 7, 7), (6272, 49, 7, 1), torch.bool)
        buf2 = empty_strided_cuda((4, 128, 7, 7), (6272, 49, 7, 1), torch.
            float32)
        get_raw_stream(0)
        triton_poi_fused_leaky_relu_0[grid(25088)](buf0, buf1, buf2, 25088,
            XBLOCK=128, num_warps=4, num_stages=1)
        del buf0
        buf3 = extern_kernels.convolution(buf2, primals_3, stride=(2, 2),
            padding=(1, 1), dilation=(1, 1), transposed=True,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf3, (4, 64, 14, 14), (12544, 196, 14, 1))
        buf4 = empty_strided_cuda((4, 64, 14, 14), (12544, 196, 14, 1),
            torch.bool)
        buf5 = empty_strided_cuda((4, 64, 14, 14), (12544, 196, 14, 1),
            torch.float32)
        triton_poi_fused_leaky_relu_1[grid(50176)](buf3, buf4, buf5, 50176,
            XBLOCK=512, num_warps=4, num_stages=1)
        del buf3
        buf6 = extern_kernels.convolution(buf5, primals_4, stride=(2, 2),
            padding=(1, 1), dilation=(1, 1), transposed=True,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf6, (4, 1, 28, 28), (784, 784, 28, 1))
    return (buf6, primals_1, primals_2, primals_3, primals_4, buf1, buf2,
        buf4, buf5)


class DecoderNew(nn.Module):

    def __init__(self, z_dim):
        super(DecoderNew, self).__init__()
        self.deconv1 = nn.ConvTranspose2d(z_dim, 128, kernel_size=4, stride
            =1, bias=False)
        self.deconv2 = nn.ConvTranspose2d(128, 64, kernel_size=4, stride=2,
            padding=1, bias=False)
        self.deconv3 = nn.ConvTranspose2d(64, 1, kernel_size=4, stride=2,
            padding=1, bias=False)
        self.lrelu = nn.LeakyReLU()

    def forward(self, input_0):
        primals_1 = self.deconv1.weight
        primals_3 = self.deconv2.weight
        primals_4 = self.deconv3.weight
        primals_2 = input_0
        output = call([primals_1, primals_2, primals_3, primals_4])
        return output[0]


Measured latency_ms: 0.061914