mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
compute_global_tensor_info is on the hot path for DTensor.{from,to}_local. More incremental progress toward C++.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/162990
Approved by: https://github.com/ezyang
27 lines
807 B
C
27 lines
807 B
C
#pragma once
|
|
|
|
#include <c10/macros/Macros.h>
|
|
#include <torch/csrc/utils/python_compat.h>
|
|
|
|
#include <Python.h>
|
|
|
|
inline PyCFunction castPyCFunctionWithKeywords(PyCFunctionWithKeywords func) {
|
|
C10_DIAGNOSTIC_PUSH_AND_IGNORED_IF_DEFINED("-Wcast-function-type")
|
|
C10_DIAGNOSTIC_PUSH_AND_IGNORED_IF_DEFINED("-Wcast-function-type-strict")
|
|
return reinterpret_cast<PyCFunction>(func);
|
|
C10_DIAGNOSTIC_POP()
|
|
C10_DIAGNOSTIC_POP()
|
|
}
|
|
|
|
#if !IS_PYTHON_3_13_PLUS
|
|
using PyCFunctionFast = _PyCFunctionFast;
|
|
#endif
|
|
|
|
inline PyCFunction castPyCFunctionFast(PyCFunctionFast func) {
|
|
C10_DIAGNOSTIC_PUSH_AND_IGNORED_IF_DEFINED("-Wcast-function-type")
|
|
C10_DIAGNOSTIC_PUSH_AND_IGNORED_IF_DEFINED("-Wcast-function-type-strict")
|
|
return reinterpret_cast<PyCFunction>(func);
|
|
C10_DIAGNOSTIC_POP()
|
|
C10_DIAGNOSTIC_POP()
|
|
}
|