mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
To not pollute the global namespace, we should move the `from`/`to` APIs into torch::stable::detail. We are also following our normal deprecation cycle and choosing to continue exposing the global `from`/`to` for the time being as people who onboard their extensions onto 2.9 would not be able to build with 2.10 otherwise. Note that this means that within libtorch, we do not get the luxury of tacking on a `using torch::stable::detail::from` because then it leads to build time ambiguous calls --> both the global and namespace APIs are exposed, which one do I want? So that is why you see every local site is updated. Note that the update is _not_ necessary from a custom op writer point of view. FA3 can continue to build on torch nightlies without changing any code. (Since this is a header change, this PR has no implication on runtime, a previously built FA3 ABI stable wheel will continue to work fine with newer torch versions after this PR.) Once TORCH_BOX lands, we would be free to remove these global APIs when the deprecation cycle is up (April 2026) and encourage people to use TORCH_BOX and avoid from/to entirely. Pull Request resolved: https://github.com/pytorch/pytorch/pull/164956 Approved by: https://github.com/malfet ghstack dependencies: #164882
25 lines
786 B
C++
25 lines
786 B
C++
#pragma once
|
|
|
|
// This file implements tensor.h. We separated out the Tensor struct so that
|
|
// other files can depend on the Tensor struct (like library.h) and the
|
|
// implementations of the Tensor methods can depend on APIs in library.h
|
|
// without circular dependencies.
|
|
|
|
#include <torch/csrc/stable/stableivalue_conversions.h>
|
|
#include <torch/csrc/stable/tensor_struct.h>
|
|
#include <torch/headeronly/core/ScalarType.h>
|
|
#include <torch/headeronly/util/shim_utils.h>
|
|
|
|
namespace torch::stable {
|
|
|
|
using torch::headeronly::ScalarType;
|
|
|
|
inline ScalarType Tensor::scalar_type() const {
|
|
int32_t dtype;
|
|
TORCH_ERROR_CODE_CHECK(aoti_torch_get_dtype(ath_.get(), &dtype));
|
|
return torch::stable::detail::to<ScalarType>(
|
|
torch::stable::detail::from(dtype));
|
|
}
|
|
|
|
} // namespace torch::stable
|