1

I'm reading pytorch's C++ source code, and I notice that it declears struct or class like this:

struct CAFFE2_API SparseTensorImpl : public TensorImpl {
...
};

The code is in pytorch/aten/src/ATen/SparseTensorImpl.h

In fact , I've never seen such code before. What I've seen were all struct A or class A. Although it may not matter, I'm still confusing what CAFFE2_API means here.

Chuang Men
  • 371
  • 3
  • 10
  • `CAFFE2_API` must be a macro defined in some other header file. This is typically used to introduce some compiler and/or operating system dependent meta-features to the class in question (such a exportable from a shared library, not exportable, etc...) To figure out what it does you must figure out where it is defined, what it is, then check your compiler's documentation. – Sam Varshavchik Dec 30 '19 at 12:00
  • You can go to definition and see how it is defined, it's probably a precompiler directive holding some conventions like __cdecl or similiar. – Holger Dec 30 '19 at 12:00
  • [pytorch Export.h](https://github.com/pytorch/pytorch/blob/master/c10/macros/Export.h#L97) – KamilCuk Dec 30 '19 at 12:02

0 Answers0