| 59 | }; |
| 60 | |
| 61 | TEST_F(SummaryTensorOpV2Test, BasicPluginData) { |
| 62 | MakeOp(); |
| 63 | |
| 64 | // Feed and run |
| 65 | AddInputFromArray<tstring>(TensorShape({}), {"tag_foo"}); |
| 66 | AddInputFromArray<tstring>(TensorShape({}), {"some string tensor content"}); |
| 67 | |
| 68 | // Create a SummaryMetadata that stores data for 2 plugins. |
| 69 | SummaryMetadata summary_metadata; |
| 70 | SummaryMetadata::PluginData* plugin_data = |
| 71 | summary_metadata.mutable_plugin_data(); |
| 72 | plugin_data->set_plugin_name("foo"); |
| 73 | plugin_data->set_content("content_for_plugin_foo"); |
| 74 | AddInputFromArray<tstring>(TensorShape({}), |
| 75 | {summary_metadata.SerializeAsString()}); |
| 76 | |
| 77 | TF_ASSERT_OK(RunOpKernel()); |
| 78 | |
| 79 | // Check the output size. |
| 80 | Tensor* out_tensor = GetOutput(0); |
| 81 | ASSERT_EQ(0, out_tensor->dims()); |
| 82 | Summary summary; |
| 83 | ParseProtoUnlimited(&summary, out_tensor->scalar<tstring>()()); |
| 84 | ASSERT_EQ(1, summary.value_size()); |
| 85 | |
| 86 | // Check the content of the tensor stored in the summary. |
| 87 | Tensor string_content_tensor; |
| 88 | CHECK(string_content_tensor.FromProto(summary.value(0).tensor())); |
| 89 | ASSERT_EQ("some string tensor content", |
| 90 | string_content_tensor.scalar<tstring>()()); |
| 91 | |
| 92 | // Check plugin-related data. |
| 93 | ASSERT_EQ("tag_foo", summary.value(0).tag()); |
| 94 | ASSERT_EQ("foo", summary.value(0).metadata().plugin_data().plugin_name()); |
| 95 | ASSERT_EQ("content_for_plugin_foo", |
| 96 | summary.value(0).metadata().plugin_data().content()); |
| 97 | } |
| 98 | |
| 99 | } // namespace |
| 100 | } // namespace tensorflow |
nothing calls this directly
no test coverage detected