-
Notifications
You must be signed in to change notification settings - Fork 6.8k
[FFI] Adopt PackedFunc on Numpy Imperative Invoke #20006
Conversation
Hey @barry-jin , Thanks for submitting the PR
CI supported jobs: [windows-gpu, centos-cpu, unix-cpu, clang, miscellaneous, website, centos-gpu, sanity, windows-cpu, unix-gpu, edge] Note: |
@mxnet-bot run ci [all] |
Jenkins CI successfully triggered : [centos-cpu, miscellaneous, centos-gpu, windows-gpu, unix-gpu, sanity, clang, edge, website, windows-cpu, unix-cpu] |
Have you measured the improvement for this PR? Previously I thought you intend to convert the remaining operators to the new FFI, rendering the generic imperative invoke unneeded? |
Yes, some operators that takes no stringified params as invocation input will benefit a bit from it. setup = """
from mxnet import np, npx
npx.set_np()
a = np.zeros((2,2))
b = np.ones((2,2))
"""
stmt = """
c = a.copyto(b)
"""
timer = timeit.Timer(setup=setup,
stmt=stmt)
num_repeat = 1000
print(min(timer.repeat(repeat=10, number=num_repeat)) / num_repeat)
legacy
5.821948400000032e-05
New FFI
5.494140500000011e-05 npx.gather_nd setup = """
from mxnet import np, npx
npx.set_np()
a = np.zeros((2,2))
b = np.ones((2,2))
"""
stmt = """
c = npx.gather_nd(a, b)
"""
timer = timeit.Timer(setup=setup,
stmt=stmt)
num_repeat = 1000
print(min(timer.repeat(repeat=10, number=num_repeat)) / num_repeat)
legacy
8.739984900000009e-05
New FFI
7.992273099999991e-05 |
Description
Adopt PackedFunc based FFI on imperative invoke to reduce overhead.
Checklist
Essentials
Changes
Comments