未验证 提交 5d503ec9 编写于 作者: Y Yuanle Liu 提交者: GitHub

remove py::array::forcecast flag (#52039)

上级 611f7ccc
...@@ -120,8 +120,7 @@ void BindMkldnnQuantizerConfig(py::module *m); ...@@ -120,8 +120,7 @@ void BindMkldnnQuantizerConfig(py::module *m);
#endif #endif
template <typename T> template <typename T>
PaddleBuf PaddleBufCreate( PaddleBuf PaddleBufCreate(py::array_t<T, py::array::c_style> data) {
py::array_t<T, py::array::c_style | py::array::forcecast> data) {
PaddleBuf buf(data.size() * sizeof(T)); PaddleBuf buf(data.size() * sizeof(T));
std::copy_n(static_cast<const T *>(data.data()), std::copy_n(static_cast<const T *>(data.data()),
data.size(), data.size(),
...@@ -130,9 +129,8 @@ PaddleBuf PaddleBufCreate( ...@@ -130,9 +129,8 @@ PaddleBuf PaddleBufCreate(
} }
template <typename T> template <typename T>
void PaddleBufReset( void PaddleBufReset(PaddleBuf &buf, // NOLINT
PaddleBuf &buf, // NOLINT py::array_t<T, py::array::c_style> data) { // NOLINT
py::array_t<T, py::array::c_style | py::array::forcecast> data) { // NOLINT
buf.Resize(data.size() * sizeof(T)); buf.Resize(data.size() * sizeof(T));
std::copy_n(static_cast<const T *>(data.data()), std::copy_n(static_cast<const T *>(data.data()),
data.size(), data.size(),
...@@ -141,7 +139,7 @@ void PaddleBufReset( ...@@ -141,7 +139,7 @@ void PaddleBufReset(
template <typename T> template <typename T>
PaddleTensor PaddleTensorCreate( PaddleTensor PaddleTensorCreate(
py::array_t<T, py::array::c_style | py::array::forcecast> data, py::array_t<T, py::array::c_style> data,
const std::string name = "", const std::string name = "",
const std::vector<std::vector<size_t>> &lod = {}, const std::vector<std::vector<size_t>> &lod = {},
bool copy = true) { bool copy = true) {
...@@ -208,9 +206,8 @@ py::array PaddleTensorGetData(PaddleTensor &tensor) { // NOLINT ...@@ -208,9 +206,8 @@ py::array PaddleTensorGetData(PaddleTensor &tensor) { // NOLINT
} }
template <typename T> template <typename T>
void ZeroCopyTensorCreate( void ZeroCopyTensorCreate(ZeroCopyTensor &tensor, // NOLINT
ZeroCopyTensor &tensor, // NOLINT py::array_t<T, py::array::c_style> data) {
py::array_t<T, py::array::c_style | py::array::forcecast> data) {
std::vector<int> shape; std::vector<int> shape;
std::copy_n(data.shape(), data.ndim(), std::back_inserter(shape)); std::copy_n(data.shape(), data.ndim(), std::back_inserter(shape));
tensor.Reshape(std::move(shape)); tensor.Reshape(std::move(shape));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册