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
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as nn
import torch.utils.data
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_tanh_0(in_out_ptr0, in_ptr0, xnumel, XBLOCK: tl.constexpr
    ):
    xnumel = 512
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 8
    tmp0 = tl.load(in_out_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr0 + x0, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = libdevice.tanh(tmp2)
    tl.store(in_out_ptr0 + x2, tmp3, xmask)


@triton.jit
def triton_poi_fused_tanh_1(in_out_ptr0, in_ptr0, xnumel, XBLOCK: tl.constexpr
    ):
    xnumel = 384
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 6
    tmp0 = tl.load(in_out_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr0 + x0, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = libdevice.tanh(tmp2)
    tl.store(in_out_ptr0 + x2, tmp3, xmask)


@triton.jit
def triton_poi_fused_tanh_2(in_out_ptr0, in_ptr0, xnumel, XBLOCK: tl.constexpr
    ):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 4
    tmp0 = tl.load(in_out_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr0 + x0, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = libdevice.tanh(tmp2)
    tl.store(in_out_ptr0 + x2, tmp3, xmask)


@triton.jit
def triton_poi_fused_tanh_3(in_out_ptr0, in_ptr0, xnumel, XBLOCK: tl.constexpr
    ):
    xnumel = 192
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 3
    tmp0 = tl.load(in_out_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr0 + x0, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = libdevice.tanh(tmp2)
    tl.store(in_out_ptr0 + x2, tmp3, xmask)


@triton.jit
def triton_poi_fused_tanh_4(in_out_ptr0, in_ptr0, xnumel, XBLOCK: tl.constexpr
    ):
    xnumel = 128
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 2
    tmp0 = tl.load(in_out_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr0 + x0, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = libdevice.tanh(tmp2)
    tl.store(in_out_ptr0 + x2, tmp3, xmask)


def call(args):
    (primals_1, primals_2, primals_3, primals_4, primals_5, primals_6,
        primals_7, primals_8, primals_9, primals_10, primals_11, primals_12,
        primals_13, primals_14, primals_15, primals_16, primals_17,
        primals_18, primals_19, primals_20, primals_21) = args
    args.clear()
    assert_size_stride(primals_1, (8, 4), (4, 1))
    assert_size_stride(primals_2, (8,), (1,))
    assert_size_stride(primals_3, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(primals_4, (6, 8), (8, 1))
    assert_size_stride(primals_5, (6,), (1,))
    assert_size_stride(primals_6, (4, 6), (6, 1))
    assert_size_stride(primals_7, (4,), (1,))
    assert_size_stride(primals_8, (3, 4), (4, 1))
    assert_size_stride(primals_9, (3,), (1,))
    assert_size_stride(primals_10, (2, 3), (3, 1))
    assert_size_stride(primals_11, (2,), (1,))
    assert_size_stride(primals_12, (3, 2), (2, 1))
    assert_size_stride(primals_13, (3,), (1,))
    assert_size_stride(primals_14, (4, 3), (3, 1))
    assert_size_stride(primals_15, (4,), (1,))
    assert_size_stride(primals_16, (6, 4), (4, 1))
    assert_size_stride(primals_17, (6,), (1,))
    assert_size_stride(primals_18, (8, 6), (6, 1))
    assert_size_stride(primals_19, (8,), (1,))
    assert_size_stride(primals_20, (4, 8), (8, 1))
    assert_size_stride(primals_21, (4,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((64, 8), (8, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(primals_3, (64, 4), (4, 1), 0),
            reinterpret_tensor(primals_1, (4, 8), (1, 4), 0), out=buf0)
        del primals_1
        buf1 = reinterpret_tensor(buf0, (4, 4, 4, 8), (128, 32, 8, 1), 0)
        del buf0
        get_raw_stream(0)
        triton_poi_fused_tanh_0[grid(512)](buf1, primals_2, 512, XBLOCK=256,
            num_warps=4, num_stages=1)
        del primals_2
        buf2 = empty_strided_cuda((64, 6), (6, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf1, (64, 8), (8, 1), 0),
            reinterpret_tensor(primals_4, (8, 6), (1, 8), 0), out=buf2)
        buf3 = reinterpret_tensor(buf2, (4, 4, 4, 6), (96, 24, 6, 1), 0)
        del buf2
        triton_poi_fused_tanh_1[grid(384)](buf3, primals_5, 384, XBLOCK=256,
            num_warps=4, num_stages=1)
        del primals_5
        buf4 = empty_strided_cuda((64, 4), (4, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf3, (64, 6), (6, 1), 0),
            reinterpret_tensor(primals_6, (6, 4), (1, 6), 0), out=buf4)
        buf5 = reinterpret_tensor(buf4, (4, 4, 4, 4), (64, 16, 4, 1), 0)
        del buf4
        triton_poi_fused_tanh_2[grid(256)](buf5, primals_7, 256, XBLOCK=128,
            num_warps=4, num_stages=1)
        del primals_7
        buf6 = empty_strided_cuda((64, 3), (3, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf5, (64, 4), (4, 1), 0),
            reinterpret_tensor(primals_8, (4, 3), (1, 4), 0), out=buf6)
        buf7 = reinterpret_tensor(buf6, (4, 4, 4, 3), (48, 12, 3, 1), 0)
        del buf6
        triton_poi_fused_tanh_3[grid(192)](buf7, primals_9, 192, XBLOCK=128,
            num_warps=4, num_stages=1)
        del primals_9
        buf8 = empty_strided_cuda((64, 2), (2, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf7, (64, 3), (3, 1), 0),
            reinterpret_tensor(primals_10, (3, 2), (1, 3), 0), out=buf8)
        buf9 = reinterpret_tensor(buf8, (4, 4, 4, 2), (32, 8, 2, 1), 0)
        del buf8
        triton_poi_fused_tanh_4[grid(128)](buf9, primals_11, 128, XBLOCK=
            128, num_warps=4, num_stages=1)
        del primals_11
        buf10 = empty_strided_cuda((64, 3), (3, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf9, (64, 2), (2, 1), 0),
            reinterpret_tensor(primals_12, (2, 3), (1, 2), 0), out=buf10)
        buf11 = reinterpret_tensor(buf10, (4, 4, 4, 3), (48, 12, 3, 1), 0)
        del buf10
        triton_poi_fused_tanh_3[grid(192)](buf11, primals_13, 192, XBLOCK=
            128, num_warps=4, num_stages=1)
        del primals_13
        buf12 = empty_strided_cuda((64, 4), (4, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf11, (64, 3), (3, 1), 0),
            reinterpret_tensor(primals_14, (3, 4), (1, 3), 0), out=buf12)
        buf13 = reinterpret_tensor(buf12, (4, 4, 4, 4), (64, 16, 4, 1), 0)
        del buf12
        triton_poi_fused_tanh_2[grid(256)](buf13, primals_15, 256, XBLOCK=
            128, num_warps=4, num_stages=1)
        del primals_15
        buf14 = empty_strided_cuda((64, 6), (6, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf13, (64, 4), (4, 1), 0),
            reinterpret_tensor(primals_16, (4, 6), (1, 4), 0), out=buf14)
        buf15 = reinterpret_tensor(buf14, (4, 4, 4, 6), (96, 24, 6, 1), 0)
        del buf14
        triton_poi_fused_tanh_1[grid(384)](buf15, primals_17, 384, XBLOCK=
            256, num_warps=4, num_stages=1)
        del primals_17
        buf16 = empty_strided_cuda((64, 8), (8, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf15, (64, 6), (6, 1), 0),
            reinterpret_tensor(primals_18, (6, 8), (1, 6), 0), out=buf16)
        buf17 = reinterpret_tensor(buf16, (4, 4, 4, 8), (128, 32, 8, 1), 0)
        del buf16
        triton_poi_fused_tanh_0[grid(512)](buf17, primals_19, 512, XBLOCK=
            256, num_warps=4, num_stages=1)
        del primals_19
        buf18 = empty_strided_cuda((64, 4), (4, 1), torch.float32)
        extern_kernels.addmm(primals_21, reinterpret_tensor(buf17, (64, 8),
            (8, 1), 0), reinterpret_tensor(primals_20, (8, 4), (1, 8), 0),
            alpha=1, beta=1, out=buf18)
        del primals_21
    return (reinterpret_tensor(buf18, (4, 4, 4, 4), (64, 16, 4, 1), 0),
        reinterpret_tensor(primals_3, (64, 4), (4, 1), 0), buf1, buf3, buf5,
        buf7, buf9, buf11, buf13, buf15, buf17, primals_20, primals_18,
        primals_16, primals_14, primals_12, primals_10, primals_8,
        primals_6, primals_4)


class AE_big_2D_v2New(nn.Module):

    def __init__(self, n_features=4):
        super(AE_big_2D_v2New, self).__init__()
        self.en1 = nn.Linear(n_features, 8)
        self.en2 = nn.Linear(8, 6)
        self.en3 = nn.Linear(6, 4)
        self.en4 = nn.Linear(4, 3)
        self.en5 = nn.Linear(3, 2)
        self.de1 = nn.Linear(2, 3)
        self.de2 = nn.Linear(3, 4)
        self.de3 = nn.Linear(4, 6)
        self.de4 = nn.Linear(6, 8)
        self.de5 = nn.Linear(8, n_features)
        self.tanh = nn.Tanh()

    def encode(self, x):
        return self.en5(self.tanh(self.en4(self.tanh(self.en3(self.tanh(
            self.en2(self.tanh(self.en1(x)))))))))

    def decode(self, x):
        return self.de5(self.tanh(self.de4(self.tanh(self.de3(self.tanh(
            self.de2(self.tanh(self.de1(self.tanh(x))))))))))

    def describe(self):
        return 'in-8-6-4-3-2-3-4-6-8-out'

    def forward(self, input_0):
        primals_1 = self.en1.weight
        primals_2 = self.en1.bias
        primals_4 = self.en2.weight
        primals_5 = self.en2.bias
        primals_6 = self.en3.weight
        primals_7 = self.en3.bias
        primals_8 = self.en4.weight
        primals_9 = self.en4.bias
        primals_10 = self.en5.weight
        primals_11 = self.en5.bias
        primals_12 = self.de1.weight
        primals_13 = self.de1.bias
        primals_14 = self.de2.weight
        primals_15 = self.de2.bias
        primals_16 = self.de3.weight
        primals_17 = self.de3.bias
        primals_18 = self.de4.weight
        primals_19 = self.de4.bias
        primals_20 = self.de5.weight
        primals_21 = self.de5.bias
        primals_3 = input_0
        output = call([primals_1, primals_2, primals_3, primals_4,
            primals_5, primals_6, primals_7, primals_8, primals_9,
            primals_10, primals_11, primals_12, primals_13, primals_14,
            primals_15, primals_16, primals_17, primals_18, primals_19,
            primals_20, primals_21])
        return output[0]


Measured latency_ms: 0.014894