Thanks for sending an issue! Please fill in the following template to help quickly solve your problem.
image/upsample_bicubic2d_grad 算子的示例代码与文档存在代码风格不一致及可读性问题:
image/upsample_bicubic2d_grad
aclnnUpsampleBicubic2dBackwardGetWorkspaceSize
1.1
*
&
int *stream
const std::vector<T> &hostData
void *selfDeviceAddr
aclTensor *self
aclOpExecutor* executor
aclCreateTensor
aclrtMemcpy
cann/ops-cv
image/upsample_bicubic2d_grad/docs/aclnnUpsampleBicubic2dBackward.md
image/upsample_bicubic2d_grad/examples/test_aclnn_upsample_bicubic2d_grad.cpp
scalesH
scalesW
int*
const std::vector<T>&
void*
aclTensor*
aclIntArray*
aclOpExecutor*
涉及代码片段(修改前):
int Init(int32_t deviceId, aclrtStream *stream) ... int CreateAclTensor(const std::vector<T> &hostData, const std::vector<int64_t> &shape, void **deviceAddr, aclDataType dataType, aclTensor **tensor) ... void *selfDeviceAddr = nullptr; void *outDeviceAddr = nullptr; aclTensor *self = nullptr; aclTensor *out = nullptr; ... const aclIntArray *outputSize = aclCreateIntArray(outArraySize.data(), outArraySize.size()); const aclIntArray *inputSize = aclCreateIntArray(inputArraySize.data(), inputArraySize.size()); ... aclOpExecutor *executor; ret = aclnnUpsampleBicubic2dBackwardGetWorkspaceSize( self, outputSize, inputSize, 1, 1.1, 1.1, out, &workspaceSize, &executor); ... *tensor = aclCreateTensor(shape.data(), shape.size(), dataType, strides.data(), 0, aclFormat::ACL_FORMAT_NCHW, shape.data(), shape.size(), *deviceAddr); ... ret = aclrtMemcpy(resultData.data(), resultData.size() * sizeof(resultData[0]), outDeviceAddr, size * sizeof(resultData[0]), ACL_MEMCPY_DEVICE_TO_HOST);
关联 PR:https://gitcode.com/cann/ops-cv/pulls/1064
该 PR 已对上述问题进行修复,本 Issue 用于记录对应的问题单。
Thanks for sending an issue! Please fill in the following template to help quickly solve your problem.
Describe the current behavior / 问题描述 (Mandatory / 必填)
image/upsample_bicubic2d_grad算子的示例代码与文档存在代码风格不一致及可读性问题:aclnnUpsampleBicubic2dBackwardGetWorkspaceSize时,scalesH 与 scalesW 直接使用字面量1.1,未提取为具名常量,可读性较差,且不便于后续维护修改。*与引用符号&的位置不一致,部分紧贴变量名(如int *stream、const std::vector<T> &hostData、void *selfDeviceAddr、aclTensor *self),部分紧贴类型名(如aclOpExecutor* executor),不符合统一的代码风格规范。aclCreateTensor、aclrtMemcpy、aclnnUpsampleBicubic2dBackwardGetWorkspaceSize)参数被拆分到多行,格式不够紧凑,影响代码可读性。Environment / 环境信息 (Mandatory / 必填)
Steps to reproduce the issue / 重现步骤 (Mandatory / 必填)
cann/ops-cv。image/upsample_bicubic2d_grad/docs/aclnnUpsampleBicubic2dBackward.md,定位到示例代码段(约 362~480 行)。image/upsample_bicubic2d_grad/examples/test_aclnn_upsample_bicubic2d_grad.cpp,定位到aclnnUpsampleBicubic2dBackwardGetWorkspaceSize调用处(约 108~115 行)。aclnnUpsampleBicubic2dBackwardGetWorkspaceSize调用中 scalesH/scalesW 使用字面量1.1;*、&位置不一致;Describe the expected behavior / 预期结果 (Mandatory / 必填)
aclnnUpsampleBicubic2dBackwardGetWorkspaceSize调用中的1.1提取为具名常量scalesH与scalesW。*和&紧贴类型名(如int*、const std::vector<T>&、void*、aclTensor*、aclIntArray*、aclOpExecutor*)。Related log / screenshot / 日志 / 截图 (Mandatory / 必填)
涉及代码片段(修改前):
int Init(int32_t deviceId, aclrtStream *stream) ... int CreateAclTensor(const std::vector<T> &hostData, const std::vector<int64_t> &shape, void **deviceAddr, aclDataType dataType, aclTensor **tensor) ... void *selfDeviceAddr = nullptr; void *outDeviceAddr = nullptr; aclTensor *self = nullptr; aclTensor *out = nullptr; ... const aclIntArray *outputSize = aclCreateIntArray(outArraySize.data(), outArraySize.size()); const aclIntArray *inputSize = aclCreateIntArray(inputArraySize.data(), inputArraySize.size()); ... aclOpExecutor *executor; ret = aclnnUpsampleBicubic2dBackwardGetWorkspaceSize( self, outputSize, inputSize, 1, 1.1, 1.1, out, &workspaceSize, &executor); ... *tensor = aclCreateTensor(shape.data(), shape.size(), dataType, strides.data(), 0, aclFormat::ACL_FORMAT_NCHW, shape.data(), shape.size(), *deviceAddr); ... ret = aclrtMemcpy(resultData.data(), resultData.size() * sizeof(resultData[0]), outDeviceAddr, size * sizeof(resultData[0]), ACL_MEMCPY_DEVICE_TO_HOST);Special notes for this issue/备注 (Optional / 选填)
关联 PR:https://gitcode.com/cann/ops-cv/pulls/1064
该 PR 已对上述问题进行修复,本 Issue 用于记录对应的问题单。