Tannic
A C++ Tensor Library
Loading...
Searching...
No Matches
types.hpp File Reference

Core type system for the Tannic Tensor Library. More...

#include <iostream>
#include <cstdint>
#include <string>
#include <complex>
#include "runtime/types.h"
Include dependency graph for types.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  tannic
 

Functions

constexpr std::size_t tannic::dsizeof (type type)
 Returns the size in bytes of a given tensor data type.
 
constexpr std::size_t tannic::nbytesof (type dtype, std::size_t nelements)
 Returns the total number of bytes required to store nelements elements of the given data type.
 
constexpr std::string tannic::dnameof (type type)
 Returns the string name of a given tensor data type.
 
constexpr uint8_t tannic::dcodeof (type type)
 Returns the numeric code used for serialization of a data type.
 
constexpr type tannic::dtypeof (uint8_t code)
 Converts a numeric type code back to its corresponding type enum.
 
template<typename T >
constexpr type tannic::dtypeof ()
 
std::ostream & tannic::operator<< (std::ostream &ostream, type type)
 

Detailed Description

Core type system for the Tannic Tensor Library.

Author
Eric Hermosis
Date
2025

Defines the fundamental data types supported by tensors and provides utilities for:

Supported Data Types

The type enum defines all supported numeric types:

enum type {
none, // Invalid type
boolean // 1-bit-packed boolean (true, false).
int8, // 8-bit integer
int16, // 16-bit integer
int32, // 32-bit integer
int64, // 64-bit integer
float16, // 16-bit float
float32, // 32-bit float
float64, // 64-bit float (double)
complex64, // 64-bit complex (two float32)
complex128, // 128-bit complex (two float64)
TYPES // Count of types
};

Key Functions

  • dsizeof(type): Returns byte size of a type
  • dnameof(type): Returns string name of a type
  • dcodeof(type): Returns numeric code for serialization
  • dtypeof(code): Converts code back to type enum
  • operator<<: Stream output support

Example

std::cout << dnameof(float32); // "float32" std::cout << dsizeof(complex128); // 16