```python
import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline

_cpp_source = """
torch::Tensor fused_gelu_cuda(torch::Tensor x);
"""

_cuda_source = r"""
#include <torch/extension.h>
#include <ATen/cuda/CUDAContext.h>
#include <c10/cuda/CUDAGuard.h>
#include <c10/cuda/CUDAException.h>
#include <cuda_runtime.h>
#include <algorithm>
#include <cstdint>

__device__ __forceinline__ float gelu(float x) {
    float x3 = x * x * x;
    return (0.5f * x) *
           (1.0f + tanhf(0.7978845608028654f * (x + 0.044715f * x3)));
}

__device__ __forceinline__ double gelu(double x) {
    double x3 = x * x * x;
    return (0.5 * x) *
           (1.0 + tanh(0.7978845608028654 * (x + 0.044715 * x3)));
}

__global__ void gelu_float4_kernel(
    const float* __restrict__ x,
    float* __restrict__ y,
    int64_t n
) {
    int64_t i = static_cast<int64_t>(blockIdx.x) * blockDim.x + threadIdx.x;
    int64_t stride = static_cast<int64_t>(blockDim.x) * gridDim.x;
    int64_t vectors = n / 4;

    const float4* xv = reinterpret_cast<const float4*>(x);
    float4* yv = reinterpret_cast<float4*>(y);

    for (int64_t j = i; j < vectors; j += stride) {
        float4 v = xv[j];
        yv[j] = make_float4(gelu(v.x), gelu(v.y), gelu(v.z), gelu(v.w));
    }

    int64_t tail = vectors * 4 + i;
    if (tail < n) {
        y[tail] = gelu(x[tail]);
    }
}

template <typename scalar_t, typename acc_t>
__global__ void gelu_scalar_kernel(
    const scalar_t* __restrict__ x,
    scalar_t* __restrict__ y,
    int64_t n
) {
    int64_t i = static_cast<int64_t>(blockIdx.x) * blockDim.x + threadIdx.x;
    int64_t stride = static_cast<int64_t>(blockDim.x) * gridDim.x;

    for (; i < n; i += stride) {
        y[i] = static_cast<scalar_t>(gelu(static_cast<acc_t>(x[i])));
    }
}

torch::Tensor fused_gelu_cuda(torch::Tensor x) {
    TORCH_CHECK(x.is_cuda(), "Expected a CUDA tensor");
    c10::cuda::CUDAGuard guard(x.device());

    auto input = x.contiguous();
    auto output = torch::empty(input.sizes(), input.options());
    int64_t n = input.numel();
    if (n == 0) return output;

    constexpr int threads = 256;
    auto stream = at::cuda::getCurrentCUDAStream();

    if (input.scalar_type() == at::kFloat &&
        reinterpret_cast<uintptr_t>(input.data_ptr<float>()) % 16 == 0) {
        int blocks = static_cast<int>(
            std::min<int64_t>(4096, ((n + 3) / 4 + threads - 1) / threads));
        gelu_float4_kernel<<<blocks, threads, 0, stream>>>(
            input.data_ptr<float>(), output.data_ptr<float>(), n);
    } else {
        int blocks = static_cast<int>(
            std::min<int64_t>(4096, (n + threads - 1) / threads));
        AT_DISPATCH_FLOATING_TYPES_AND2(
            at::ScalarType::Half,
            at::ScalarType::BFloat16,
            input.scalar_type(),
            "fused_gelu",
            [&] {
                using acc_t = typename std::conditional<
                    std::is_same<scalar_t, double>::value, double, float>::type;
                gelu_scalar_kernel<scalar_t, acc_t>
                    <<<blocks, threads, 0, stream>>>(
                        input.data_ptr<scalar_t>(),
                        output.data_ptr<scalar_t>(),
                        n);
            });
    }

    C10_CUDA_KERNEL_LAUNCH_CHECK();
    return output;
}
"""

_fused_gelu = load_inline(
    name="fused_tanh_gelu_cuda",
    cpp_sources=_cpp_source,
    cuda_sources=_cuda_source,
    functions=["fused_gelu_cuda"],
    extra_cflags=["-O3"],
    extra_cuda_cflags=["-O3", "--fmad=false"],
    verbose=False,
)


class ModelNew(nn.Module):
    def __init__(self):
        super().__init__()

    def forward(self, x):
        return _fused_gelu.fused_gelu_cuda(x)
```