12#ifndef ARCCORE_BASE_VALUEFILLER_H
13#define ARCCORE_BASE_VALUEFILLER_H
18#include "arccore/base/BFloat16.h"
19#include "arccore/base/Float16.h"
26namespace Arccore::ValueFiller::impl
32template <
typename DataType>
37 using ClampValue = std::pair<DataType, DataType>;
39 : m_clamp_value(clamp_value)
41 ClampValue clampValue()
const
48 ClampValue m_clamp_value;
51template <
typename DataType>
55 return { { -334353.245, +73536.324 } };
57template <> BuildInfo<double> _getFloatBuildInfo<double>()
59 return { { -334353.245, +73536.324 } };
61template <> BuildInfo<float> _getFloatBuildInfo<float>()
63 return { { -14353.245f, 3536.324f } };
65template <> BuildInfo<BFloat16> _getFloatBuildInfo<BFloat16>()
69template <> BuildInfo<Float16> _getFloatBuildInfo<Float16>()
73template <
typename DataType> BuildInfo<DataType> _getIntegerBuildInfo(std::true_type)
75 if constexpr (
sizeof(DataType) == 1)
76 return { { -25, 32 } };
77 if constexpr (
sizeof(DataType) == 2)
78 return { { -212, 345 } };
79 if constexpr (
sizeof(DataType) == 4)
80 return { { -14353, 12345 } };
81 if constexpr (
sizeof(DataType) == 8)
82 return { { -234353, 452345 } };
84template <
typename DataType> BuildInfo<DataType> _getIntegerBuildInfo(std::false_type)
86 if constexpr (
sizeof(DataType) == 1)
88 if constexpr (
sizeof(DataType) == 2)
89 return { { 0, 721 } };
90 if constexpr (
sizeof(DataType) == 4)
91 return { { 0, 29540 } };
92 if constexpr (
sizeof(DataType) == 8)
93 return { { 0, 1290325 } };
99template <
typename DataType>
102template <
typename DataType>
107 using value_type = DataType;
112 : m_min_clamp(build_info.clampValue().first)
113 , m_max_clamp(build_info.clampValue().second)
118 DataType minClamp()
const {
return m_min_clamp; }
119 DataType maxClamp()
const {
return m_max_clamp; }
123 DataType m_min_clamp = {};
124 DataType m_max_clamp = {};
130template <
typename DataType,
typename RandomGeneratorDataType = DataType>
138 using UniformGeneratorType = std::uniform_int_distribution<RandomGeneratorDataType>;
143 :
BaseClass(impl::_getIntegerBuildInfo<DataType>(std::is_signed<DataType>{}))
150template <
typename DataType,
typename RandomGeneratorDataType = DataType>
158 using UniformGeneratorType = std::uniform_real_distribution<RandomGeneratorDataType>;
163 :
BaseClass(impl::_getFloatBuildInfo<DataType>())
172:
public IntegerFillTraitsT<char,std::conditional<std::is_signed_v<char>,short,unsigned short>::type>
277namespace Arccore::ValueFiller
283template <
typename DataType>
inline
286 std::seed_seq rng_seed{ seed };
287 using TraitsType = impl::FillTraitsT<DataType>;
288 using UniformGeneratorType =
typename TraitsType::UniformGeneratorType;
289 TraitsType traits_value;
290 std::mt19937_64 randomizer(rng_seed);
291 UniformGeneratorType rng_distrib(traits_value.minClamp(), traits_value.maxClamp());
294 for (
Int32 i = 0; i < n1; ++i) {
295 values[i] =
static_cast<DataType
>(rng_distrib(randomizer));
Déclarations des types de la composante 'base' de Arccore.
Type flottant demi-précision.
constexpr ARCCORE_HOST_DEVICE SizeType size() const noexcept
Retourne la taille du tableau.
Vue d'un tableau d'éléments de type T.
Arccore::Float16 Float16
Type 'Float16' (binary16)
Arccore::BFloat16 BFloat16
Type 'Brain Float16'.
std::int64_t Int64
Type entier signé sur 64 bits.
std::int32_t Int32
Type entier signé sur 32 bits.