已合并
fix(nn): release resources on init failure in aclnn examples and docs #8693
苏世创建于 8月14日
fix(nn): release resources on init failure in aclnn examples and docs #8693
已合并
共 72 个文件变更+287-182
| @@ -269,9 +269,11 @@ int Init(int32_t deviceId, aclrtStream* stream) { | |||
| 269 | auto ret = aclInit(nullptr); | 269 | auto ret = aclInit(nullptr); |
| 270 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 270 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 271 | ret = aclrtSetDevice(deviceId); | 271 | ret = aclrtSetDevice(deviceId); |
| 272 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 272 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 273 | ret = aclrtCreateStream(stream); | 273 | ret = aclrtCreateStream(stream); |
| 274 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 274 | + CHECK_RET(ret == ACL_SUCCESS, |
| 275 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 276 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 275 | return 0; | 277 | return 0; |
| 276 | } | 278 | } |
| 277 | 279 | ||
| @@ -39,9 +39,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 39 | auto ret = aclInit(nullptr); | 39 | auto ret = aclInit(nullptr); |
| 40 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 40 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 41 | ret = aclrtSetDevice(deviceId); | 41 | ret = aclrtSetDevice(deviceId); |
| 42 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 42 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 43 | ret = aclrtCreateStream(stream); | 43 | ret = aclrtCreateStream(stream); |
| 44 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 44 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 45 | + aclFinalize(); return ret); | ||
| 45 | return 0; | 46 | return 0; |
| 46 | } | 47 | } |
| 47 | 48 | ||
| @@ -151,4 +152,4 @@ int main() | |||
| 151 | aclFinalize(); | 152 | aclFinalize(); |
| 152 | 153 | ||
| 153 | return 0; | 154 | return 0; |
| 154 | -} | 155 | +} |
| @@ -258,9 +258,11 @@ int Init(int32_t deviceId, aclrtStream* stream) { | |||
| 258 | auto ret = aclInit(nullptr); | 258 | auto ret = aclInit(nullptr); |
| 259 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 259 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 260 | ret = aclrtSetDevice(deviceId); | 260 | ret = aclrtSetDevice(deviceId); |
| 261 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 261 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 262 | ret = aclrtCreateStream(stream); | 262 | ret = aclrtCreateStream(stream); |
| 263 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 263 | + CHECK_RET(ret == ACL_SUCCESS, |
| 264 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 265 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 264 | return 0; | 266 | return 0; |
| 265 | } | 267 | } |
| 266 | 268 | ||
| @@ -39,9 +39,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 39 | auto ret = aclInit(nullptr); | 39 | auto ret = aclInit(nullptr); |
| 40 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 40 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 41 | ret = aclrtSetDevice(deviceId); | 41 | ret = aclrtSetDevice(deviceId); |
| 42 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 42 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 43 | ret = aclrtCreateStream(stream); | 43 | ret = aclrtCreateStream(stream); |
| 44 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 44 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 45 | + aclFinalize(); return ret); | ||
| 45 | return 0; | 46 | return 0; |
| 46 | } | 47 | } |
| 47 | 48 | ||
| @@ -140,4 +141,4 @@ int main() | |||
| 140 | aclFinalize(); | 141 | aclFinalize(); |
| 141 | 142 | ||
| 142 | return 0; | 143 | return 0; |
| 143 | -} | 144 | +} |
| @@ -267,9 +267,11 @@ int Init(int32_t deviceId, aclrtStream* stream) { | |||
| 267 | auto ret = aclInit(nullptr); | 267 | auto ret = aclInit(nullptr); |
| 268 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 268 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 269 | ret = aclrtSetDevice(deviceId); | 269 | ret = aclrtSetDevice(deviceId); |
| 270 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 270 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 271 | ret = aclrtCreateStream(stream); | 271 | ret = aclrtCreateStream(stream); |
| 272 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 272 | + CHECK_RET(ret == ACL_SUCCESS, |
| 273 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 274 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 273 | return 0; | 275 | return 0; |
| 274 | } | 276 | } |
| 275 | 277 | ||
| @@ -40,9 +40,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 40 | auto ret = aclInit(nullptr); | 40 | auto ret = aclInit(nullptr); |
| 41 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 41 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 42 | ret = aclrtSetDevice(deviceId); | 42 | ret = aclrtSetDevice(deviceId); |
| 43 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 43 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 44 | ret = aclrtCreateStream(stream); | 44 | ret = aclrtCreateStream(stream); |
| 45 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 45 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 46 | + aclFinalize(); return ret); | ||
| 46 | return 0; | 47 | return 0; |
| 47 | } | 48 | } |
| 48 | 49 | ||
| @@ -152,4 +153,4 @@ int main() | |||
| 152 | aclFinalize(); | 153 | aclFinalize(); |
| 153 | 154 | ||
| 154 | return 0; | 155 | return 0; |
| 155 | -} | 156 | +} |
| @@ -260,9 +260,12 @@ int Init(int32_t deviceId, aclrtStream* stream) { | |||
| 260 | auto ret = aclInit(nullptr); | 260 | auto ret = aclInit(nullptr); |
| 261 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 261 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 262 | ret = aclrtSetDevice(deviceId); | 262 | ret = aclrtSetDevice(deviceId); |
| 263 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 263 | + CHECK_RET(ret == ACL_SUCCESS, |
| 264 | + LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); | ||
| 264 | ret = aclrtCreateStream(stream); | 265 | ret = aclrtCreateStream(stream); |
| 265 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 266 | + CHECK_RET(ret == ACL_SUCCESS, |
| 267 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 268 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 266 | return 0; | 269 | return 0; |
| 267 | } | 270 | } |
| 268 | 271 | ||
| @@ -39,9 +39,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 39 | auto ret = aclInit(nullptr); | 39 | auto ret = aclInit(nullptr); |
| 40 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 40 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 41 | ret = aclrtSetDevice(deviceId); | 41 | ret = aclrtSetDevice(deviceId); |
| 42 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 42 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 43 | ret = aclrtCreateStream(stream); | 43 | ret = aclrtCreateStream(stream); |
| 44 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 44 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 45 | + aclFinalize(); return ret); | ||
| 45 | return 0; | 46 | return 0; |
| 46 | } | 47 | } |
| 47 | 48 | ||
| @@ -139,4 +140,4 @@ int main() | |||
| 139 | aclrtResetDevice(deviceId); | 140 | aclrtResetDevice(deviceId); |
| 140 | aclFinalize(); | 141 | aclFinalize(); |
| 141 | return 0; | 142 | return 0; |
| 142 | -} | 143 | +} |
| @@ -91,7 +91,7 @@ aclnnStatus aclnnLogSoftmaxV2( | |||
| 91 | #include <vector> | 91 | #include <vector> |
| 92 | #include "acl/acl.h" | 92 | #include "acl/acl.h" |
| 93 | // 实际使用时,请包含正确的头文件 | 93 | // 实际使用时,请包含正确的头文件 |
| 94 | -// #include "aclnn_log_softmax_v2.h" | 94 | +// #include "aclnn_log_softmax_v2.h" |
| 95 | 95 | ||
| 96 | // 以下为示例代码,函数签名仅为示意 | 96 | // 以下为示例代码,函数签名仅为示意 |
| 97 | aclnnStatus aclnnLogSoftmaxV2GetWorkspaceSize(const aclTensor *self, int64_t dim, aclTensor *out, | 97 | aclnnStatus aclnnLogSoftmaxV2GetWorkspaceSize(const aclTensor *self, int64_t dim, aclTensor *out, |
| @@ -134,9 +134,11 @@ int Init(int32_t deviceId, aclrtStream* stream) { | |||
| 134 | auto ret = aclInit(nullptr); | 134 | auto ret = aclInit(nullptr); |
| 135 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 135 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 136 | ret = aclrtSetDevice(deviceId); | 136 | ret = aclrtSetDevice(deviceId); |
| 137 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 137 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 138 | ret = aclrtCreateStream(stream); | 138 | ret = aclrtCreateStream(stream); |
| 139 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 139 | + CHECK_RET(ret == ACL_SUCCESS, |
| 140 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 141 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 140 | return 0; | 142 | return 0; |
| 141 | } | 143 | } |
| 142 | 144 | ||
| @@ -45,9 +45,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 45 | auto ret = aclInit(nullptr); | 45 | auto ret = aclInit(nullptr); |
| 46 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 46 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 47 | ret = aclrtSetDevice(deviceId); | 47 | ret = aclrtSetDevice(deviceId); |
| 48 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 48 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 49 | ret = aclrtCreateStream(stream); | 49 | ret = aclrtCreateStream(stream); |
| 50 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 50 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 51 | + aclFinalize(); return ret); | ||
| 51 | return 0; | 52 | return 0; |
| 52 | } | 53 | } |
| 53 | 54 | ||
| @@ -410,4 +411,4 @@ int main(int argc, char* argv[]) | |||
| 410 | } | 411 | } |
| 411 | 412 | ||
| 412 | return 0; | 413 | return 0; |
| 413 | -} | 414 | +} |
| @@ -226,9 +226,11 @@ int Init(int32_t deviceId, aclrtStream* stream) { | |||
| 226 | auto ret = aclInit(nullptr); | 226 | auto ret = aclInit(nullptr); |
| 227 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 227 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 228 | ret = aclrtSetDevice(deviceId); | 228 | ret = aclrtSetDevice(deviceId); |
| 229 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 229 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 230 | ret = aclrtCreateStream(stream); | 230 | ret = aclrtCreateStream(stream); |
| 231 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 231 | + CHECK_RET(ret == ACL_SUCCESS, |
| 232 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 233 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 232 | return 0; | 234 | return 0; |
| 233 | } | 235 | } |
| 234 | 236 | ||
| @@ -43,15 +43,14 @@ int64_t GetShapeSize(const std::vector<int64_t>& shape) | |||
| 43 | return shapeSize; | 43 | return shapeSize; |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | -void PrintOutResult(const std::vector<int64_t>& shape, void* deviceAddr, | 46 | +void PrintOutResult(const std::vector<int64_t>& shape, void* deviceAddr, const std::vector<float>& yHostData, |
| 47 | - const std::vector<float>& yHostData, const std::vector<float>& dyHostData) | 47 | + const std::vector<float>& dyHostData) |
| 48 | { | 48 | { |
| 49 | auto totalSize = GetShapeSize(shape); | 49 | auto totalSize = GetShapeSize(shape); |
| 50 | auto size = std::min(totalSize, static_cast<int64_t>(10)); | 50 | auto size = std::min(totalSize, static_cast<int64_t>(10)); |
| 51 | std::vector<float> resultData(size, 0); | 51 | std::vector<float> resultData(size, 0); |
| 52 | - auto ret = aclrtMemcpy( | 52 | + auto ret = aclrtMemcpy(resultData.data(), resultData.size() * sizeof(resultData[0]), deviceAddr, |
| 53 | - resultData.data(), resultData.size() * sizeof(resultData[0]), deviceAddr, size * sizeof(resultData[0]), | 53 | + size * sizeof(resultData[0]), ACL_MEMCPY_DEVICE_TO_HOST); |
| 54 | - ACL_MEMCPY_DEVICE_TO_HOST); | ||
| 55 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("copy result from device to host failed. ERROR: %d\n", ret); return); | 54 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("copy result from device to host failed. ERROR: %d\n", ret); return); |
| 56 | LOG_PRINT("Notice: Only printing the first 10 elements.\n"); | 55 | LOG_PRINT("Notice: Only printing the first 10 elements.\n"); |
| 57 | int64_t C = shape.back(); | 56 | int64_t C = shape.back(); |
| @@ -62,8 +61,8 @@ void PrintOutResult(const std::vector<int64_t>& shape, void* deviceAddr, | |||
| 62 | dot += yHostData[row * C + j] * dyHostData[row * C + j]; | 61 | dot += yHostData[row * C + j] * dyHostData[row * C + j]; |
| 63 | } | 62 | } |
| 64 | float expected = yHostData[i] * (dyHostData[i] - dot); | 63 | float expected = yHostData[i] * (dyHostData[i] - dot); |
| 65 | - LOG_PRINT("softmax_grad y[%ld]=%f, dy[%ld]=%f, result[%ld]=%f, expected=%f\n", | 64 | + LOG_PRINT("softmax_grad y[%ld]=%f, dy[%ld]=%f, result[%ld]=%f, expected=%f\n", i, yHostData[i], i, |
| 66 | - i, yHostData[i], i, dyHostData[i], i, resultData[i], expected); | 65 | + dyHostData[i], i, resultData[i], expected); |
| 67 | } | 66 | } |
| 68 | } | 67 | } |
| 69 | 68 | ||
| @@ -72,16 +71,16 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 72 | auto ret = aclInit(nullptr); | 71 | auto ret = aclInit(nullptr); |
| 73 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 72 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 74 | ret = aclrtSetDevice(deviceId); | 73 | ret = aclrtSetDevice(deviceId); |
| 75 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 74 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 76 | ret = aclrtCreateStream(stream); | 75 | ret = aclrtCreateStream(stream); |
| 77 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 76 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 77 | + aclFinalize(); return ret); | ||
| 78 | return 0; | 78 | return 0; |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | template <typename T> | 81 | template <typename T> |
| 82 | -int CreateAclTensor( | 82 | +int CreateAclTensor(const std::vector<T>& hostData, const std::vector<int64_t>& shape, void** deviceAddr, |
| 83 | - const std::vector<T>& hostData, const std::vector<int64_t>& shape, void** deviceAddr, aclDataType dataType, | 83 | + aclDataType dataType, aclTensor** tensor) |
| 84 | - aclTensor** tensor) | ||
| 85 | { | 84 | { |
| 86 | auto size = GetShapeSize(shape) * sizeof(T); | 85 | auto size = GetShapeSize(shape) * sizeof(T); |
| 87 | auto ret = aclrtMalloc(deviceAddr, size, ACL_MEM_MALLOC_HUGE_FIRST); | 86 | auto ret = aclrtMalloc(deviceAddr, size, ACL_MEM_MALLOC_HUGE_FIRST); |
| @@ -94,9 +93,8 @@ int CreateAclTensor( | |||
| 94 | strides[i] = shape[i + 1] * strides[i + 1]; | 93 | strides[i] = shape[i + 1] * strides[i + 1]; |
| 95 | } | 94 | } |
| 96 | 95 | ||
| 97 | - *tensor = aclCreateTensor( | 96 | + *tensor = aclCreateTensor(shape.data(), shape.size(), dataType, strides.data(), 0, aclFormat::ACL_FORMAT_ND, |
| 98 | - shape.data(), shape.size(), dataType, strides.data(), 0, aclFormat::ACL_FORMAT_ND, shape.data(), shape.size(), | 97 | + shape.data(), shape.size(), *deviceAddr); |
| 99 | - *deviceAddr); | ||
| 100 | return 0; | 98 | return 0; |
| 101 | } | 99 | } |
| 102 | 100 | ||
| @@ -111,8 +109,7 @@ int main() | |||
| 111 | aclTensor* y = nullptr; | 109 | aclTensor* y = nullptr; |
| 112 | void* yDeviceAddr = nullptr; | 110 | void* yDeviceAddr = nullptr; |
| 113 | std::vector<int64_t> yShape = {2, 4}; | 111 | std::vector<int64_t> yShape = {2, 4}; |
| 114 | - std::vector<float> yHostData = {0.25f, 0.25f, 0.25f, 0.25f, | 112 | + std::vector<float> yHostData = {0.25f, 0.25f, 0.25f, 0.25f, 0.1f, 0.2f, 0.3f, 0.4f}; |
| 115 | - 0.1f, 0.2f, 0.3f, 0.4f}; | ||
| 116 | ret = CreateAclTensor(yHostData, yShape, &yDeviceAddr, aclDataType::ACL_FLOAT, &y); | 113 | ret = CreateAclTensor(yHostData, yShape, &yDeviceAddr, aclDataType::ACL_FLOAT, &y); |
| 117 | CHECK_RET(ret == ACL_SUCCESS, return ret); | 114 | CHECK_RET(ret == ACL_SUCCESS, return ret); |
| 118 | 115 | ||
| @@ -120,8 +117,7 @@ int main() | |||
| 120 | aclTensor* dy = nullptr; | 117 | aclTensor* dy = nullptr; |
| 121 | void* dyDeviceAddr = nullptr; | 118 | void* dyDeviceAddr = nullptr; |
| 122 | std::vector<int64_t> dyShape = {2, 4}; | 119 | std::vector<int64_t> dyShape = {2, 4}; |
| 123 | - std::vector<float> dyHostData = {0.1f, 0.2f, 0.3f, 0.4f, | 120 | + std::vector<float> dyHostData = {0.1f, 0.2f, 0.3f, 0.4f, 0.1f, 0.1f, 0.1f, 0.1f}; |
| 124 | - 0.1f, 0.1f, 0.1f, 0.1f}; | ||
| 125 | ret = CreateAclTensor(dyHostData, dyShape, &dyDeviceAddr, aclDataType::ACL_FLOAT, &dy); | 121 | ret = CreateAclTensor(dyHostData, dyShape, &dyDeviceAddr, aclDataType::ACL_FLOAT, &dy); |
| 126 | CHECK_RET(ret == ACL_SUCCESS, return ret); | 122 | CHECK_RET(ret == ACL_SUCCESS, return ret); |
| 127 | 123 | ||
| @@ -321,9 +321,11 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 321 | auto ret = aclInit(nullptr); | 321 | auto ret = aclInit(nullptr); |
| 322 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 322 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 323 | ret = aclrtSetDevice(deviceId); | 323 | ret = aclrtSetDevice(deviceId); |
| 324 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 324 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 325 | ret = aclrtCreateStream(stream); | 325 | ret = aclrtCreateStream(stream); |
| 326 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 326 | + CHECK_RET(ret == ACL_SUCCESS, |
| 327 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 328 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 327 | return 0; | 329 | return 0; |
| 328 | } | 330 | } |
| 329 | 331 | ||
Mexperimental/norm/sync_batch_norm_backward_elemt/examples/test_aclnn_batch_norm_elemt_backward.cpp+3-2
| @@ -39,9 +39,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 39 | auto ret = aclInit(nullptr); | 39 | auto ret = aclInit(nullptr); |
| 40 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 40 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 41 | ret = aclrtSetDevice(deviceId); | 41 | ret = aclrtSetDevice(deviceId); |
| 42 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 42 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 43 | ret = aclrtCreateStream(stream); | 43 | ret = aclrtCreateStream(stream); |
| 44 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 44 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 45 | + aclFinalize(); return ret); | ||
| 45 | return 0; | 46 | return 0; |
| 46 | } | 47 | } |
| 47 | 48 | ||
| @@ -64,9 +64,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 64 | auto ret = aclInit(nullptr); | 64 | auto ret = aclInit(nullptr); |
| 65 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 65 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 66 | ret = aclrtSetDevice(deviceId); | 66 | ret = aclrtSetDevice(deviceId); |
| 67 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 67 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 68 | ret = aclrtCreateStream(stream); | 68 | ret = aclrtCreateStream(stream); |
| 69 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 69 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 70 | + aclFinalize(); return ret); | ||
| 70 | return 0; | 71 | return 0; |
| 71 | } | 72 | } |
| 72 | 73 | ||
| @@ -93,9 +93,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 93 | auto ret = aclInit(nullptr); | 93 | auto ret = aclInit(nullptr); |
| 94 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 94 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 95 | ret = aclrtSetDevice(deviceId); | 95 | ret = aclrtSetDevice(deviceId); |
| 96 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 96 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 97 | ret = aclrtCreateStream(stream); | 97 | ret = aclrtCreateStream(stream); |
| 98 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 98 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 99 | + aclFinalize(); return ret); | ||
| 99 | return 0; | 100 | return 0; |
| 100 | } | 101 | } |
| 101 | 102 | ||
| @@ -407,9 +407,11 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 407 | auto ret = aclInit(nullptr); | 407 | auto ret = aclInit(nullptr); |
| 408 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 408 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 409 | ret = aclrtSetDevice(deviceId); | 409 | ret = aclrtSetDevice(deviceId); |
| 410 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 410 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 411 | ret = aclrtCreateStream(stream); | 411 | ret = aclrtCreateStream(stream); |
| 412 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 412 | + CHECK_RET(ret == ACL_SUCCESS, |
| 413 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 414 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 413 | return 0; | 415 | return 0; |
| 414 | } | 416 | } |
| 415 | 417 | ||
| @@ -42,9 +42,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 42 | auto ret = aclInit(nullptr); | 42 | auto ret = aclInit(nullptr); |
| 43 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 43 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 44 | ret = aclrtSetDevice(deviceId); | 44 | ret = aclrtSetDevice(deviceId); |
| 45 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 45 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 46 | ret = aclrtCreateStream(stream); | 46 | ret = aclrtCreateStream(stream); |
| 47 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 47 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 48 | + aclFinalize(); return ret); | ||
| 48 | return 0; | 49 | return 0; |
| 49 | } | 50 | } |
| 50 | 51 | ||
| @@ -323,9 +323,11 @@ int Init(int32_t deviceId, aclrtStream* stream) { | |||
| 323 | auto ret = aclInit(nullptr); | 323 | auto ret = aclInit(nullptr); |
| 324 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 324 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 325 | ret = aclrtSetDevice(deviceId); | 325 | ret = aclrtSetDevice(deviceId); |
| 326 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 326 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 327 | ret = aclrtCreateStream(stream); | 327 | ret = aclrtCreateStream(stream); |
| 328 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 328 | + CHECK_RET(ret == ACL_SUCCESS, |
| 329 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 330 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 329 | return 0; | 331 | return 0; |
| 330 | } | 332 | } |
| 331 | 333 | ||
| @@ -429,9 +429,11 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 429 | auto ret = aclInit(nullptr); | 429 | auto ret = aclInit(nullptr); |
| 430 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 430 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 431 | ret = aclrtSetDevice(deviceId); | 431 | ret = aclrtSetDevice(deviceId); |
| 432 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 432 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 433 | ret = aclrtCreateStream(stream); | 433 | ret = aclrtCreateStream(stream); |
| 434 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 434 | + CHECK_RET(ret == ACL_SUCCESS, |
| 435 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 436 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 435 | return 0; | 437 | return 0; |
| 436 | } | 438 | } |
| 437 | 439 | ||
| @@ -40,9 +40,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 40 | auto ret = aclInit(nullptr); | 40 | auto ret = aclInit(nullptr); |
| 41 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 41 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 42 | ret = aclrtSetDevice(deviceId); | 42 | ret = aclrtSetDevice(deviceId); |
| 43 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 43 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 44 | ret = aclrtCreateStream(stream); | 44 | ret = aclrtCreateStream(stream); |
| 45 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 45 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 46 | + aclFinalize(); return ret); | ||
| 46 | return 0; | 47 | return 0; |
| 47 | } | 48 | } |
| 48 | 49 | ||
| @@ -547,9 +547,11 @@ int Init(int32_t deviceId, aclrtStream *stream) { | |||
| 547 | auto ret = aclInit(nullptr); | 547 | auto ret = aclInit(nullptr); |
| 548 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 548 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 549 | ret = aclrtSetDevice(deviceId); | 549 | ret = aclrtSetDevice(deviceId); |
| 550 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 550 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 551 | ret = aclrtCreateStream(stream); | 551 | ret = aclrtCreateStream(stream); |
| 552 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 552 | + CHECK_RET(ret == ACL_SUCCESS, |
| 553 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 554 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 553 | return 0; | 555 | return 0; |
| 554 | } | 556 | } |
| 555 | 557 | ||
| @@ -46,9 +46,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 46 | auto ret = aclInit(nullptr); | 46 | auto ret = aclInit(nullptr); |
| 47 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 47 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 48 | ret = aclrtSetDevice(deviceId); | 48 | ret = aclrtSetDevice(deviceId); |
| 49 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevicefailed. ERROR: %d\n", ret); return ret); | 49 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 50 | ret = aclrtCreateStream(stream); | 50 | ret = aclrtCreateStream(stream); |
| 51 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 51 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 52 | + aclFinalize(); return ret); | ||
| 52 | return 0; | 53 | return 0; |
| 53 | } | 54 | } |
| 54 | 55 | ||
| @@ -339,9 +339,11 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 339 | auto ret = aclInit(nullptr); | 339 | auto ret = aclInit(nullptr); |
| 340 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 340 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 341 | ret = aclrtSetDevice(deviceId); | 341 | ret = aclrtSetDevice(deviceId); |
| 342 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 342 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 343 | ret = aclrtCreateStream(stream); | 343 | ret = aclrtCreateStream(stream); |
| 344 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 344 | + CHECK_RET(ret == ACL_SUCCESS, |
| 345 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 346 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 345 | 347 | ||
| 346 | return 0; | 348 | return 0; |
| 347 | } | 349 | } |
| @@ -40,9 +40,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 40 | auto ret = aclInit(nullptr); | 40 | auto ret = aclInit(nullptr); |
| 41 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 41 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 42 | ret = aclrtSetDevice(deviceId); | 42 | ret = aclrtSetDevice(deviceId); |
| 43 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 43 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 44 | ret = aclrtCreateStream(stream); | 44 | ret = aclrtCreateStream(stream); |
| 45 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 45 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 46 | + aclFinalize(); return ret); | ||
| 46 | 47 | ||
| 47 | return 0; | 48 | return 0; |
| 48 | } | 49 | } |
| @@ -324,9 +324,11 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 324 | auto ret = aclInit(nullptr); | 324 | auto ret = aclInit(nullptr); |
| 325 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 325 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 326 | ret = aclrtSetDevice(deviceId); | 326 | ret = aclrtSetDevice(deviceId); |
| 327 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 327 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 328 | ret = aclrtCreateStream(stream); | 328 | ret = aclrtCreateStream(stream); |
| 329 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 329 | + CHECK_RET(ret == ACL_SUCCESS, |
| 330 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 331 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 330 | 332 | ||
| 331 | return 0; | 333 | return 0; |
| 332 | } | 334 | } |
| @@ -40,9 +40,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 40 | auto ret = aclInit(nullptr); | 40 | auto ret = aclInit(nullptr); |
| 41 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 41 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 42 | ret = aclrtSetDevice(deviceId); | 42 | ret = aclrtSetDevice(deviceId); |
| 43 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 43 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 44 | ret = aclrtCreateStream(stream); | 44 | ret = aclrtCreateStream(stream); |
| 45 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 45 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 46 | + aclFinalize(); return ret); | ||
| 46 | 47 | ||
| 47 | return 0; | 48 | return 0; |
| 48 | } | 49 | } |
| @@ -471,9 +471,11 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 471 | auto ret = aclInit(nullptr); | 471 | auto ret = aclInit(nullptr); |
| 472 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 472 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 473 | ret = aclrtSetDevice(deviceId); | 473 | ret = aclrtSetDevice(deviceId); |
| 474 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 474 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 475 | ret = aclrtCreateStream(stream); | 475 | ret = aclrtCreateStream(stream); |
| 476 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 476 | + CHECK_RET(ret == ACL_SUCCESS, |
| 477 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 478 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 477 | 479 | ||
| 478 | return 0; | 480 | return 0; |
| 479 | } | 481 | } |
| @@ -47,9 +47,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 47 | auto ret = aclInit(nullptr); | 47 | auto ret = aclInit(nullptr); |
| 48 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 48 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 49 | ret = aclrtSetDevice(deviceId); | 49 | ret = aclrtSetDevice(deviceId); |
| 50 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 50 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 51 | ret = aclrtCreateStream(stream); | 51 | ret = aclrtCreateStream(stream); |
| 52 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 52 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 53 | + aclFinalize(); return ret); | ||
| 53 | 54 | ||
| 54 | return 0; | 55 | return 0; |
| 55 | } | 56 | } |
| @@ -431,9 +431,11 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 431 | auto ret = aclInit(nullptr); | 431 | auto ret = aclInit(nullptr); |
| 432 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 432 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 433 | ret = aclrtSetDevice(deviceId); | 433 | ret = aclrtSetDevice(deviceId); |
| 434 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 434 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 435 | ret = aclrtCreateStream(stream); | 435 | ret = aclrtCreateStream(stream); |
| 436 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 436 | + CHECK_RET(ret == ACL_SUCCESS, |
| 437 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 438 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 437 | 439 | ||
| 438 | return 0; | 440 | return 0; |
| 439 | } | 441 | } |
| @@ -479,9 +479,11 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 479 | auto ret = aclInit(nullptr); | 479 | auto ret = aclInit(nullptr); |
| 480 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 480 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 481 | ret = aclrtSetDevice(deviceId); | 481 | ret = aclrtSetDevice(deviceId); |
| 482 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 482 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 483 | ret = aclrtCreateStream(stream); | 483 | ret = aclrtCreateStream(stream); |
| 484 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 484 | + CHECK_RET(ret == ACL_SUCCESS, |
| 485 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 486 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 485 | 487 | ||
| 486 | return 0; | 488 | return 0; |
| 487 | } | 489 | } |
| @@ -40,9 +40,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 40 | auto ret = aclInit(nullptr); | 40 | auto ret = aclInit(nullptr); |
| 41 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 41 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 42 | ret = aclrtSetDevice(deviceId); | 42 | ret = aclrtSetDevice(deviceId); |
| 43 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 43 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 44 | ret = aclrtCreateStream(stream); | 44 | ret = aclrtCreateStream(stream); |
| 45 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 45 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 46 | + aclFinalize(); return ret); | ||
| 46 | 47 | ||
| 47 | return 0; | 48 | return 0; |
| 48 | } | 49 | } |
| @@ -40,9 +40,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 40 | auto ret = aclInit(nullptr); | 40 | auto ret = aclInit(nullptr); |
| 41 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 41 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 42 | ret = aclrtSetDevice(deviceId); | 42 | ret = aclrtSetDevice(deviceId); |
| 43 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 43 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 44 | ret = aclrtCreateStream(stream); | 44 | ret = aclrtCreateStream(stream); |
| 45 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 45 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 46 | + aclFinalize(); return ret); | ||
| 46 | 47 | ||
| 47 | return 0; | 48 | return 0; |
| 48 | } | 49 | } |
| @@ -466,9 +466,11 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 466 | auto ret = aclInit(nullptr); | 466 | auto ret = aclInit(nullptr); |
| 467 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 467 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 468 | ret = aclrtSetDevice(deviceId); | 468 | ret = aclrtSetDevice(deviceId); |
| 469 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 469 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 470 | ret = aclrtCreateStream(stream); | 470 | ret = aclrtCreateStream(stream); |
| 471 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 471 | + CHECK_RET(ret == ACL_SUCCESS, |
| 472 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 473 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 472 | 474 | ||
| 473 | return 0; | 475 | return 0; |
| 474 | } | 476 | } |
| @@ -40,9 +40,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 40 | auto ret = aclInit(nullptr); | 40 | auto ret = aclInit(nullptr); |
| 41 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 41 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 42 | ret = aclrtSetDevice(deviceId); | 42 | ret = aclrtSetDevice(deviceId); |
| 43 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 43 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 44 | ret = aclrtCreateStream(stream); | 44 | ret = aclrtCreateStream(stream); |
| 45 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 45 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 46 | + aclFinalize(); return ret); | ||
| 46 | 47 | ||
| 47 | return 0; | 48 | return 0; |
| 48 | } | 49 | } |
| @@ -443,9 +443,11 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 443 | auto ret = aclInit(nullptr); | 443 | auto ret = aclInit(nullptr); |
| 444 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 444 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 445 | ret = aclrtSetDevice(deviceId); | 445 | ret = aclrtSetDevice(deviceId); |
| 446 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 446 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 447 | ret = aclrtCreateStream(stream); | 447 | ret = aclrtCreateStream(stream); |
| 448 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 448 | + CHECK_RET(ret == ACL_SUCCESS, |
| 449 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 450 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 449 | return 0; | 451 | return 0; |
| 450 | } | 452 | } |
| 451 | 453 | ||
| @@ -433,9 +433,11 @@ int Init(int32_t deviceId, aclrtStream* stream) { | |||
| 433 | auto ret = aclInit(nullptr); | 433 | auto ret = aclInit(nullptr); |
| 434 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 434 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 435 | ret = aclrtSetDevice(deviceId); | 435 | ret = aclrtSetDevice(deviceId); |
| 436 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 436 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 437 | ret = aclrtCreateStream(stream); | 437 | ret = aclrtCreateStream(stream); |
| 438 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 438 | + CHECK_RET(ret == ACL_SUCCESS, |
| 439 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 440 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 439 | return 0; | 441 | return 0; |
| 440 | } | 442 | } |
| 441 | 443 | ||
| @@ -40,9 +40,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 40 | auto ret = aclInit(nullptr); | 40 | auto ret = aclInit(nullptr); |
| 41 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 41 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 42 | ret = aclrtSetDevice(deviceId); | 42 | ret = aclrtSetDevice(deviceId); |
| 43 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 43 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 44 | ret = aclrtCreateStream(stream); | 44 | ret = aclrtCreateStream(stream); |
| 45 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 45 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 46 | + aclFinalize(); return ret); | ||
| 46 | return 0; | 47 | return 0; |
| 47 | } | 48 | } |
| 48 | 49 | ||
| @@ -227,4 +228,4 @@ int main() | |||
| 227 | aclrtResetDevice(deviceId); | 228 | aclrtResetDevice(deviceId); |
| 228 | aclFinalize(); | 229 | aclFinalize(); |
| 229 | return 0; | 230 | return 0; |
| 230 | -} | 231 | +} |
| @@ -40,9 +40,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 40 | auto ret = aclInit(nullptr); | 40 | auto ret = aclInit(nullptr); |
| 41 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 41 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 42 | ret = aclrtSetDevice(deviceId); | 42 | ret = aclrtSetDevice(deviceId); |
| 43 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 43 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 44 | ret = aclrtCreateStream(stream); | 44 | ret = aclrtCreateStream(stream); |
| 45 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 45 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 46 | + aclFinalize(); return ret); | ||
| 46 | return 0; | 47 | return 0; |
| 47 | } | 48 | } |
| 48 | 49 | ||
| @@ -227,4 +228,4 @@ int main() | |||
| 227 | aclrtResetDevice(deviceId); | 228 | aclrtResetDevice(deviceId); |
| 228 | aclFinalize(); | 229 | aclFinalize(); |
| 229 | return 0; | 230 | return 0; |
| 230 | -} | 231 | +} |
| @@ -365,9 +365,11 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 365 | auto ret = aclInit(nullptr); | 365 | auto ret = aclInit(nullptr); |
| 366 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 366 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 367 | ret = aclrtSetDevice(deviceId); | 367 | ret = aclrtSetDevice(deviceId); |
| 368 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 368 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 369 | ret = aclrtCreateStream(stream); | 369 | ret = aclrtCreateStream(stream); |
| 370 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 370 | + CHECK_RET(ret == ACL_SUCCESS, |
| 371 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 372 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 371 | return 0; | 373 | return 0; |
| 372 | } | 374 | } |
| 373 | 375 | ||
| @@ -41,9 +41,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 41 | auto ret = aclInit(nullptr); | 41 | auto ret = aclInit(nullptr); |
| 42 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 42 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 43 | ret = aclrtSetDevice(deviceId); | 43 | ret = aclrtSetDevice(deviceId); |
| 44 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 44 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 45 | ret = aclrtCreateStream(stream); | 45 | ret = aclrtCreateStream(stream); |
| 46 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 46 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 47 | + aclFinalize(); return ret); | ||
| 47 | return 0; | 48 | return 0; |
| 48 | } | 49 | } |
| 49 | 50 | ||
| @@ -203,4 +204,4 @@ int main() | |||
| 203 | aclrtResetDevice(deviceId); | 204 | aclrtResetDevice(deviceId); |
| 204 | aclFinalize(); | 205 | aclFinalize(); |
| 205 | return 0; | 206 | return 0; |
| 206 | -} | 207 | +} |
| @@ -441,9 +441,11 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 441 | auto ret = aclInit(nullptr); | 441 | auto ret = aclInit(nullptr); |
| 442 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 442 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 443 | ret = aclrtSetDevice(deviceId); | 443 | ret = aclrtSetDevice(deviceId); |
| 444 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 444 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 445 | ret = aclrtCreateStream(stream); | 445 | ret = aclrtCreateStream(stream); |
| 446 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 446 | + CHECK_RET(ret == ACL_SUCCESS, |
| 447 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 448 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 447 | return 0; | 449 | return 0; |
| 448 | } | 450 | } |
| 449 | 451 | ||
| @@ -45,9 +45,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 45 | auto ret = aclInit(nullptr); | 45 | auto ret = aclInit(nullptr); |
| 46 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 46 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 47 | ret = aclrtSetDevice(deviceId); | 47 | ret = aclrtSetDevice(deviceId); |
| 48 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 48 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 49 | ret = aclrtCreateStream(stream); | 49 | ret = aclrtCreateStream(stream); |
| 50 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 50 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 51 | + aclFinalize(); return ret); | ||
| 51 | return 0; | 52 | return 0; |
| 52 | } | 53 | } |
| 53 | 54 | ||
| @@ -283,9 +283,11 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 283 | auto ret = aclInit(nullptr); | 283 | auto ret = aclInit(nullptr); |
| 284 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 284 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 285 | ret = aclrtSetDevice(deviceId); | 285 | ret = aclrtSetDevice(deviceId); |
| 286 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 286 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 287 | ret = aclrtCreateStream(stream); | 287 | ret = aclrtCreateStream(stream); |
| 288 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 288 | + CHECK_RET(ret == ACL_SUCCESS, |
| 289 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 290 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 289 | 291 | ||
| 290 | return 0; | 292 | return 0; |
| 291 | } | 293 | } |
| @@ -40,9 +40,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 40 | auto ret = aclInit(nullptr); | 40 | auto ret = aclInit(nullptr); |
| 41 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 41 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 42 | ret = aclrtSetDevice(deviceId); | 42 | ret = aclrtSetDevice(deviceId); |
| 43 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 43 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 44 | ret = aclrtCreateStream(stream); | 44 | ret = aclrtCreateStream(stream); |
| 45 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 45 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 46 | + aclFinalize(); return ret); | ||
| 46 | 47 | ||
| 47 | return 0; | 48 | return 0; |
| 48 | } | 49 | } |
| @@ -412,9 +412,11 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 412 | auto ret = aclInit(nullptr); | 412 | auto ret = aclInit(nullptr); |
| 413 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 413 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 414 | ret = aclrtSetDevice(deviceId); | 414 | ret = aclrtSetDevice(deviceId); |
| 415 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 415 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 416 | ret = aclrtCreateStream(stream); | 416 | ret = aclrtCreateStream(stream); |
| 417 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 417 | + CHECK_RET(ret == ACL_SUCCESS, |
| 418 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 419 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 418 | return 0; | 420 | return 0; |
| 419 | } | 421 | } |
| 420 | 422 | ||
| @@ -41,9 +41,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 41 | auto ret = aclInit(nullptr); | 41 | auto ret = aclInit(nullptr); |
| 42 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 42 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 43 | ret = aclrtSetDevice(deviceId); | 43 | ret = aclrtSetDevice(deviceId); |
| 44 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 44 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 45 | ret = aclrtCreateStream(stream); | 45 | ret = aclrtCreateStream(stream); |
| 46 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 46 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 47 | + aclFinalize(); return ret); | ||
| 47 | return 0; | 48 | return 0; |
| 48 | } | 49 | } |
| 49 | 50 | ||
| @@ -230,4 +231,4 @@ int main() | |||
| 230 | aclFinalize(); | 231 | aclFinalize(); |
| 231 | 232 | ||
| 232 | return 0; | 233 | return 0; |
| 233 | -} | 234 | +} |
| @@ -344,9 +344,11 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 344 | auto ret = aclInit(nullptr); | 344 | auto ret = aclInit(nullptr); |
| 345 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 345 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 346 | ret = aclrtSetDevice(deviceId); | 346 | ret = aclrtSetDevice(deviceId); |
| 347 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 347 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 348 | ret = aclrtCreateStream(stream); | 348 | ret = aclrtCreateStream(stream); |
| 349 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 349 | + CHECK_RET(ret == ACL_SUCCESS, |
| 350 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 351 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 350 | return 0; | 352 | return 0; |
| 351 | } | 353 | } |
| 352 | 354 | ||
| @@ -610,9 +610,11 @@ aclnnStatus aclnnLayerNormWithImplMode( | |||
| 610 | auto ret = aclInit(nullptr); | 610 | auto ret = aclInit(nullptr); |
| 611 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 611 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 612 | ret = aclrtSetDevice(deviceId); | 612 | ret = aclrtSetDevice(deviceId); |
| 613 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 613 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 614 | ret = aclrtCreateStream(stream); | 614 | ret = aclrtCreateStream(stream); |
| 615 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 615 | + CHECK_RET(ret == ACL_SUCCESS, |
| 616 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 617 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 616 | return 0; | 618 | return 0; |
| 617 | } | 619 | } |
| 618 | 620 | ||
| @@ -814,9 +816,11 @@ aclnnStatus aclnnLayerNormWithImplMode( | |||
| 814 | auto ret = aclInit(nullptr); | 816 | auto ret = aclInit(nullptr); |
| 815 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 817 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 816 | ret = aclrtSetDevice(deviceId); | 818 | ret = aclrtSetDevice(deviceId); |
| 817 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 819 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 818 | ret = aclrtCreateStream(stream); | 820 | ret = aclrtCreateStream(stream); |
| 819 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 821 | + CHECK_RET(ret == ACL_SUCCESS, |
| 822 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 823 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 820 | return 0; | 824 | return 0; |
| 821 | } | 825 | } |
| 822 | 826 | ||
| @@ -41,9 +41,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 41 | auto ret = aclInit(nullptr); | 41 | auto ret = aclInit(nullptr); |
| 42 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 42 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 43 | ret = aclrtSetDevice(deviceId); | 43 | ret = aclrtSetDevice(deviceId); |
| 44 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 44 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 45 | ret = aclrtCreateStream(stream); | 45 | ret = aclrtCreateStream(stream); |
| 46 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 46 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 47 | + aclFinalize(); return ret); | ||
| 47 | return 0; | 48 | return 0; |
| 48 | } | 49 | } |
| 49 | 50 | ||
| @@ -203,4 +204,4 @@ int main() | |||
| 203 | aclrtResetDevice(deviceId); | 204 | aclrtResetDevice(deviceId); |
| 204 | aclFinalize(); | 205 | aclFinalize(); |
| 205 | return 0; | 206 | return 0; |
| 206 | -} | 207 | +} |
| @@ -41,9 +41,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 41 | auto ret = aclInit(nullptr); | 41 | auto ret = aclInit(nullptr); |
| 42 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 42 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 43 | ret = aclrtSetDevice(deviceId); | 43 | ret = aclrtSetDevice(deviceId); |
| 44 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 44 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 45 | ret = aclrtCreateStream(stream); | 45 | ret = aclrtCreateStream(stream); |
| 46 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 46 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 47 | + aclFinalize(); return ret); | ||
| 47 | return 0; | 48 | return 0; |
| 48 | } | 49 | } |
| 49 | 50 | ||
| @@ -203,4 +204,4 @@ int main() | |||
| 203 | aclrtResetDevice(deviceId); | 204 | aclrtResetDevice(deviceId); |
| 204 | aclFinalize(); | 205 | aclFinalize(); |
| 205 | return 0; | 206 | return 0; |
| 206 | -} | 207 | +} |
| @@ -41,9 +41,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 41 | auto ret = aclInit(nullptr); | 41 | auto ret = aclInit(nullptr); |
| 42 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 42 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 43 | ret = aclrtSetDevice(deviceId); | 43 | ret = aclrtSetDevice(deviceId); |
| 44 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 44 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 45 | ret = aclrtCreateStream(stream); | 45 | ret = aclrtCreateStream(stream); |
| 46 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 46 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 47 | + aclFinalize(); return ret); | ||
| 47 | return 0; | 48 | return 0; |
| 48 | } | 49 | } |
| 49 | 50 | ||
| @@ -220,4 +221,4 @@ int main() | |||
| 220 | aclrtResetDevice(deviceId); | 221 | aclrtResetDevice(deviceId); |
| 221 | aclFinalize(); | 222 | aclFinalize(); |
| 222 | return 0; | 223 | return 0; |
| 223 | -} | 224 | +} |
| @@ -314,9 +314,11 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 314 | auto ret = aclInit(nullptr); | 314 | auto ret = aclInit(nullptr); |
| 315 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 315 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 316 | ret = aclrtSetDevice(deviceId); | 316 | ret = aclrtSetDevice(deviceId); |
| 317 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 317 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 318 | ret = aclrtCreateStream(stream); | 318 | ret = aclrtCreateStream(stream); |
| 319 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 319 | + CHECK_RET(ret == ACL_SUCCESS, |
| 320 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 321 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 320 | return 0; | 322 | return 0; |
| 321 | } | 323 | } |
| 322 | 324 | ||
| @@ -317,9 +317,11 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 317 | auto ret = aclInit(nullptr); | 317 | auto ret = aclInit(nullptr); |
| 318 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 318 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 319 | ret = aclrtSetDevice(deviceId); | 319 | ret = aclrtSetDevice(deviceId); |
| 320 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 320 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 321 | ret = aclrtCreateStream(stream); | 321 | ret = aclrtCreateStream(stream); |
| 322 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 322 | + CHECK_RET(ret == ACL_SUCCESS, |
| 323 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 324 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 323 | return 0; | 325 | return 0; |
| 324 | } | 326 | } |
| 325 | 327 | ||
| @@ -39,9 +39,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 39 | auto ret = aclInit(nullptr); | 39 | auto ret = aclInit(nullptr); |
| 40 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 40 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 41 | ret = aclrtSetDevice(deviceId); | 41 | ret = aclrtSetDevice(deviceId); |
| 42 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 42 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 43 | ret = aclrtCreateStream(stream); | 43 | ret = aclrtCreateStream(stream); |
| 44 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 44 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 45 | + aclFinalize(); return ret); | ||
| 45 | return 0; | 46 | return 0; |
| 46 | } | 47 | } |
| 47 | 48 | ||
| @@ -157,4 +158,4 @@ int main() | |||
| 157 | aclFinalize(); | 158 | aclFinalize(); |
| 158 | 159 | ||
| 159 | return 0; | 160 | return 0; |
| 160 | -} | 161 | +} |
| @@ -39,9 +39,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 39 | auto ret = aclInit(nullptr); | 39 | auto ret = aclInit(nullptr); |
| 40 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 40 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 41 | ret = aclrtSetDevice(deviceId); | 41 | ret = aclrtSetDevice(deviceId); |
| 42 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 42 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 43 | ret = aclrtCreateStream(stream); | 43 | ret = aclrtCreateStream(stream); |
| 44 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 44 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 45 | + aclFinalize(); return ret); | ||
| 45 | return 0; | 46 | return 0; |
| 46 | } | 47 | } |
| 47 | 48 | ||
| @@ -154,4 +155,4 @@ int main() | |||
| 154 | aclrtResetDevice(deviceId); | 155 | aclrtResetDevice(deviceId); |
| 155 | aclFinalize(); | 156 | aclFinalize(); |
| 156 | return 0; | 157 | return 0; |
| 157 | -} | 158 | +} |
| @@ -314,9 +314,11 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 314 | auto ret = aclInit(nullptr); | 314 | auto ret = aclInit(nullptr); |
| 315 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 315 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 316 | ret = aclrtSetDevice(deviceId); | 316 | ret = aclrtSetDevice(deviceId); |
| 317 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 317 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 318 | ret = aclrtCreateStream(stream); | 318 | ret = aclrtCreateStream(stream); |
| 319 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 319 | + CHECK_RET(ret == ACL_SUCCESS, |
| 320 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 321 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 320 | 322 | ||
| 321 | return 0; | 323 | return 0; |
| 322 | } | 324 | } |
| @@ -40,9 +40,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 40 | auto ret = aclInit(nullptr); | 40 | auto ret = aclInit(nullptr); |
| 41 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 41 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 42 | ret = aclrtSetDevice(deviceId); | 42 | ret = aclrtSetDevice(deviceId); |
| 43 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 43 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 44 | ret = aclrtCreateStream(stream); | 44 | ret = aclrtCreateStream(stream); |
| 45 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 45 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 46 | + aclFinalize(); return ret); | ||
| 46 | 47 | ||
| 47 | return 0; | 48 | return 0; |
| 48 | } | 49 | } |
| @@ -449,9 +449,11 @@ int Init(int32_t deviceId, aclrtStream* stream) { | |||
| 449 | auto ret = aclInit(nullptr); | 449 | auto ret = aclInit(nullptr); |
| 450 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 450 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 451 | ret = aclrtSetDevice(deviceId); | 451 | ret = aclrtSetDevice(deviceId); |
| 452 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 452 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 453 | ret = aclrtCreateStream(stream); | 453 | ret = aclrtCreateStream(stream); |
| 454 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 454 | + CHECK_RET(ret == ACL_SUCCESS, |
| 455 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 456 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 455 | return 0; | 457 | return 0; |
| 456 | } | 458 | } |
| 457 | 459 | ||
| @@ -70,9 +70,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 70 | auto ret = aclInit(nullptr); | 70 | auto ret = aclInit(nullptr); |
| 71 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 71 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 72 | ret = aclrtSetDevice(deviceId); | 72 | ret = aclrtSetDevice(deviceId); |
| 73 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 73 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 74 | ret = aclrtCreateStream(stream); | 74 | ret = aclrtCreateStream(stream); |
| 75 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 75 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 76 | + aclFinalize(); return ret); | ||
| 76 | 77 | ||
| 77 | return 0; | 78 | return 0; |
| 78 | } | 79 | } |
| @@ -328,9 +328,11 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 328 | auto ret = aclInit(nullptr); | 328 | auto ret = aclInit(nullptr); |
| 329 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 329 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 330 | ret = aclrtSetDevice(deviceId); | 330 | ret = aclrtSetDevice(deviceId); |
| 331 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 331 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 332 | ret = aclrtCreateStream(stream); | 332 | ret = aclrtCreateStream(stream); |
| 333 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 333 | + CHECK_RET(ret == ACL_SUCCESS, |
| 334 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 335 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 334 | 336 | ||
| 335 | return 0; | 337 | return 0; |
| 336 | } | 338 | } |
| @@ -39,9 +39,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 39 | auto ret = aclInit(nullptr); | 39 | auto ret = aclInit(nullptr); |
| 40 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 40 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 41 | ret = aclrtSetDevice(deviceId); | 41 | ret = aclrtSetDevice(deviceId); |
| 42 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 42 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 43 | ret = aclrtCreateStream(stream); | 43 | ret = aclrtCreateStream(stream); |
| 44 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 44 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 45 | + aclFinalize(); return ret); | ||
| 45 | 46 | ||
| 46 | return 0; | 47 | return 0; |
| 47 | } | 48 | } |
| @@ -370,9 +370,11 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 370 | auto ret = aclInit(nullptr); | 370 | auto ret = aclInit(nullptr); |
| 371 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 371 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 372 | ret = aclrtSetDevice(deviceId); | 372 | ret = aclrtSetDevice(deviceId); |
| 373 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 373 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 374 | ret = aclrtCreateStream(stream); | 374 | ret = aclrtCreateStream(stream); |
| 375 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 375 | + CHECK_RET(ret == ACL_SUCCESS, |
| 376 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 377 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 376 | 378 | ||
| 377 | return 0; | 379 | return 0; |
| 378 | } | 380 | } |
| @@ -42,9 +42,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 42 | auto ret = aclInit(nullptr); | 42 | auto ret = aclInit(nullptr); |
| 43 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 43 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 44 | ret = aclrtSetDevice(deviceId); | 44 | ret = aclrtSetDevice(deviceId); |
| 45 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 45 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 46 | ret = aclrtCreateStream(stream); | 46 | ret = aclrtCreateStream(stream); |
| 47 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 47 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 48 | + aclFinalize(); return ret); | ||
| 48 | 49 | ||
| 49 | return 0; | 50 | return 0; |
| 50 | } | 51 | } |
| @@ -393,9 +393,11 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 393 | auto ret = aclInit(nullptr); | 393 | auto ret = aclInit(nullptr); |
| 394 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 394 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 395 | ret = aclrtSetDevice(deviceId); | 395 | ret = aclrtSetDevice(deviceId); |
| 396 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 396 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 397 | ret = aclrtCreateStream(stream); | 397 | ret = aclrtCreateStream(stream); |
| 398 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 398 | + CHECK_RET(ret == ACL_SUCCESS, |
| 399 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 400 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 399 | 401 | ||
| 400 | return 0; | 402 | return 0; |
| 401 | } | 403 | } |
| @@ -42,9 +42,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 42 | auto ret = aclInit(nullptr); | 42 | auto ret = aclInit(nullptr); |
| 43 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 43 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 44 | ret = aclrtSetDevice(deviceId); | 44 | ret = aclrtSetDevice(deviceId); |
| 45 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 45 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 46 | ret = aclrtCreateStream(stream); | 46 | ret = aclrtCreateStream(stream); |
| 47 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 47 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 48 | + aclFinalize(); return ret); | ||
| 48 | 49 | ||
| 49 | return 0; | 50 | return 0; |
| 50 | } | 51 | } |
| @@ -342,9 +342,11 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 342 | auto ret = aclInit(nullptr); | 342 | auto ret = aclInit(nullptr); |
| 343 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 343 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 344 | ret = aclrtSetDevice(deviceId); | 344 | ret = aclrtSetDevice(deviceId); |
| 345 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 345 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 346 | ret = aclrtCreateStream(stream); | 346 | ret = aclrtCreateStream(stream); |
| 347 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 347 | + CHECK_RET(ret == ACL_SUCCESS, |
| 348 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 349 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 348 | return 0; | 350 | return 0; |
| 349 | } | 351 | } |
| 350 | 352 | ||
| @@ -39,9 +39,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 39 | auto ret = aclInit(nullptr); | 39 | auto ret = aclInit(nullptr); |
| 40 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 40 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 41 | ret = aclrtSetDevice(deviceId); | 41 | ret = aclrtSetDevice(deviceId); |
| 42 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 42 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 43 | ret = aclrtCreateStream(stream); | 43 | ret = aclrtCreateStream(stream); |
| 44 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 44 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 45 | + aclFinalize(); return ret); | ||
| 45 | return 0; | 46 | return 0; |
| 46 | } | 47 | } |
| 47 | 48 | ||
| @@ -208,4 +209,4 @@ int main() | |||
| 208 | aclrtResetDevice(deviceId); | 209 | aclrtResetDevice(deviceId); |
| 209 | aclFinalize(); | 210 | aclFinalize(); |
| 210 | return 0; | 211 | return 0; |
| 211 | -} | 212 | +} |
| @@ -425,9 +425,11 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 425 | auto ret = aclInit(nullptr); | 425 | auto ret = aclInit(nullptr); |
| 426 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 426 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 427 | ret = aclrtSetDevice(deviceId); | 427 | ret = aclrtSetDevice(deviceId); |
| 428 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 428 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 429 | ret = aclrtCreateStream(stream); | 429 | ret = aclrtCreateStream(stream); |
| 430 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 430 | + CHECK_RET(ret == ACL_SUCCESS, |
| 431 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 432 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 431 | return 0; | 433 | return 0; |
| 432 | } | 434 | } |
| 433 | 435 | ||
| @@ -39,7 +39,7 @@ void PrintOutResult(std::vector<int64_t>& shape, void** deviceAddr) | |||
| 39 | std::vector<float> resultData(size, 0); | 39 | std::vector<float> resultData(size, 0); |
| 40 | auto ret = aclrtMemcpy(resultData.data(), resultData.size() * sizeof(resultData[0]), *deviceAddr, | 40 | auto ret = aclrtMemcpy(resultData.data(), resultData.size() * sizeof(resultData[0]), *deviceAddr, |
| 41 | size * sizeof(resultData[0]), ACL_MEMCPY_DEVICE_TO_HOST); | 41 | size * sizeof(resultData[0]), ACL_MEMCPY_DEVICE_TO_HOST); |
| 42 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("copy result from device to host failed. ERROR: %d\n", ret); return ); | 42 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("copy result from device to host failed. ERROR: %d\n", ret); return); |
| 43 | for (int64_t i = 0; i < size; i++) { | 43 | for (int64_t i = 0; i < size; i++) { |
| 44 | LOG_PRINT("result[%ld] is: %f\n", i, resultData[i]); | 44 | LOG_PRINT("result[%ld] is: %f\n", i, resultData[i]); |
| 45 | } | 45 | } |
| @@ -51,9 +51,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 51 | auto ret = aclInit(nullptr); | 51 | auto ret = aclInit(nullptr); |
| 52 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 52 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 53 | ret = aclrtSetDevice(deviceId); | 53 | ret = aclrtSetDevice(deviceId); |
| 54 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 54 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 55 | ret = aclrtCreateStream(stream); | 55 | ret = aclrtCreateStream(stream); |
| 56 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 56 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 57 | + aclFinalize(); return ret); | ||
| 57 | return 0; | 58 | return 0; |
| 58 | } | 59 | } |
| 59 | 60 | ||
| @@ -219,4 +220,4 @@ int main() | |||
| 219 | aclrtResetDevice(deviceId); | 220 | aclrtResetDevice(deviceId); |
| 220 | aclFinalize(); | 221 | aclFinalize(); |
| 221 | return 0; | 222 | return 0; |
| 222 | -} | 223 | +} |
| @@ -341,9 +341,11 @@ int Init(int32_t deviceId, aclrtStream* stream) { | |||
| 341 | auto ret = aclInit(nullptr); | 341 | auto ret = aclInit(nullptr); |
| 342 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 342 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 343 | ret = aclrtSetDevice(deviceId); | 343 | ret = aclrtSetDevice(deviceId); |
| 344 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 344 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 345 | ret = aclrtCreateStream(stream); | 345 | ret = aclrtCreateStream(stream); |
| 346 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 346 | + CHECK_RET(ret == ACL_SUCCESS, |
| 347 | + LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); | ||
| 348 | + aclrtResetDevice(deviceId); aclFinalize(); return ret); | ||
| 347 | return 0; | 349 | return 0; |
| 348 | } | 350 | } |
| 349 | 351 | ||
| @@ -39,9 +39,10 @@ int Init(int32_t deviceId, aclrtStream* stream) | |||
| 39 | auto ret = aclInit(nullptr); | 39 | auto ret = aclInit(nullptr); |
| 40 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | 40 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); |
| 41 | ret = aclrtSetDevice(deviceId); | 41 | ret = aclrtSetDevice(deviceId); |
| 42 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | 42 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); aclFinalize(); return ret); |
| 43 | ret = aclrtCreateStream(stream); | 43 | ret = aclrtCreateStream(stream); |
| 44 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | 44 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); aclrtResetDevice(deviceId); |
| 45 | + aclFinalize(); return ret); | ||
| 45 | return 0; | 46 | return 0; |
| 46 | } | 47 | } |
| 47 | 48 | ||
| @@ -193,4 +194,4 @@ int main() | |||
| 193 | aclFinalize(); | 194 | aclFinalize(); |
| 194 | 195 | ||
| 195 | return 0; | 196 | return 0; |
| 196 | -} | 197 | +} |