Remove deprecated variable_tensor_functions (#15003)
authorPeter Goldsborough <psag@fb.com>
Wed, 12 Dec 2018 00:36:25 +0000 (16:36 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Wed, 12 Dec 2018 01:16:11 +0000 (17:16 -0800)
Summary:
Removing the deprecated functions in `torch/csrc/variable_tensor_functions.h` (like `torch::CPU`) and corresponding implementations from `torch/csrc/torch.cpp` from master after the release.

ezyang gchanan soumith
Pull Request resolved: https://github.com/pytorch/pytorch/pull/15003

Differential Revision: D13418086

Pulled By: goldsborough

fbshipit-source-id: a0accdf6f7b0efa1ec07ac7b74b86ff2da37543f

12 files changed:
test/cpp/jit/tests.h
tools/jit/templates/register_aten_ops.cpp
torch/CMakeLists.txt
torch/csrc/jit/fuser/cpu/fused_kernel.cpp
torch/csrc/jit/interpreter.cpp
torch/csrc/jit/python_interpreter.cpp
torch/csrc/jit/register_prim_ops.cpp
torch/csrc/jit/tracer.cpp
torch/csrc/tensor/python_tensor.cpp
torch/csrc/torch.cpp [deleted file]
torch/csrc/variable_tensor_functions.h [deleted file]
torch/extension.h

index d087803..db1caf2 100644 (file)
@@ -53,7 +53,6 @@
 #include "torch/csrc/jit/symbolic_variable.h"
 #include "torch/csrc/jit/tracer.h"
 #include "torch/csrc/utils/hash.h"
-#include "torch/csrc/variable_tensor_functions.h"
 #include "torch/csrc/autograd/generated/variable_factories.h"
 
 #include "torch/csrc/autograd/engine.h"
index a3e0785..69d724d 100644 (file)
@@ -5,7 +5,6 @@
 #include "torch/csrc/jit/interned_strings.h"
 
 #include "torch/csrc/utils/functional.h"
-#include "torch/csrc/variable_tensor_functions.h"
 #include "torch/csrc/autograd/generated/variable_factories.h"
 
 #include <ATen/ATen.h>
index e8d2a5e..44c4bd9 100644 (file)
@@ -194,7 +194,6 @@ set(TORCH_SRCS
   ${TORCH_SRC_DIR}/csrc/jit/script/module.cpp
   ${TORCH_SRC_DIR}/csrc/jit/tracer.cpp
   ${TORCH_SRC_DIR}/csrc/jit/hooks_for_testing.cpp
-  ${TORCH_SRC_DIR}/csrc/torch.cpp
   ${TORCH_SRC_DIR}/csrc/utils/tensor_flatten.cpp
   ${TORCH_SRC_DIR}/csrc/utils/variadic.cpp
   ${TORCH_ROOT}/test/cpp/jit/no-gtest.cpp
index 4ecda91..ad11b14 100644 (file)
@@ -114,7 +114,6 @@ FusedKernelCPU::FusedKernelCPU(
           std::move(chunk_desc),
           std::move(concat_desc),
           has_random) {
-  auto& config = getConfig();
   TempFile so_file(so_template, 3);
   TempFile cpp_file(cpp_template, 4);
   cpp_file.write(code_);
index b0271cc..a8a44d8 100644 (file)
@@ -11,7 +11,6 @@
 #include <torch/csrc/jit/ivalue.h>
 #include <torch/csrc/jit/constants.h>
 #include <torch/csrc/jit/operator.h>
-#include <torch/csrc/variable_tensor_functions.h>
 #include <torch/csrc/jit/script/jit_exception.h>
 
 #include <exception>
index 0b430af..a418d64 100644 (file)
@@ -11,8 +11,6 @@
 #include <torch/csrc/jit/ir.h>
 #include <torch/csrc/jit/pybind_utils.h>
 
-#include <torch/csrc/variable_tensor_functions.h>
-
 #include <typeinfo>
 
 #include <torch/csrc/autograd/python_engine.h>
index a5a173f..a478fd6 100644 (file)
@@ -9,7 +9,6 @@
 #include <torch/csrc/jit/operator.h>
 #include <torch/csrc/jit/custom_operator.h>
 #include <torch/csrc/jit/script/jit_exception.h>
-#include <torch/csrc/variable_tensor_functions.h>
 
 #include <ATen/ExpandUtils.h>
 #include <ATen/WrapDimUtils.h>
index 5b7d5a6..ef15721 100644 (file)
@@ -6,7 +6,6 @@
 #include <torch/csrc/autograd/engine.h>
 #include <torch/csrc/jit/passes/dead_code_elimination.h>
 #include <torch/csrc/jit/passes/remove_expands.h>
-#include <torch/csrc/variable_tensor_functions.h>
 
 #include <string>
 #include <sstream>
index 6fcece3..04f05b5 100644 (file)
@@ -16,7 +16,6 @@
 #include <torch/csrc/utils/python_strings.h>
 #include <torch/csrc/utils/tensor_new.h>
 #include <torch/csrc/utils/tensor_types.h>
-#include <torch/csrc/variable_tensor_functions.h>
 
 #include <ATen/ATen.h>
 
@@ -279,7 +278,7 @@ void initialize_python_bindings() {
   py_bind_tensor_types(tensor_types);
 
   // Use torch.float32 as the default tensor type
-  set_default_tensor_type(torch::CPU(kFloat));
+  set_default_tensor_type(at::globalContext().getVariableType(at::Backend::CPU, at::kFloat));
 }
 
 static void py_bind_tensor_types(const std::vector<PyTensorType>& tensor_types) {
diff --git a/torch/csrc/torch.cpp b/torch/csrc/torch.cpp
deleted file mode 100644 (file)
index 656cae7..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#include <torch/csrc/variable_tensor_functions.h>
-#include <torch/csrc/autograd/generated/VariableType.h>
-#include <torch/csrc/autograd/variable.h>
-
-namespace torch {
-at::TypeExtendedInterface& getVariableType(at::Backend backend, at::ScalarType type) {
-  return *autograd::VariableType::getVariableTypeFromBaseType(at::getNonVariableType(backend, type));
-}
-
-at::TypeExtendedInterface& CPU(at::ScalarType type) {
-  return torch::getVariableType(at::Backend::CPU, type);
-}
-
-at::TypeExtendedInterface& CUDA(at::ScalarType type) {
-  return torch::getVariableType(at::Backend::CUDA, type);
-}
-
-at::Tensor toTensor(const at::Scalar& scalar) {
-  return autograd::make_variable(scalar_to_tensor(scalar));
-}
-
-void set_requires_grad(at::Tensor& tensor, bool requires_grad) noexcept {
-  autograd::as_variable_ref(tensor).set_requires_grad(requires_grad);
-}
-
-bool requires_grad(const at::Tensor& tensor) noexcept {
-  return autograd::as_variable_ref(tensor).requires_grad();
-}
-} // namespace torch
diff --git a/torch/csrc/variable_tensor_functions.h b/torch/csrc/variable_tensor_functions.h
deleted file mode 100644 (file)
index 3878a3c..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-#pragma once
-
-#include <ATen/ATen.h>
-#include <ATen/core/Deprecated.h>
-#include <torch/csrc/THP_export.h>
-
-namespace torch {
-
-// NOTE: This API is currently highly experimental and may change drastically
-// in the near future.
-
-// These functions provide a small wrapper around aten ensuring
-// that we create tensors with type Variable rather than raw tensors
-// when we create new tensors. We also provide a few accessors like
-// requires_grad that make it easier to get to varible information when we have
-// a at::Tensor
-
-/// Returns a `TypeExtendedInterface` object for the given backend (e.g.
-/// `at::kCPU`) and `ScalarType` (e.g. `at::kDouble`).
-/// TODO: Eliminate this function as much as possible
-AT_DEPRECATED(THP_CLASS at::TypeExtendedInterface& getVariableType(
-    at::Backend backend,
-    at::ScalarType type));
-
-/// Returns a `TypeExtendedInterface` object for the CPU backend and the given
-/// `ScalarType` (e.g. `at::kDouble`). Equivalent to `getVariableType(kCPU,
-/// type)`.
-/// TODO: Eliminate this function as much as possible
-AT_DEPRECATED(THP_CLASS at::TypeExtendedInterface& CPU(at::ScalarType type));
-
-/// Returns a `TypeExtendedInterface` object for the CUDA backend and the given
-/// `ScalarType` (e.g. `at::kDouble`). Equivalent to `getVariableType(kCUDA,
-/// type)`.
-/// TODO: Eliminate this function as much as possible
-AT_DEPRECATED(THP_CLASS at::TypeExtendedInterface& CUDA(at::ScalarType type));
-
-/// Sets the `requires_grad` property of the given `Tensor`.
-AT_DEPRECATED(THP_CLASS void set_requires_grad(
-    at::Tensor& tensor,
-    bool requires_grad) noexcept);
-
-/// Returns the `requires_grad` of the given `Tensor`.
-AT_DEPRECATED(THP_CLASS bool requires_grad(const at::Tensor& tensor) noexcept);
-
-} // namespace torch
index 0ff1425..2ba1117 100644 (file)
@@ -4,5 +4,3 @@
 #include <torch/all.h>
 // Python bindings for the C++ frontend (includes Python.h).
 #include <torch/python.h>
-// Deprecated tensor factories (to be removed).
-#include <torch/csrc/variable_tensor_functions.h>