| 130 | }; |
| 131 | |
| 132 | TEST_F(GraphPropertiesTest, StaticProperties) { |
| 133 | TrivialTestGraphInputYielder fake_input(4, 1, 10, false, |
| 134 | cluster_->GetDeviceNames()); |
| 135 | GrapplerItem item; |
| 136 | CHECK(fake_input.NextItem(&item)); |
| 137 | |
| 138 | GraphProperties properties(item); |
| 139 | Status s = properties.InferStatically(true); |
| 140 | TF_CHECK_OK(s); |
| 141 | |
| 142 | for (const auto& node : item.graph.node()) { |
| 143 | if (node.op() == "RandomStandardNormal") { |
| 144 | // The node has one input (the shape of the tensor to generate). |
| 145 | EXPECT_EQ(1, properties.GetInputProperties(node.name()).size()); |
| 146 | // The const node has one output. |
| 147 | const auto props = properties.GetOutputProperties(node.name()); |
| 148 | EXPECT_EQ(1, props.size()); |
| 149 | const OpInfo::TensorProperties& prop = props[0]; |
| 150 | EXPECT_EQ(DT_FLOAT, prop.dtype()); |
| 151 | EXPECT_FALSE(prop.shape().unknown_rank()); |
| 152 | EXPECT_EQ(2, prop.shape().dim_size()); |
| 153 | EXPECT_EQ(10, prop.shape().dim(0).size()); |
| 154 | EXPECT_EQ(1, prop.shape().dim(1).size()); |
| 155 | } else if (node.op() == "AddN") { |
| 156 | const auto in_props = properties.GetInputProperties(node.name()); |
| 157 | EXPECT_EQ(1, in_props.size()); |
| 158 | const OpInfo::TensorProperties& in_prop = in_props[0]; |
| 159 | EXPECT_EQ(DT_FLOAT, in_prop.dtype()); |
| 160 | EXPECT_FALSE(in_prop.shape().unknown_rank()); |
| 161 | EXPECT_EQ(2, in_prop.shape().dim_size()); |
| 162 | EXPECT_EQ(10, in_prop.shape().dim(0).size()); |
| 163 | EXPECT_EQ(1, in_prop.shape().dim(1).size()); |
| 164 | const auto out_props = properties.GetOutputProperties(node.name()); |
| 165 | EXPECT_EQ(1, out_props.size()); |
| 166 | string in_prop_str; |
| 167 | ::tensorflow::protobuf::TextFormat::PrintToString(in_prop, &in_prop_str); |
| 168 | string out_prop_str; |
| 169 | ::tensorflow::protobuf::TextFormat::PrintToString(out_props[0], |
| 170 | &out_prop_str); |
| 171 | EXPECT_EQ(in_prop_str, out_prop_str); |
| 172 | } |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | TEST_F(GraphPropertiesTest, ClearProperties) { |
| 177 | TrivialTestGraphInputYielder fake_input(4, 1, 10, false, |
nothing calls this directly
no test coverage detected