|
|
|
@ -87,10 +87,7 @@ Status TransShapeToFracNz(const ShapeVector &src_shape, DataType data_type, Shap
|
|
|
|
|
hw_shape.push_back(DIM_DEFAULT_VALUE);
|
|
|
|
|
hw_shape.push_back(src_shape[kNdDimIndexN]);
|
|
|
|
|
if (!IsShapeValid(dst_shape)) {
|
|
|
|
|
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Check][DSTShape]Failed, dst shape %s",
|
|
|
|
|
ShapeToString(dst_shape).c_str());
|
|
|
|
|
REPORT_CALL_ERROR("E19999", "Failed to check dst shape %s",
|
|
|
|
|
ShapeToString(dst_shape).c_str());
|
|
|
|
|
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check dst shape %s", ShapeToString(dst_shape).c_str());
|
|
|
|
|
return ACL_ERROR_GE_SHAPE_INVALID;
|
|
|
|
|
}
|
|
|
|
|
return SUCCESS;
|
|
|
|
@ -109,10 +106,7 @@ Status TransShapeToFracNz(const ShapeVector &src_shape, DataType data_type, Shap
|
|
|
|
|
hw_shape.push_back(src_shape[size - kNdDimCountBackwardsWH]);
|
|
|
|
|
hw_shape.push_back(src_shape[size - kNdDimCountBackwardsW]);
|
|
|
|
|
if (!IsShapeValid(dst_shape)) {
|
|
|
|
|
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Check][DSTShape]Failed, dst shape %s",
|
|
|
|
|
ShapeToString(dst_shape).c_str());
|
|
|
|
|
REPORT_CALL_ERROR("E19999", "Failed to check dst shape %s",
|
|
|
|
|
ShapeToString(dst_shape).c_str());
|
|
|
|
|
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check dst shape %s", ShapeToString(dst_shape).c_str());
|
|
|
|
|
return ACL_ERROR_GE_SHAPE_INVALID;
|
|
|
|
|
}
|
|
|
|
|
return SUCCESS;
|
|
|
|
@ -123,12 +117,10 @@ Status CheckShapeRelation(const TransArgs &args, ShapeVector &hw_shape) {
|
|
|
|
|
ShapeVector expect_src_shape;
|
|
|
|
|
auto ret = TransShapeToFracNz(args.dst_shape, args.src_data_type, expect_src_shape, hw_shape);
|
|
|
|
|
if (ret != SUCCESS) {
|
|
|
|
|
GELOGE(ret, "[Transfer][ShapeToFracNz]Failed, shape from %s to %s, shape %s to %s, "
|
|
|
|
|
"data type %s, error_code:%u", TypeUtils::FormatToSerialString(args.dst_format).c_str(),
|
|
|
|
|
TypeUtils::FormatToSerialString(args.src_format).c_str(),
|
|
|
|
|
ShapeToString(args.dst_shape).c_str(),
|
|
|
|
|
ShapeToString(args.src_shape).c_str(),
|
|
|
|
|
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), ret);
|
|
|
|
|
GELOGE(ret, "Trans shape from %s to %s, shape %s to %s, data type %s failed",
|
|
|
|
|
TypeUtils::FormatToSerialString(args.dst_format).c_str(),
|
|
|
|
|
TypeUtils::FormatToSerialString(args.src_format).c_str(), ShapeToString(args.dst_shape).c_str(),
|
|
|
|
|
ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str());
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
if (!IsTransShapeSrcCorrect(args, expect_src_shape)) {
|
|
|
|
@ -147,14 +139,10 @@ Status TransFormatFromNdToFracNz(const TransArgs &args, TransResult &result, con
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size](), std::default_delete<uint8_t[]>());
|
|
|
|
|
if (dst == nullptr) {
|
|
|
|
|
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "[Allocate][DSTMemory]Failed to allocate memory "
|
|
|
|
|
"for dst buf %ld when trans format from %s to %s",
|
|
|
|
|
dst_size, TypeUtils::FormatToSerialString(args.src_format).c_str(),
|
|
|
|
|
TypeUtils::FormatToSerialString(args.dst_format).c_str());
|
|
|
|
|
REPORT_CALL_ERROR("E19999", "Failed to allocate memory for dst buf %ld "
|
|
|
|
|
"trans format from %s to %s",
|
|
|
|
|
dst_size, TypeUtils::FormatToSerialString(args.src_format).c_str(),
|
|
|
|
|
TypeUtils::FormatToSerialString(args.dst_format).c_str());
|
|
|
|
|
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION,
|
|
|
|
|
"Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld",
|
|
|
|
|
TypeUtils::FormatToSerialString(args.src_format).c_str(),
|
|
|
|
|
TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size);
|
|
|
|
|
return ACL_ERROR_GE_MEMORY_ALLOCATION;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -188,10 +176,8 @@ Status TransFormatFromNdToFracNz(const TransArgs &args, TransResult &result, con
|
|
|
|
|
auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset,
|
|
|
|
|
static_cast<size_t>(size * w0));
|
|
|
|
|
if (ret != EOK) {
|
|
|
|
|
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED,"[Operate][DSTMemory]Failed at offset %ld, "
|
|
|
|
|
"error-code %d", dst_offset, ret);
|
|
|
|
|
REPORT_CALL_ERROR("E19999", "Failed to operate dst memory at offset %ld, error-code %d",
|
|
|
|
|
dst_offset, ret);
|
|
|
|
|
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED,
|
|
|
|
|
"Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret);
|
|
|
|
|
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -205,10 +191,8 @@ Status TransFormatFromNdToFracNz(const TransArgs &args, TransResult &result, con
|
|
|
|
|
auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset,
|
|
|
|
|
static_cast<size_t>(size));
|
|
|
|
|
if (ret != EOK) {
|
|
|
|
|
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED,"[Operate][DSTMemory]Failed at offset %ld, "
|
|
|
|
|
"error-code %d", dst_offset, ret);
|
|
|
|
|
REPORT_CALL_ERROR("E19999", "Failed to operate dst memory at offset %ld, error-code %d",
|
|
|
|
|
dst_offset, ret);
|
|
|
|
|
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED,
|
|
|
|
|
"Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret);
|
|
|
|
|
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -229,12 +213,8 @@ Status TransFormatFromFracNzToNd(const TransArgs &args, TransResult &result, con
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size], std::default_delete<uint8_t[]>());
|
|
|
|
|
if (dst == nullptr) {
|
|
|
|
|
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "[Allocate][DSTMemory]Failed to trans format "
|
|
|
|
|
"from %s to %s, memory for dst buf %ld",
|
|
|
|
|
TypeUtils::FormatToSerialString(args.src_format).c_str(),
|
|
|
|
|
TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size);
|
|
|
|
|
REPORT_CALL_ERROR("E19999", "Failed to trans format from %s to %s and allocate memory "
|
|
|
|
|
"for dst buf %ld",
|
|
|
|
|
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION,
|
|
|
|
|
"Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld",
|
|
|
|
|
TypeUtils::FormatToSerialString(args.src_format).c_str(),
|
|
|
|
|
TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size);
|
|
|
|
|
return ACL_ERROR_GE_MEMORY_ALLOCATION;
|
|
|
|
@ -270,11 +250,8 @@ Status TransFormatFromFracNzToNd(const TransArgs &args, TransResult &result, con
|
|
|
|
|
ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset,
|
|
|
|
|
static_cast<size_t>(size * w0));
|
|
|
|
|
if (ret != EOK) {
|
|
|
|
|
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "[Operate][DSTMemory]Failed at offset %ld, "
|
|
|
|
|
"error-code %d",
|
|
|
|
|
dst_offset, ret);
|
|
|
|
|
REPORT_CALL_ERROR("E19999", "Failed to operate dst memory at offset %ld, error-code %d",
|
|
|
|
|
dst_offset, ret);
|
|
|
|
|
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED,
|
|
|
|
|
"Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret);
|
|
|
|
|
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -288,11 +265,8 @@ Status TransFormatFromFracNzToNd(const TransArgs &args, TransResult &result, con
|
|
|
|
|
ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset,
|
|
|
|
|
static_cast<size_t>(size));
|
|
|
|
|
if (ret != EOK) {
|
|
|
|
|
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "[Operate][DSTMemory]Failed at offset %ld, "
|
|
|
|
|
"error-code %d",
|
|
|
|
|
dst_offset, ret);
|
|
|
|
|
REPORT_CALL_ERROR("E19999", "Failed to operate dst memory at offset %ld, error-code %d",
|
|
|
|
|
dst_offset, ret);
|
|
|
|
|
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED,
|
|
|
|
|
"Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret);
|
|
|
|
|
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -307,38 +281,18 @@ Status TransFormatFromFracNzToNd(const TransArgs &args, TransResult &result, con
|
|
|
|
|
Status FormatTransferFractalNz::TransFormat(const TransArgs &args, TransResult &result) {
|
|
|
|
|
if (!IsDataTypeSupport(args.src_data_type)) {
|
|
|
|
|
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID,
|
|
|
|
|
"[Check][Datatype]Failed, trans format from %s to %s, src shape %s, dst shape %s, "
|
|
|
|
|
"data type %s is not supported",
|
|
|
|
|
"Trans format from %s to %s, src shape %s, dst shape %s, data type %s is not supported",
|
|
|
|
|
TypeUtils::FormatToSerialString(args.src_format).c_str(),
|
|
|
|
|
TypeUtils::FormatToSerialString(args.dst_format).c_str(),
|
|
|
|
|
ShapeToString(args.src_shape).c_str(),
|
|
|
|
|
ShapeToString(args.dst_shape).c_str(),
|
|
|
|
|
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str());
|
|
|
|
|
REPORT_INNER_ERROR("E19999", "Check datatype failed, trans format from %s to %s, src shape %s, "
|
|
|
|
|
"dst shape %s, data type %s is not supported",
|
|
|
|
|
TypeUtils::FormatToSerialString(args.src_format).c_str(),
|
|
|
|
|
TypeUtils::FormatToSerialString(args.dst_format).c_str(),
|
|
|
|
|
ShapeToString(args.src_shape).c_str(),
|
|
|
|
|
ShapeToString(args.dst_shape).c_str(),
|
|
|
|
|
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str());
|
|
|
|
|
TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.src_shape).c_str(),
|
|
|
|
|
ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str());
|
|
|
|
|
return ACL_ERROR_GE_DATATYPE_INVALID;
|
|
|
|
|
}
|
|
|
|
|
if (!CheckShape(args.src_format, args.src_shape) || !IsShapeValid(args.dst_shape)) {
|
|
|
|
|
GELOGE(ACL_ERROR_GE_SHAPE_INVALID,
|
|
|
|
|
"[Check][Shape]Failed, trans format from %s to %s, "
|
|
|
|
|
"src shape %s, dst shape %s, data type %s is not supported",
|
|
|
|
|
TypeUtils::FormatToSerialString(args.src_format).c_str(),
|
|
|
|
|
TypeUtils::FormatToSerialString(args.dst_format).c_str(),
|
|
|
|
|
ShapeToString(args.src_shape).c_str(),
|
|
|
|
|
ShapeToString(args.dst_shape).c_str(),
|
|
|
|
|
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str());
|
|
|
|
|
REPORT_INNER_ERROR("E19999", "Check shape failed, trans format from %s to %s, "
|
|
|
|
|
"src shape %s, dst shape %s, data type %s is not supported",
|
|
|
|
|
"Trans format from %s to %s, src shape %s, dst shape %s, data type %s is not supported",
|
|
|
|
|
TypeUtils::FormatToSerialString(args.src_format).c_str(),
|
|
|
|
|
TypeUtils::FormatToSerialString(args.dst_format).c_str(),
|
|
|
|
|
ShapeToString(args.src_shape).c_str(),
|
|
|
|
|
ShapeToString(args.dst_shape).c_str(),
|
|
|
|
|
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str());
|
|
|
|
|
TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.src_shape).c_str(),
|
|
|
|
|
ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str());
|
|
|
|
|
return ACL_ERROR_GE_SHAPE_INVALID;
|
|
|
|
|
}
|
|
|
|
|
GELOGD("Begin to trans format from %s to %s, src shape %s, dst shape %s, data type %s",
|
|
|
|
@ -361,34 +315,16 @@ Status FormatTransferFractalNz::TransShape(Format src_format, const ShapeVector
|
|
|
|
|
Format dst_format, ShapeVector &dst_shape) {
|
|
|
|
|
if (!IsDataTypeSupport(data_type)) {
|
|
|
|
|
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID,
|
|
|
|
|
"[Check][Datatype]Failed, trans format from %s to %s, src shape %s, "
|
|
|
|
|
"data type %s is not supported",
|
|
|
|
|
TypeUtils::FormatToSerialString(src_format).c_str(),
|
|
|
|
|
TypeUtils::FormatToSerialString(dst_format).c_str(),
|
|
|
|
|
ShapeToString(src_shape).c_str(),
|
|
|
|
|
TypeUtils::DataTypeToSerialString(data_type).c_str());
|
|
|
|
|
REPORT_INNER_ERROR("E19999", "Check datatype failed, trans format from %s to %s, src shape %s, "
|
|
|
|
|
"data type %s is not supported",
|
|
|
|
|
TypeUtils::FormatToSerialString(src_format).c_str(),
|
|
|
|
|
TypeUtils::FormatToSerialString(dst_format).c_str(),
|
|
|
|
|
ShapeToString(src_shape).c_str(),
|
|
|
|
|
TypeUtils::DataTypeToSerialString(data_type).c_str());
|
|
|
|
|
"Trans format from %s to %s, src shape %s, data type %s is not supported",
|
|
|
|
|
TypeUtils::FormatToSerialString(src_format).c_str(), TypeUtils::FormatToSerialString(dst_format).c_str(),
|
|
|
|
|
ShapeToString(src_shape).c_str(), TypeUtils::DataTypeToSerialString(data_type).c_str());
|
|
|
|
|
return ACL_ERROR_GE_DATATYPE_INVALID;
|
|
|
|
|
}
|
|
|
|
|
if (!CheckShape(src_format, src_shape)) {
|
|
|
|
|
GELOGE(ACL_ERROR_GE_SHAPE_INVALID,
|
|
|
|
|
"[Check][Shape]Failed, trans format from %s to %s, src shape %s, "
|
|
|
|
|
"data type %s is not supported",
|
|
|
|
|
TypeUtils::FormatToSerialString(src_format).c_str(),
|
|
|
|
|
TypeUtils::FormatToSerialString(dst_format).c_str(),
|
|
|
|
|
ShapeToString(src_shape).c_str(),
|
|
|
|
|
TypeUtils::DataTypeToSerialString(data_type).c_str());
|
|
|
|
|
REPORT_INNER_ERROR("E19999", "Check shape failed, trans format from %s to %s, src shape %s, "
|
|
|
|
|
"data type %s is not supported",
|
|
|
|
|
TypeUtils::FormatToSerialString(src_format).c_str(),
|
|
|
|
|
TypeUtils::FormatToSerialString(dst_format).c_str(),
|
|
|
|
|
ShapeToString(src_shape).c_str(),
|
|
|
|
|
TypeUtils::DataTypeToSerialString(data_type).c_str());
|
|
|
|
|
"Trans format from %s to %s, src shape %s, data type %s is not supported",
|
|
|
|
|
TypeUtils::FormatToSerialString(src_format).c_str(), TypeUtils::FormatToSerialString(dst_format).c_str(),
|
|
|
|
|
ShapeToString(src_shape).c_str(), TypeUtils::DataTypeToSerialString(data_type).c_str());
|
|
|
|
|
return ACL_ERROR_GE_SHAPE_INVALID;
|
|
|
|
|
}
|
|
|
|
|
ShapeVector hw_shape;
|
|
|
|
@ -398,39 +334,19 @@ Status FormatTransferFractalNz::TransShape(Format src_format, const ShapeVector
|
|
|
|
|
Status FormatTransferFractalNzND::TransFormat(const TransArgs &args, TransResult &result) {
|
|
|
|
|
if (!IsDataTypeSupport(args.src_data_type)) {
|
|
|
|
|
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID,
|
|
|
|
|
"[Check][Datatype]Failed, trans format from %s to %s, src shape %s, dst shape %s, "
|
|
|
|
|
"data type %s is not supported",
|
|
|
|
|
"Trans format from %s to %s, src shape %s, dst shape %s, data type %s is not supported",
|
|
|
|
|
TypeUtils::FormatToSerialString(args.src_format).c_str(),
|
|
|
|
|
TypeUtils::FormatToSerialString(args.dst_format).c_str(),
|
|
|
|
|
ShapeToString(args.src_shape).c_str(),
|
|
|
|
|
ShapeToString(args.dst_shape).c_str(),
|
|
|
|
|
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str());
|
|
|
|
|
REPORT_INNER_ERROR("E19999", "Check datatype failed, trans format from %s to %s, src shape %s, "
|
|
|
|
|
"dst shape %s, data type %s is not supported",
|
|
|
|
|
TypeUtils::FormatToSerialString(args.src_format).c_str(),
|
|
|
|
|
TypeUtils::FormatToSerialString(args.dst_format).c_str(),
|
|
|
|
|
ShapeToString(args.src_shape).c_str(),
|
|
|
|
|
ShapeToString(args.dst_shape).c_str(),
|
|
|
|
|
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str());
|
|
|
|
|
TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.src_shape).c_str(),
|
|
|
|
|
ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str());
|
|
|
|
|
return ACL_ERROR_GE_DATATYPE_INVALID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!IsShapeValid(args.src_shape) || !CheckShape(args.dst_format, args.dst_shape)) {
|
|
|
|
|
GELOGE(ACL_ERROR_GE_SHAPE_INVALID,
|
|
|
|
|
"[Check][Shape]Failed, trans format from %s to %s, src shape %s, dst shape %s, "
|
|
|
|
|
"data type %s is not supported",
|
|
|
|
|
TypeUtils::FormatToSerialString(args.src_format).c_str(),
|
|
|
|
|
TypeUtils::FormatToSerialString(args.dst_format).c_str(),
|
|
|
|
|
ShapeToString(args.src_shape).c_str(),
|
|
|
|
|
ShapeToString(args.dst_shape).c_str(),
|
|
|
|
|
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str());
|
|
|
|
|
REPORT_INNER_ERROR("E19999", "Check shape failed, trans format from %s to %s, src shape %s, "
|
|
|
|
|
"dst shape %s, data type %s is not supported",
|
|
|
|
|
"Trans format from %s to %s, src shape %s, dst shape %s, data type %s is not supported",
|
|
|
|
|
TypeUtils::FormatToSerialString(args.src_format).c_str(),
|
|
|
|
|
TypeUtils::FormatToSerialString(args.dst_format).c_str(),
|
|
|
|
|
ShapeToString(args.src_shape).c_str(),
|
|
|
|
|
ShapeToString(args.dst_shape).c_str(),
|
|
|
|
|
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str());
|
|
|
|
|
TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.src_shape).c_str(),
|
|
|
|
|
ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str());
|
|
|
|
|
return ACL_ERROR_GE_SHAPE_INVALID;
|
|
|
|
|
}
|
|
|
|
|
GELOGD("Begin to trans format from %s to %s, src shape %s, dst shape %s, data type %s",
|
|
|
|
|