It seems you have figured out most of your questions. Regarding  DEFINE_DISPATCH, it seems that it is defined here: https://github.com/pytorch/pytorch/blob/master/aten/src/ATen/native/DispatchStub.h 1
#define DEFINE_DISPATCH(name) struct name name
If you get ATen related header included, you should be able to use it, right?