Change:
One representative error: The cause of the problem is : It seems that on clang, changing the type parameter here is sufficient to cause template instantiation to fail. Maybe the easiest way to fix this is to write a more portable version of PyIntFromLong (and friends) which always returns .

Discussion:
END_HANDLE_TH_ERRORS } <ins> // The type for PyInt_FromLong varies between Windows (int64_t) and // Linux (long).  Unfortunately, on Clang, if the template type argument // does not *exactly* line up, Clang discards the template // specialization.  So we write a little stub function which does have // the right type. static PyObject* PortablePyInt_FromLong(int64_t ival) { return PyInt_FromLong(ival); } </ins> static struct PyGetSetDef batch_norm_forward_properties[] = { THP_FUNCTION_DEFAULT_PROPERTIES, {(char*)"running_mean", (getter)getTensorAttr<BatchNormForward, BatchNormParams,

static struct PyGetSetDef conv_forward_properties[] = { THP_FUNCTION_DEFAULT_PROPERTIES, {(char*)"stride", (getter)getTupleAttr<ConvForward, std::vector<int>, ConvParams, <del> &ConvParams::stride, int64_t, PyInt_FromLong>, NULL, NULL, NULL}, </del> <ins> &ConvParams::stride, int64_t, PortablePyInt_FromLong>, NULL, NULL, NULL}, </ins> {(char*)"padding", (getter)getTupleAttr<ConvForward, std::vector<int>, ConvParams, <del> &ConvParams::padding, int64_t, PyInt_FromLong>, NULL, NULL, NULL}, </del> <ins> &ConvParams::padding, int64_t, PortablePyInt_FromLong>, NULL, NULL, NULL}, </ins> {(char*)"dilation", (getter)getTupleAttr<ConvForward, std::vector<int>, ConvParams, <del> &ConvParams::dilation, int64_t, PyInt_FromLong>, NULL, NULL, NULL}, </del> <ins> &ConvParams::dilation, int64_t, PortablePyInt_FromLong>, NULL, NULL, NULL}, </ins> {(char*)"transposed", (getter)getValueAttr<ConvForward, bool, ConvParams, &ConvParams::transposed, long, PyBool_FromLong>, NULL, NULL, NULL}, {(char*)"output_padding", (getter)getTupleAttr<ConvForward, std::vector<int>, ConvParams, <del> &ConvParams::output_padding, int64_t, PyInt_FromLong>, NULL, NULL, NULL}, </del> <ins> &ConvParams::output_padding, int64_t, PortablePyInt_FromLong>, NULL, NULL, NULL}, </ins> {(char*)"groups", (getter)getValueAttr<ConvForward, int, ConvParams, <del> &ConvParams::groups, int64_t, PyInt_FromLong>, NULL, NULL, NULL}, </del> <ins> &ConvParams::groups, int64_t, PortablePyInt_FromLong>, NULL, NULL, NULL}, </ins> {NULL} }; static struct PyGetSetDef conv_backward_properties[] = { THP_FUNCTION_DEFAULT_PROPERTIES, {(char*)"stride", (getter)getTupleAttr<ConvBackward, std::vector<int>, ConvParams, <del> &ConvParams::stride, int64_t, PyInt_FromLong>, NULL, NULL, NULL}, </del> <ins> &ConvParams::stride, int64_t, PortablePyInt_FromLong>, NULL, NULL, NULL}, </ins> {(char*)"padding", (getter)getTupleAttr<ConvBackward, std::vector<int>, ConvParams, <del> &ConvParams::padding, int64_t, PyInt_FromLong>, NULL, NULL, NULL}, </del> <ins> &ConvParams::padding, int64_t, PortablePyInt_FromLong>, NULL, NULL, NULL}, </ins> {(char*)"dilation", (getter)getTupleAttr<ConvBackward, std::vector<int>, ConvParams, <del> &ConvParams::dilation, int64_t, PyInt_FromLong>, NULL, NULL, NULL}, </del> <ins> &ConvParams::dilation, int64_t, PortablePyInt_FromLong>, NULL, NULL, NULL}, </ins> {(char*)"transposed", (getter)getValueAttr<ConvBackward, bool, ConvParams, &ConvParams::transposed, long, PyBool_FromLong>, NULL, NULL, NULL}, {(char*)"output_padding", (getter)getTupleAttr<ConvBackward, std::vector<int>, ConvParams, <del> &ConvParams::output_padding, int64_t, PyInt_FromLong>, NULL, NULL, NULL}, </del> <ins> &ConvParams::output_padding, int64_t, PortablePyInt_FromLong>, NULL, NULL, NULL}, </ins> {(char*)"groups", (getter)getValueAttr<ConvBackward, int, ConvParams, <del> &ConvParams::groups, int64_t, PyInt_FromLong>, NULL, NULL, NULL}, </del> <ins> &ConvParams::groups, int64_t, PortablePyInt_FromLong>, NULL, NULL, NULL}, </ins> {NULL} }; static struct PyGetSetDef conv_backward_backward_properties[] = { THP_FUNCTION_DEFAULT_PROPERTIES, {(char*)"stride", (getter)getTupleAttr<ConvBackwardBackward, std::vector<int>, ConvParams, <del> &ConvParams::stride, int64_t, PyInt_FromLong>, NULL, NULL, NULL}, </del> <ins> &ConvParams::stride, int64_t, PortablePyInt_FromLong>, NULL, NULL, NULL}, </ins> {(char*)"padding", (getter)getTupleAttr<ConvBackwardBackward, std::vector<int>, ConvParams, <del> &ConvParams::padding, int64_t, PyInt_FromLong>, NULL, NULL, NULL}, </del> <ins> &ConvParams::padding, int64_t, PortablePyInt_FromLong>, NULL, NULL, NULL}, </ins> {(char*)"dilation", (getter)getTupleAttr<ConvBackwardBackward, std::vector<int>, ConvParams, <del> &ConvParams::dilation, int64_t, PyInt_FromLong>, NULL, NULL, NULL}, </del> <ins> &ConvParams::dilation, int64_t, PortablePyInt_FromLong>, NULL, NULL, NULL}, </ins> {(char*)"transposed", (getter)getValueAttr<ConvBackwardBackward, bool, ConvParams, &ConvParams::transposed, long, PyBool_FromLong>, NULL, NULL, NULL}, {(char*)"output_padding", (getter)getTupleAttr<ConvBackwardBackward, std::vector<int>, ConvParams, <del> &ConvParams::output_padding, int64_t, PyInt_FromLong>, NULL, NULL, NULL}, </del> <ins> &ConvParams::output_padding, int64_t, PortablePyInt_FromLong>, NULL, NULL, NULL}, </ins> {(char*)"groups", (getter)getValueAttr<ConvBackwardBackward, int, ConvParams, <del> &ConvParams::groups, int64_t, PyInt_FromLong>, NULL, NULL, NULL}, </del> <ins> &ConvParams::groups, int64_t, PortablePyInt_FromLong>, NULL, NULL, NULL}, </ins> {NULL} };