Fix HandleCopies so it no longer invokes UB when the params or out TensorMaps are empty with no backing data.

PiperOrigin-RevId: 313686113
Change-Id: I4b38d7e7e8cebb40d8b7f2390f841f0b541a01e5
This commit is contained in:
A. Unique TensorFlower 2020-05-28 16:54:35 -07:00 committed by TensorFlower Gardener
parent f5e17f30bd
commit 547daed259

View File

@ -44,8 +44,8 @@ SliceIndex HandleCopies(OpKernelContext* ctx,
const SliceIndex indices_size = static_cast<SliceIndex>(indices.dimension(0));
const SliceIndex batch_size = static_cast<SliceIndex>(params.dimension(0));
const Index limit = static_cast<Index>(params.dimension(1));
T* out_base = &out(0, 0, 0);
const T* params_base = &params(0, 0, 0);
T* out_base = out.data();
const T* params_base = params.data();
if (static_slice_elems >= 0) {
// Give compiler static knowledge of the number of elements/bytes
slice_elems = static_slice_elems;