blob: 767dc1f4ec4aa2536913e35c2af8b6aa92b63ecd (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "cell_type.h"
#include <stdio.h>
#include <cstdlib>
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/vespalib/util/stringfmt.h>
using vespalib::make_string_short::fmt;
namespace vespalib::eval {
uint32_t
CellTypeUtils::alignment(CellType cell_type)
{
return TypifyCellType::resolve(cell_type, [](auto t)->uint32_t
{
using T = typename decltype(t)::type;
return alignof(T);
});
}
size_t
CellTypeUtils::mem_size(CellType cell_type, size_t sz)
{
return TypifyCellType::resolve(cell_type, [sz](auto t)->size_t
{
using T = typename decltype(t)::type;
return (sz * sizeof(T));
});
}
std::vector<CellType>
CellTypeUtils::list_types()
{
return {CellType::DOUBLE, CellType::FLOAT, CellType::BFLOAT16, CellType::INT8 };
}
std::vector<CellType>
CellTypeUtils::list_stable_types()
{
return {CellType::DOUBLE, CellType::FLOAT};
}
std::vector<CellType>
CellTypeUtils::list_unstable_types()
{
return {CellType::BFLOAT16, CellType::INT8 };
}
}
|