Skip to content

Commit 58b4c9a

Browse files
emailweixudzhwinter
authored andcommitted
Fixing duplicate struct name TensorSetConstant. (#5532)
TensorSetConstant struct is used both in math_function.cc and math_function.cu. Somehow the release version can correctly handle it. But in debug version, set_constant_with_place() in math_function.cu uses the TensorSetConstant in math_function.cc and causes crash.
1 parent edb22c2 commit 58b4c9a

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

paddle/operators/math/math_function.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,8 @@ void gemv<platform::CPUPlace, double>(const platform::DeviceContext& context,
234234

235235
template struct SetConstant<platform::CPUPlace, float>;
236236

237-
struct TensorSetConstant {
238-
TensorSetConstant(framework::Tensor* tensor, float value)
237+
struct TensorSetConstantCPU {
238+
TensorSetConstantCPU(framework::Tensor* tensor, float value)
239239
: tensor_(tensor), value_(value) {}
240240
template <typename T>
241241
void operator()() const {
@@ -252,7 +252,7 @@ void set_constant_with_place<platform::CPUPlace>(
252252
const platform::DeviceContext& context, framework::Tensor* tensor,
253253
float value) {
254254
framework::VisitDataType(framework::ToDataType(tensor->type()),
255-
TensorSetConstant(tensor, value));
255+
TensorSetConstantCPU(tensor, value));
256256
}
257257

258258
struct TensorSetConstantWithPlace : public boost::static_visitor<void> {

paddle/operators/math/math_function.cu

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ void gemv<platform::GPUPlace, double>(const platform::DeviceContext& context,
233233

234234
template struct SetConstant<platform::GPUPlace, float>;
235235

236-
struct TensorSetConstant {
237-
TensorSetConstant(const platform::DeviceContext& context,
236+
struct TensorSetConstantGPU {
237+
TensorSetConstantGPU(const platform::DeviceContext& context,
238238
framework::Tensor* tensor, float value)
239239
: context_(context), tensor_(tensor), value_(value) {}
240240

@@ -254,7 +254,7 @@ void set_constant_with_place<platform::GPUPlace>(
254254
const platform::DeviceContext& context, framework::Tensor* tensor,
255255
float value) {
256256
framework::VisitDataType(framework::ToDataType(tensor->type()),
257-
TensorSetConstant(context, tensor, value));
257+
TensorSetConstantGPU(context, tensor, value));
258258
}
259259

260260
} // namespace math

0 commit comments

Comments
 (0)