// Copyright (c) 2025 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include <fcntl.h>
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

#include "paddle/extension.h"
#include "paddle/phi/core/allocator.h"
#include "paddle/phi/core/dense_tensor.h"
#include "xpu/plugin.h"
#include <paddle/phi/backends/xpu/xpu_context.h>

template <paddle::DataType D> class PDTraits;

template <> class PDTraits<paddle::DataType::FLOAT32> {
  public:
    typedef float DataType;
    typedef float data_t;
};

template <> class PDTraits<paddle::DataType::FLOAT16> {
  public:
    typedef float16 DataType;
    typedef paddle::float16 data_t;
};

template <> class PDTraits<paddle::DataType::BFLOAT16> {
  public:
    typedef bfloat16 DataType;
    typedef paddle::bfloat16 data_t;
};

template <> class PDTraits<paddle::DataType::INT8> {
  public:
    typedef int8_t DataType;
    typedef int8_t data_t;
};

template <> class PDTraits<paddle::DataType::UINT8> {
  public:
    typedef uint8_t DataType;
    typedef uint8_t data_t;
};

template <> class PDTraits<paddle::DataType::INT64> {
  public:
    typedef int64_t DataType;
    typedef int64_t data_t;
};
