| 35 | namespace { |
| 36 | |
| 37 | TEST(AttrTypeMap, Lookup) { |
| 38 | const AttrTypeMap* m = nullptr; |
| 39 | // Unknown ops are assumed to be functions. |
| 40 | // Their maps are filled with default attributes. |
| 41 | bool is_function = false; |
| 42 | Status s = AttrTypeMapForOp("SomeFunctionName", &m, &is_function); |
| 43 | EXPECT_TRUE(s.ok()); |
| 44 | EXPECT_TRUE(is_function); |
| 45 | ASSERT_NE(m->end(), m->find("executor_type")); |
| 46 | EXPECT_EQ(TF_ATTR_STRING, m->find("executor_type")->second); |
| 47 | ASSERT_NE(m->end(), m->find("config_proto")); |
| 48 | EXPECT_EQ(TF_ATTR_STRING, m->find("config_proto")->second); |
| 49 | |
| 50 | is_function = true; |
| 51 | s = AttrTypeMapForOp("MatMul", &m, &is_function); |
| 52 | EXPECT_FALSE(is_function); |
| 53 | ASSERT_TRUE(s.ok()) << s; |
| 54 | |
| 55 | TF_AttrType t; |
| 56 | unsigned char is_list = 1; |
| 57 | s = AttrTypeByName(*m, "ThisAttribyteCannotPossiblyExist", &t, &is_list); |
| 58 | EXPECT_FALSE(s.ok()); |
| 59 | EXPECT_NE(is_list, 0); |
| 60 | s = AttrTypeByName(*m, "transpose_a", &t, &is_list); |
| 61 | ASSERT_TRUE(s.ok()) << s; |
| 62 | EXPECT_EQ(TF_ATTR_BOOL, t); |
| 63 | EXPECT_EQ(is_list, 0); |
| 64 | |
| 65 | s = AttrTypeMapForOp("Squeeze", &m, &is_function); |
| 66 | ASSERT_TRUE(s.ok()) << s; |
| 67 | s = AttrTypeByName(*m, "squeeze_dims", &t, &is_list); |
| 68 | ASSERT_TRUE(s.ok()) << s; |
| 69 | EXPECT_EQ(TF_ATTR_INT, t); |
| 70 | EXPECT_NE(is_list, 0); |
| 71 | } |
| 72 | |
| 73 | TEST(AttrTypeMap, CacheKey) { |
| 74 | AttrBuilder a("op_name"); |
nothing calls this directly
no test coverage detected