Avoid retaining two copies of each constant in `ConstantOp`.
authorDerek Murray <mrry@google.com>
Sun, 4 Feb 2018 19:24:51 +0000 (11:24 -0800)
committerTensorFlower Gardener <gardener@tensorflow.org>
Sun, 4 Feb 2018 19:28:47 +0000 (11:28 -0800)
commitfc09f65a5d283baa9af182536e3e3652c7a41dd7
treeded2909f5abbd5aff90c5d22e02d5a03ae059afb
parentde6037d7505cd24b24fd937d1c011c8d24ca0e81
Avoid retaining two copies of each constant in `ConstantOp`.

Presently, the kernel keeps two copies of the constant tensor value, which can be large:
1. In the `ConstantOp::tensor_` field.
2. In the `OpKernel::def_` field (as an attr of the `NodeDef`).

Since we can be sure that `ConstantOp` will never need to access the
tensor value from `OpKernel::def_`, this change introduces a mechanism
for `OpKernel` implementations to store a stripped `NodeDef` in the
base class, and uses it in `ConstantOp` to avoid storing the tensor
value attr.

PiperOrigin-RevId: 184455793
tensorflow/core/framework/op_kernel.cc
tensorflow/core/framework/op_kernel.h
tensorflow/core/kernels/constant_op.cc