| 69 | } // namespace |
| 70 | |
| 71 | ConstantOp::ConstantOp(OpKernelConstruction* ctx) |
| 72 | : OpKernel(ctx, StripTensorDataFromNodeDef(ctx)), |
| 73 | tensor_(ctx->output_type(0)) { |
| 74 | const TensorProto* proto = nullptr; |
| 75 | OP_REQUIRES_OK(ctx, ctx->GetAttr("value", &proto)); |
| 76 | OP_REQUIRES_OK(ctx, ctx->device()->MakeTensorFromProto( |
| 77 | *proto, AllocatorAttributes(), &tensor_)); |
| 78 | OP_REQUIRES( |
| 79 | ctx, ctx->output_type(0) == tensor_.dtype(), |
| 80 | errors::InvalidArgument("Type mismatch between value (", |
| 81 | DataTypeString(tensor_.dtype()), ") and dtype (", |
| 82 | DataTypeString(ctx->output_type(0)), ")")); |
| 83 | } |
| 84 | |
| 85 | void ConstantOp::Compute(OpKernelContext* ctx) { |
| 86 | ctx->set_output(0, tensor_); |
nothing calls this directly
no test coverage detected