Skip to content

Commit e87faa9

Browse files
authored
apply comments for PR 38854 [ipu_commit/update_ipu_backend] (PaddlePaddle#391)
* apply comments 01 * update error messag * add clang-format on
1 parent d880b2a commit e87faa9

File tree

5 files changed

+33
-32
lines changed

5 files changed

+33
-32
lines changed

paddle/fluid/platform/device/ipu/CMakeLists.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,8 @@
11
IF(WITH_IPU)
22
FILE(GLOB POPART_CANONICALIZATION_SRC ${PADDLE_SOURCE_DIR}/paddle/fluid/platform/device/ipu/popart_canonicalization/*.cc)
3-
4-
set(POPART_PATTERNS_SRC
5-
""
6-
)
7-
8-
set(POPART_OPERATORS_SRC
9-
""
10-
)
11-
123
list(APPEND PADDLE_IPU_SRC ${POPART_CANONICALIZATION_SRC})
13-
list(APPEND PADDLE_IPU_SRC ${POPART_PATTERNS_SRC})
14-
list(APPEND PADDLE_IPU_SRC ${POPART_OPERATORS_SRC})
154
set(PADDLE_IPU_LIB "${CMAKE_CURRENT_BINARY_DIR}/libpaddle_ipu.so" CACHE STRING "")
165
set(PADDLE_IPU_LIB_DIR "${CMAKE_CURRENT_BINARY_DIR}" CACHE STRING "")
17-
186
set(IPU_BACKEND_SRC
197
"ipu_device.cc"
208
"ipu_strategy.cc"

paddle/fluid/platform/device/ipu/ipu_compiler.cc

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ popart::AdamMode AdamModeFromStr(const std::string& str) {
3333
} else if (str == "lamb") {
3434
return popart::AdamMode::Lamb;
3535
} else {
36-
PADDLE_THROW(platform::errors::InvalidArgument("Uknown AdamMode: %s", str));
36+
PADDLE_THROW(platform::errors::InvalidArgument(
37+
"Uknown AdamMode: %s, AdamMode must be one of these values: adam, "
38+
"adamax or lamb",
39+
str));
3740
}
3841
}
3942

@@ -47,8 +50,10 @@ popart::AdaptiveMode AdaptiveModeFromStr(const std::string& str) {
4750
} else if (str == "centered_rmsprop") {
4851
return popart::AdaptiveMode::CenteredRMSProp;
4952
} else {
50-
PADDLE_THROW(
51-
platform::errors::InvalidArgument("Uknown AdaptiveMode: %s", str));
53+
PADDLE_THROW(platform::errors::InvalidArgument(
54+
"Uknown AdaptiveMode: %s, AdaptiveMode must be one of these values: "
55+
"adadelta, adagrad, rmsprop or centered_rmsprop",
56+
str));
5257
}
5358
}
5459

@@ -58,8 +63,10 @@ popart::WeightDecayMode WeightDecayModeFromStr(const std::string& str) {
5863
} else if (str == "l2_regularization") {
5964
return popart::WeightDecayMode::L2Regularization;
6065
} else {
61-
PADDLE_THROW(
62-
platform::errors::InvalidArgument("Uknown WeightDecayMode: %s", str));
66+
PADDLE_THROW(platform::errors::InvalidArgument(
67+
"Uknown WeightDecayMode: %s, WeightDecayMode must be decay or "
68+
"l2_regularization",
69+
str));
6370
}
6471
}
6572

@@ -215,8 +222,10 @@ void Compiler::LowerBody(const Graph* graph) {
215222
if (itr != name_function_.end()) {
216223
itr->second(node->Op());
217224
} else {
218-
PADDLE_THROW(
219-
platform::errors::NotFound("%s is not registered", op_type));
225+
PADDLE_THROW(platform::errors::NotFound(
226+
"%s is not registered, please check for unsupported operators for "
227+
"running on IPU",
228+
op_type));
220229
}
221230
}
222231
}
@@ -250,9 +259,11 @@ void Compiler::InitOutputs(const std::vector<std::string>& fetch_list) {
250259
for (const auto& fetch_name : fetch_list) {
251260
fetch_list_.push_back(fetch_name);
252261
auto tensor = resources_->tensors.find(fetch_name);
253-
PADDLE_ENFORCE_NE(tensor, resources_->tensors.end(),
254-
platform::errors::NotFound(
255-
"output tensor %s does not exist.", fetch_name));
262+
PADDLE_ENFORCE_NE(
263+
tensor, resources_->tensors.end(),
264+
platform::errors::NotFound(
265+
"Output tensor %s is not found, please check the model.",
266+
fetch_name));
256267
VLOG(10) << "fetch_name= " << fetch_name;
257268
VLOG(10) << "popart output tensor id = " << tensor->second;
258269
builder_->addOutputTensor(tensor->second);

paddle/fluid/platform/device/ipu/ipu_device.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
1+
/* Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
22
33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.

paddle/fluid/platform/device/ipu/ipu_utils.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ namespace paddle {
2929
namespace platform {
3030
namespace ipu {
3131

32-
using platform::float16;
33-
using framework::Tensor;
34-
using framework::LoDTensor;
35-
using framework::Scope;
36-
using framework::OpDesc;
37-
using framework::ir::Graph;
38-
using framework::ir::Node;
39-
using framework::BlockDesc;
32+
using float16 = platform::float16;
33+
using Tensor = framework::Tensor;
34+
using LoDTensor = framework::LoDTensor;
35+
using Scope = framework::Scope;
36+
using OpDesc = framework::OpDesc;
37+
using Graph = framework::ir::Graph;
38+
using Node = framework::ir::Node;
39+
using BlockDesc = framework::BlockDesc;
4040

4141
// onnx dtype
4242
// https://github.com/onnx/onnx/blob/master/onnx/onnx-ml.proto3

paddle/fluid/platform/device/ipu/supported_ops_custom.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
1+
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -17,3 +17,5 @@
1717
#pragma once
1818

1919
OP_DECL(popart_nllloss_v2, aiGraphcoreOpset.nllloss, SIG_ARG(INT32,popart::ReductionType,reduction) OPT_ARG(INT32,ignoreIndex) ARG(BOOL,inputIsLogProbability) ) // NOLINT
20+
21+
// clang-format on

0 commit comments

Comments
 (0)