!9358 PyNative Bugfix

From: @jojobugfree
Reviewed-by: @chujinjin,@jjfeing
Signed-off-by: @jjfeing
pull/9358/MERGE
mindspore-ci-bot 4 years ago committed by Gitee
commit efc7e9f89e

@ -824,10 +824,6 @@ bool AscendKernelRuntime::ResetDevice() {
bool AscendKernelRuntime::HcclInit() {
auto context_ptr = MsContext::GetInstance();
MS_EXCEPTION_IF_NULL(context_ptr);
if (context_ptr->get_param<int>(MS_CTX_EXECUTION_MODE) == kPynativeMode) {
MS_LOG(INFO) << "PyNative hccl init";
return kernel::HcclContext::GetInstance().InitHccl();
}
if (!context::IsTsdOpened(context_ptr)) {
MS_LOG(EXCEPTION) << "Hccl dependent tsd is not open";
}
@ -857,6 +853,10 @@ bool AscendKernelRuntime::HcclInit() {
MS_LOG(ERROR) << "Hcom init failed.";
return false;
}
if (context_ptr->get_param<int>(MS_CTX_EXECUTION_MODE) == kPynativeMode) {
MS_LOG(INFO) << "PyNative hccl init";
return kernel::HcclContext::GetInstance().InitHccl();
}
return true;
}

@ -86,4 +86,4 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR}/../)
add_library(_ut_serving_obj OBJECT ${SERVING_SRC_TEST})
add_compile_definitions(ENABLE_DVPP_INTERFACE)

@ -1,26 +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 ACL_STUB_INC_ACL_H
#define ACL_STUB_INC_ACL_H
#include "acl_base.h"
#include "acl_mdl.h"
#include "acl_rt.h"
aclError aclInit(const char *configPath);
aclError aclFinalize();
#endif // ACL_STUB_INC_ACL_H

@ -1,85 +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 ACL_STUB_INC_ACL_BASE
#define ACL_STUB_INC_ACL_BASE
#include <stdint.h>
#include <stddef.h>
typedef void *aclrtStream;
typedef void *aclrtEvent;
typedef void *aclrtContext;
typedef int aclError;
typedef uint16_t aclFloat16;
typedef struct aclDataBuffer aclDataBuffer;
typedef struct aclTensorDesc aclTensorDesc;
const int ACL_ERROR_NONE = 0;
typedef enum {
ACL_DT_UNDEFINED = -1,
ACL_FLOAT = 0,
ACL_FLOAT16 = 1,
ACL_INT8 = 2,
ACL_INT32 = 3,
ACL_UINT8 = 4,
ACL_INT16 = 6,
ACL_UINT16 = 7,
ACL_UINT32 = 8,
ACL_INT64 = 9,
ACL_UINT64 = 10,
ACL_DOUBLE = 11,
ACL_BOOL = 12,
} aclDataType;
typedef enum {
ACL_FORMAT_UNDEFINED = -1,
ACL_FORMAT_NCHW = 0,
ACL_FORMAT_NHWC = 1,
ACL_FORMAT_ND = 2,
ACL_FORMAT_NC1HWC0 = 3,
ACL_FORMAT_FRACTAL_Z = 4,
ACL_FORMAT_FRACTAL_NZ = 29,
} aclFormat;
typedef enum {
ACL_DEBUG,
ACL_INFO,
ACL_WARNING,
ACL_ERROR,
} aclLogLevel;
aclDataBuffer *aclCreateDataBuffer(void *data, size_t size);
aclError aclDestroyDataBuffer(const aclDataBuffer *dataBuffer);
void *aclGetDataBufferAddr(const aclDataBuffer *dataBuffer);
uint32_t aclGetDataBufferSize(const aclDataBuffer *dataBuffer);
size_t aclDataTypeSize(aclDataType dataType);
aclTensorDesc *aclCreateTensorDesc(aclDataType dataType, int numDims, const int64_t *dims, aclFormat format);
void aclDestroyTensorDesc(const aclTensorDesc *desc);
aclDataType aclGetTensorDescType(const aclTensorDesc *desc);
aclFormat aclGetTensorDescFormat(const aclTensorDesc *desc);
size_t aclGetTensorDescSize(const aclTensorDesc *desc);
size_t aclGetTensorDescElementCount(const aclTensorDesc *desc);
size_t aclGetTensorDescNumDims(const aclTensorDesc *desc);
int64_t aclGetTensorDescDim(const aclTensorDesc *desc, size_t index);
void aclAppLog(aclLogLevel logLevel, const char *func, const char *file, uint32_t line, const char *fmt, ...);
#define ACL_APP_LOG(level, fmt, ...) aclAppLog(level, __FUNCTION__, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
#endif

