mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 05:34:18 +08:00
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.
20 lines
392 B
C++
20 lines
392 B
C++
#define __STDC_FORMAT_MACROS
|
|
|
|
#include <Python.h>
|
|
#include <structmember.h>
|
|
|
|
#define THP_HOST_HALF
|
|
|
|
#include <stdbool.h>
|
|
#include <vector>
|
|
#include <stack>
|
|
#include <tuple>
|
|
#include <TH/THMath.h>
|
|
|
|
#include "torch/csrc/THP.h"
|
|
#include "torch/csrc/copy_utils.h"
|
|
#include "torch/csrc/DynamicTypes.h"
|
|
#include "torch/csrc/utils/tensor_numpy.h"
|
|
|
|
//generic_include TH torch/csrc/generic/Tensor.cpp
|