This example:

  
      github.com
  
  
    pytorch/pytorch/blob/master/test/cpp_extensions/complex_registration_extension.cpp 9
#include <torch/extension.h>

#include <ATen/CPUFloatType.h>
#include <ATen/Type.h>
#include <ATen/core/VariableHooksInterface.h>
#include <ATen/detail/ComplexHooksInterface.h>

#include "ATen/Allocator.h"
#include "ATen/CPUGenerator.h"
#include "ATen/DeviceGuard.h"
#include "ATen/NativeFunctions.h"
#include "ATen/Utils.h"
#include "ATen/WrapDimUtils.h"
#include "ATen/core/Half.h"
#include "ATen/core/TensorImpl.h"
#include "ATen/core/UndefinedTensorImpl.h"
#include "c10/util/Optional.h"

#include <cstddef>
#include <functional>


  This file has been truncated. show original

  
  
    
    
  
  


illustrates creating a new tensor type using an existing supported scalar type, which in this case is ScalarType::ComplexFloat.
Should/could supporting a new scalar type, say bfloat, int4, etc., be done through cpp extension or does it need to be added to the aten/c10 code in the PyTorch repo where the existing scalar types are defined (ScalarType.h, etc.)?
In either case, is there a tutorial or checklist for this?