Skip to content

Optimize WeightedSumOp for two inputs#11049

Closed
xiaomengy wants to merge 1 commit intopytorch:masterfrom
xiaomengy:export-D9566692
Closed

Optimize WeightedSumOp for two inputs#11049
xiaomengy wants to merge 1 commit intopytorch:masterfrom
xiaomengy:export-D9566692

Conversation

@xiaomengy
Copy link
Contributor

@xiaomengy xiaomengy commented Aug 30, 2018

Summary: Optimize WeightedSumOp for four inputs (2 weighted inputs), just call one kernel instead of two kernels.

Differential Revision: D9566692

@xiaomengy
Copy link
Contributor Author

@pytrochbot retest this please

@xiaomengy
Copy link
Contributor Author

Some benchmark on GPU

input_shape = [100, 100, 100, 500],
param = model.WeightedSum([param, One, gradient, lr], param)
orginal: 46.43ms
new CUDA: 32.15ms
new CUDNN: 31.16ms

So this diff can reduce about 30% time of WeightedSumOp on training jobs.

This comment was marked as off-topic.

This comment was marked as off-topic.

Copy link
Member

@houseroad houseroad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@xiaomengy
Copy link
Contributor Author

@pytorchbot retest this please

Summary:
Pull Request resolved: pytorch#11049

Optimize WeightedSumOp for two inputs

Reviewed By: houseroad

Differential Revision: D9566692

fbshipit-source-id: d14d2b3105947f99a780848f4317acc3fb717572
@xiaomengy xiaomengy deleted the export-D9566692 branch September 1, 2018 18:56
@xkszltl
Copy link
Contributor

xkszltl commented Sep 2, 2018

Getting the following error on Linux (CentOS 7 + gcc 7.3.1 + CUDA 9.2.148) after this PR:

pytorch/caffe2/operators/utility_ops.h:328:55: error: cannot call member function 'int caffe2::OperatorBase::InputSize() const' without object

@xkszltl
Copy link
Contributor

xkszltl commented Sep 2, 2018

It is reported for caffe2/CMakeFiles/caffe2_gpu.dir/operators/caffe2_gpu_generated_loss_op.cu.o

PenghuiCheng pushed a commit to PenghuiCheng/pytorch that referenced this pull request Sep 11, 2018
Summary:
Pull Request resolved: pytorch#11049

Optimize WeightedSumOp for two inputs

Reviewed By: houseroad

Differential Revision: D9566692

fbshipit-source-id: 9aab1f02251d386b6f7d0699ae11eeb2ea2b5b4f
@ezyang ezyang added the merged label Jun 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants