mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-15 21:00:47 +00:00
Summary: There is a module called `2to3` which you can target for future specifically to remove these, the directory of `caffe2` has the most redundant imports: ```2to3 -f future -w caffe2``` Pull Request resolved: https://github.com/pytorch/pytorch/pull/45033 Reviewed By: seemethere Differential Revision: D23808648 Pulled By: bugra fbshipit-source-id: 38971900f0fe43ab44a9168e57f2307580d36a38
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
|
|
|
|
|
|
|
|
|
|
import argparse
|
|
import numpy as np
|
|
|
|
from caffe2.python import core, workspace
|
|
|
|
|
|
def benchmark_mul_gradient(args):
|
|
workspace.FeedBlob("dC", np.random.rand(args.m, args.n).astype(np.float32))
|
|
workspace.FeedBlob("A", np.random.rand(args.m, args.n).astype(np.float32))
|
|
workspace.FeedBlob("B", np.random.rand(args.m).astype(np.float32))
|
|
|
|
net = core.Net("mynet")
|
|
net.MulGradient(["dC", "A", "B"], ["dA", "dB"], broadcast=True, axis=0)
|
|
workspace.CreateNet(net)
|
|
|
|
workspace.BenchmarkNet(net.Name(), 1, args.iteration, True)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser(
|
|
description="benchmark for MulGradient.")
|
|
parser.add_argument(
|
|
'-m', type=int, default=9508,
|
|
help="The number of rows of A")
|
|
parser.add_argument(
|
|
"-n", type=int, default=80,
|
|
help="The number of columns of A")
|
|
parser.add_argument(
|
|
'-i', "--iteration", type=int, default=100,
|
|
help="The number of iterations.")
|
|
args, extra_args = parser.parse_known_args()
|
|
core.GlobalInit(['python'] + extra_args)
|
|
benchmark_mul_gradient(args)
|