| 31 | : OpKernel(context) {} |
| 32 | |
| 33 | void Compute(OpKernelContext* c) override { |
| 34 | const Tensor& tag = c->input(0); |
| 35 | OP_REQUIRES(c, IsLegacyScalar(tag.shape()), |
| 36 | errors::InvalidArgument("tag must be scalar")); |
| 37 | const Tensor& tensor = c->input(1); |
| 38 | const Tensor& serialized_summary_metadata_tensor = c->input(2); |
| 39 | |
| 40 | Summary s; |
| 41 | Summary::Value* v = s.add_value(); |
| 42 | v->set_tag(string(tag.scalar<tstring>()())); // NOLINT |
| 43 | |
| 44 | if (tensor.dtype() == DT_STRING) { |
| 45 | // tensor_util.makeNdarray doesn't work for strings in tensor_content |
| 46 | tensor.AsProtoField(v->mutable_tensor()); |
| 47 | } else { |
| 48 | tensor.AsProtoTensorContent(v->mutable_tensor()); |
| 49 | } |
| 50 | |
| 51 | v->mutable_metadata()->ParseFromString( |
| 52 | serialized_summary_metadata_tensor.scalar<tstring>()()); |
| 53 | |
| 54 | Tensor* summary_tensor = nullptr; |
| 55 | OP_REQUIRES_OK(c, c->allocate_output(0, TensorShape({}), &summary_tensor)); |
| 56 | CHECK(SerializeToTString(s, &summary_tensor->scalar<tstring>()())); |
| 57 | } |
| 58 | }; |
| 59 | |
| 60 | #define REGISTER(T) \ |
nothing calls this directly
no test coverage detected