MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / UniformTest

Method UniformTest

tensorflow/compiler/xla/tests/prng_test.cc:51–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49
50template <typename T>
51Literal PrngTest::UniformTest(T a, T b, absl::Span<const int64> dims,
52 int64 seed) {
53 XlaBuilder builder(TestName());
54 RngUniform(
55 ConstantR0<T>(&builder, a), ConstantR0<T>(&builder, b),
56 ShapeUtil::MakeShape(primitive_util::NativeToPrimitiveType<T>(), dims));
57
58 SetSeed(seed);
59 auto actual =
60 ExecuteAndTransfer(&builder, /*arguments=*/{}).ConsumeValueOrDie();
61 EXPECT_THAT(dims, ::testing::ElementsAreArray(actual.shape().dimensions()));
62 actual.EachCell<T>([=](absl::Span<const int64>, T value) {
63 EXPECT_LE(a, value);
64 EXPECT_LT(value, b);
65 });
66 return actual;
67}
68
69// Uniform random number generation tests
70XLA_TEST_F(PrngTest, ScalarU01) { UniformTest<float>(0, 1, {}); }

Callers

nothing calls this directly

Calls 6

TestNameFunction · 0.85
RngUniformFunction · 0.85
MakeShapeFunction · 0.85
ConsumeValueOrDieMethod · 0.80
dimensionsMethod · 0.45
shapeMethod · 0.45

Tested by

no test coverage detected