Skip to content

Commit

Permalink
Move UndefinedTensorImpl to c10 (meh) (#14817)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: pytorch/pytorch#14817

unfortunately, we still need this.

Reviewed By: ezyang

Differential Revision: D13348041

fbshipit-source-id: e8dcc89f5c71bd1ea2c9813990dac6e58e63b1fd
  • Loading branch information
smessmer authored and facebook-github-bot committed Dec 12, 2018
1 parent 2dfdbef commit 63db95d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 36 deletions.
35 changes: 1 addition & 34 deletions aten/src/ATen/core/UndefinedTensorImpl.h
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
34 changes: 34 additions & 0 deletions c10/core/UndefinedTensorImpl.h
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 63db95d

Please sign in to comment.