@ -1,75 +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 ACL_STUB_INC_ACL_MDL
#define ACL_STUB_INC_ACL_MDL
#include "acl_base.h"
#define ACL_MAX_DIM_CNT 128
#define ACL_MAX_TENSOR_NAME_LEN 128
#define ACL_MAX_BATCH_NUM 128
#define ACL_MAX_HW_NUM 128
#define ACL_MAX_SHAPE_COUNT 128
typedef struct aclmdlDataset aclmdlDataset;
typedef struct aclmdlDesc aclmdlDesc;
typedef struct aclmdlIODims {
char name[ACL_MAX_TENSOR_NAME_LEN];
size_t dimCount;
int64_t dims[ACL_MAX_DIM_CNT];
} aclmdlIODims;
aclmdlDesc *aclmdlCreateDesc();
aclError aclmdlDestroyDesc(aclmdlDesc *modelDesc);
aclError aclmdlGetDesc(aclmdlDesc *modelDesc, uint32_t modelId);
size_t aclmdlGetNumInputs(aclmdlDesc *modelDesc);
size_t aclmdlGetNumOutputs(aclmdlDesc *modelDesc);
size_t aclmdlGetInputSizeByIndex(aclmdlDesc *modelDesc, size_t index);
size_t aclmdlGetOutputSizeByIndex(aclmdlDesc *modelDesc, size_t index);
aclmdlDataset *aclmdlCreateDataset();
aclError aclmdlDestroyDataset(const aclmdlDataset *dataSet);
aclError aclmdlAddDatasetBuffer(aclmdlDataset *dataSet, aclDataBuffer *dataBuffer);
size_t aclmdlGetDatasetNumBuffers(const aclmdlDataset *dataSet);
aclDataBuffer *aclmdlGetDatasetBuffer(const aclmdlDataset *dataSet, size_t index);
aclError aclmdlLoadFromFile(const char *modelPath, uint32_t *modelId);
aclError aclmdlLoadFromMem(const void *model, size_t modelSize, uint32_t *modelId);
aclError aclmdlLoadFromFileWithMem(const char *modelPath, uint32_t *modelId, void *workPtr, size_t workSize,
void *weightPtr, size_t weightSize);
aclError aclmdlLoadFromMemWithMem(const void *model, size_t modelSize, uint32_t *modelId, void *workPtr,
size_t workSize, void *weightPtr, size_t weightSize);
aclError aclmdlExecute(uint32_t modelId, const aclmdlDataset *input, aclmdlDataset *output);
aclError aclmdlExecuteAsync(uint32_t modelId, const aclmdlDataset *input, aclmdlDataset *output, aclrtStream stream);
aclError aclmdlUnload(uint32_t modelId);
aclError aclmdlQuerySize(const char *fileName, size_t *workSize, size_t *weightSize);
aclError aclmdlQuerySizeFromMem(const void *model, size_t modelSize, size_t *workSize, size_t *weightSize);
aclError aclmdlGetInputDims(const aclmdlDesc *modelDesc, size_t index, aclmdlIODims *dims);
aclError aclmdlGetOutputDims(const aclmdlDesc *modelDesc, size_t index, aclmdlIODims *dims);
aclError aclmdlGetCurOutputDims(const aclmdlDesc *modelDesc, size_t index, aclmdlIODims *dims);
aclFormat aclmdlGetInputFormat(const aclmdlDesc *modelDesc, size_t index);
aclFormat aclmdlGetOutputFormat(const aclmdlDesc *modelDesc, size_t index);
aclDataType aclmdlGetInputDataType(const aclmdlDesc *modelDesc, size_t index);
aclDataType aclmdlGetOutputDataType(const aclmdlDesc *modelDesc, size_t index);
#endif

