Skip to content
DeepForgeby svx
All problems
EasyML Fundamentalsml-354

Batch Padding Waste

Problem

Compute wasted padding slots when batching: ceil(n_requests / batch_size) * batch_size - n_requests. Non-positive arguments return 0.

Hint

Padding keeps tensor shapes fixed but wastes compute on empty slots.

Test cases

case 1
in: [100,32]
expected: 28
case 2
in: [64,8]
expected: 0
case 3
in: [5,7]
expected: 2
case 4
in: [0,4]
expected: 0
Starter codePython
import math

def batch_padding_waste(n_requests, batch_size):
    # Your code here
    pass

4 test cases · run your code against them in the editor