Return single Tensor when TensorTuple's size is one, otherwise py::tuple
| 60 | |
| 61 | // Return single Tensor when TensorTuple's size is one, otherwise py::tuple |
| 62 | py::object PackTensorTuple(const one::TensorTuple& tp) { |
| 63 | if (tp.size() == 1) { |
| 64 | return py::cast(tp.at(0)); |
| 65 | } else { |
| 66 | py::tuple out = py::tuple(tp.size()); |
| 67 | for (int i = 0; i < tp.size(); ++i) { out[i] = tp.at(i); } |
| 68 | return py::cast<py::object>(out); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | // wrap PyFunction, unpack the inputs from TensorTuple and pack outputs to TensorTuple |
| 73 | one::AutogradFunctionBase::FType PackPyFunctionToFType(const py::function& func) { |
no test coverage detected