@ -1,89 +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 ACL_STUB_INC_ACL_RT_H
#define ACL_STUB_INC_ACL_RT_H
#include "acl_base.h"
typedef enum aclrtRunMode {
ACL_DEVICE,
ACL_HOST,
} aclrtRunMode;
typedef enum aclrtTsId {
ACL_TS_ID_AICORE,
ACL_TS_ID_AIVECTOR,
ACL_TS_ID_RESERVED,
} aclrtTsId;
typedef enum aclrtEventStatus {
ACL_EVENT_STATUS_COMPLETE,
ACL_EVENT_STATUS_NOT_READY,
ACL_EVENT_STATUS_RESERVED,
} aclrtEventStatus;
typedef enum aclrtCallbackBlockType {
ACL_CALLBACK_NO_BLOCK,
ACL_CALLBACK_BLOCK,
} aclrtCallbackBlockType;
typedef enum aclrtMemcpyKind {
ACL_MEMCPY_HOST_TO_HOST,
ACL_MEMCPY_HOST_TO_DEVICE,
ACL_MEMCPY_DEVICE_TO_HOST,
ACL_MEMCPY_DEVICE_TO_DEVICE,
} aclrtMemcpyKind;
typedef enum aclrtMemMallocPolicy {
ACL_MEM_MALLOC_HUGE_FIRST,
ACL_MEM_MALLOC_HUGE_ONLY,
ACL_MEM_MALLOC_NORMAL_ONLY,
} aclrtMemMallocPolicy;
typedef struct rtExceptionInfo aclrtExceptionInfo;
typedef void (*aclrtCallback)(void *userData);
typedef void (*aclrtExceptionInfoCallback)(aclrtExceptionInfo *exceptionInfo);
aclError aclrtCreateContext(aclrtContext *context, int32_t deviceId);
aclError aclrtDestroyContext(aclrtContext context);
aclError aclrtSetCurrentContext(aclrtContext context);
aclError aclrtGetCurrentContext(aclrtContext *context);
aclError aclrtSetDevice(int32_t deviceId);
aclError aclrtResetDevice(int32_t deviceId);
aclError aclrtGetDevice(int32_t *deviceId);
aclError aclrtGetRunMode(aclrtRunMode *runMode);
aclError aclrtSynchronizeDevice(void);
aclError aclrtSetTsDevice(aclrtTsId tsId);
aclError aclrtGetDeviceCount(uint32_t *count);
aclError aclrtMalloc(void **devPtr, size_t size, aclrtMemMallocPolicy policy);
aclError aclrtFree(void *devPtr);
aclError aclrtMallocHost(void **hostPtr, size_t size);
aclError aclrtFreeHost(void *hostPtr);
aclError aclrtMemcpy(void *dst, size_t destMax, const void *src, size_t count, aclrtMemcpyKind kind);
aclError aclrtMemset(void *devPtr, size_t maxCount, int32_t value, size_t count);
aclError aclrtMemcpyAsync(void *dst, size_t destMax, const void *src, size_t count, aclrtMemcpyKind kind,
aclrtStream stream);
aclError aclrtMemsetAsync(void *devPtr, size_t maxCount, int32_t value, size_t count, aclrtStream stream);
aclError aclrtCreateStream(aclrtStream *stream);
aclError aclrtDestroyStream(aclrtStream stream);
aclError aclrtSynchronizeStream(aclrtStream stream);
aclError aclrtStreamWaitEvent(aclrtStream stream, aclrtEvent event);
#endif

