Skip to content
Snippets Groups Projects
Forked from Eclipse Projects / aidge / aidge_core
2538 commits behind the upstream repository.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
Data.hpp 1.82 KiB
/********************************************************************************
 * Copyright (c) 2023 CEA-List
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0.
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 ********************************************************************************/

#ifndef __AIDGE_DATA_H__
#define __AIDGE_DATA_H__

#include "aidge/utils/Parameter.hpp"

namespace Aidge {
enum class DataType {
    Float64,
    Float32,
    Float16,
    BFloat16,
    Binary,
    Ternary,
    Int2,
    Int3,
    Int4,
    Int5,
    Int6,
    Int7,
    Int8,
    Int16,
    Int32,
    Int64,
    UInt2,
    UInt3,
    UInt4,
    UInt5,
    UInt6,
    UInt7,
    UInt8,
    UInt16,
    UInt32,
    UInt64
};

class Data {
public:
    constexpr Data(const char* type): mType(type) {};
    constexpr const char* type() const {
        return mType;
    }
    virtual ~Data() = default;

private:
    const char* mType;
};
}

namespace {
template <typename T> struct NativeType { static const Aidge::DataType type; };
template <> const Aidge::DataType NativeType<double>::type = Aidge::DataType::Float64;
template <> const Aidge::DataType NativeType<float>::type = Aidge::DataType::Float32;
template <> const Aidge::DataType NativeType<long>::type = Aidge::DataType::Int64;
template <> const Aidge::DataType NativeType<int>::type = Aidge::DataType::Int32;

template <>
const char* const EnumStrings<Aidge::DataType>::data[]
    = {"Float64", "Float32", "Float16", "BFloat16", "Binary", "Ternary", 
       "Int2", "Int3", "Int4", "Int5", "Int6", "Int7", "Int8", "Int16", 
       "Int32", "Int64", "UInt2", "UInt3", "UInt4", "UInt5", "UInt6", 
       "UInt7", "UInt8", "UInt16", "UInt32", "UInt64"};
}

#endif /* __AIDGE_DATA_H__ */