Skip to content

Commit

Permalink
[phi::DenseTensor] Replace Tensor with phi::DenseTensor (#48682)
Browse files Browse the repository at this point in the history
  • Loading branch information
Liyulingyue authored Dec 7, 2022
1 parent 693de9f commit 6542027
Show file tree
Hide file tree
Showing 419 changed files with 2,450 additions and 2,880 deletions.
10 changes: 5 additions & 5 deletions paddle/fluid/imperative/gradient_accumulator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -644,11 +644,11 @@ void GradientAccumulator::CallGradientHooks() {
true,
platform::errors::PreconditionNotMet(
"Only can call gradient hooks after sum gradient completed."));
PADDLE_ENFORCE_EQ(
HasInnerVar(),
true,
platform::errors::PreconditionNotMet(
"Leaf Tensor's inner var is nullptr when call gradient hook."));
PADDLE_ENFORCE_EQ(HasInnerVar(),
true,
platform::errors::PreconditionNotMet(
"Leaf Tensor's inner var is nullptr when "
"call gradient hook."));
PADDLE_ENFORCE_EQ(
inner_var_->Var().IsInitialized(),
true,
Expand Down
4 changes: 1 addition & 3 deletions paddle/fluid/operators/abs_op_mlu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ limitations under the Licnse. */
namespace paddle {
namespace operators {

using Tensor = phi::DenseTensor;

template <typename T>
class AbsMLUKernel : public framework::OpKernel<T> {
public:
Expand Down Expand Up @@ -54,7 +52,7 @@ class AbsGradMLUKernel : public framework::OpKernel<T> {
MLUCnnlOpTensorDesc mul_op_desc(
CNNL_OP_TENSOR_MUL, ToCnnlDataType<T>(), CNNL_NOT_PROPAGATE_NAN);

Tensor sign_x;
phi::DenseTensor sign_x;
sign_x.mutable_data<T>(x->dims(), ctx.GetPlace());

MLUCnnl::Sign(ctx,
Expand Down
2 changes: 0 additions & 2 deletions paddle/fluid/operators/abs_op_npu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ limitations under the Licnse. */
namespace paddle {
namespace operators {

using Tensor = phi::DenseTensor;

template <typename DeviceContext, typename T>
class AbsNPUKernel : public framework::OpKernel<T> {
public:
Expand Down
4 changes: 1 addition & 3 deletions paddle/fluid/operators/activation_op_mlu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ limitations under the Licnse. */
namespace paddle {
namespace operators {

using Tensor = phi::DenseTensor;

template <cnnlActivationMode_t act_mode, typename T>
class ActivationMLUKernel : public framework::OpKernel<T> {
public:
Expand Down Expand Up @@ -442,7 +440,7 @@ class ReciprocalGradMLUKernel : public framework::OpKernel<T> {
auto* dx = ctx.Output<phi::DenseTensor>(framework::GradVarName("X"));
auto place = ctx.GetPlace();
dx->mutable_data<T>(place);
Tensor square_out;
phi::DenseTensor square_out;
square_out.Resize(out->dims());
square_out.mutable_data<T>(place);
MLUCnnlTensorDesc out_desc(*out);
Expand Down
Loading

0 comments on commit 6542027

Please sign in to comment.