Fix bug where int attributes >= 2**31 caused on exception on some platforms.
PiperOrigin-RevId: 343544621 Change-Id: I0881f6f77d6293a25b6804a1a8ebe4692222dd55
This commit is contained in:
parent
ce73ff7126
commit
35696cc325
tensorflow/python/eager
@ -243,7 +243,7 @@ struct FastPathOpExecInfo {
|
||||
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
PARSE_VALUE(ParseIntValue, int, PyLong_Check, PyLong_AsLong)
|
||||
PARSE_VALUE(ParseInt64Value, int64_t, PyLong_Check, PyLong_AsLong)
|
||||
PARSE_VALUE(ParseInt64Value, int64_t, PyLong_Check, PyLong_AsLongLong)
|
||||
#else
|
||||
PARSE_VALUE(ParseIntValue, int, PyInt_Check, PyInt_AsLong)
|
||||
#endif
|
||||
|
@ -368,5 +368,19 @@ class Tests(test.TestCase):
|
||||
|
||||
self.assertNotRegex(full_exception_text, "_FallbackException")
|
||||
|
||||
def testIntAttrThatDoesNotFitIn32Bits(self):
|
||||
# Tests bug where int attributes >= 2**31 raised an exception on platforms
|
||||
# where sizeof(long) = 32 bits.
|
||||
ctx = context.context()
|
||||
ctx.ensure_initialized()
|
||||
shape = constant_op.constant([10])
|
||||
minval = constant_op.constant(0)
|
||||
maxval = constant_op.constant(10)
|
||||
seed = 2**50
|
||||
pywrap_tfe.TFE_Py_FastPathExecute(ctx, "RandomUniformInt", None,
|
||||
shape, minval, maxval,
|
||||
"seed", seed)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test.main()
|
||||
|
Loading…
Reference in New Issue
Block a user