Giter Club home page Giter Club logo

Comments (6)

redwrasse avatar redwrasse commented on April 27, 2024

Looks to me like the sobol operation has a couple overflow checks for skip and num_results + skip, though they don't always get triggered (as in the example given in the issue description)

import tensorflow as tf


int32max = 2147483647

testcases = [(1, int32max), (1, int32max+1), (int32max, int32max), (1, int(1e5)), (1, int(1e10)), (1, int(1e15)), (1, int(1e20))]

for num_results, skip in testcases:
    try:
        a = float(tf.math.sobol_sample(1, num_results, skip))
        print(f"computed {a} for num_results={num_results}, skip={skip}")
    except Exception as err:
        print(f"error computing for num_results={num_results}, skip={skip}: {err}")

Console output on my laptop:

error computing for num_results=1, skip=2147483647: num_results+skip must be less than 2147483647 [Op:SobolSample]
error computing for num_results=1, skip=2147483648: skip must be non-negative [Op:SobolSample]
error computing for num_results=2147483647, skip=2147483647: num_results+skip must be less than 2147483647 [Op:SobolSample]
computed 0.5610733032226562 for num_results=1, skip=100000
computed -0.5015935897827148 for num_results=1, skip=10000000000
error computing for num_results=1, skip=1000000000000000: skip must be non-negative [Op:SobolSample]
error computing for num_results=1, skip=100000000000000000000: Can't convert Python sequence with out-of-range integer to Tensor.

from tensorflow.

redwrasse avatar redwrasse commented on April 27, 2024

This thread argues signed integer input overflow is not the responsibility of Tensorflow to check unless it causes system crash.

It may be worth nonetheless extending the unit tests for those overflow checks that are implemented in https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/kernels/sobol_op.cc#L137.

from tensorflow.

sushreebarsa avatar sushreebarsa commented on April 27, 2024

@nfergu Though I was able to replicate the issue reported here, could you please try reducing the skip value. Smaller skip values require less complex calculations and might avoid overflow.
Thank you!

from tensorflow.

nfergu avatar nfergu commented on April 27, 2024

@sushreebarsa Thanks! We already reduced the skip value, as you suggested. We’re happy with this workaround.

from tensorflow.

sushreebarsa avatar sushreebarsa commented on April 27, 2024

@nfergu Thank you for the response!
Could you please move this issue to closed status if the workaround works for you?
Thank you!

from tensorflow.

google-ml-butler avatar google-ml-butler commented on April 27, 2024

Are you satisfied with the resolution of your issue?
Yes
No

from tensorflow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.