Skip to content
Permalink
Browse files Browse the repository at this point in the history
Fix tf.raw_ops.SparseAdd invalid memory access failure.
PiperOrigin-RevId: 370568774
Change-Id: I5f73b31c865f2948a1c8dfb7ebd22b3cfb6405bf
  • Loading branch information
Amit Patankar authored and tensorflower-gardener committed Apr 26, 2021
1 parent b53e666 commit 6fd02f4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tensorflow/core/kernels/sparse_add_op.cc
Expand Up @@ -14,6 +14,7 @@ limitations under the License.
==============================================================================*/

#include "tensorflow/core/framework/op_kernel.h"
#include "tensorflow/core/framework/op_requires.h"
#include "tensorflow/core/framework/register_types.h"
#include "tensorflow/core/framework/tensor.h"
#include "tensorflow/core/framework/tensor_util.h"
Expand Down Expand Up @@ -101,6 +102,10 @@ class SparseAddOp : public OpKernel {
std::vector<T> out_values;
const int num_dims = a_shape->dim_size(0);

OP_REQUIRES(ctx, num_dims > 0,
errors::InvalidArgument("Invalid input_a shape. Received: ",
a_shape->DebugString()));

// The input and output sparse tensors are assumed to be ordered along
// increasing dimension number.
int64 i = 0, j = 0;
Expand Down

0 comments on commit 6fd02f4

Please sign in to comment.