Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

Warn user against using torch tensors as arguments of random variables #1639

Commits on Aug 31, 2022

  1. Warn user against using torch tensors as arguments of random variables (

    facebookresearch#1639)
    
    Summary:
    Pull Request resolved: facebookresearch#1639
    
    Bean Machine uses the hash value of the arguments of random variables to identify them, which means that foo(1) and foo(tensor(1)) are considered two different random variables. Further in PyTorch, tensors are hashed by memory address instead of by value, so we can have hash(tensor(1)) != hash(tensor(1)). Therefore, it’s not recommended to use tensors as indices of random variables.
    In this change,
    1. In `rv_identifier.py` we identify if tensors are used as arguments to RVs and warn the user against its use.
    2. Added a test case to `rv_identifier_test.py` to check if the warning is triggered correctly when the user provides a tensor instead of a primitive argument.
    
    Differential Revision: D39169577
    
    fbshipit-source-id: 927af335f605cfc12fae6f3a6ca7784122579559
    AishwaryaSivaraman authored and facebook-github-bot committed Aug 31, 2022
    Configuration menu
    Copy the full SHA
    7fab2a5 View commit details
    Browse the repository at this point in the history