已合并
wqbmmv3 do not support nz in dav3510 #4100
zhangquanxin创建于 4月22日
wqbmmv3 do not support nz in dav3510 #4100
已合并
共 2 个文件变更+17-12
Rmatmul/quant_batch_matmul_v3/examples/arch35/test_aclnn_quant_matmul_weight_nz a8w4.cpp→matmul/quant_batch_matmul_v3/examples/arch35/test_aclnn_quant_matmul_weight_nz_a8w4.cpp+2-2
| @@ -126,8 +126,8 @@ int AclnnQuantMatmulWeightNzTest(int32_t deviceId, aclrtStream& stream) | |||
| 126 | int64_t groupSize = 32; | 126 | int64_t groupSize = 32; |
| 127 | std::vector<int64_t> x1Shape = {m, k}; | 127 | std::vector<int64_t> x1Shape = {m, k}; |
| 128 | std::vector<int64_t> x2Shape = {n, k}; | 128 | std::vector<int64_t> x2Shape = {n, k}; |
| 129 | - std::vector<int64_t> x1ScaleShape = {m, k / groupSize}; | 129 | + std::vector<int64_t> x1ScaleShape = {m, k / groupSize / 2, 2}; |
| 130 | - std::vector<int64_t> x2ScaleShape = {n, k / groupSize}; | 130 | + std::vector<int64_t> x2ScaleShape = {n, k / groupSize / 2, 2}; |
| 131 | std::vector<int64_t> outShape = {m, n}; | 131 | std::vector<int64_t> outShape = {m, n}; |
| 132 | void* x1DeviceAddr = nullptr; | 132 | void* x1DeviceAddr = nullptr; |
| 133 | void* x2DeviceAddr = nullptr; | 133 | void* x2DeviceAddr = nullptr; |
| @@ -832,6 +832,19 @@ static bool CheckNotNull( | |||
| 832 | return true; | 832 | return true; |
| 833 | } | 833 | } |
| 834 | 834 | ||
| 835 | +static bool CheckWeightFormat(const aclTensor* weight) | ||
| 836 | +{ | ||
| 837 | + if (op::GetCurrentPlatformInfo().GetCurNpuArch() == NpuArch::DAV_3510) { | ||
| 838 | + if (weight->GetStorageFormat() != op::Format::FORMAT_ND) { | ||
| 839 | + OP_LOGE(ACLNN_ERR_PARAM_INVALID, | ||
| 840 | + "In DAV_3510, aclnnWeightQuantBatchMatmulV2 and aclnnWeightQuantBatchMatmulV3 weight format only " | ||
| 841 | + "support FORMAT_ND."); | ||
| 842 | + return false; | ||
| 843 | + } | ||
| 844 | + } | ||
| 845 | + return true; | ||
| 846 | +} | ||
| 847 | + | ||
| 835 | static bool CheckOptionalNotNull(const aclTensor* quantScaleOptional, const aclTensor* quantOffsetOptional) | 848 | static bool CheckOptionalNotNull(const aclTensor* quantScaleOptional, const aclTensor* quantOffsetOptional) |
| 836 | { | 849 | { |
| 837 | if (GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND310P) { | 850 | if (GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND310P) { |
| @@ -1738,15 +1751,7 @@ aclnnStatus aclnnWeightQuantBatchMatmulV2GetWorkspaceSize( | |||
| 1738 | CHECK_RET(socRes == ACLNN_SUCCESS, socRes); | 1751 | CHECK_RET(socRes == ACLNN_SUCCESS, socRes); |
| 1739 | CHECK_RET(CheckNotNull(x, weight, antiquantScale, y), ACLNN_ERR_PARAM_NULLPTR); | 1752 | CHECK_RET(CheckNotNull(x, weight, antiquantScale, y), ACLNN_ERR_PARAM_NULLPTR); |
| 1740 | CHECK_RET(CheckOptionalNotNull(quantScaleOptional, quantOffsetOptional), ACLNN_ERR_PARAM_NULLPTR); | 1753 | CHECK_RET(CheckOptionalNotNull(quantScaleOptional, quantOffsetOptional), ACLNN_ERR_PARAM_NULLPTR); |
| 1741 | - if (op::GetCurrentPlatformInfo().GetCurNpuArch() == NpuArch::DAV_3510) { | 1754 | + CHECK_RET(CheckWeightFormat(weight), ACLNN_ERR_PARAM_INVALID); |
| 1742 | - OP_CHECK( | ||
| 1743 | - weight->GetStorageFormat() == op::Format::FORMAT_ND, | ||
| 1744 | - OP_LOGE( | ||
| 1745 | - ACLNN_ERR_PARAM_INVALID, | ||
| 1746 | - "In DAV_3510, aclnnWeightQuantBatchMatmulV2 not support FORMAT_FRACTAL_NZ and only support " | ||
| 1747 | - "FORMAT_ND."), | ||
| 1748 | - return ACLNN_ERR_PARAM_INVALID); | ||
| 1749 | - } | ||
| 1750 | const aclTensor* tensorWeight = weight; | 1755 | const aclTensor* tensorWeight = weight; |
| 1751 | const aclTensor* antiquantScaleRef = antiquantScale; | 1756 | const aclTensor* antiquantScaleRef = antiquantScale; |
| 1752 | const aclTensor* tensorQuantScaleOptional = quantScaleOptional; | 1757 | const aclTensor* tensorQuantScaleOptional = quantScaleOptional; |
| @@ -1798,7 +1803,7 @@ aclnnStatus aclnnWeightQuantBatchMatmulV3GetWorkspaceSize( | |||
| 1798 | CHECK_RET(socRes == ACLNN_SUCCESS, socRes); | 1803 | CHECK_RET(socRes == ACLNN_SUCCESS, socRes); |
| 1799 | CHECK_RET(CheckNotNull(x, weight, antiquantScale, y), ACLNN_ERR_PARAM_NULLPTR); | 1804 | CHECK_RET(CheckNotNull(x, weight, antiquantScale, y), ACLNN_ERR_PARAM_NULLPTR); |
| 1800 | CHECK_RET(CheckOptionalNotNull(quantScaleOptional, quantOffsetOptional), ACLNN_ERR_PARAM_NULLPTR); | 1805 | CHECK_RET(CheckOptionalNotNull(quantScaleOptional, quantOffsetOptional), ACLNN_ERR_PARAM_NULLPTR); |
| 1801 | - | 1806 | + CHECK_RET(CheckWeightFormat(weight), ACLNN_ERR_PARAM_INVALID); |
| 1802 | const aclTensor* tensorWeight = weight; | 1807 | const aclTensor* tensorWeight = weight; |
| 1803 | const aclTensor* antiquantScaleRef = antiquantScale; | 1808 | const aclTensor* antiquantScaleRef = antiquantScale; |
| 1804 | const aclTensor* tensorQuantScaleOptional = quantScaleOptional; | 1809 | const aclTensor* tensorQuantScaleOptional = quantScaleOptional; |