@ -1,112 +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 ACL_STUB_INC_ACL_DVPP_H
#define ACL_STUB_INC_ACL_DVPP_H
#include <stddef.h>
#include "acl/acl.h"
#include "acl/acl_base.h"
typedef struct acldvppPicDesc acldvppPicDesc;
typedef struct acldvppRoiConfig acldvppRoiConfig;
typedef struct acldvppResizeConfig acldvppResizeConfig;
typedef struct acldvppChannelDesc acldvppChannelDesc;
typedef struct acldvppStreamDesc acldvppStreamDesc;
typedef struct acldvppBatchPicDesc acldvppBatchPicDesc;
enum acldvppPixelFormat {
PIXEL_FORMAT_YUV_400 = 0,
PIXEL_FORMAT_YUV_SEMIPLANAR_420 = 1, // YUV
PIXEL_FORMAT_YVU_SEMIPLANAR_420 = 2, // YVU
PIXEL_FORMAT_YUV_SEMIPLANAR_422 = 3, // YUV
PIXEL_FORMAT_YVU_SEMIPLANAR_422 = 4, // YVU
PIXEL_FORMAT_YUV_SEMIPLANAR_444 = 5, // YUV
PIXEL_FORMAT_YVU_SEMIPLANAR_444 = 6, // YVU
};
enum acldvppStreamFormat {
H265_MAIN_LEVEL = 0,
H254_BASELINE_LEVEL = 1,
H254_MAIN_LEVEL,
H254_HIGH_LEVEL,
};
enum acldvppChannelMode { DVPP_CHNMODE_VPC = 1, DVPP_CHNMODE_JPEGD = 2, DVPP_CHNMODE_JPEGE = 4 };
aclError acldvppMalloc(void **devPtr, size_t size);
aclError acldvppFree(void *devPtr);
acldvppChannelDesc *acldvppCreateChannelDesc();
aclError acldvppDestroyChannelDesc(acldvppChannelDesc *channelDesc);
acldvppPicDesc *acldvppCreatePicDesc();
aclError acldvppDestroyPicDesc(acldvppPicDesc *picDesc);
aclError acldvppSetPicDescSize(acldvppPicDesc *picDesc, uint32_t size);
aclError acldvppSetPicDescFormat(acldvppPicDesc *picDesc, acldvppPixelFormat format);
aclError acldvppSetPicDescWidth(acldvppPicDesc *picDesc, uint32_t width);
aclError acldvppSetPicDescHeight(acldvppPicDesc *picDesc, uint32_t height);
aclError acldvppSetPicDescData(acldvppPicDesc *picDesc, void *dataDev);
aclError acldvppSetPicDescWidthStride(acldvppPicDesc *picDesc, uint32_t widthStride);
aclError acldvppSetPicDescHeightStride(acldvppPicDesc *picDesc, uint32_t heightStride);
aclError acldvppSetPicDescRetCode(acldvppPicDesc *picDesc, uint32_t retCode);
uint32_t acldvppGetPicDescSize(acldvppPicDesc *picDesc);
acldvppPixelFormat acldvppGetPicDescFormat(acldvppPicDesc *picDesc);
uint32_t acldvppGetPicDescWidth(acldvppPicDesc *picDesc);
uint32_t acldvppGetPicDescHeight(acldvppPicDesc *picDesc);
void *acldvppGetPicDescData(acldvppPicDesc *picDesc);
uint32_t acldvppGetPicDescWidthStride(acldvppPicDesc *picDesc);
uint32_t acldvppGetPicDescHeightStride(acldvppPicDesc *picDesc);
uint32_t acldvppGetPicDescRetCode(acldvppPicDesc *picDesc);
acldvppRoiConfig *acldvppCreateRoiConfig(uint32_t left, uint32_t right, uint32_t top, uint32_t bottom);
aclError acldvppDestroyRoiConfig(acldvppRoiConfig *roiConfig);
aclError acldvppSetRoiConfigLeft(acldvppRoiConfig *roiConfig, uint32_t left);
aclError acldvppSetRoiConfigRight(acldvppRoiConfig *roiConfig, uint32_t right);
aclError acldvppSetRoiConfigTop(acldvppRoiConfig *roiConfig, uint32_t top);
aclError acldvppSetRoiConfigBottom(acldvppRoiConfig *roiConfig, uint32_t bottom);
aclError acldvppSetRoiConfig(acldvppRoiConfig *roiConfig, uint32_t left, uint32_t right, uint32_t top, uint32_t bottom);
acldvppResizeConfig *acldvppCreateResizeConfig();
aclError acldvppDestroyResizeConfig(acldvppResizeConfig *resizeConfig);
aclError acldvppJpegPredictDecSize(const void *data, uint32_t dataSize, acldvppPixelFormat ouputPixelFormat,
uint32_t *decSize);
aclError acldvppCreateChannel(acldvppChannelDesc *channelDesc);
aclError acldvppDestroyChannel(acldvppChannelDesc *channelDesc);
aclError acldvppVpcResizeAsync(acldvppChannelDesc *channelDesc, acldvppPicDesc *inputDesc, acldvppPicDesc *outputDesc,
acldvppResizeConfig *resizeConfig, aclrtStream stream);
aclError acldvppVpcCropAsync(acldvppChannelDesc *channelDesc, acldvppPicDesc *inputDesc, acldvppPicDesc *outputDesc,
acldvppRoiConfig *cropArea, aclrtStream stream);
aclError acldvppVpcCropAndPasteAsync(acldvppChannelDesc *channelDesc, acldvppPicDesc *inputDesc,
acldvppPicDesc *outputDesc, acldvppRoiConfig *cropArea,
acldvppRoiConfig *pasteArea, aclrtStream stream);
aclError acldvppVpcBatchCropAsync(acldvppChannelDesc *channelDesc, acldvppBatchPicDesc *srcBatchDesc, uint32_t *roiNums,
uint32_t size, acldvppBatchPicDesc *dstBatchDesc, acldvppRoiConfig *cropAreas[],
aclrtStream stream);
aclError acldvppJpegDecodeAsync(acldvppChannelDesc *channelDesc, const void *data, uint32_t size,
acldvppPicDesc *outputDesc, aclrtStream stream);
acldvppBatchPicDesc *acldvppCreateBatchPicDesc(uint32_t batchSize);
acldvppPicDesc *acldvppGetPicDesc(acldvppBatchPicDesc *batchPicDesc, uint32_t index);
aclError acldvppDestroyBatchPicDesc(acldvppBatchPicDesc *batchPicDesc);
#endif // ACL_STUB_INC_ACL_DVPP_H
Loading…
Cancel
Save