Skip to content

Commit 377c919

Browse files
committed
resolve develop conflict
2 parents cad6872 + 2f75465 commit 377c919

File tree

117 files changed

+13281
-1003
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+13281
-1003
lines changed

cmake/external/lite.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ if (NOT LITE_SOURCE_DIR OR NOT LITE_BINARY_DIR)
3434
set(LITE_INSTALL_DIR ${THIRD_PARTY_PATH}/install/lite)
3535

3636
if(NOT LITE_GIT_TAG)
37-
set(LITE_GIT_TAG 42ab4d559f6659edfc35040fb30fdcec3dc3f8aa)
37+
set(LITE_GIT_TAG dfdfa6440c83bf0b415f9f5a9ff84842ce0bb0fa)
3838
endif()
3939

4040
if(NOT CUDA_ARCH_NAME)

paddle/fluid/framework/framework.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ message VarType {
115115
SIZE_T = 19;
116116
UINT8 = 20;
117117
INT8 = 21;
118+
BF16 = 22;
118119

119120
// Other types that may need additional descriptions
120121
LOD_TENSOR = 7;

paddle/fluid/framework/op_version_registry.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ struct OpUpdateRecord {
3434
kModifyAttr,
3535
kNewAttr,
3636
kNewInput,
37-
kNewOutput
37+
kNewOutput,
38+
kBugfixWithBehaviorChanged,
3839
};
3940
Type type_;
4041
std::string remark_;
@@ -82,6 +83,11 @@ struct NewOutput : OpUpdateRecord {
8283
std::string name_;
8384
};
8485

86+
struct BugfixWithBehaviorChanged : OpUpdateRecord {
87+
explicit BugfixWithBehaviorChanged(const std::string& remark)
88+
: OpUpdateRecord({Type::kBugfixWithBehaviorChanged, remark}) {}
89+
};
90+
8591
class OpVersionDesc {
8692
public:
8793
OpVersionDesc& ModifyAttr(const std::string& name, const std::string& remark,
@@ -110,6 +116,12 @@ class OpVersionDesc {
110116
return *this;
111117
}
112118

119+
OpVersionDesc& BugfixWithBehaviorChanged(const std::string& remark) {
120+
infos_.push_back(std::shared_ptr<OpUpdateRecord>(
121+
new compatible::BugfixWithBehaviorChanged(remark)));
122+
return *this;
123+
}
124+
113125
private:
114126
std::vector<std::shared_ptr<OpUpdateRecord>> infos_;
115127
};

paddle/fluid/framework/op_version_registry_test.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ namespace compatible {
2323

2424
TEST(test_operator_version, test_operator_version) {
2525
REGISTER_OP_VERSION(test__)
26+
.AddCheckpoint(
27+
R"ROC(Fix the bug of reshape op, support the case of axis < 0)ROC",
28+
framework::compatible::OpVersionDesc().BugfixWithBehaviorChanged(
29+
"Support the case of axis < 0"))
2630
.AddCheckpoint(
2731
R"ROC(
2832
Upgrade reshape, modified one attribute [axis] and add a new attribute [size].

paddle/fluid/framework/tensor_util.cc

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -913,10 +913,20 @@ std::ostream& print_tensor(std::ostream& os, const framework::Tensor& tensor) {
913913
auto element_num = tensor.numel();
914914

915915
os << " - data: [";
916-
if (element_num > 0) {
917-
os << inspect[0];
918-
for (int j = 1; j < element_num; ++j) {
919-
os << " " << inspect[j];
916+
// Note: int8_t && uint8_t is typedf of char, ostream unable to print properly
917+
if (typeid(int8_t) == typeid(T) || typeid(uint8_t) == typeid(T)) {
918+
if (element_num > 0) {
919+
os << signed(inspect[0]);
920+
for (int j = 1; j < element_num; ++j) {
921+
os << " " << signed(inspect[j]);
922+
}
923+
}
924+
} else {
925+
if (element_num > 0) {
926+
os << inspect[0];
927+
for (int j = 1; j < element_num; ++j) {
928+
os << " " << inspect[j];
929+
}
920930
}
921931
}
922932
os << "]";

paddle/fluid/imperative/backward_strategy.h

Lines changed: 0 additions & 33 deletions
This file was deleted.

paddle/fluid/imperative/basic_engine.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@
3030
#include "paddle/fluid/operators/math/math_function.h"
3131
#include "paddle/fluid/platform/profiler.h"
3232

33+
DECLARE_bool(sort_sum_gradient);
34+
3335
namespace paddle {
3436
namespace imperative {
3537

36-
void BasicEngine::Init(VarBase* var, const detail::BackwardStrategy& strategy,
37-
bool retain_graph) {
38-
backward_strategy_ = strategy;
38+
void BasicEngine::Init(VarBase* var, bool retain_graph) {
39+
sorted_sum_gradient_ = FLAGS_sort_sum_gradient;
3940
retain_graph_ = retain_graph;
4041
init_node_ = var->GradVarBase()->GradNode();
4142
var->GradVarBase()->ClearGradNode();
@@ -105,7 +106,7 @@ void BasicEngine::PrepareGradAccumulators(const OpBase& op) {
105106

106107
auto& accumulator = accumulators_[var.get()];
107108
if (!accumulator) {
108-
if (backward_strategy_.sorted_sum_gradient_) {
109+
if (sorted_sum_gradient_) {
109110
accumulator.reset(new SortedGradientAccumulator(var.get()));
110111
} else {
111112
accumulator.reset(new EagerGradientAccumulator(var.get()));

paddle/fluid/imperative/basic_engine.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include <unordered_map>
1919
#include <utility>
2020
#include <vector>
21-
#include "paddle/fluid/imperative/backward_strategy.h"
2221
#include "paddle/fluid/imperative/engine.h"
2322
#include "paddle/fluid/imperative/gradient_accumulator.h"
2423

@@ -30,8 +29,7 @@ class OpBase;
3029

3130
class BasicEngine : public Engine {
3231
public:
33-
void Init(VarBase* var, const detail::BackwardStrategy& strategy,
34-
bool retain_graph = false);
32+
void Init(VarBase* var, bool retain_graph = false);
3533

3634
void Execute() override;
3735

@@ -46,7 +44,7 @@ class BasicEngine : public Engine {
4644

4745
private:
4846
std::shared_ptr<GradOpNode> init_node_;
49-
detail::BackwardStrategy backward_strategy_;
47+
bool sorted_sum_gradient_;
5048
std::unordered_map<GradOpNode*, size_t> node_deps_;
5149
std::unordered_map<VariableWrapper*, std::unique_ptr<GradientAccumulator>>
5250
accumulators_;

paddle/fluid/imperative/partial_grad_engine.cc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
#include "paddle/fluid/platform/profiler.h"
3434
#include "paddle/fluid/string/string_helper.h"
3535

36+
DECLARE_bool(sort_sum_gradient);
37+
3638
namespace paddle {
3739
namespace imperative {
3840

@@ -529,8 +531,7 @@ class PartialGradTask {
529531
const std::vector<std::shared_ptr<VarBase>> &output_targets,
530532
const std::vector<std::shared_ptr<VarBase>> &output_grads,
531533
const std::vector<std::shared_ptr<VarBase>> &no_grad_vars,
532-
const platform::Place &place,
533-
const detail::BackwardStrategy &strategy, bool create_graph,
534+
const platform::Place &place, bool create_graph,
534535
bool retain_graph, bool allow_unused, bool only_inputs);
535536

536537
std::vector<std::shared_ptr<VarBase>> Run();
@@ -577,23 +578,22 @@ class PartialGradTask {
577578
bool retain_graph_;
578579
bool allow_unused_;
579580
bool only_inputs_;
580-
detail::BackwardStrategy strategy_;
581+
bool sorted_sum_gradient_{FLAGS_sort_sum_gradient};
581582
};
582583

583584
PartialGradTask::PartialGradTask(
584585
const std::vector<std::shared_ptr<VarBase>> &input_targets,
585586
const std::vector<std::shared_ptr<VarBase>> &output_targets,
586587
const std::vector<std::shared_ptr<VarBase>> &output_grads,
587588
const std::vector<std::shared_ptr<VarBase>> &no_grad_vars,
588-
const platform::Place &place, const detail::BackwardStrategy &strategy,
589-
bool create_graph, bool retain_graph, bool allow_unused, bool only_inputs) {
589+
const platform::Place &place, bool create_graph, bool retain_graph,
590+
bool allow_unused, bool only_inputs) {
590591
input_targets_ = input_targets;
591592
place_ = place;
592593
create_graph_ = create_graph;
593594
retain_graph_ = retain_graph;
594595
allow_unused_ = allow_unused;
595596
only_inputs_ = only_inputs;
596-
strategy_ = strategy;
597597

598598
PADDLE_ENFORCE_EQ(only_inputs_, true,
599599
platform::errors::Unimplemented(
@@ -981,7 +981,7 @@ void PartialGradTask::PrepareInitialGradientAccumulators(const OpBase *op) {
981981

982982
if (!accumulator) {
983983
accumulator.reset(new GradientAccumulationInfo(
984-
var, strategy_.sorted_sum_gradient_, create_graph_));
984+
var, sorted_sum_gradient_, create_graph_));
985985
}
986986

987987
accumulator->IncreaseTotalRefCnt();
@@ -1033,11 +1033,11 @@ PartialGradEngine::PartialGradEngine(
10331033
const std::vector<std::shared_ptr<VarBase>> &output_targets,
10341034
const std::vector<std::shared_ptr<VarBase>> &output_grads,
10351035
const std::vector<std::shared_ptr<VarBase>> &no_grad_vars,
1036-
const platform::Place &place, const detail::BackwardStrategy &strategy,
1037-
bool create_graph, bool retain_graph, bool allow_unused, bool only_inputs)
1036+
const platform::Place &place, bool create_graph, bool retain_graph,
1037+
bool allow_unused, bool only_inputs)
10381038
: task_(new PartialGradTask(input_targets, output_targets, output_grads,
1039-
no_grad_vars, place, strategy, create_graph,
1040-
retain_graph, allow_unused, only_inputs)) {}
1039+
no_grad_vars, place, create_graph, retain_graph,
1040+
allow_unused, only_inputs)) {}
10411041

10421042
PartialGradEngine::~PartialGradEngine() { Clear(); }
10431043

paddle/fluid/imperative/partial_grad_engine.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
#include <memory>
1818
#include <vector>
19-
#include "paddle/fluid/imperative/backward_strategy.h"
2019
#include "paddle/fluid/imperative/engine.h"
2120
#include "paddle/fluid/platform/place.h"
2221

@@ -33,8 +32,7 @@ class PartialGradEngine : public Engine {
3332
const std::vector<std::shared_ptr<VarBase>> &output_targets,
3433
const std::vector<std::shared_ptr<VarBase>> &output_grads,
3534
const std::vector<std::shared_ptr<VarBase>> &no_grad_vars,
36-
const platform::Place &place,
37-
const detail::BackwardStrategy &strategy, bool create_graph,
35+
const platform::Place &place, bool create_graph,
3836
bool retain_graph, bool allow_unused, bool only_inputs);
3937

4038
~PartialGradEngine();

0 commit comments

Comments
 (0)