Home
last modified time | relevance | path

Searched refs:bfloat16 (Results 1 – 25 of 307) sorted by relevance

12345678910>>...13

/external/tensorflow/tensorflow/compiler/xla/tests/
Dbfloat16_test.cc54 auto x = ConstantR0<bfloat16>(&builder, static_cast<bfloat16>(2.0f)); in XLA_TEST_F()
55 auto y = ConstantR0<bfloat16>(&builder, static_cast<bfloat16>(1.0f)); in XLA_TEST_F()
58 ComputeAndCompareR0<bfloat16>(&builder, static_cast<bfloat16>(3.0f), {}, in XLA_TEST_F()
64 auto x = ConstantR0<bfloat16>(&builder, static_cast<bfloat16>(4.0f)); in XLA_TEST_F()
67 ComputeAndCompareR0<bfloat16>(&builder, static_cast<bfloat16>(1.387f), {}, in XLA_TEST_F()
73 Neg(ConstantR0<bfloat16>(&builder, static_cast<bfloat16>(2.1f))); in XLA_TEST_F()
75 ComputeAndCompareR0<bfloat16>(&builder, static_cast<bfloat16>(-2.1f), {}, in XLA_TEST_F()
85 auto operand = ConstantR4FromArray4D<bfloat16>( in XLA_TEST_F()
87 {{{{static_cast<bfloat16>(1.f)}, {static_cast<bfloat16>(2.f)}}, in XLA_TEST_F()
88 {{static_cast<bfloat16>(3.f)}, {static_cast<bfloat16>(4.f)}}}, in XLA_TEST_F()
[all …]
Dprng_test.cc93 UniformTest<bfloat16>(static_cast<bfloat16>(std::get<1>(test_params).first), in XLA_TEST_P()
94 static_cast<bfloat16>(std::get<1>(test_params).second), in XLA_TEST_P()
107 -std::numeric_limits<Eigen::bfloat16>::min()),
120 bfloat16 low = static_cast<bfloat16>(32.25); in XLA_TEST_F()
121 bfloat16 high = static_cast<bfloat16>(33); in XLA_TEST_F()
122 bfloat16 interval = static_cast<bfloat16>(0.25); in XLA_TEST_F()
127 auto result = UniformTest<bfloat16>(low, high, {}, /*seed=*/seed); in XLA_TEST_F()
128 result.EachCell<bfloat16>([&](absl::Span<const int64>, bfloat16 value) { in XLA_TEST_F()
/external/tensorflow/tensorflow/core/lib/bfloat16/
Dbfloat16.h45 struct bfloat16 { struct
48 B16_DEVICE_FUNC bfloat16() : value(ZERO_VALUE) {} in bfloat16() function
50 B16_DEVICE_FUNC static bfloat16 truncate_to_bfloat16(const float v) { in truncate_to_bfloat16() argument
51 bfloat16 output; in truncate_to_bfloat16()
65 B16_DEVICE_FUNC explicit bfloat16(const float v) { in bfloat16() argument
69 B16_DEVICE_FUNC explicit bfloat16(const double val) in bfloat16() function
70 : bfloat16(static_cast<float>(val)) {} in bfloat16()
73 B16_DEVICE_FUNC explicit bfloat16(const complex64& val) in bfloat16() function
74 : bfloat16(val.real()) {} in bfloat16()
76 B16_DEVICE_FUNC explicit bfloat16(const complex128& val) in bfloat16() argument
[all …]
DBUILD14 # name = "bfloat16",
15 # hdrs = ["bfloat16.h"],
26 # "bfloat16.h",
31 ["bfloat16.h"],
Dbfloat16.cc22 const uint16_t bfloat16::NAN_VALUE;
23 const uint16_t bfloat16::ZERO_VALUE;
25 B16_DEVICE_FUNC bfloat16::operator Eigen::half() const { in operator Eigen::half()
/external/tensorflow/tensorflow/python/lib/core/
Dbfloat16.cc31 using bfloat16 = Eigen::bfloat16; typedef
68 bfloat16 value;
78 bfloat16 PyBfloat16_Bfloat16(PyObject* object) { in PyBfloat16_Bfloat16()
83 Safe_PyObjectPtr PyBfloat16_FromBfloat16(bfloat16 x) { in PyBfloat16_FromBfloat16()
94 bool CastToBfloat16(PyObject* arg, bfloat16* output) { in CastToBfloat16()
105 *output = bfloat16(d); in CastToBfloat16()
114 *output = bfloat16(static_cast<float>(l)); in CastToBfloat16()
120 *output = bfloat16(f); in CastToBfloat16()
126 *output = bfloat16(f); in CastToBfloat16()
132 *output = bfloat16(f); in CastToBfloat16()
[all …]
Dbfloat16_test.py36 bfloat16 = _pywrap_bfloat16.TF_bfloat16_type() variable
40 a = a.astype(np.float32) if a.dtype == bfloat16 else a
41 b = b.astype(np.float32) if b.dtype == bfloat16 else b
62 np.testing.assert_equal(v, float(bfloat16(v)))
66 np.testing.assert_equal(-3.75, dtype(bfloat16(dtype(-3.75))))
67 np.testing.assert_equal(1.5, float(bfloat16(dtype(1.5))))
68 np.testing.assert_equal(4.5, dtype(bfloat16(np.array(4.5, dtype))))
70 np.array([2, 5, -1], bfloat16), bfloat16(np.array([2, 5, -1], dtype)))
74 self.assertEqual(v, int(bfloat16(v)))
80 } for dtype in [bfloat16, np.float16, np.float32, np.float64]))
[all …]
/external/tensorflow/tensorflow/compiler/xla/client/lib/
Dquantize_test.cc30 using bfloat16 = tensorflow::bfloat16; typedef
79 Array2D<bfloat16> GenerateLargeSizeMinCombinedOutput( in GenerateLargeSizeMinCombinedOutput()
98 Array2D<bfloat16> output(output_height, output_width, bfloat16(0.0)); in GenerateLargeSizeMinCombinedOutput()
106 const bfloat16 scale_factor = in GenerateLargeSizeMinCombinedOutput()
108 (static_cast<bfloat16>(std::numeric_limits<NativeT>::max() - in GenerateLargeSizeMinCombinedOutput()
114 bfloat16 result = in GenerateLargeSizeMinCombinedOutput()
115 static_cast<bfloat16>(input(h, w) + half_range) * scale_factor + in GenerateLargeSizeMinCombinedOutput()
129 std::vector<bfloat16> GenerateMinCombinedOutput(const QuantizedRange &range) { in GenerateMinCombinedOutput()
136 const bfloat16 scale_factor = in GenerateMinCombinedOutput()
138 (static_cast<bfloat16>(std::numeric_limits<NativeT>::max() - in GenerateMinCombinedOutput()
[all …]
Dconstants.cc51 return ConstantR0<Eigen::bfloat16>( in Epsilon()
52 builder, static_cast<Eigen::bfloat16>( in Epsilon()
53 Eigen::NumTraits<Eigen::bfloat16>::epsilon())); in Epsilon()
75 return ConstantR0<Eigen::bfloat16>( in MinFiniteValue()
76 builder, Eigen::NumTraits<Eigen::bfloat16>::lowest()); in MinFiniteValue()
92 return ConstantR0<Eigen::bfloat16>( in MinPositiveNormalValue()
93 builder, std::numeric_limits<Eigen::bfloat16>::min()); in MinPositiveNormalValue()
115 return ConstantR0<Eigen::bfloat16>( in MaxFiniteValue()
116 builder, Eigen::NumTraits<Eigen::bfloat16>::highest()); in MaxFiniteValue()
133 return ConstantR0<Eigen::bfloat16>( in NanValue()
[all …]
Dquantize.h45 tensorflow::bfloat16 min = tensorflow::bfloat16(0.0f);
46 tensorflow::bfloat16 max = tensorflow::bfloat16(0.0f);
140 const tensorflow::bfloat16 scale_factor =
142 (static_cast<tensorflow::bfloat16>(std::numeric_limits<T>::max() -
146 XlaOp half_range_bf16 = xla::ConstantR0<tensorflow::bfloat16>(
147 builder, static_cast<bfloat16>(half_range));
151 sum * xla::ConstantR0<tensorflow::bfloat16>(builder, scale_factor) +
152 xla::ConstantR0<tensorflow::bfloat16>(builder, range.min);
/external/tensorflow/tensorflow/core/framework/
Dbfloat16.cc22 void RoundFloatToBFloat16(const float* src, bfloat16* dst, int64 size) { in RoundFloatToBFloat16()
24 Eigen::Map<Eigen::Array<bfloat16, Eigen::Dynamic, 1>> dst_eigen(dst, size); in RoundFloatToBFloat16()
25 dst_eigen = src_eigen.cast<bfloat16>(); in RoundFloatToBFloat16()
28 void FloatToBFloat16(const float* src, bfloat16* dst, int64 size) { in FloatToBFloat16()
31 memcpy(dst, src, sizeof(bfloat16)); in FloatToBFloat16()
35 reinterpret_cast<const char*>(src) + sizeof(float) - sizeof(bfloat16), in FloatToBFloat16()
36 sizeof(bfloat16)); in FloatToBFloat16()
41 void BFloat16ToFloat(const bfloat16* src, float* dst, int64 size) { in BFloat16ToFloat()
42 Eigen::Map<const Eigen::Array<bfloat16, Eigen::Dynamic, 1>> src_eigen(src, in BFloat16ToFloat()
Dbfloat16_test.cc31 bfloat16 b[100]; in TEST()
46 bfloat16* out = new bfloat16[N]; in BM_FloatToBFloat16()
54 state.SetBytesProcessed(tot * (sizeof(float) + sizeof(bfloat16))); in BM_FloatToBFloat16()
65 bfloat16* out = new bfloat16[N]; in BM_RoundFloatToBFloat16()
75 state.SetBytesProcessed(tot * (sizeof(float) + sizeof(bfloat16))); in BM_RoundFloatToBFloat16()
85 bfloat16* inp = new bfloat16[N]; in BM_BFloat16ToFloat()
94 state.SetBytesProcessed(tot * (sizeof(float) + sizeof(bfloat16))); in BM_BFloat16ToFloat()
Dnumeric_types.h45 static inline tensorflow::bfloat16 FloatToBFloat16(float float_val) { in FloatToBFloat16()
47 return *reinterpret_cast<tensorflow::bfloat16*>( in FloatToBFloat16()
50 return *reinterpret_cast<tensorflow::bfloat16*>( in FloatToBFloat16()
88 struct hash<Eigen::bfloat16> {
89 std::size_t operator()(const Eigen::bfloat16& a) const {
Dbfloat16.h52 void RoundFloatToBFloat16(const float* src, bfloat16* dst, int64 size);
55 void FloatToBFloat16(const float* src, bfloat16* dst, int64 size);
57 void BFloat16ToFloat(const bfloat16* src, float* dst, int64 size);
/external/tensorflow/tensorflow/python/tpu/
Dbfloat16_test.py26 from tensorflow.python.tpu import bfloat16
36 with bfloat16.bfloat16_scope() as bf:
42 with bfloat16.bfloat16_scope('bfloat16') as bf:
53 with bfloat16.bfloat16_scope('bf16'):
54 a = math_ops.cast(a, dtypes.bfloat16)
55 b = math_ops.cast(b, dtypes.bfloat16)
57 with bfloat16.bfloat16_scope():
58 d = math_ops.cast(d, dtypes.bfloat16)
75 with bfloat16.bfloat16_scope() as scope:
78 v2 = variable_scope.get_variable("v2", [], dtype=dtypes.bfloat16)
[all …]
/external/tensorflow/tensorflow/core/kernels/
Dconcat_op_test.cc138 ConcatHelper<bfloat16>(state, 1, dim2); in BM_ConcatDim1bfloat16()
190 ConcatManyHelper<bfloat16>(state, 1, dim2); in BM_ConcatManyDim1bfloat16()
234 typedef Eigen::TensorMap<Eigen::Tensor<bfloat16, 1, Eigen::RowMajor>,
242 bfloat16* data = new bfloat16[size]; in MemcpyManyAlternative1()
247 std::vector<bfloat16*> inputs(kNumCopies); in MemcpyManyAlternative1()
251 bfloat16* result = new bfloat16[size]; in MemcpyManyAlternative1()
253 bfloat16* output = &result[j * dim2]; in MemcpyManyAlternative1()
258 memcpy(output, inputs[j], dim2 * sizeof(bfloat16)); in MemcpyManyAlternative1()
267 dim2 * kNumCopies * sizeof(bfloat16)); in MemcpyManyAlternative1()
275 bfloat16* data = new bfloat16[size]; in MemcpyManyAlternative2()
[all …]
Ddequantize_op.cc47 bfloat16 Cast<bfloat16>(float v) { in Cast()
48 return bfloat16(v); in Cast()
259 .TypeConstraint<bfloat16>("dtype"),
260 DequantizeOp<CPUDevice, quint8, bfloat16>);
264 .TypeConstraint<bfloat16>("dtype"),
265 DequantizeOp<CPUDevice, qint8, bfloat16>);
269 .TypeConstraint<bfloat16>("dtype"),
270 DequantizeOp<CPUDevice, quint16, bfloat16>);
274 .TypeConstraint<bfloat16>("dtype"),
275 DequantizeOp<CPUDevice, qint16, bfloat16>);
[all …]
Dcast_op_impl_bfloat.cc26 CURRY_TYPES3(CAST_CASE, CPUDevice, bfloat16); in GetCpuCastFromBfloat()
36 functor::CastFunctor<GPUDevice, float, bfloat16> func; in GetGpuCastFromBfloat()
38 inp.flat<bfloat16>(), truncate); in GetGpuCastFromBfloat()
/external/tensorflow/tensorflow/python/kernel_tests/
Dsparse_matmul_op_test.py79 for x_dtype in (dtypes.float32, dtypes.bfloat16):
80 for y_dtype in (dtypes.float32, dtypes.bfloat16):
87 for x_dtype in (dtypes.float32, dtypes.bfloat16):
88 for y_dtype in (dtypes.float32, dtypes.bfloat16):
95 for x_dtype in (dtypes.float32, dtypes.bfloat16):
96 for y_dtype in (dtypes.float32, dtypes.bfloat16):
106 for x_dtype in (dtypes.float32, dtypes.bfloat16):
107 for y_dtype in (dtypes.float32, dtypes.bfloat16):
119 for x_dtype in (dtypes.float32, dtypes.bfloat16):
120 for y_dtype in (dtypes.float32, dtypes.bfloat16):
[all …]
/external/tensorflow/tensorflow/compiler/xla/
Dbit_cast.h46 inline tensorflow::bfloat16 BitCast<tensorflow::bfloat16, uint16_t>(
48 tensorflow::bfloat16 result;
54 inline uint16 BitCast<uint16, tensorflow::bfloat16>(tensorflow::bfloat16 src) {
Dliteral_util.cc93 return ConvertType<bfloat16, float>(bf16_literal); in ConvertBF16ToF32()
98 return ConvertType<bfloat16, double>(bf16_literal); in ConvertBF16ToF64()
103 return ConvertType<float, bfloat16>(f32_literal); in ConvertF32ToBF16()
113 return ConvertType<double, bfloat16>(f64_literal); in ConvertF64ToBF16()
146 return LiteralUtil::CreateR0<bfloat16>(static_cast<bfloat16>(0.0f)); in Zero()
187 return LiteralUtil::CreateR0<bfloat16>(static_cast<bfloat16>(1.0f)); in One()
241 return LiteralUtil::CreateR0<bfloat16>( in MinValue()
242 static_cast<bfloat16>(-std::numeric_limits<float>::infinity())); in MinValue()
282 return LiteralUtil::CreateR0<bfloat16>( in MaxValue()
283 static_cast<bfloat16>(std::numeric_limits<float>::infinity())); in MaxValue()
[all …]
Dliteral_test.cc124 auto bf16_lit = LiteralUtil::CreateR0<bfloat16>(static_cast<bfloat16>(0.5f)); in TEST_F()
129 LiteralUtil::CreateR0<bfloat16>(static_cast<bfloat16>(3.14f)); in TEST_F()
133 LiteralUtil::CreateR0<bfloat16>(static_cast<bfloat16>(9.001f)); in TEST_F()
536 bfloat16 b8(8.0f); in TEST_F()
537 bfloat16 b9(9.0f); in TEST_F()
539 EXPECT_TRUE(LiteralUtil::CreateR2<bfloat16>({{b8}, {b8}}).IsAll(8)); in TEST_F()
540 EXPECT_FALSE(LiteralUtil::CreateR2<bfloat16>({{b8}, {b9}}).IsAll(8)); in TEST_F()
541 EXPECT_FALSE(LiteralUtil::CreateR2<bfloat16>({{b9}, {b8}}).IsAll(8)); in TEST_F()
544 bfloat16 b91(9.001f); in TEST_F()
545 bfloat16 b90(9.00f); in TEST_F()
[all …]
Dbit_cast_test.cc25 using ::tensorflow::bfloat16;
30 bfloat16 float_val = BitCast<bfloat16>(initial_rep); in TEST()
/external/tensorflow/tensorflow/core/kernels/mkl/
Dmkl_cwise_ops_common.cc72 int32, int64, bfloat16);
74 double, int32, int64, bfloat16);
76 int32, int64, complex64, complex128, bfloat16);
78 uint8, int32, bfloat16);
80 double, int32, int64, bfloat16);
83 bfloat16);
/external/tensorflow/tensorflow/core/lib/random/
Drandom_distributions.h35 PHILOX_DEVICE_INLINE bfloat16 Uint16ToGfloat16(uint16 x);
94 class UniformDistribution<Generator, bfloat16> {
103 typedef Array<bfloat16, kResultElementCount> ResultType;
104 typedef bfloat16 ResultElementType;
417 class NormalDistribution<Generator, bfloat16> {
426 typedef Array<bfloat16, kResultElementCount> ResultType;
427 typedef bfloat16 ResultElementType;
439 result[i] = bfloat16(f[0]); in operator()
440 result[i + 1] = bfloat16(f[1]); in operator()
560 class TruncatedNormalDistribution<SingleSampleGenerator, bfloat16> {
[all …]

12345678910>>...13