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

Handle scalar input to assert_equal in eager. #20232

Merged
merged 1 commit into from
Jun 25, 2018
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions tensorflow/python/kernel_tests/check_ops_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ def test_doesnt_raise_when_equal(self):
out = array_ops.identity(small)
self.evaluate(out)

@test_util.run_in_graph_and_eager_modes()
def test_scalar_comparison(self):
const_true = constant_op.constant(True, name="true")
const_false = constant_op.constant(False, name="false")
with self.assertRaisesRegexp(errors.InvalidArgumentError, "fail"):
check_ops.assert_equal(const_true, const_false, message="fail")

def test_returns_none_with_eager(self):
with context.eager_mode():
small = constant_op.constant([1, 2], name="small")
Expand Down
4 changes: 2 additions & 2 deletions tensorflow/python/ops/check_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,8 @@ def assert_equal(x, y, data=None, summarize=None, message=None, name=None):
y_sum, y_np[:y_sum]))

index_and_values_str = ''
if x.shape == y.shape:
# If the shapes of x and y are the same,
if x.shape == y.shape and x.shape.as_list():
# If the shapes of x and y are the same (and not scalars),
# Get the values that actually differed and their indices.
# If shapes are different this information is more confusing
# than useful.
Expand Down