mirror of
				https://github.com/pytorch/pytorch.git
				synced 2025-11-04 16:04:58 +08:00 
			
		
		
		
	Hashing for constant and singleton SymInt/SymBool (#109170)
Bugfix: - previously, SymBool does not implement `__eq__`, Python falls back to default `__eq__ `and `__hash__` - in this PR, we make SymBool implement `__eq__` - symbolic SymBool now raises an error when hashed just like SymInt/SymFloat New feature: - previously, SymInt and SymFloat are unhashable (even if you are singleton or constant) - in this PR, SymInt and SymBool are hashable if singleton/constant Stay the same: - SymNode are hashable due to default Python behavior Pull Request resolved: https://github.com/pytorch/pytorch/pull/109170 Approved by: https://github.com/ezyang ghstack dependencies: #109169
This commit is contained in:
		
				
					committed by
					
						
						PyTorch MergeBot
					
				
			
			
				
	
			
			
			
						parent
						
							5252fcb133
						
					
				
				
					commit
					8bc00dfffd
				
			@ -1265,6 +1265,11 @@ void initJITBindings(PyObject* module) {
 | 
			
		||||
          "is_symbolic",
 | 
			
		||||
          [](const c10::SymNode& node) {
 | 
			
		||||
            return node->is_symbolic();
 | 
			
		||||
          })
 | 
			
		||||
      .def(
 | 
			
		||||
          "singleton_int",
 | 
			
		||||
          [](const c10::SymNode& node) {
 | 
			
		||||
            return node->singleton_int();
 | 
			
		||||
          });
 | 
			
		||||
 | 
			
		||||
  // clang-format on
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user