| 77 | explicit SummaryTensorOp(OpKernelConstruction* context) : OpKernel(context) {} |
| 78 | |
| 79 | void Compute(OpKernelContext* c) override { |
| 80 | const Tensor& tensor = c->input(0); |
| 81 | |
| 82 | Summary s; |
| 83 | Summary::Value* v = s.add_value(); |
| 84 | v->set_node_name(c->op_kernel().name()); |
| 85 | |
| 86 | if (tensor.dtype() == DT_STRING) { |
| 87 | // tensor_util.makeNdarray doesn't work for strings in tensor_content |
| 88 | tensor.AsProtoField(v->mutable_tensor()); |
| 89 | } else { |
| 90 | tensor.AsProtoTensorContent(v->mutable_tensor()); |
| 91 | } |
| 92 | |
| 93 | Tensor* summary_tensor = nullptr; |
| 94 | OP_REQUIRES_OK(c, c->allocate_output(0, TensorShape({}), &summary_tensor)); |
| 95 | CHECK(SerializeToTString(s, &summary_tensor->scalar<tstring>()())); |
| 96 | } |
| 97 | }; |
| 98 | |
| 99 | #define REGISTER(T) \ |
nothing calls this directly
no test coverage detected