mirror of
https://github.com/ml-explore/mlx.git
synced 2025-09-18 01:50:16 +08:00
Added mx.stack c++ frontend impl (#123)
* stack C++ operation + python bindings
This commit is contained in:
@@ -2230,6 +2230,36 @@ void init_ops(py::module_& m) {
|
||||
Returns:
|
||||
array: The concatenated array.
|
||||
)pbdoc");
|
||||
m.def(
|
||||
"stack",
|
||||
[](const std::vector<array>& arrays,
|
||||
std::optional<int> axis,
|
||||
StreamOrDevice s) {
|
||||
if (axis.has_value()) {
|
||||
return stack(arrays, axis.value(), s);
|
||||
} else {
|
||||
return stack(arrays, s);
|
||||
}
|
||||
},
|
||||
"arrays"_a,
|
||||
py::pos_only(),
|
||||
"axis"_a = 0,
|
||||
py::kw_only(),
|
||||
"stream"_a = none,
|
||||
R"pbdoc(
|
||||
stack(arrays: List[array], axis: Optional[int] = 0, *, stream: Union[None, Stream, Device] = None) -> array
|
||||
|
||||
Stacks the arrays along a new axis.
|
||||
|
||||
Args:
|
||||
arrays (list(array)): A list of arrays to stack.
|
||||
axis (int, optional): The axis in the result array along which the
|
||||
input arrays are stacked. Defaults to ``0``.
|
||||
stream (Stream, optional): Stream or device. Defaults to ``None``.
|
||||
|
||||
Returns:
|
||||
array: The resulting stacked array.
|
||||
)pbdoc");
|
||||
m.def(
|
||||
"pad",
|
||||
[](const array& a,
|
||||
|
Reference in New Issue
Block a user