clean codex

This commit is contained in:
caifubi 2021-03-31 11:18:59 +08:00
parent d346a861bc
commit 58f3ea002d
8 changed files with 16 additions and 111 deletions

View File

@ -23,13 +23,16 @@ constexpr auto kHcclConfigFileOld = "RANK_TABLE_FILE";
namespace mindspore { namespace mindspore {
namespace kernel { namespace kernel {
std::string GetRankId() { int GetRankId() {
std::string rank_id_str; auto rank_id_env = std::getenv("RANK_ID");
rank_id_str = std::getenv("RANK_ID"); if (rank_id_env == nullptr) {
if (rank_id_str.empty()) { MS_LOG(EXCEPTION) << "No RANK_ID, please export RANK_ID";
MS_LOG(ERROR) << "Get hccl rankid failed, please set env RANK_ID"; }
try {
return std::stoi(rank_id_env);
} catch (std::invalid_argument &e) {
MS_LOG(EXCEPTION) << "Invalid rankd id env:" << rank_id_env;
} }
return rank_id_str;
} }
bool HcclContext::InitHccl() { bool HcclContext::InitHccl() {
@ -45,14 +48,7 @@ bool HcclContext::InitHccl() {
} }
} }
auto rank_id = GetRankId(); rank_id_ = GetRankId();
try {
rank_id_ = std::stoi(rank_id);
} catch (std::invalid_argument &e) {
MS_LOG(ERROR) << "Invalid rankd id env:" << rank_id;
return false;
}
if (rank_id_ < 0 || rank_id_ > 7) { if (rank_id_ < 0 || rank_id_ > 7) {
MS_LOG(ERROR) << "rank_id needs to be between 0-7"; MS_LOG(ERROR) << "rank_id needs to be between 0-7";
return false; return false;

View File

@ -46,7 +46,6 @@
#include "backend/optimizer/mem_reuse/mem_reuse_checker.h" #include "backend/optimizer/mem_reuse/mem_reuse_checker.h"
#endif #endif
#include "runtime/device/ascend/executor/tiling/op_tiling_calculater.h" #include "runtime/device/ascend/executor/tiling/op_tiling_calculater.h"
#include "runtime/device/executor/executor_callback.h"
#include "runtime/device/ascend/executor/hccl_dynamic_kernel.h" #include "runtime/device/ascend/executor/hccl_dynamic_kernel.h"
#include "utils/config_manager.h" #include "utils/config_manager.h"
#include "runtime/device/ascend/profiling/reporter/op_name_task_stream_reporter.h" #include "runtime/device/ascend/profiling/reporter/op_name_task_stream_reporter.h"

View File

@ -24,7 +24,6 @@
#include "utils/utils.h" #include "utils/utils.h"
#include "backend/session/anf_runtime_algorithm.h" #include "backend/session/anf_runtime_algorithm.h"
#include "backend/kernel_compiler/aicpu/aicpu_util.h" #include "backend/kernel_compiler/aicpu/aicpu_util.h"
#include "runtime/device/executor/executor_callback.h"
namespace mindspore { namespace mindspore {
namespace device { namespace device {

View File

@ -37,7 +37,10 @@ bool AicpuExtInfoHandler::Parse(const std::string &ext_info) {
ext_info_.reset(new (std::nothrow) uint8_t[ext_info_len_]); ext_info_.reset(new (std::nothrow) uint8_t[ext_info_len_]);
MS_EXCEPTION_IF_NULL(ext_info_); MS_EXCEPTION_IF_NULL(ext_info_);
(void)memcpy_s(ext_info_.get(), ext_info_len_, ext_info.c_str(), ext_info.size()); auto ret = memcpy_s(ext_info_.get(), ext_info_len_, ext_info.c_str(), ext_info.size());
if (ret != 0) {
MS_LOG(EXCEPTION) << "The memcpy_s failed, errorno(" << ret << ")";
}
input_shape_and_type_.clear(); input_shape_and_type_.clear();
output_shape_and_type_.clear(); output_shape_and_type_.clear();

View File

@ -1,39 +0,0 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "runtime/device/executor/executor_callback.h"
#include "utils/log_adapter.h"
namespace mindspore {
namespace device {
void ExecutorCallback::RegistCallback(const std::function<void()> &callback) {
std::lock_guard<std::mutex> guard(lock_);
callback_queue_.push(callback);
}
void ExecutorCallback::Consume() {
std::lock_guard<std::mutex> guard(lock_);
while (!callback_queue_.empty()) {
auto callback_func = callback_queue_.front();
callback_queue_.pop();
if (!callback_func) {
MS_LOG(EXCEPTION) << "callback_func is empty";
}
callback_func();
}
}
} // namespace device
} // namespace mindspore

View File

@ -1,47 +0,0 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MINDSPORE_MINDSPORE_CCSRC_RUNTIME_DEVICE_EXECUTOR_EXECUTOR_CALLBACK_H_
#define MINDSPORE_MINDSPORE_CCSRC_RUNTIME_DEVICE_EXECUTOR_EXECUTOR_CALLBACK_H_
#include <queue>
#include <mutex>
#include <functional>
#include "utils/ms_utils.h"
namespace mindspore {
namespace device {
class ExecutorCallback {
public:
static ExecutorCallback &GetInstance() {
static ExecutorCallback instance;
return instance;
}
void RegistCallback(const std::function<void()> &callback);
void Consume();
private:
ExecutorCallback() = default;
~ExecutorCallback() = default;
DISABLE_COPY_AND_ASSIGN(ExecutorCallback);
std::queue<std::function<void()>> callback_queue_;
std::mutex lock_;
};
} // namespace device
} // namespace mindspore
#endif // MINDSPORE_MINDSPORE_CCSRC_RUNTIME_DEVICE_EXECUTOR_EXECUTOR_CALLBACK_H_

View File

@ -1124,6 +1124,7 @@ class BatchNorm(PrimitiveWithInfer):
Inputs: Inputs:
If `is_training` is False, inputs are Tensors. If `is_training` is False, inputs are Tensors.
- **input_x** (Tensor) - Tensor of shape :math:`(N, C)`, with float16 or float32 data type. - **input_x** (Tensor) - Tensor of shape :math:`(N, C)`, with float16 or float32 data type.
- **scale** (Tensor) - Tensor of shape :math:`(C,)`, with float16 or float32 data type. - **scale** (Tensor) - Tensor of shape :math:`(C,)`, with float16 or float32 data type.
- **bias** (Tensor) - Tensor of shape :math:`(C,)`, has the same data type with `scale`. - **bias** (Tensor) - Tensor of shape :math:`(C,)`, has the same data type with `scale`.
@ -1131,6 +1132,7 @@ class BatchNorm(PrimitiveWithInfer):
- **variance** (Tensor) - Tensor of shape :math:`(C,)`, has the same data type with `mean`. - **variance** (Tensor) - Tensor of shape :math:`(C,)`, has the same data type with `mean`.
If `is_training` is True, `scale`, `bias`, `mean` and `variance` are Parameters. If `is_training` is True, `scale`, `bias`, `mean` and `variance` are Parameters.
- **input_x** (Tensor) - Tensor of shape :math:`(N, C)`, with float16 or float32 data type. - **input_x** (Tensor) - Tensor of shape :math:`(N, C)`, with float16 or float32 data type.
- **scale** (Parameter) - Parameter of shape :math:`(C,)`, with float16 or float32 data type. - **scale** (Parameter) - Parameter of shape :math:`(C,)`, with float16 or float32 data type.
- **bias** (Parameter) - Parameter of shape :math:`(C,)`, has the same data type with `scale`. - **bias** (Parameter) - Parameter of shape :math:`(C,)`, has the same data type with `scale`.

View File

@ -19,19 +19,11 @@
#include "runtime/device/ascend/executor/rts/profiling_rts_dynamic_kernel.h" #include "runtime/device/ascend/executor/rts/profiling_rts_dynamic_kernel.h"
#include "runtime/device/ascend/executor/ai_core_dynamic_kernel.h" #include "runtime/device/ascend/executor/ai_core_dynamic_kernel.h"
#include "profiler/device/ascend/rt_callback_manager.h" #include "profiler/device/ascend/rt_callback_manager.h"
#include "runtime/device/executor/executor_callback.h"
#include "profiler/device/ascend/ascend_profiling.h" #include "profiler/device/ascend/ascend_profiling.h"
#include "runtime/device/ascend/executor/tiling/op_tiling_calculater.h" #include "runtime/device/ascend/executor/tiling/op_tiling_calculater.h"
#include "backend/kernel_compiler/host/host_kernel_metadata.h" #include "backend/kernel_compiler/host/host_kernel_metadata.h"
#include "backend/kernel_compiler/host/host_kernel_build.h" #include "backend/kernel_compiler/host/host_kernel_build.h"
namespace mindspore {
namespace device {
void ExecutorCallback::RegistCallback(const std::function<void()> &callback) {}
void ExecutorCallback::Consume() {}
} // namespace device
} // namespace mindspore
namespace mindspore { namespace mindspore {
namespace device { namespace device {
namespace ascend { namespace ascend {