Move UndefinedTensorImpl to c10 (meh) (#14817)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/14817

unfortunately, we still need this.

Reviewed By: ezyang

Differential Revision: D13348041

fbshipit-source-id: e8dcc89f5c71bd1ea2c9813990dac6e58e63b1fd
This commit is contained in:
Sebastian Messmer 2018-12-11 20:40:33 -08:00 committed by Facebook Github Bot
parent 2dfdbef91d
commit 63db95dd11
3 changed files with 37 additions and 36 deletions

View file

@ -1,34 +1 @@
#pragma once
#include <c10/core/TensorImpl.h>
namespace at {
struct CAFFE2_API UndefinedTensorImpl final : public TensorImpl {
public:
// Without this, we get:
// error: identifier "at::UndefinedTensorImpl::_singleton" is undefined in device code
// (ostensibly because the constexpr tricks MSVC into trying to compile this
// function for device as well).
#ifdef _WIN32
static inline TensorImpl * singleton() {
#else
static constexpr inline TensorImpl * singleton() {
#endif
return &_singleton;
}
IntList sizes() const override;
IntList strides() const override;
int64_t size(int64_t d) const override;
int64_t stride(int64_t d) const override;
int64_t dim() const override;
const Storage& storage() const override;
int64_t storage_offset() const override;
private:
UndefinedTensorImpl();
static UndefinedTensorImpl _singleton;
public:
friend struct UndefinedType;
};
} // namespace at
#include <c10/core/UndefinedTensorImpl.h>

View file

@ -1,7 +1,7 @@
#include <ATen/core/UndefinedTensorImpl.h>
#include <c10/core/UndefinedTensorImpl.h>
#include <c10/util/Exception.h>
namespace at {
namespace c10 {
// should this use the globalContext? Can it get a context passed in somehow?
UndefinedTensorImpl::UndefinedTensorImpl()

View file

@ -0,0 +1,34 @@
#pragma once
#include <c10/core/TensorImpl.h>
namespace c10 {
struct C10_API UndefinedTensorImpl final : public TensorImpl {
public:
// Without this, we get:
// error: identifier "at::UndefinedTensorImpl::_singleton" is undefined in device code
// (ostensibly because the constexpr tricks MSVC into trying to compile this
// function for device as well).
#ifdef _WIN32
static inline TensorImpl * singleton() {
#else
static constexpr inline TensorImpl * singleton() {
#endif
return &_singleton;
}
IntList sizes() const override;
IntList strides() const override;
int64_t size(int64_t d) const override;
int64_t stride(int64_t d) const override;
int64_t dim() const override;
const Storage& storage() const override;
int64_t storage_offset() const override;
private:
UndefinedTensorImpl();
static UndefinedTensorImpl _singleton;
public:
friend struct UndefinedType;
};
} // namespace c10