Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tf.raw_ops.RaggedTensorToTensor failing CHECK. #49338

Merged
merged 1 commit into from May 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 11 additions & 9 deletions tensorflow/core/kernels/ragged_tensor_to_tensor_op.cc
Expand Up @@ -208,7 +208,7 @@ class RaggedTensorToTensorBaseOp : public OpKernel {
}

void CalculateOutputIndexRowSplit(
const RowPartitionTensor& row_split,
OpKernelContext* context, const RowPartitionTensor& row_split,
const vector<INDEX_TYPE>& parent_output_index,
INDEX_TYPE output_index_multiplier, INDEX_TYPE output_size,
vector<INDEX_TYPE>* result) {
Expand All @@ -233,7 +233,8 @@ class RaggedTensorToTensorBaseOp : public OpKernel {
}
}
if (row_split_size > 0) {
DCHECK_EQ(result->size(), row_split(row_split_size - 1));
OP_REQUIRES(context, result->size() == row_split(row_split_size - 1),
errors::InvalidArgument("Invalid row split size."));
}
}

Expand All @@ -259,7 +260,7 @@ class RaggedTensorToTensorBaseOp : public OpKernel {
// result[7] = -1 because parent_output_index[value_rowids[6]] == -1
// result[8] = parent_output_index[value_rowids[7]]
void CalculateOutputIndexValueRowID(
const RowPartitionTensor& value_rowids,
OpKernelContext* context, const RowPartitionTensor& value_rowids,
const vector<INDEX_TYPE>& parent_output_index,
INDEX_TYPE output_index_multiplier, INDEX_TYPE output_size,
vector<INDEX_TYPE>* result) {
Expand Down Expand Up @@ -293,7 +294,8 @@ class RaggedTensorToTensorBaseOp : public OpKernel {
}
result->push_back(current_output_index);
}
DCHECK_EQ(result->size(), value_rowids.size());
OP_REQUIRES(context, result->size() == value_rowids.size(),
errors::InvalidArgument("Invalid row ids."));
}

Status CalculateOutputIndex(OpKernelContext* context, int dimension,
Expand All @@ -307,13 +309,13 @@ class RaggedTensorToTensorBaseOp : public OpKernel {
switch (partition_type) {
case RowPartitionType::VALUE_ROWIDS:
CalculateOutputIndexValueRowID(
row_partition_tensor, parent_output_index, output_index_multiplier,
output_size, result);
context, row_partition_tensor, parent_output_index,
output_index_multiplier, output_size, result);
return tensorflow::Status::OK();
case RowPartitionType::ROW_SPLITS:
CalculateOutputIndexRowSplit(row_partition_tensor, parent_output_index,
output_index_multiplier, output_size,
result);
CalculateOutputIndexRowSplit(
context, row_partition_tensor, parent_output_index,
output_index_multiplier, output_size, result);
return tensorflow::Status::OK();
default:
return errors::InvalidArgument(
Expand Down