parameters: (typ: Type)
docstring: This function takes a type from NativeFunctions and converts it for use with
      lazy tensor codegen.  Currently its output is used in several places, and so far
      it has been possible for them to all use the same conversions, but that may not be
      optimal or possible in the finished system.
  
      Type conversion for lazy currently consists of
       (1) changing Tensor-like things into Value-like things
       (2) wrapping everything in a BaseCType
       (3) making reference types into values (e.g. vector instead of IntArrayRef)
  
      (1) converts Tensors to Values since Values are how Lazy IR represents tensors.  There
      is special handling for Optional[Tensor] or List[Tensor], etc- hence 'tensor-like'
  
      This is incomplete- there are assertions in places that it's expected to need to add
      more types as the codegen is used with more operators.
docstring_summary: This function takes a type from NativeFunctions and converts it for use with
      lazy tensor codegen.  Currently its output is used in several places, and so far
      it has been possible for them to all use the same conversions, but that may not be
      optimal or possible in the finished system.
docstring_tokens: This function takes a type from NativeFunctions and converts it for use with lazy tensor codegen . Currently its output is used in several places and so far it has been possible for them to all use the same conversions but that may not be optimal or possible in the finished system .
function: def process_ir_type(typ: Type) -> Union[BaseCType, VectorCType, OptionalCType, ListCType]:
      """
      This function takes a type from NativeFunctions and converts it for use with
      lazy tensor codegen.  Currently its output is used in several places, and so far
      it has been possible for them to all use the same conversions, but that may not be
      optimal or possible in the finished system.
  
      Type conversion for lazy currently consists of
       (1) changing Tensor-like things into Value-like things
       (2) wrapping everything in a BaseCType
       (3) making reference types into values (e.g. vector instead of IntArrayRef)
  
      (1) converts Tensors to Values since Values are how Lazy IR represents tensors.  There
      is special handling for Optional[Tensor] or List[Tensor], etc- hence 'tensor-like'
  
      This is incomplete- there are assertions in places that it's expected to need to add
      more types as the codegen is used with more operators.
      """
      if isinstance(typ, BaseType):
          if typ.name == BaseTy.Tensor:
              return BaseCType(valueT)
          elif typ.name == BaseTy.Scalar:
              return BaseCType(scalarT)
          elif typ.name == BaseTy.ScalarType:
              return BaseCType(scalarTypeT)
          elif typ.name == BaseTy.int:
              return BaseCType(longT)
          elif typ.name == BaseTy.bool:
              return BaseCType(boolT)
          elif typ.name == BaseTy.float:
              return BaseCType(doubleT)
          elif typ.name == BaseTy.str:
              return BaseCType(stringT)
          else:
              raise AssertionError(f"TODO add support for type {repr(typ)}")
      elif isinstance(typ, OptionalType):
          return OptionalCType(process_ir_type(typ.elem))
      elif isinstance(typ, ListType):
          if str(typ.elem) == 'Tensor?':
              # TODO(whc) is this actually correct? or should it use a Vector like above
              return ListCType(OptionalCType(BaseCType(valueT)))
          else:
              return VectorCType(process_ir_type(typ.elem))
      else:
          raise AssertionError(f"unrecognized type {repr(typ)}")
function_tokens: def process_ir_type ( typ : Type ) -> Union [ BaseCType , VectorCType , OptionalCType , ListCType ] : if isinstance ( typ , BaseType ) : if typ . name == BaseTy . Tensor : return BaseCType ( valueT ) elif typ . name == BaseTy . Scalar : return BaseCType ( scalarT ) elif typ . name == BaseTy . ScalarType : return BaseCType ( scalarTypeT ) elif typ . name == BaseTy . int : return BaseCType ( longT ) elif typ . name == BaseTy . bool : return BaseCType ( boolT ) elif typ . name == BaseTy . float : return BaseCType ( doubleT ) elif typ . name == BaseTy . str : return BaseCType ( stringT ) else : raise AssertionError ( f"TODO add support for type {repr(typ)}" ) elif isinstance ( typ , OptionalType ) : return OptionalCType ( process_ir_type ( typ . elem ) ) elif isinstance ( typ , ListType ) : if str ( typ . elem ) == 'Tensor?' : # TODO(whc) is this actually correct? or should it use a Vector like above return ListCType ( OptionalCType ( BaseCType ( valueT ) ) ) else : return VectorCType ( process_ir_type ( typ . elem ) ) else : raise AssertionError ( f"unrecognized type {repr(typ)}" )