diff --git a/tensorflow/python/eager/pywrap_tfe_src.cc b/tensorflow/python/eager/pywrap_tfe_src.cc index 8c226f6c681..d41f5d736c8 100644 --- a/tensorflow/python/eager/pywrap_tfe_src.cc +++ b/tensorflow/python/eager/pywrap_tfe_src.cc @@ -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 diff --git a/tensorflow/python/eager/pywrap_tfe_test.py b/tensorflow/python/eager/pywrap_tfe_test.py index 324a314a540..af0f27cef09 100644 --- a/tensorflow/python/eager/pywrap_tfe_test.py +++ b/tensorflow/python/eager/pywrap_tfe_test.py @@ -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()