| 908 | } |
| 909 | |
| 910 | std::tuple<std::vector<int32_t>, bool> tuple2vector(py::object shape) { |
| 911 | std::vector<int32_t> shp; |
| 912 | if (!PyTuple_Check(shape.ptr())) { |
| 913 | return {shp, false}; |
| 914 | } |
| 915 | py::tuple tup = py::reinterpret_borrow<py::tuple>(shape); |
| 916 | for (size_t i = 0; i < tup.size(); ++i) { |
| 917 | if (!PyLong_Check(tup[i].ptr())) { |
| 918 | shp.clear(); |
| 919 | return {shp, false}; |
| 920 | } else { |
| 921 | shp.push_back(tup[i].cast<int32_t>()); |
| 922 | } |
| 923 | } |
| 924 | return {shp, true}; |
| 925 | } |
| 926 | |
| 927 | bool enable_fastpath(py::handle inp) { |
| 928 | auto&& tm_tr = TransformationManager::get_instance() |
no test coverage detected