/external/tensorflow/tensorflow/compiler/xla/tests/ |
D | bfloat16_test.cc | 54 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 …]
|
D | prng_test.cc | 92 UniformTest<bfloat16>(static_cast<bfloat16>(low), in XLA_TEST_F() 93 static_cast<bfloat16>(high), {}, /*seed=*/seed); in XLA_TEST_F() 96 UniformTest<bfloat16>(static_cast<bfloat16>(32.75), in XLA_TEST_F() 97 static_cast<bfloat16>(33), {}, /*seed=*/seed); in XLA_TEST_F() 98 UniformTest<bfloat16>(static_cast<bfloat16>(32.50), in XLA_TEST_F() 99 static_cast<bfloat16>(32.75), {}, /*seed=*/seed); in XLA_TEST_F() 100 UniformTest<bfloat16>(static_cast<bfloat16>(-33.00), in XLA_TEST_F() 101 static_cast<bfloat16>(-32.75), {}, /*seed=*/seed); in XLA_TEST_F() 102 UniformTest<bfloat16>(static_cast<bfloat16>(-32.75), in XLA_TEST_F() 103 static_cast<bfloat16>(-32.50), {}, /*seed=*/seed); in XLA_TEST_F() [all …]
|
D | dynamic_ops_test.cc | 217 XLA_TEST_F(DynamicSliceTest, Int32R1BF16) { TestR1<int32, bfloat16>(); } in XLA_TEST_F() 226 XLA_TEST_F(DynamicSliceTest, Int32R2BF16) { TestR2<int32, bfloat16>(); } in XLA_TEST_F() 235 XLA_TEST_F(DynamicSliceTest, Int32R3BF16) { TestR3<int32, bfloat16>(); } in XLA_TEST_F() 568 XLA_TEST_F(DynamicUpdateSliceTest, Int32R0BF16) { TestR0<int32, bfloat16>(); } in XLA_TEST_F() 573 XLA_TEST_F(DynamicUpdateSliceTest, Int32R1BF16) { TestR1<int32, bfloat16>(); } in XLA_TEST_F() 581 XLA_TEST_F(DynamicUpdateSliceTest, Int32R2BF16) { TestR2<int32, bfloat16>(); } in XLA_TEST_F() 590 XLA_TEST_F(DynamicUpdateSliceTest, Int32R3BF16) { TestR3<int32, bfloat16>(); } in XLA_TEST_F() 600 XLA_TEST_F(DynamicUpdateSliceTest, Int32OOBBF16) { TestOOB<int32, bfloat16>(); } in XLA_TEST_F() 674 RunR3Contiguous<bfloat16>(operand_shape, /*index=*/1, /*size=*/1); in XLA_TEST_F() 686 RunR3Contiguous<bfloat16>(operand_shape, /*index=*/1, /*size=*/2); in XLA_TEST_F() [all …]
|
/external/tensorflow/tensorflow/core/lib/bfloat16/ |
D | bfloat16.h | 45 struct bfloat16 { struct 48 B16_DEVICE_FUNC bfloat16() : value(ZERO_VALUE) {} in bfloat16() argument 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() function 69 B16_DEVICE_FUNC explicit bfloat16(const double val) in bfloat16() argument 70 : bfloat16(static_cast<float>(val)) {} in bfloat16() 73 B16_DEVICE_FUNC explicit bfloat16(const complex64& val) in bfloat16() argument 74 : bfloat16(val.real()) {} in bfloat16() 76 B16_DEVICE_FUNC explicit bfloat16(const complex128& val) in bfloat16() function [all …]
|
D | bfloat16.cc | 22 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/compiler/xla/client/lib/ |
D | quantize_test.cc | 30 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 …]
|
D | constants.cc | 51 return ConstantR0<bfloat16>(builder, bfloat16::epsilon()); in Epsilon() 73 return ConstantR0<bfloat16>(builder, bfloat16::lowest()); in MinFiniteValue() 89 return ConstantR0<bfloat16>(builder, bfloat16::min_positive_normal()); in MinPositiveNormalValue() 111 return ConstantR0<bfloat16>(builder, bfloat16::highest()); in MaxFiniteValue() 128 return ConstantR0<bfloat16>( in NanValue() 129 builder, bfloat16(std::numeric_limits<float>::quiet_NaN())); in NanValue()
|
D | quantize.h | 45 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/python/lib/core/ |
D | bfloat16_test.py | 32 bfloat16 = pywrap_tensorflow.TF_bfloat16_type() variable 53 self._assertFloatIdentical(v, float(bfloat16(v))) 57 self.assertEqual(v, int(bfloat16(v))) 60 self.assertEqual("0", str(bfloat16(0.0))) 61 self.assertEqual("1", str(bfloat16(1.0))) 62 self.assertEqual("-3.5", str(bfloat16(-3.5))) 63 self.assertEqual("0.0078125", str(bfloat16(float.fromhex("1.0p-7")))) 64 self.assertEqual("inf", str(bfloat16(float("inf")))) 65 self.assertEqual("-inf", str(bfloat16(float("-inf")))) 66 self.assertEqual("nan", str(bfloat16(float("nan")))) [all …]
|
D | bfloat16.cc | 81 bfloat16 value; 91 bfloat16 PyBfloat16_Bfloat16(PyObject* object) { in PyBfloat16_Bfloat16() 96 Safe_PyObjectPtr PyBfloat16_FromBfloat16(bfloat16 x) { in PyBfloat16_FromBfloat16() 108 bool AsBfloat16(PyObject* arg, bfloat16* output) { in AsBfloat16() 119 *output = bfloat16(d); in AsBfloat16() 128 *output = bfloat16(static_cast<float>(l)); in AsBfloat16() 134 *output = bfloat16(f); in AsBfloat16() 144 bfloat16 x = PyBfloat16_Bfloat16(self); in PyBfloat16_Float() 150 bfloat16 x = PyBfloat16_Bfloat16(self); in PyBfloat16_Int() 157 bfloat16 x = PyBfloat16_Bfloat16(self); in PyBfloat16_Negative() [all …]
|
/external/tensorflow/tensorflow/core/framework/ |
D | numeric_types.h | 49 static inline tensorflow::bfloat16 FloatToBFloat16(float float_val) { in FloatToBFloat16() 51 return *reinterpret_cast<tensorflow::bfloat16*>( in FloatToBFloat16() 54 return *reinterpret_cast<tensorflow::bfloat16*>( in FloatToBFloat16() 63 struct NumTraits<tensorflow::bfloat16> 64 : GenericNumTraits<tensorflow::bfloat16> { 70 static EIGEN_STRONG_INLINE tensorflow::bfloat16 highest() { 74 static EIGEN_STRONG_INLINE tensorflow::bfloat16 lowest() { 78 static EIGEN_STRONG_INLINE tensorflow::bfloat16 infinity() { 82 static EIGEN_STRONG_INLINE tensorflow::bfloat16 quiet_NaN() { 94 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE tensorflow::bfloat16 log( [all …]
|
D | bfloat16_test.cc | 27 EXPECT_EQ(0.0f, static_cast<float>(bfloat16())); in TEST() 36 EXPECT_EQ(v, static_cast<float>(static_cast<bfloat16>(v))); in TEST() 41 bfloat16 a(12); in TEST() 62 bfloat16 truncated = bfloat16::truncate_to_bfloat16((GetParam().input)); in TEST_P() 70 bfloat16 rounded = bfloat16::round_to_bfloat16((GetParam().input)); in TEST_P() 131 bfloat16 b[100]; in TEST() 143 EXPECT_LT(1.0f, static_cast<float>(bfloat16::epsilon() + bfloat16(1.0f))); in TEST() 144 EXPECT_EQ(1.0f, static_cast<float>((bfloat16::epsilon() / bfloat16(2.0f)) + in TEST() 145 bfloat16(1.0f))); in TEST() 149 EXPECT_EQ(-3.0f, static_cast<float>(-bfloat16(3.0f))); in TEST() [all …]
|
/external/tensorflow/tensorflow/compiler/tests/ |
D | sort_ops_test.py | 52 [dtypes.bfloat16.as_numpy_dtype, np.float32, np.int32, np.uint32]) 61 [dtypes.bfloat16.as_numpy_dtype, np.float32, np.int32, np.uint32]) 63 [dtypes.bfloat16.as_numpy_dtype, np.float32, np.int32, np.uint32, 79 [dtypes.bfloat16.as_numpy_dtype, np.float32, np.int32, np.uint32]) 84 if dtype == dtypes.bfloat16.as_numpy_dtype: 104 [dtypes.bfloat16.as_numpy_dtype, np.float32, np.int32, np.uint32]) 109 if dtype == dtypes.bfloat16.as_numpy_dtype: 133 bfloat16 = dtypes.bfloat16.as_numpy_dtype 134 if bfloat16 not in self.numeric_types: 138 p = array_ops.placeholder(dtypes.bfloat16) [all …]
|
/external/tensorflow/tensorflow/core/kernels/ |
D | concat_op_test.cc | 88 ConcatHelper<bfloat16>(iters, 1, dim2); in BM_ConcatDim1bfloat16() 128 ConcatManyHelper<bfloat16>(iters, 1, dim2); in BM_ConcatManyDim1bfloat16() 163 typedef Eigen::TensorMap<Eigen::Tensor<bfloat16, 1, Eigen::RowMajor>, 172 bfloat16* data = new bfloat16[size]; in MemcpyManyAlternative1() 177 kNumCopies * sizeof(bfloat16)); in MemcpyManyAlternative1() 180 std::vector<bfloat16*> inputs(kNumCopies); in MemcpyManyAlternative1() 184 bfloat16* result = new bfloat16[size]; in MemcpyManyAlternative1() 186 bfloat16* output = &result[j * dim2]; in MemcpyManyAlternative1() 191 memcpy(output, inputs[j], dim2 * sizeof(bfloat16)); in MemcpyManyAlternative1() 207 bfloat16* data = new bfloat16[size]; in MemcpyManyAlternative2() [all …]
|
D | cast_op.h | 75 SPECIALIZE_CAST(devname, bfloat16, float) \ 134 constexpr int MantissaWidth<bfloat16>() { 283 struct scalar_cast_op<::tensorflow::bfloat16, float> { 287 const ::tensorflow::bfloat16& a) const { 304 struct functor_traits<scalar_cast_op<::tensorflow::bfloat16, float>> { 309 struct scalar_cast_op<float, ::tensorflow::bfloat16> { 311 typedef ::tensorflow::bfloat16 result_type; 312 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const ::tensorflow::bfloat16 operator()( 314 return ::tensorflow::bfloat16(a); 319 struct functor_traits<scalar_cast_op<float, ::tensorflow::bfloat16>> {
|
D | sparse_matmul_op.cc | 168 ALWAYS_INLINE bool IsZero(bfloat16 v) { in IsZero() 285 ALWAYS_INLINE float ConvertBfloat16ToFloat(const bfloat16* src) { in ConvertBfloat16ToFloat() 287 auto tmp = reinterpret_cast<bfloat16*>(&out); in ConvertBfloat16ToFloat() 296 ALWAYS_INLINE Packet ConvertFourBfloat16ToFloat(const bfloat16* src) { in ConvertFourBfloat16ToFloat() 301 ALWAYS_INLINE Packet ConvertTwoBfloat16ToFloat(const bfloat16* src) { in ConvertTwoBfloat16ToFloat() 312 ALWAYS_INLINE void ScalarMulAdd(const float a, const bfloat16** inp, in ScalarMulAdd() 320 const float a3, const bfloat16** inp1, in ScalarMulAdd3Way() 321 const bfloat16** inp2, in ScalarMulAdd3Way() 322 const bfloat16** inp3, float** out) { in ScalarMulAdd3Way() 344 ALWAYS_INLINE void LoadSingleScalar(const bfloat16** data, Packet* l) { in LoadSingleScalar() [all …]
|
D | cast_op_impl_bfloat.cc | 26 CURRY_TYPES3(CAST_CASE, CPUDevice, bfloat16); in GetCpuCastFromBfloat() 35 functor::CastFunctor<GPUDevice, float, bfloat16> func; in GetGpuCastFromBfloat() 37 inp.flat<bfloat16>(), truncate); in GetGpuCastFromBfloat()
|
D | cast_op_test.cc | 92 TEST_CAST(in, bfloat16); \ 109 TEST_ALL_CASTS_FROM(bfloat16) in TEST_ALL_CASTS_FROM() 170 (sizeof(float) + sizeof(bfloat16))); in BM_cpu_float_bfloat16() 172 test::Benchmark("cpu", Cast<float, bfloat16>(num)).Run(iters); in BM_cpu_float_bfloat16() 179 (sizeof(float) + sizeof(bfloat16))); in BM_cpu_bfloat16_float() 181 test::Benchmark("cpu", Cast<bfloat16, float>(num)).Run(iters); in BM_cpu_bfloat16_float()
|
/external/tensorflow/tensorflow/python/kernel_tests/ |
D | sparse_matmul_op_test.py | 79 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/python/tpu/ |
D | bfloat16_test.py | 26 from tensorflow.python.tpu import bfloat16 34 with bfloat16.bfloat16_scope() as bf: 41 with bfloat16.bfloat16_scope() as scope: 44 v2 = variable_scope.get_variable("v2", [], dtype=dtypes.bfloat16) 45 self.assertEqual(v2.dtype.base_dtype, dtypes.bfloat16)
|
/external/tensorflow/tensorflow/core/lib/random/ |
D | random_distributions.h | 38 PHILOX_DEVICE_INLINE bfloat16 Uint16ToGfloat16(uint16 x); 97 class UniformDistribution<Generator, bfloat16> { 106 typedef Array<bfloat16, kResultElementCount> ResultType; 107 typedef bfloat16 ResultElementType; 353 class NormalDistribution<Generator, bfloat16> { 362 typedef Array<bfloat16, kResultElementCount> ResultType; 363 typedef bfloat16 ResultElementType; 375 result[i] = bfloat16(f[0]); in operator() 376 result[i + 1] = bfloat16(f[1]); in operator() 492 class TruncatedNormalDistribution<SingleSampleGenerator, bfloat16> { [all …]
|
D | random_distributions_test.cc | 261 UniformMomentsTest<bfloat16>(1 << 20, 40, strides, bfloat16(kZLimitBfloat16)); in TEST() 266 NormalMomentsTest<bfloat16>(8 << 20, 25, strides, bfloat16(kZLimitBfloat16)); in TEST() 271 RandomParametersMomentsTest<bfloat16>(1 << 20, 40, strides, in TEST() 272 bfloat16(kZLimitBfloat16)); in TEST()
|
/external/tensorflow/tensorflow/compiler/xla/ |
D | literal_test.cc | 124 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() 540 bfloat16 b8(8.0f); in TEST_F() 541 bfloat16 b9(9.0f); in TEST_F() 543 EXPECT_TRUE(LiteralUtil::CreateR2<bfloat16>({{b8}, {b8}}).IsAll(8)); in TEST_F() 544 EXPECT_FALSE(LiteralUtil::CreateR2<bfloat16>({{b8}, {b9}}).IsAll(8)); in TEST_F() 545 EXPECT_FALSE(LiteralUtil::CreateR2<bfloat16>({{b9}, {b8}}).IsAll(8)); in TEST_F() 548 bfloat16 b91(9.001f); in TEST_F() 549 bfloat16 b90(9.00f); in TEST_F() [all …]
|
D | literal_util.cc | 93 return ConvertType<bfloat16, float>(bf16_literal); in ConvertBF16ToF32() 98 return ConvertType<float, bfloat16>(f32_literal); in ConvertF32ToBF16() 126 return LiteralUtil::CreateR0<bfloat16>(static_cast<bfloat16>(0.0f)); in Zero() 163 return LiteralUtil::CreateR0<bfloat16>(static_cast<bfloat16>(1.0f)); in One() 219 return LiteralUtil::CreateR0<bfloat16>( in MinValue() 220 static_cast<bfloat16>(-std::numeric_limits<float>::infinity())); in MinValue() 259 return LiteralUtil::CreateR0<bfloat16>( in MaxValue() 260 static_cast<bfloat16>(std::numeric_limits<float>::infinity())); in MaxValue() 381 return LiteralUtil::CreateR0<bfloat16>( in GetFirstScalarLiteral() 382 literal.GetFirstElement<bfloat16>()); in GetFirstScalarLiteral()
|
/external/tensorflow/tensorflow/compiler/tf2xla/lib/ |
D | util.cc | 46 return xla::ConstantR0<bfloat16>(builder, static_cast<bfloat16>(value)); in FloatLiteral() 106 xla::LiteralUtil::CreateR0<bfloat16>(static_cast<bfloat16>(value)); in IntegerLiteral()
|