-
-
Notifications
You must be signed in to change notification settings - Fork 872
GSoC 2025 ‐ Muhammad Haris
Hi, I'm Muhammad Haris from Islamabad, Pakistan. I hold a Bachelors degree in Mechanical Engineering from Air University, Islamabad. My open-source journey began in February 2024 when I first learned about the Google Summer of Code (GSoC) program. Although my initial application wasn't successful, I remained engaged and continued contributing. That persistence paid off—this year, when I was selected to work on the same project I had applied for the year before. It’s really been a rewarding experience in terms of growth and learning.
JavaScript’s built-in arrays are not designed for efficient operations on large, multi-dimensional datasets. stdlib
addresses this gap by providing the ndarray
API, a general-purpose interface for creating and manipulating multi-dimensional arrays.
This project built on those foundations by extending the ndarray
API to achieve API parity with JavaScript’s Array.prototype
. The goal was to make ndarrays feel as natural and intuitive to use as native arrays without compromising performance. This involved implementing high-level parity functions in ndarray/*
or blas/ext/*
, along with the necessary lower-level utilities in ndarray/base/*
or blas/ext/base/*
, respectively.
Over the course of the project, I implemented a wide range of functions such as concat
, find
, some
, fill
, indexOf
, findIndex
, with
and more.
The general implementation process was as following:
- Determine whether any lower-level utilities were required to support the top-level parity function.
- If needed, implement the required lower-level functions within the
ndarray/base/*
orblas/ext/base/*
namespaces. - With the necessary low-level machinery in place, implement the user-facing API in the
ndarray/base/*
orblas/ext/*
namespace.
The functions implemented can be grouped into the following categories:
-
Functions implemented in
ndarray/*
namespace: For most of these functions specialized kernels were implemented at the base-level inndarray/base/*
for dimensions up to10d
and a generalizednd
kernel for higher-dimensional cases. Along with tests and benchmarks for each dimension which significantly increased the implementation time for these functions. In cases where a base-level implementation already existed (or was not needed), only the top-level function was implemented.ndarray/ ├── map │ └── User-facing wrapper around the base implementation └── base/ └── map └── Base implementation with specialized kernels
-
Functions implemented in
blas/ext/*
namespace: For these functions,1D strided
functions were implemented in theblas/ext/base/*
and relevant ndarray wrappers inblas/ext/base/ndarray/*
. These implementations were relatively less time-consuming since they didn't involve implementing specialized kernels for various dimensions.blas/ext/ └── index-of └── Top-level wrapper (calls into ndarray wrappers) └── base/ndarray/ ├── sindex-of (ndarray wrapper over base/sindex-of) ├── dindex-of (ndarray wrapper over base/dindex-of) └── gindex-of (ndarray wrapper over base/gindex-of) ├── base/sindex-of (single-precision 1D strided function) ├── base/dindex-of (double-precision 1D strided function) └── base/gindex-of (generic 1D strided function)
Following is the list of PRs I worked on over the 12-week period. These include the implementation of new functions, supporting utility functions and various maintenance related PRs:
-
ndarray/*
namespace:-
ndarray/some-by: - Top Level Implementation: https://github.com/stdlib-js/stdlib/pull/7145 - Base Implementation: https://github.com/stdlib-js/stdlib/pull/7087 - Description: Test whether at least
n
elements along one or more ndarray dimensions pass a test implemented by a predicate function. -
ndarray/some: - Top Level Implementation: WIP - Base Level Implementation: https://github.com/stdlib-js/stdlib/pull/7653 - Description: Test whether at least
n
elements along one or more ndarray dimensions are truthy. -
ndarray/find: - Top Level Implementation: WIP - Base Implementation: https://github.com/stdlib-js/stdlib/pull/7426 - Description: Return the first element along one or more ndarray dimensions which passes a test implemented by a predicate function.
-
ndarray/every-by: - Top Level Implementation: WIP - Base Implementation: https://github.com/stdlib-js/stdlib/pull/6667 - Description: Test whether all elements along one or more ndarray pass a test implemented by a predicate function.
-
ndarray/fill-slice: - Top Level Implementation: https://github.com/stdlib-js/stdlib/pull/7911 - Base Implementation: Not applicable. - Description: Fill an input ndarray slice with a specified value.
-
ndarray/with: - Top Level Implementation: https://github.com/stdlib-js/stdlib/pull/7971 - Base Level Implementation: Not applicable. - Description: Return an ndarray with element at specified indices replaced by a provided value.
-
ndarray/any: - Top Level Implementation: WIP - Base Level Implementation: https://github.com/stdlib-js/stdlib/pull/7640 - Description: Test whether at least one element in an ndarray is truthy.
-
ndarray/any-by: - Top Level Implementation: WIP - Base Level Implementation: https://github.com/stdlib-js/stdlib/pull/7664 - Description: Test whether at least one element in an ndarray passes a test implemented by a predicate function.
-
ndarray/concat: - Top Level Implementation: https://github.com/stdlib-js/stdlib/pull/7969 - Base Level Implementation: Not applicable. - Description: Concatenate a list of ndarrays along a specified ndarray dimension. - Related Function: https://github.com/stdlib-js/stdlib/pull/7853
-
Utility functions & other maintenance PRs:
-
ndarray/base/unary-reduce-subarray-by: - Implementation: https://github.com/stdlib-js/stdlib/pull/7008 - Description: Perform a reduction over a list of specified dimensions in an input ndarray according to a callback function and assign results to a provided output ndarray.
-
ndarray/base/unary-reduce-strided1d-by: - Implementation: https://github.com/stdlib-js/stdlib/pull/7214 - Description: Perform a reduction over a list of specified dimensions in an input ndarray via a one-dimensional strided array reduction function accepting a callback and assign results to a provided output ndarray.
-
stats/base/ndarray/max-by: - Implementation: https://github.com/stdlib-js/stdlib/pull/7194 - Description: Compute the maximum value of a one-dimensional ndarray via a callback function.
-
Adding missing tests: https://github.com/stdlib-js/stdlib/pull/7235, https://github.com/stdlib-js/stdlib/pull/7285, https://github.com/stdlib-js/stdlib/pull/7304, https://github.com/stdlib-js/stdlib/pull/7305
-
General Maintenance: https://github.com/stdlib-js/stdlib/pull/7463, https://github.com/stdlib-js/stdlib/pull/6421, https://github.com/stdlib-js/stdlib/pull/7894
-
-
-
blas/ext/*
namespace*:-
blas/ext/index-of: -- Description: Return the first index of a specified search element along an ndarray dimension. -- Top Level Implementation: https://github.com/stdlib-js/stdlib/pull/7565 -- ndarray wrappers: https://github.com/stdlib-js/stdlib/pull/7529, https://github.com/stdlib-js/stdlib/pull/7539, https://github.com/stdlib-js/stdlib/pull/7541 -- 1D strided implementation: https://github.com/stdlib-js/stdlib/pull/7318, https://github.com/stdlib-js/stdlib/pull/7465, https://github.com/stdlib-js/stdlib/pull/7493
-
blas/ext/last-index-of: -- Description: Return the last index of a specified search element along an ndarray dimension. -- Top Level Implementation: https://github.com/stdlib-js/stdlib/pull/7665 -- ndarray wrappers: https://github.com/stdlib-js/stdlib/pull/7603, https://github.com/stdlib-js/stdlib/pull/7605, https://github.com/stdlib-js/stdlib/pull/7607 -- 1D strided implementation: https://github.com/stdlib-js/stdlib/pull/7587, https://github.com/stdlib-js/stdlib/pull/7597, https://github.com/stdlib-js/stdlib/pull/7598
-
blas/ext/find-index: -- Description: Return the index of the first element along an ndarray dimension which passes a test implemented by a predicate function. -- Top Level Implementation: https://github.com/stdlib-js/stdlib/pull/7814 -- ndarray wrappers: https://github.com/stdlib-js/stdlib/pull/7743 -- 1D strided implementation: https://github.com/stdlib-js/stdlib/pull/7727
-
blas/ext/find-last-index: -- Description: Return the index of the last element along an ndarray dimension which passes a test implemented by a predicate function. -- Top Level Implementation: https://github.com/stdlib-js/stdlib/pull/7827 -- ndarray wrappers: https://github.com/stdlib-js/stdlib/pull/7786 -- 1D strided implementation: https://github.com/stdlib-js/stdlib/pull/7785
-
blas/ext/sorthp: -- Description: WIP -- Top Level Implementation: WIP -- ndarray wrappers: https://github.com/stdlib-js/stdlib/pull/7756, https://github.com/stdlib-js/stdlib/pull/7839, https://github.com/stdlib-js/stdlib/pull/7854 -- 1D strided implementation: Not applicable (already present). -- Other lower level functions: https://github.com/stdlib-js/stdlib/pull/7828, https://github.com/stdlib-js/stdlib/pull/7821, https://github.com/stdlib-js/stdlib/pull/7772
-
At this stage, a few top-level implementations are still pending, including blas/ext/sorthp
, ndarray/any-by
, ndarray/any
, ndarray/find
, ndarray/every-by
, and ndarray/some
. In addition, during the final week of the project I began work on ndarray/flatten
, ndarray/flat-map
, ndarray/pop
, and ndarray/shift
, which are currently in progress.
A few functions still remain to be implemented, as outlined in the tracking issue, including those mentioned above. With the exception of ndarray/reduce
, the remaining functions won't require implementing specialized kernels, which should significantly reduce the time needed to complete them. That said, some functions, such as ndarray/splice
, will require additional R&D to determine how they should operate on ndarrays, which may increase the time to completion.
One of the main challenges was the sheer effort required in implementing implementing functions which require specialized kernels. Each kernel brought with it a heavy workload — documentation, testing, and benchmarking across up to 10 dimensions — which significantly increased the time required for each function. This demanded not only the technical ability but also persistence and patience.
Another challenge was thinking about overall design: it was not always obvious where each piece of the overall machinery should fit and how it would contribute to the bigger picture of the stdlib
ecosystem. Because user-level functions often required building multiple layers of lower-level machinery, I gained a stronger appreciation for how much effort and foresight goes into API design.
This has truly been a great journey. I am very grateful for the opportunity to contribute and grow through this experience.
I want to thank @kgryte and @Planeshifter for creating such a welcoming community and for their support and guidance whenever I needed it. In particular, @kgryte has been an incredible source of both technical help and motivation, and I truly appreciate the time and effort he dedicated to mentoring me.
I would also like to congratulate @aayush0325, @anandkaranubc, @ShabiShett07, and @gururaj1512 on successfully completing their GSoC projects, and I wish them all the best in their future endeavors.