| 25 | namespace tensorflow { |
| 26 | |
| 27 | _HostConstantOp::_HostConstantOp(OpKernelConstruction* ctx) |
| 28 | : OpKernel(ctx), tensor_(ctx->output_type(0)) { |
| 29 | const TensorProto* proto = nullptr; |
| 30 | AllocatorAttributes alloc_attr; |
| 31 | alloc_attr.set_on_host(true); |
| 32 | OP_REQUIRES_OK(ctx, ctx->GetAttr("value", &proto)); |
| 33 | OP_REQUIRES_OK( |
| 34 | ctx, ctx->device()->MakeTensorFromProto(*proto, alloc_attr, &tensor_)); |
| 35 | OP_REQUIRES( |
| 36 | ctx, ctx->output_type(0) == tensor_.dtype(), |
| 37 | errors::InvalidArgument("Type mismatch between value (", |
| 38 | DataTypeString(tensor_.dtype()), ") and dtype (", |
| 39 | DataTypeString(ctx->output_type(0)), ")")); |
| 40 | } |
| 41 | |
| 42 | void _HostConstantOp::Compute(OpKernelContext* ctx) { |
| 43 | ctx->set_output(0, tensor_); |
nothing calls this directly
no test coverage detected