InitialTensorOptions.h 693 B

1234567891011121314151617181920
  1. #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
  2. #pragma once
  3. #include <c10/core/TensorOptions.h>
  4. namespace at {
  5. // Represents the initial TensorOptions, before the "defaults" are ever changed.
  6. // This is designed to be used in library code, where the explicit devices,
  7. // dtypes, etc. are known. NOTE: this is not a stable API.
  8. inline TensorOptions initialTensorOptions() {
  9. return TensorOptions(kCPU).dtype(kFloat).layout(kStrided).requires_grad(
  10. false);
  11. }
  12. } // namespace at
  13. #else
  14. #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
  15. #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)