Skip to content

Commit e54af2b

Browse files
committed
add solution
1 parent 073a455 commit e54af2b

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed
Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1-
def your_function(...):
2-
# reference implementation
3-
...
1+
import numpy as np
2+
3+
def checkpoint_forward(funcs, input_arr):
4+
"""
5+
Applies a list of functions in sequence to the input array, simulating gradient checkpointing by not storing intermediates.
6+
7+
Args:
8+
funcs (list of callables): List of functions to apply in sequence.
9+
input_arr (np.ndarray): Input numpy array.
10+
11+
Returns:
12+
np.ndarray: The output after applying all functions, same shape as output of last function.
13+
"""
14+
x = input_arr
15+
for f in funcs:
16+
x = f(x)
17+
return x.astype(float)

0 commit comments

Comments
 (0)