Enforce that named_tensor_meta_ is non-null only if there is a non-wildcard name (#38725)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/38725
Today, there are two equivalent representations: named_tensor_meta_ is
null, or named_tensor_meta_ is non-null but all of the dimension names
are wildcard. Let's reduce the opportunity for behavior divergence by
making the second representation illegal.
This will make it easier for me to add a dispatch key for named
tensor as I can rely on setters to always go through TensorImpl to
maintain invariants on DispatchKey.
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Test Plan: Imported from OSS
Differential Revision: D21662641
Pulled By: ezyang
fbshipit-source-id: ccc6566d23ad2ba850f653364a86cc8db0428223