Skip to content

Commit 1b0e0ec

Browse files
Merge pull request #51711 from yongtang:46899-tf.range
PiperOrigin-RevId: 393844345 Change-Id: I2a72193d4416b8b009bc0b21489a42061f164203
2 parents 2adc043 + 8ad2e07 commit 1b0e0ec

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Diff for: tensorflow/core/kernels/sequence_ops.cc

+3-2
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,10 @@ class RangeOp : public OpKernel {
7878
} else {
7979
size = static_cast<int64>(std::ceil(std::abs((limit - start) / delta)));
8080
}
81+
TensorShape shape;
82+
OP_REQUIRES_OK(context, shape.AddDimWithStatus(size));
8183
Tensor* out = nullptr;
82-
OP_REQUIRES_OK(context,
83-
context->allocate_output(0, TensorShape({size}), &out));
84+
OP_REQUIRES_OK(context, context->allocate_output(0, shape, &out));
8485
auto flat = out->flat<T>();
8586
T val = start;
8687
for (int64_t i = 0; i < size; ++i) {

Diff for: tensorflow/python/kernel_tests/init_ops_test.py

+7
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,13 @@ def testLargeLimits(self):
550550
v = math_ops.range(0, 9223372036854775807)
551551
self.evaluate(v)
552552

553+
def testLargeStarts(self):
554+
# Test case for GitHub issue 46899.
555+
with self.session():
556+
with self.assertRaises(errors_impl.InternalError):
557+
v = math_ops.range(start=-1e+38, limit=1)
558+
self.evaluate(v)
559+
553560

554561
# TODO(vrv): move to sequence_ops_test?
555562
class LinSpaceTest(test.TestCase):

0 commit comments

Comments
 (0)