-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
【Hackathon 8th No.2】为 Paddle 新增 baddbmm API #70757
base: develop
Are you sure you want to change the base?
Conversation
modified: paddle/fluid/pybind/pybind.cc modified: paddle/phi/core/memory/stats.cc modified: paddle/phi/core/memory/stats.h modified: python/paddle/device/cuda/__init__.py
modified: paddle/fluid/pybind/pybind.cc modified: python/paddle/device/cuda/__init__.py
modified: paddle/fluid/pybind/pybind.cc modified: paddle/phi/core/memory/stats.cc modified: paddle/phi/core/memory/stats.h modified: test/cpp/fluid/memory/stats_test.cc
new file: test/legacy_test/test_cuda_memory_stats.py new file: test/legacy_test/test_cuda_reset_peak_memory_stats.py
new file: test/legacy_test/test_cuda_reset_max_memory_allocated.py
modified: python/paddle/device/cuda/__init__.py modified: test/legacy_test/test_cuda_memory_stats.py modified: test/legacy_test/test_cuda_reset_max_memory_allocated.py modified: test/legacy_test/test_cuda_reset_peak_memory_stats.py
modified: paddle/fluid/pybind/pybind.cc modified: paddle/phi/core/memory/stats.cc modified: paddle/phi/core/memory/stats.h modified: test/cpp/fluid/memory/stats_test.cc
modified: python/paddle/device/cuda/__init__.py modified: test/legacy_test/test_cuda_reset_max_memory_allocated.py new file: test/legacy_test/test_cuda_reset_max_memory_reserved.py
modified: paddle/fluid/pybind/pybind.cc modified: python/paddle/device/cuda/__init__.py deleted: test/legacy_test/test_cuda_memory_stats.py deleted: test/legacy_test/test_cuda_reset_peak_memory_stats.py
modified: paddle/phi/infermeta/ternary.cc modified: paddle/phi/infermeta/ternary.h new file: paddle/phi/kernels/baddbmm_grad_kernel.h new file: paddle/phi/kernels/baddbmm_kernel.h new file: paddle/phi/kernels/cpu/baddbmm_grad_kernel.cc new file: paddle/phi/kernels/cpu/baddbmm_kernel.cc modified: paddle/phi/kernels/funcs/blas/blas.h modified: paddle/phi/kernels/funcs/blas/blas_impl.cu.h modified: paddle/phi/kernels/funcs/blas/blas_impl.h new file: paddle/phi/kernels/gpu/baddbmm_grad_kernel.cu new file: paddle/phi/kernels/gpu/baddbmm_kernel.cu new file: paddle/phi/kernels/impl/baddbmm_grad_kernel_impl.h new file: paddle/phi/kernels/impl/baddbmm_kernel_impl.h modified: paddle/phi/ops/yaml/backward.yaml modified: paddle/phi/ops/yaml/ops.yaml modified: python/paddle/__init__.py modified: python/paddle/tensor/__init__.py modified: python/paddle/tensor/math.py
modified: paddle/fluid/pir/dialect/op_generator/decomp_interface_gen_op_list.py modified: paddle/fluid/pir/dialect/operator/interface/infer_symbolic_shape/multiary_infer_sym.cc modified: paddle/fluid/pir/dialect/operator/interface/infer_symbolic_shape/multiary_infer_sym.h modified: paddle/fluid/primitive/decomp_rule/decomp_rule/composite.h modified: paddle/phi/api/ext/tensor_compat.h modified: paddle/phi/kernels/impl/baddbmm_grad_kernel_impl.h modified: paddle/phi/ops/yaml/op_compat.yaml new file: test/legacy_test/test_baddbmm_op.py
你的PR提交成功,感谢你对开源项目的贡献! |
modified: ../paddle/phi/kernels/funcs/blas/blas_impl.cu.h modified: ../paddle/phi/kernels/impl/baddbmm_kernel_impl.h
modified: ../paddle/phi/ops/yaml/ops.yaml
modified: ../test/legacy_test/test_baddbmm_op.py
modified: ../test/legacy_test/test_baddbmm_op.py
modified: ../test/legacy_test/test_baddbmm_op.py
modified: ../test/legacy_test/test_baddbmm_op.py
modified: ../test/legacy_test/test_baddbmm_op.py
modified: ../test/legacy_test/test_baddbmm_op.py new file: ../test/legacy_test/test_baddbmm_op1.py new file: ../test/legacy_test/test_baddbmm_op2.py new file: ../test/legacy_test/test_baddbmm_op3.py
modified: ../test/legacy_test/test_baddbmm_op1.py
modified: ../paddle/phi/api/ext/tensor_compat.h
modified: ../paddle/phi/kernels/funcs/blas/blas_impl.hip.h
modified: ../paddle/phi/kernels/funcs/blas/blas_impl.hip.h
modified: ../test/legacy_test/test_baddbmm_op3.py new file: ../test/legacy_test/test_baddbmm_op4.py
@@ -163,6 +163,67 @@ bool Addmm_OpInferSymbolicShape(pir::Operation *op, | |||
return AddmmOpInferSymbolicShape(op, infer_context); | |||
} | |||
|
|||
bool BaddbmmOpInferSymbolicShape( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
调整代码位置,函数名按照ABC排列
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
收到,已修改,谢谢
@@ -21,6 +21,8 @@ namespace paddle::dialect { | |||
OP_DECLARE_INFER_SYMBOLIC_SHAPE(Accuracy) | |||
OP_DECLARE_INFER_SYMBOLIC_SHAPE(Addmm) | |||
OP_DECLARE_INFER_SYMBOLIC_SHAPE(Addmm_) | |||
OP_DECLARE_INFER_SYMBOLIC_SHAPE(Baddbmm) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
调整代码位置,函数名按照ABC排列
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
收到,已修改,谢谢
@@ -0,0 +1,33 @@ | |||
/* Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
新增文件注意一下copyright 年份
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
收到,新增文件均已修改,谢谢
@@ -1183,6 +1183,152 @@ inline void Blas<phi::GPUContext>::GEMM(CBLAS_TRANSPOSE transA, | |||
#endif // CUDA_VERSION >= 8000 | |||
} | |||
|
|||
template <> | |||
template <typename T, typename U> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里是否需要和.h一致 template <typename T, typename U = T>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
辛苦检查同级文件
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里在模板偏特化时,应该不能再设置默认的模板参数了。
以下为报错提示:
/Paddle_2_GPU/Paddle/paddle/phi/kernels/funcs/blas/blas_impl.cu.h(1187): error: a default template argument cannot be specified on the declaration of a member of a class template outside of its class
辛苦在PR描述中补充精度验证代码和精度误差 |
modified: paddle/fluid/pir/dialect/operator/interface/infer_symbolic_shape/multiary_infer_sym.cc modified: paddle/fluid/pir/dialect/operator/interface/infer_symbolic_shape/multiary_infer_sym.h modified: paddle/phi/kernels/baddbmm_grad_kernel.h modified: paddle/phi/kernels/baddbmm_kernel.h modified: paddle/phi/kernels/cpu/baddbmm_grad_kernel.cc modified: paddle/phi/kernels/cpu/baddbmm_kernel.cc modified: paddle/phi/kernels/gpu/baddbmm_grad_kernel.cu modified: paddle/phi/kernels/gpu/baddbmm_kernel.cu modified: paddle/phi/kernels/impl/baddbmm_grad_kernel_impl.h modified: paddle/phi/kernels/impl/baddbmm_kernel_impl.h modified: test/legacy_test/test_baddbmm_op.py modified: test/legacy_test/test_baddbmm_op1.py modified: test/legacy_test/test_baddbmm_op2.py modified: test/legacy_test/test_baddbmm_op3.py modified: test/legacy_test/test_baddbmm_op4.py
modified: test/legacy_test/CMakeLists.txt modified: test/legacy_test/test_baddbmm_op.py new file: test/legacy_test/test_baddbmm_op5.py
modified: paddle/phi/kernels/funcs/blas/blas_impl.hip.h
验证代码添加在了RFC文档中。 以下为测试结果:
max diff between paddle matmul and torch baddbmm is 0.0021514892578125
max diff between paddle baddbmm and torch baddbmm is 0.0
max diff between paddle baddbmm and paddle matmul is 0.0021514892578125
max diff between paddle matmul and torch baddbmm is 0.25
max diff between paddle baddbmm and torch baddbmm is 0.0
max diff between paddle baddbmm and paddle matmul is 0.25
max diff between paddle matmul and torch baddbmm is 2.0
max diff between paddle baddbmm and torch baddbmm is 0.0
max diff between paddle baddbmm and paddle matmul is 2.0 |
modified: paddle/fluid/pir/dialect/operator/interface/infer_symbolic_shape/multiary_infer_sym.cc modified: paddle/phi/infermeta/ternary.cc modified: paddle/phi/kernels/impl/baddbmm_grad_kernel_impl.h modified: paddle/phi/kernels/impl/baddbmm_kernel_impl.h modified: python/paddle/tensor/math.py modified: test/legacy_test/CMakeLists.txt new file: test/legacy_test/test_baddbmm_op6.py
modified: ../paddle/phi/infermeta/ternary.cc modified: ../test/legacy_test/test_baddbmm_op3.py
modified: ../python/paddle/tensor/math.py new file: ../test/legacy_test/test_baddbmm_op7.py
modified: ../test/legacy_test/CMakeLists.txt modified: ../test/legacy_test/test_baddbmm_op7.py
python/paddle/tensor/math.py
Outdated
raise ValueError( | ||
f"If input's dimension[2] is not equal to y's dimension[2], input's dimension[2] must be 1. But received input's dimension[2] = {input_shape[2]}, y's dimension[2] = {y_shape[2]}" | ||
) | ||
# 上面的判断已经包含了这种情况 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
注释如不必要,可以删除
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
收到,已修改,谢谢
python/paddle/tensor/math.py
Outdated
raise ValueError( | ||
f"If input's dimension[2] is not equal to y's dimension[2], input's dimension[2] must be 1. But received input's dimension[2] = {input_shape[2]}, y's dimension[2] = {y_shape[2]}" | ||
) | ||
# 上面的判断已经包含了这种情况 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
注释问题
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
收到,已修改,谢谢
modified: ../paddle/phi/api/ext/tensor_compat.h modified: ../python/paddle/tensor/math.py
PR Category
User Experience
PR Types
New features
Description
https://github.com/PaddlePaddle/community/blob/master/hackathon/hackathon_8th/%E3%80%90Hackathon_8th%E3%80%91%E4%B8%AA%E4%BA%BA%E6%8C%91%E6%88%98%E8%B5%9B%E2%80%94%E6%A1%86%E6%9E%B6%E5%BC%80%E5%8F%91%E4%BB%BB%E5%8A%A1%E5%90%88%E9%9B%86.md#no2-%E4%B8%BA-paddle-%E6%96%B0%E5%A2%9E-baddbmm-api
新增加了float16和bfloat16的特例化