!39901 Fix aicpu compile bug.

Merge pull request !39901 from linqingke/aicpu
This commit is contained in:
i-robot 2022-08-06 06:19:37 +00:00 committed by Gitee
commit 71609ea685
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 25 additions and 22 deletions

View File

@ -122,6 +122,8 @@ void SharderNonBlock::ParallelFor(int64_t total, int64_t per_unit_size, const Sh
work(start, limit);
} catch (std::exception &) {
AICPU_LOGE("exception occurred in work function with start: %lld, limit: %lld", start, limit);
} catch (...) {
AICPU_LOGE("Executor call destructor failed.");
}
int32_t sem_post_ret = sem_post(&sem);

View File

@ -35,21 +35,21 @@ void RandomShuffleKernel::IndexShuffle(const size_t &size, void *data) {
}
template <typename Scalar>
AicpuKernelErrCode RandomShuffleKernel::ScalarShuffle() {
uint32_t RandomShuffleKernel::ScalarShuffle() {
// Copy input to output, then shuffle output.
const size_t &input_size = block_num_ * block_size_ * sizeof(Scalar);
auto ret =
memcpy_s(reinterpret_cast<void *>(io_addrs_[1]), input_size, reinterpret_cast<void *>(io_addrs_[0]), input_size);
if (ret != EOK) {
AICPU_LOGE("memcpy_s() failed: %d.", ret);
return AICPU_KERNEL_STATE_INTERNAL_ERROR;
return kAicpuKernelStateInternalError;
}
IndexShuffle<Scalar>(block_num_, reinterpret_cast<void *>(io_addrs_[1]));
return AICPU_KERNEL_STATE_SUCCESS;
return kAicpuKernelStateSucess;
}
AicpuKernelErrCode RandomShuffleKernel::TensorShuffle() {
uint32_t RandomShuffleKernel::TensorShuffle() {
std::vector<size_t> permutation(block_num_);
for (size_t i = 0; i < block_num_; i++) {
permutation[i] = i;
@ -64,11 +64,11 @@ AicpuKernelErrCode RandomShuffleKernel::TensorShuffle() {
auto ret = memcpy_s(reinterpret_cast<void *>(output_offset), size, reinterpret_cast<void *>(input_offset), size);
if (ret != EOK) {
AICPU_LOGE("memcpy_s() failed: %d.", ret);
return AICPU_KERNEL_STATE_INTERNAL_ERROR;
return kAicpuKernelStateInternalError;
}
}
return AICPU_KERNEL_STATE_SUCCESS;
return kAicpuKernelStateSucess;
}
uint32_t RandomShuffleKernel::ParseKernelParam() {
@ -82,7 +82,7 @@ uint32_t RandomShuffleKernel::ParseKernelParam() {
const size_t &num_input = node_def_.inputs_size();
if (num_input != 1) {
AICPU_LOGE("For RandomShuffle: input num should be 1.");
return AICPU_KERNEL_STATE_PARAM_INVALID;
return kAicpuKernelStateInvalid;
}
::aicpuops::Tensor input = node_def_.inputs(static_cast<int>(0));
@ -95,14 +95,14 @@ uint32_t RandomShuffleKernel::ParseKernelParam() {
size_t dim = static_cast<size_t>(shape.dim_size());
if (dim == 0) {
// Input is a scalar: keep block number to be 1.
return AICPU_KERNEL_STATE_SUCCESS;
return kAicpuKernelStateSucess;
}
for (size_t i = 1; i < dim; i++) {
block_size_ *= static_cast<size_t>(shape.dim(i).size());
}
return AICPU_KERNEL_STATE_SUCCESS;
return kAicpuKernelStateSucess;
}
uint32_t RandomShuffleKernel::DoCompute() {
@ -112,7 +112,7 @@ uint32_t RandomShuffleKernel::DoCompute() {
size_in_bytes);
if (ret != EOK) {
AICPU_LOGE("memcpy_s() failed: %d.", ret);
return AICPU_KERNEL_STATE_INTERNAL_ERROR;
return kAicpuKernelStateInternalError;
}
}

View File

@ -33,8 +33,8 @@ class RandomShuffleKernel : public KernelBase {
template <typename Scalar>
void IndexShuffle(const size_t &size, void *data);
template <typename Scalar>
AicpuKernelErrCode ScalarShuffle();
AicpuKernelErrCode TensorShuffle();
uint32_t ScalarShuffle();
uint32_t TensorShuffle();
size_t block_num_{1};
size_t block_size_{1};

View File

@ -19,7 +19,7 @@ import os
import shutil
import sys
import traceback
from datetime import datetime
from datetime import datetime, timezone
from tbe.common.rl_bank.bank_manager import set_current_op_name
from tbe.common.repository_manager.interface import cann_kb_finalize, cann_kb_init
@ -127,13 +127,6 @@ def __init_tune_env(job, need_ga):
try:
import auto_tune.auto_tune_main as at_atm
from schedule_search.rl_online_tune import rl_tune_init # pylint: disable=unused-import
if need_ga:
res = at_atm.ga_tune_init()
if not res:
job.error("check soc version failed in tune init")
job.error("GATune run Failed. Run .o Failed, because soc_version doesn't match the device")
return False
return True
except ImportError:
msg = "TBEException", \
"No module named `auto_tune` or `schedule_search`. If you want tune your op's performance," \
@ -148,6 +141,14 @@ def __init_tune_env(job, need_ga):
finally:
pass
if need_ga:
res = at_atm.ga_tune_init()
if not res:
job.error("check soc version failed in tune init")
job.error("GATune run Failed. Run .o Failed, because soc_version doesn't match the device")
return False
return True
def __creating_default_custom_path(auto_tiling_mode, base_custom_path):
"""
@ -208,7 +209,7 @@ def _parallel_compilation_init(initialize: TbeJob):
real_debug_level = get_real_op_debug_level(initialize.content)
auto_tiling_mode = initialize.content["SocInfo"]["autoTilingMode"]
offline_tune = initialize.content["SocInfo"]["offlineTune"]
pid_ts = "{}_pid{}".format(datetime.now().strftime('%Y%m%d_%H%M%S%f')[:-3], os.getpid())
pid_ts = "{}_pid{}".format(datetime.now(tz=timezone.utc).strftime('%Y%m%d_%H%M%S%f')[:-3], os.getpid())
ret = init_multi_process_env(False, soc_info, auto_tiling_mode, real_debug_level,
None, 1, pid_ts)
if ret is None:
@ -284,7 +285,7 @@ def _normalize_module_name(module_name, py_module_path):
:return:
"""
if py_module_path not in sys.path:
sys.path.insert(0, py_module_path)
sys.path.append(py_module_path)
sync_syspath(py_module_path)