Skip to content

Commit

Permalink
apply comments for PR 38854 [ipu_commit/update_ipu_backend] (PaddlePa…
Browse files Browse the repository at this point in the history
…ddle#391)

* apply comments 01

* update error messag

* add clang-format on
  • Loading branch information
gglin001 authored Jan 17, 2022
1 parent d880b2a commit e87faa9
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 32 deletions.
12 changes: 0 additions & 12 deletions paddle/fluid/platform/device/ipu/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
IF(WITH_IPU)
FILE(GLOB POPART_CANONICALIZATION_SRC ${PADDLE_SOURCE_DIR}/paddle/fluid/platform/device/ipu/popart_canonicalization/*.cc)

set(POPART_PATTERNS_SRC
""
)

set(POPART_OPERATORS_SRC
""
)

list(APPEND PADDLE_IPU_SRC ${POPART_CANONICALIZATION_SRC})
list(APPEND PADDLE_IPU_SRC ${POPART_PATTERNS_SRC})
list(APPEND PADDLE_IPU_SRC ${POPART_OPERATORS_SRC})
set(PADDLE_IPU_LIB "${CMAKE_CURRENT_BINARY_DIR}/libpaddle_ipu.so" CACHE STRING "")
set(PADDLE_IPU_LIB_DIR "${CMAKE_CURRENT_BINARY_DIR}" CACHE STRING "")

set(IPU_BACKEND_SRC
"ipu_device.cc"
"ipu_strategy.cc"
Expand Down
31 changes: 21 additions & 10 deletions paddle/fluid/platform/device/ipu/ipu_compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ popart::AdamMode AdamModeFromStr(const std::string& str) {
} else if (str == "lamb") {
return popart::AdamMode::Lamb;
} else {
PADDLE_THROW(platform::errors::InvalidArgument("Uknown AdamMode: %s", str));
PADDLE_THROW(platform::errors::InvalidArgument(
"Uknown AdamMode: %s, AdamMode must be one of these values: adam, "
"adamax or lamb",
str));
}
}

Expand All @@ -47,8 +50,10 @@ popart::AdaptiveMode AdaptiveModeFromStr(const std::string& str) {
} else if (str == "centered_rmsprop") {
return popart::AdaptiveMode::CenteredRMSProp;
} else {
PADDLE_THROW(
platform::errors::InvalidArgument("Uknown AdaptiveMode: %s", str));
PADDLE_THROW(platform::errors::InvalidArgument(
"Uknown AdaptiveMode: %s, AdaptiveMode must be one of these values: "
"adadelta, adagrad, rmsprop or centered_rmsprop",
str));
}
}

Expand All @@ -58,8 +63,10 @@ popart::WeightDecayMode WeightDecayModeFromStr(const std::string& str) {
} else if (str == "l2_regularization") {
return popart::WeightDecayMode::L2Regularization;
} else {
PADDLE_THROW(
platform::errors::InvalidArgument("Uknown WeightDecayMode: %s", str));
PADDLE_THROW(platform::errors::InvalidArgument(
"Uknown WeightDecayMode: %s, WeightDecayMode must be decay or "
"l2_regularization",
str));
}
}

Expand Down Expand Up @@ -215,8 +222,10 @@ void Compiler::LowerBody(const Graph* graph) {
if (itr != name_function_.end()) {
itr->second(node->Op());
} else {
PADDLE_THROW(
platform::errors::NotFound("%s is not registered", op_type));
PADDLE_THROW(platform::errors::NotFound(
"%s is not registered, please check for unsupported operators for "
"running on IPU",
op_type));
}
}
}
Expand Down Expand Up @@ -250,9 +259,11 @@ void Compiler::InitOutputs(const std::vector<std::string>& fetch_list) {
for (const auto& fetch_name : fetch_list) {
fetch_list_.push_back(fetch_name);
auto tensor = resources_->tensors.find(fetch_name);
PADDLE_ENFORCE_NE(tensor, resources_->tensors.end(),
platform::errors::NotFound(
"output tensor %s does not exist.", fetch_name));
PADDLE_ENFORCE_NE(
tensor, resources_->tensors.end(),
platform::errors::NotFound(
"Output tensor %s is not found, please check the model.",
fetch_name));
VLOG(10) << "fetch_name= " << fetch_name;
VLOG(10) << "popart output tensor id = " << tensor->second;
builder_->addOutputTensor(tensor->second);
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/platform/device/ipu/ipu_device.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
/* Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
16 changes: 8 additions & 8 deletions paddle/fluid/platform/device/ipu/ipu_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ namespace paddle {
namespace platform {
namespace ipu {

using platform::float16;
using framework::Tensor;
using framework::LoDTensor;
using framework::Scope;
using framework::OpDesc;
using framework::ir::Graph;
using framework::ir::Node;
using framework::BlockDesc;
using float16 = platform::float16;
using Tensor = framework::Tensor;
using LoDTensor = framework::LoDTensor;
using Scope = framework::Scope;
using OpDesc = framework::OpDesc;
using Graph = framework::ir::Graph;
using Node = framework::ir::Node;
using BlockDesc = framework::BlockDesc;

// onnx dtype
// https://github.com/onnx/onnx/blob/master/onnx/onnx-ml.proto3
Expand Down
4 changes: 3 additions & 1 deletion paddle/fluid/platform/device/ipu/supported_ops_custom.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -17,3 +17,5 @@
#pragma once

OP_DECL(popart_nllloss_v2, aiGraphcoreOpset.nllloss, SIG_ARG(INT32,popart::ReductionType,reduction) OPT_ARG(INT32,ignoreIndex) ARG(BOOL,inputIsLogProbability) ) // NOLINT

// clang-format on

0 comments on commit e87faa9

Please sign in to comment.