MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / tuple2vector

Function tuple2vector

imperative/python/src/tensor_utils.cpp:910–925  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

908}
909
910std::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
927bool enable_fastpath(py::handle inp) {
928 auto&& tm_tr = TransformationManager::get_instance()

Callers 2

_reshape_cppFunction · 0.85
_adaptive_pool2d_cppFunction · 0.85

Calls 4

ptrMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected