mirror of
https://github.com/ml-explore/mlx.git
synced 2025-08-21 20:46:46 +08:00
spelling: element-wise
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
This commit is contained in:
parent
07cb2f70c7
commit
f242b42493
@ -69,7 +69,7 @@ C++ API:
|
|||||||
.. code-block:: C++
|
.. code-block:: C++
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scale and sum two vectors elementwise
|
* Scale and sum two vectors element-wise
|
||||||
* z = alpha * x + beta * y
|
* z = alpha * x + beta * y
|
||||||
*
|
*
|
||||||
* Follow numpy style broadcasting between x and y
|
* Follow numpy style broadcasting between x and y
|
||||||
@ -284,7 +284,7 @@ pointwise. This is captured in the templated function :meth:`axpby_impl`.
|
|||||||
T alpha = static_cast<T>(alpha_);
|
T alpha = static_cast<T>(alpha_);
|
||||||
T beta = static_cast<T>(beta_);
|
T beta = static_cast<T>(beta_);
|
||||||
|
|
||||||
// Do the elementwise operation for each output
|
// Do the element-wise operation for each output
|
||||||
for (size_t out_idx = 0; out_idx < out.size(); out_idx++) {
|
for (size_t out_idx = 0; out_idx < out.size(); out_idx++) {
|
||||||
// Map linear indices to offsets in x and y
|
// Map linear indices to offsets in x and y
|
||||||
auto x_offset = elem_to_loc(out_idx, x.shape(), x.strides());
|
auto x_offset = elem_to_loc(out_idx, x.shape(), x.strides());
|
||||||
@ -697,7 +697,7 @@ are already provided, adding our :meth:`axpby` becomes very simple!
|
|||||||
py::kw_only(),
|
py::kw_only(),
|
||||||
"stream"_a = py::none(),
|
"stream"_a = py::none(),
|
||||||
R"pbdoc(
|
R"pbdoc(
|
||||||
Scale and sum two vectors elementwise
|
Scale and sum two vectors element-wise
|
||||||
``z = alpha * x + beta * y``
|
``z = alpha * x + beta * y``
|
||||||
|
|
||||||
Follows numpy style broadcasting between ``x`` and ``y``
|
Follows numpy style broadcasting between ``x`` and ``y``
|
||||||
|
@ -26,7 +26,7 @@ namespace mlx::core {
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scale and sum two vectors elementwise
|
* Scale and sum two vectors element-wise
|
||||||
* z = alpha * x + beta * y
|
* z = alpha * x + beta * y
|
||||||
*
|
*
|
||||||
* Follow numpy style broadcasting between x and y
|
* Follow numpy style broadcasting between x and y
|
||||||
@ -91,7 +91,7 @@ void axpby_impl(
|
|||||||
T alpha = static_cast<T>(alpha_);
|
T alpha = static_cast<T>(alpha_);
|
||||||
T beta = static_cast<T>(beta_);
|
T beta = static_cast<T>(beta_);
|
||||||
|
|
||||||
// Do the elementwise operation for each output
|
// Do the element-wise operation for each output
|
||||||
for (size_t out_idx = 0; out_idx < out.size(); out_idx++) {
|
for (size_t out_idx = 0; out_idx < out.size(); out_idx++) {
|
||||||
// Map linear indices to offsets in x and y
|
// Map linear indices to offsets in x and y
|
||||||
auto x_offset = elem_to_loc(out_idx, x.shape(), x.strides());
|
auto x_offset = elem_to_loc(out_idx, x.shape(), x.strides());
|
||||||
|
@ -12,7 +12,7 @@ namespace mlx::core {
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scale and sum two vectors elementwise
|
* Scale and sum two vectors element-wise
|
||||||
* z = alpha * x + beta * y
|
* z = alpha * x + beta * y
|
||||||
*
|
*
|
||||||
* Follow numpy style broadcasting between x and y
|
* Follow numpy style broadcasting between x and y
|
||||||
|
@ -23,7 +23,7 @@ PYBIND11_MODULE(mlx_sample_extensions, m) {
|
|||||||
py::kw_only(),
|
py::kw_only(),
|
||||||
"stream"_a = py::none(),
|
"stream"_a = py::none(),
|
||||||
R"pbdoc(
|
R"pbdoc(
|
||||||
Scale and sum two vectors elementwise
|
Scale and sum two vectors element-wise
|
||||||
``z = alpha * x + beta * y``
|
``z = alpha * x + beta * y``
|
||||||
|
|
||||||
Follows numpy style broadcasting between ``x`` and ``y``
|
Follows numpy style broadcasting between ``x`` and ``y``
|
||||||
|
@ -989,7 +989,7 @@ TEST_CASE("test as_strided grads") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("test jvp from vjp") {
|
TEST_CASE("test jvp from vjp") {
|
||||||
// Unary elementwise ops
|
// Unary element-wise ops
|
||||||
{
|
{
|
||||||
auto x = random::uniform({5, 10});
|
auto x = random::uniform({5, 10});
|
||||||
eval(x);
|
eval(x);
|
||||||
@ -1022,7 +1022,7 @@ TEST_CASE("test jvp from vjp") {
|
|||||||
CHECK(compute_derivs(mlx::core::rsqrt));
|
CHECK(compute_derivs(mlx::core::rsqrt));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Binary elementwise ops
|
// Binary element-wise ops
|
||||||
{
|
{
|
||||||
auto x = random::uniform({5, 10});
|
auto x = random::uniform({5, 10});
|
||||||
auto y = random::uniform({5, 10});
|
auto y = random::uniform({5, 10});
|
||||||
|
Loading…
Reference in New Issue
Block a user