TinyLlama.cpp
1.0
A lightweight C++ implementation of the TinyLlama language model
Loading...
Searching...
No Matches
model_macros.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <algorithm>
4
#include <cmath>
5
6
#ifdef _MSC_VER
7
#ifndef NOMINMAX
8
#define NOMINMAX
9
#endif
10
#endif
11
12
#ifdef min
13
#undef min
14
#endif
15
16
#ifdef max
17
#undef max
18
#endif
19
20
namespace
detail
{
21
template
<
typename
T>
22
inline
T
safe_min
(T a, T b) {
23
return
(std::min)(a, b);
// Parentheses prevent macro expansion
24
}
25
26
template
<
typename
T>
27
inline
T
safe_max
(T a, T b) {
28
return
(std::max)(a, b);
// Parentheses prevent macro expansion
29
}
30
31
inline
float
safe_sqrt
(
float
x) {
32
return
(std::sqrt)(x);
// Parentheses prevent macro expansion
33
}
34
}
// namespace detail
35
36
#define SAFE_MIN(a, b) detail::safe_min((a), (b))
37
#define SAFE_MAX(a, b) detail::safe_max((a), (b))
38
#define SAFE_SQRT(x) detail::safe_sqrt(x)
detail
Definition
model_macros.h:20
detail::safe_max
T safe_max(T a, T b)
Definition
model_macros.h:27
detail::safe_min
T safe_min(T a, T b)
Definition
model_macros.h:22
detail::safe_sqrt
float safe_sqrt(float x)
Definition
model_macros.h:31
Generated by
1.9.8