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

Function list2vector

imperative/python/src/tensor_utils.cpp:1526–1537  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1524}
1525
1526std::vector<int32_t> list2vector(py::handle li) {
1527 std::vector<int32_t> axis;
1528 if (is_py_sequence(li)) {
1529 py::list tmp_list = py::reinterpret_steal<py::list>(PySequence_List(li.ptr()));
1530 for (size_t i = 0; i < tmp_list.size(); ++i) {
1531 axis.push_back(tmp_list[i].attr("__int__")().cast<int32_t>());
1532 }
1533 } else {
1534 axis.push_back(getattr(li, "__int__")().cast<int32_t>());
1535 }
1536 return axis;
1537}
1538
1539py::object _expand_dims_cpp(py::handle inp_hdl, py::handle axis_hdl) {
1540 std::vector<int32_t> axis = list2vector(axis_hdl);

Callers 2

_expand_dims_cppFunction · 0.85
_squeeze_cppFunction · 0.85

Calls 5

is_py_sequenceFunction · 0.85
attrMethod · 0.80
ptrMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected