Add SingletonSymIntNode (#107089)

Adds `SingletonSymNodeImpl` (alternatively, `SkolemSymNodeImpl`). This is a int-like object that only allows  the`eq` operation; any other operation produces an error.

The main complexity is that we require operations that dispatch to SymNode must take and return SymNodes, but when performing operations involving `SingletonSymNodeImpl`, operations involving SymNode can return non-SymNode bools.  For more discussion see [here](https://docs.google.com/document/d/18iqMdnHlUnvoTz4BveBbyWFi_tCRmFoqMFdBHKmCm_k/edit)
- Introduce `ConstantSymNodeImpl` a generalization of `LargeNegativeIntSymNodeImpl` and replace usage of `LargeNegativeIntSymNodeImpl`  in SymInt.
- Also use ConstantSymNodeImpl to enable SymBool to store its data on a SymNode. Remove the  assumption that if SymBool holds a non-null SymNode, it must be symbolic.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/107089
Approved by: https://github.com/ezyang
ghstack dependencies: #107839
This commit is contained in:
soulitzer
2023-08-24 12:34:18 -04:00
committed by PyTorch MergeBot
parent a41d15e458
commit d7130e9704
16 changed files with 343 additions and 131 deletions

View File

@ -97,7 +97,7 @@ void restoreAccurateTypeTags(const IValue& root, const TypePtr& type_tag) {
// no op, there is nothing to tag
break;
case c10::SymBoolType::Kind:
TORCH_CHECK(!w.value.toSymBool().is_symbolic());
TORCH_CHECK(!w.value.toSymBool().is_heap_allocated());
// no op, there is nothing to tag
break;
case DynamicType::Kind: