pytorch/torch/csrc/cuda/Tensor.cpp
Sam Gross d0cabbde74
Implement Variable.from_numpy (#4043)
Implements from_numpy using ATen tensors. Variable.from_numpy is a
convenient placeholder for the variant that returns Variables until we
merge Tensor and Variable.

The behavior is slightly changed:

 - from_numpy() on an empty array now returns an empty tensor instead of
   throwing an exception. The shape may not be preserved.
 - CharTensor(ndarray) used to throw an exception. It now copies the
   ndarray. Copying is implemented via ATen toType.
2017-12-06 14:08:56 -05:00

22 lines
508 B
C++

#define __STDC_FORMAT_MACROS
#include <Python.h>
#include <structmember.h>
#include <TH/THMath.h>
#include <stdbool.h>
#include <vector>
#include <stack>
#include <tuple>
#include "torch/csrc/cuda/THCP.h"
#include "torch/csrc/cuda/override_macros.h"
#include "torch/csrc/copy_utils.h"
#include "torch/csrc/DynamicTypes.h"
#include "torch/csrc/utils/tensor_numpy.h"
//generic_include THC torch/csrc/generic/Tensor.cpp
#include "torch/csrc/cuda/undef_macros.h"
#include "torch/csrc/cuda/restore_macros.h"