[PyTorch][jit] Add Type::{castRaw,expectRef} (#50061)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/50061
These are more efficient than creating an extra `shared_ptr`
when you just want to access the casted value.
ghstack-source-id: 119325644
Test Plan: CI
Reviewed By: ezyang
Differential Revision: D25766630
fbshipit-source-id: 46f11f70333b44714cab708a4850922ab7486793