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

Function parse_args

imperative/python/src/tensor.cpp:400–415  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

398};
399
400py::tuple parse_args(py::tuple args, const PyArgDescs& descs) {
401 size_t nr_args = args.size();
402 size_t nr_items = descs.items.size();
403 mgb_assert(nr_args <= nr_items, "too many args");
404 if (nr_args == nr_items) {
405 return args;
406 }
407 py::tuple ret(nr_items);
408 for (size_t i = 0; i < nr_args; ++i) {
409 ret[i] = args[i];
410 }
411 for (size_t i = nr_args; i < nr_items; ++i) {
412 ret[i] = descs.items[i].default_value();
413 }
414 return ret;
415}
416
417py::tuple parse_args_and_kwargs(
418 py::tuple args, py::dict kwargs, const PyArgDescs& descs) {

Callers 1

TensorWrapperMethod · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected