Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Benchmarks] using setup for functional benchmarks #351

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions benchmarks/nn/functional_benchmarks_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# we use deepcopy as our implementation modifies the modules in-place
import argparse
from copy import deepcopy

import pytest
import torch
Expand All @@ -27,11 +26,11 @@ def net():


def _functorch_make_functional(net):
functorch_make_functional(deepcopy(net))
functorch_make_functional(net)


def _make_functional(net):
make_functional(deepcopy(net))
make_functional(net)


def make_tdmodule():
Expand Down Expand Up @@ -129,14 +128,23 @@ def test_tdseq_dispatch(benchmark):


# Creation
def test_instantiation_functorch(benchmark, net):
def test_instantiation_functorch(
benchmark,
):
benchmark.pedantic(
_functorch_make_functional, args=(net,), iterations=10, rounds=100
_functorch_make_functional,
setup=lambda: ((make_net(),), {}),
iterations=1,
rounds=10000,
)


def test_instantiation_td(benchmark, net):
benchmark.pedantic(_make_functional, args=(net,), iterations=10, rounds=100)
def test_instantiation_td(
benchmark,
):
benchmark.pedantic(
_make_functional, setup=lambda: ((make_net(),), {}), iterations=1, rounds=10000
)


# Execution
Expand Down