NumPy strides use bytes. OneFlow strides use element counts.
| 91 | |
| 92 | // NumPy strides use bytes. OneFlow strides use element counts. |
| 93 | std::vector<size_t> OFStrideToNumpyStride(const Stride& stride, const DataType data_type) { |
| 94 | size_t ndim = stride.size(); |
| 95 | auto result = std::vector<size_t>(ndim); |
| 96 | int byte_per_elem = GetSizeOfDataType(data_type); |
| 97 | for (int i = 0; i < ndim; i++) { result[i] = stride.at(i) * byte_per_elem; } |
| 98 | return result; |
| 99 | } |
| 100 | |
| 101 | bool PyArrayCheckLongScalar(PyObject* obj) { |
| 102 | return PyArray_CheckScalar(obj) && PyDataType_ISINTEGER(PyArray_DescrFromScalar(obj)); |
no test coverage detected