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

Function TEST

tensorflow/compiler/xla/text_literal_reader_test.cc:30–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28namespace {
29
30TEST(TextLiteralReaderTest, ReadsR3File) {
31 string contents = R"(f32[1,2,3]
32(0,0,0): 42.5
33(0,0,1): 43.5
34(0,0,2): 44.5
35(0,1,0): 45.5
36(0,1,1): 46.5
37(0,1,2): 47.5
38)";
39
40 string fname = tensorflow::testing::TmpDir() + "/ReadsR3File.data.txt";
41 EXPECT_TRUE(
42 tensorflow::WriteStringToFile(tensorflow::Env::Default(), fname, contents)
43 .ok());
44
45 Literal literal = TextLiteralReader::ReadPath(fname).ConsumeValueOrDie();
46 EXPECT_TRUE(
47 ShapeUtil::Equal(ShapeUtil::MakeShape(F32, {1, 2, 3}), literal.shape()));
48 EXPECT_EQ(42.5, literal.Get<float>({0, 0, 0}));
49 EXPECT_EQ(43.5, literal.Get<float>({0, 0, 1}));
50 EXPECT_EQ(44.5, literal.Get<float>({0, 0, 2}));
51 EXPECT_EQ(45.5, literal.Get<float>({0, 1, 0}));
52 EXPECT_EQ(46.5, literal.Get<float>({0, 1, 1}));
53 EXPECT_EQ(47.5, literal.Get<float>({0, 1, 2}));
54}
55
56} // namespace
57} // namespace xla

Callers

nothing calls this directly

Calls 8

TmpDirFunction · 0.85
WriteStringToFileFunction · 0.85
DefaultFunction · 0.85
MakeShapeFunction · 0.85
ConsumeValueOrDieMethod · 0.80
EqualClass · 0.70
okMethod · 0.45
shapeMethod · 0.45

Tested by

no test coverage detected