* opt log at release mode
* add MGE_OVERRIDE_LOG_LEVEL for runtime debug
//! env to config LogLevel
//! DEBUG = 0, INFO = 1, WARN = 2, ERROR = 3, NO_LOG = 4
//! for example , export MGE_OVERRIDE_LOG_LEVEL=0, means set LogLevel to DEBUG
GitOrigin-RevId: 16cd674c56
tags/v1.3.1
| @@ -25,13 +25,13 @@ | |||||
| #include "megdnn/internal/visibility_prologue.h" | #include "megdnn/internal/visibility_prologue.h" | ||||
| #if MEGDNN_DISABLE_FLOAT16 | #if MEGDNN_DISABLE_FLOAT16 | ||||
| #define MEGDNN_INC_FLOAT16(_x) | |||||
| #define MEGDNN_FLOAT16_SELECT(_x, _y) _y | |||||
| #define DNN_INC_FLOAT16(_x) | |||||
| #define DNN_FLOAT16_SELECT(_x, _y) _y | |||||
| #else | #else | ||||
| #include "megdnn/dtype/half.hpp" | #include "megdnn/dtype/half.hpp" | ||||
| #include "megdnn/dtype/bfloat16.hpp" | #include "megdnn/dtype/bfloat16.hpp" | ||||
| #define MEGDNN_INC_FLOAT16(_x) _x | |||||
| #define MEGDNN_FLOAT16_SELECT(_x, _y) _x | |||||
| #define DNN_INC_FLOAT16(_x) _x | |||||
| #define DNN_FLOAT16_SELECT(_x, _y) _x | |||||
| #endif | #endif | ||||
| namespace megdnn { | namespace megdnn { | ||||
| @@ -49,8 +49,8 @@ namespace megdnn { | |||||
| cb(IntB2) \ | cb(IntB2) \ | ||||
| cb(IntB4) \ | cb(IntB4) \ | ||||
| cb(Byte) \ | cb(Byte) \ | ||||
| MEGDNN_INC_FLOAT16(cb(Float16)) \ | |||||
| MEGDNN_INC_FLOAT16(cb(BFloat16)) \ | |||||
| DNN_INC_FLOAT16(cb(Float16)) \ | |||||
| DNN_INC_FLOAT16(cb(BFloat16)) \ | |||||
| cb(UintB4) \ | cb(UintB4) \ | ||||
| cb(Bool) \ | cb(Bool) \ | ||||
| cb(Uint16) \ | cb(Uint16) \ | ||||
| @@ -65,8 +65,8 @@ namespace megdnn { | |||||
| cb(Int16) \ | cb(Int16) \ | ||||
| cb(Int32) \ | cb(Int32) \ | ||||
| cb(Byte) \ | cb(Byte) \ | ||||
| MEGDNN_INC_FLOAT16(cb(Float16)) \ | |||||
| MEGDNN_INC_FLOAT16(cb(BFloat16)) \ | |||||
| DNN_INC_FLOAT16(cb(Float16)) \ | |||||
| DNN_INC_FLOAT16(cb(BFloat16)) \ | |||||
| cb(Bool) \ | cb(Bool) \ | ||||
| cb(Uint16) \ | cb(Uint16) \ | ||||
| @@ -108,8 +108,8 @@ namespace megdnn { | |||||
| #define MEGDNN_FOREACH_COMPUTING_DTYPE_FLOAT(cb) \ | #define MEGDNN_FOREACH_COMPUTING_DTYPE_FLOAT(cb) \ | ||||
| cb(::megdnn::dtype::Float32) \ | cb(::megdnn::dtype::Float32) \ | ||||
| MEGDNN_INC_FLOAT16(cb(::megdnn::dtype::Float16)) \ | |||||
| MEGDNN_INC_FLOAT16(cb(::megdnn::dtype::BFloat16)) | |||||
| DNN_INC_FLOAT16(cb(::megdnn::dtype::Float16)) \ | |||||
| DNN_INC_FLOAT16(cb(::megdnn::dtype::BFloat16)) | |||||
| /*! | /*! | ||||
| @@ -360,8 +360,8 @@ typedef int8_t dt_int8; | |||||
| typedef uint8_t dt_uint8; | typedef uint8_t dt_uint8; | ||||
| typedef bool dt_bool; | typedef bool dt_bool; | ||||
| typedef uint16_t dt_uint16; | typedef uint16_t dt_uint16; | ||||
| MEGDNN_INC_FLOAT16(typedef half_float::half dt_float16;) | |||||
| MEGDNN_INC_FLOAT16(typedef half_bfloat16::bfloat16 dt_bfloat16;) | |||||
| DNN_INC_FLOAT16(typedef half_float::half dt_float16;) | |||||
| DNN_INC_FLOAT16(typedef half_bfloat16::bfloat16 dt_bfloat16;) | |||||
| #define MEGDNN_PARAMETERIZED_DTYPE_ENUM_BASE 100000 | #define MEGDNN_PARAMETERIZED_DTYPE_ENUM_BASE 100000 | ||||
| #if MEGDNN_CC_HOST | #if MEGDNN_CC_HOST | ||||
| @@ -722,10 +722,10 @@ MEGDNN_DEF_DT(Int8, dt_int8, INT, SIGNED, INT8_MIN, INT8_MAX); | |||||
| MEGDNN_DEF_DT(Uint8, dt_uint8, INT, UNSIGNED, 0, UINT8_MAX); | MEGDNN_DEF_DT(Uint8, dt_uint8, INT, UNSIGNED, 0, UINT8_MAX); | ||||
| MEGDNN_DEF_DT(Bool, dt_bool, BOOL, UNSIGNED, false, true); | MEGDNN_DEF_DT(Bool, dt_bool, BOOL, UNSIGNED, false, true); | ||||
| MEGDNN_DEF_DT(Uint16, dt_uint16, INT, UNSIGNED, 0, UINT16_MAX); | MEGDNN_DEF_DT(Uint16, dt_uint16, INT, UNSIGNED, 0, UINT16_MAX); | ||||
| MEGDNN_INC_FLOAT16(MEGDNN_DEF_DT(Float16, dt_float16, FLOAT, SIGNED, | |||||
| DNN_INC_FLOAT16(MEGDNN_DEF_DT(Float16, dt_float16, FLOAT, SIGNED, | |||||
| std::numeric_limits<dt_float16>::lowest(), | std::numeric_limits<dt_float16>::lowest(), | ||||
| std::numeric_limits<dt_float16>::max())); | std::numeric_limits<dt_float16>::max())); | ||||
| MEGDNN_INC_FLOAT16(MEGDNN_DEF_DT(BFloat16, dt_bfloat16, FLOAT, SIGNED, | |||||
| DNN_INC_FLOAT16(MEGDNN_DEF_DT(BFloat16, dt_bfloat16, FLOAT, SIGNED, | |||||
| std::numeric_limits<dt_bfloat16>::lowest(), | std::numeric_limits<dt_bfloat16>::lowest(), | ||||
| std::numeric_limits<dt_bfloat16>::max())); | std::numeric_limits<dt_bfloat16>::max())); | ||||
| @@ -270,8 +270,7 @@ void megdnn::aarch64::warp_perspective_cv_exec( | |||||
| DISPATCH_IMODE(imode, bmode, ch, cb) | DISPATCH_IMODE(imode, bmode, ch, cb) | ||||
| #undef cb | #undef cb | ||||
| } else { | } else { | ||||
| megdnn_throw( | |||||
| megdnn_mangle("Unsupported datatype of WarpPerspective optr.")); | |||||
| megdnn_throw("Unsupported datatype of WarpPerspective optr."); | |||||
| } | } | ||||
| } | } | ||||
| // vim: syntax=cpp.doxygen | // vim: syntax=cpp.doxygen | ||||
| @@ -152,8 +152,9 @@ struct PostProcess<ctype, dtype, megdnn::PostprocessMode::NO_PROCESS> { | |||||
| MEGDNN_MARK_USED_VAR(OH); | MEGDNN_MARK_USED_VAR(OH); | ||||
| MEGDNN_MARK_USED_VAR(OW); | MEGDNN_MARK_USED_VAR(OW); | ||||
| MEGDNN_MARK_USED_VAR(pack_oc_size); | MEGDNN_MARK_USED_VAR(pack_oc_size); | ||||
| megdnn_assert(bias_mode == megdnn::BiasMode::NO_BIAS && | |||||
| nonlineMode == megdnn::NonlineMode::IDENTITY); | |||||
| megdnn_throw_if(bias_mode != megdnn::BiasMode::NO_BIAS || | |||||
| nonlineMode != megdnn::NonlineMode::IDENTITY, | |||||
| megdnn_error, "biasmode or nonlineMode do not support"); | |||||
| } | } | ||||
| }; | }; | ||||
| @@ -310,7 +311,8 @@ struct PostProcess<ctype, dtype, megdnn::PostprocessMode::ADD_BIAS> { | |||||
| megdnn::BiasMode bias_mode, megdnn::NonlineMode nonlineMode, | megdnn::BiasMode bias_mode, megdnn::NonlineMode nonlineMode, | ||||
| megdnn::DType bias_type, megdnn::DType dst_type, size_t N, | megdnn::DType bias_type, megdnn::DType dst_type, size_t N, | ||||
| size_t OC, size_t OH, size_t OW, size_t pack_oc_size = 1) { | size_t OC, size_t OH, size_t OW, size_t pack_oc_size = 1) { | ||||
| megdnn_assert(nonlineMode == megdnn::NonlineMode::IDENTITY); | |||||
| megdnn_throw_if(nonlineMode != megdnn::NonlineMode::IDENTITY, | |||||
| megdnn_error, "nonlineMode do not support"); | |||||
| FOR_BIAS(bias_mode, OH, OW); | FOR_BIAS(bias_mode, OH, OW); | ||||
| } | } | ||||
| }; | }; | ||||
| @@ -115,7 +115,7 @@ bool ElemwiseImpl::AlgoBinaryVecBcast101x4::is_available( | |||||
| auto& elparam = kern_param.binary_elparam; | auto& elparam = kern_param.binary_elparam; | ||||
| auto& src0 = elparam[0]; | auto& src0 = elparam[0]; | ||||
| #if __ARM_FEATURE_FP16_VECTOR_ARITHMETIC | #if __ARM_FEATURE_FP16_VECTOR_ARITHMETIC | ||||
| if (MEGDNN_FLOAT16_SELECT(src0.layout.dtype == dtype::Float16{}, false)) { | |||||
| if (DNN_FLOAT16_SELECT(src0.layout.dtype == dtype::Float16{}, false)) { | |||||
| return false; | return false; | ||||
| } | } | ||||
| #endif | #endif | ||||
| @@ -23,8 +23,7 @@ namespace arm_common { | |||||
| } \ | } \ | ||||
| const char* name() const override { \ | const char* name() const override { \ | ||||
| if (m_name.empty()) { \ | if (m_name.empty()) { \ | ||||
| m_name = megdnn_mangle( \ | |||||
| ssprintf("Elemwise::AlgoBinaryCase" #case)); \ | |||||
| m_name = ssprintf("Elemwise::AlgoBinaryCase" #case); \ | |||||
| } \ | } \ | ||||
| return m_name.c_str(); \ | return m_name.c_str(); \ | ||||
| } \ | } \ | ||||
| @@ -66,7 +66,7 @@ void ElemwiseImpl::exec(const TensorNDArray& srcs, _megdnn_tensor_out dst) { | |||||
| } | } | ||||
| if (m_dst->layout.dtype == dtype::Float32() || | if (m_dst->layout.dtype == dtype::Float32() || | ||||
| MEGDNN_FLOAT16_SELECT(m_dst->layout.dtype == dtype::Float16(), false) || | |||||
| DNN_FLOAT16_SELECT(m_dst->layout.dtype == dtype::Float16(), false) || | |||||
| m_dst->layout.dtype == dtype::Int32() || | m_dst->layout.dtype == dtype::Int32() || | ||||
| m_dst->layout.dtype == dtype::Int16() || | m_dst->layout.dtype == dtype::Int16() || | ||||
| m_dst->layout.dtype == dtype::Int8()) { | m_dst->layout.dtype == dtype::Int8()) { | ||||
| @@ -63,18 +63,18 @@ public: | |||||
| }; | }; | ||||
| #if __ARM_FEATURE_FP16_VECTOR_ARITHMETIC | #if __ARM_FEATURE_FP16_VECTOR_ARITHMETIC | ||||
| #define DISPATCH_TYPE(_case) \ | |||||
| if (src0.layout.dtype == dtype::Float32{}) { \ | |||||
| DISPATCH_MODE_FLOAT(_case, float, 0); \ | |||||
| } else if (MEGDNN_FLOAT16_SELECT(src0.layout.dtype == dtype::Float16{}, \ | |||||
| false)) { \ | |||||
| DISPATCH_MODE_FLOAT(_case, __fp16, 1); \ | |||||
| } else if (src0.layout.dtype == dtype::Int32{}) { \ | |||||
| DISPATCH_MODE_INT(_case, int, 2); \ | |||||
| } else if (src0.layout.dtype == dtype::Int16{}) { \ | |||||
| DISPATCH_MODE_INT(_case, dt_int16, 3); \ | |||||
| } else if (src0.layout.dtype == dtype::Int8{}) { \ | |||||
| DISPATCH_MODE_INT(_case, dt_int8, 4); \ | |||||
| #define DISPATCH_TYPE(_case) \ | |||||
| if (src0.layout.dtype == dtype::Float32{}) { \ | |||||
| DISPATCH_MODE_FLOAT(_case, float, 0); \ | |||||
| } else if (DNN_FLOAT16_SELECT(src0.layout.dtype == dtype::Float16{}, \ | |||||
| false)) { \ | |||||
| DISPATCH_MODE_FLOAT(_case, __fp16, 1); \ | |||||
| } else if (src0.layout.dtype == dtype::Int32{}) { \ | |||||
| DISPATCH_MODE_INT(_case, int, 2); \ | |||||
| } else if (src0.layout.dtype == dtype::Int16{}) { \ | |||||
| DISPATCH_MODE_INT(_case, dt_int16, 3); \ | |||||
| } else if (src0.layout.dtype == dtype::Int8{}) { \ | |||||
| DISPATCH_MODE_INT(_case, dt_int8, 4); \ | |||||
| } | } | ||||
| #else | #else | ||||
| #define DISPATCH_TYPE(_case) \ | #define DISPATCH_TYPE(_case) \ | ||||
| @@ -23,8 +23,7 @@ namespace arm_common { | |||||
| } \ | } \ | ||||
| const char* name() const override { \ | const char* name() const override { \ | ||||
| if (m_name.empty()) { \ | if (m_name.empty()) { \ | ||||
| m_name = megdnn_mangle( \ | |||||
| ssprintf("Elemwise::AlgoTernaryFma3" #case)); \ | |||||
| m_name = ssprintf("Elemwise::AlgoTernaryFma3" #case); \ | |||||
| } \ | } \ | ||||
| return m_name.c_str(); \ | return m_name.c_str(); \ | ||||
| } \ | } \ | ||||
| @@ -21,7 +21,7 @@ class ElemwiseImpl::AlgoUnary final : public ElemwiseImpl::AlgoBase { | |||||
| } | } | ||||
| const char* name() const override { | const char* name() const override { | ||||
| if (m_name.empty()) { | if (m_name.empty()) { | ||||
| m_name = megdnn_mangle(ssprintf("Elemwise::AlgoUnary")); | |||||
| m_name = ssprintf("Elemwise::AlgoUnary"); | |||||
| } | } | ||||
| return m_name.c_str(); | return m_name.c_str(); | ||||
| } | } | ||||
| @@ -916,7 +916,7 @@ void ReduceImpl::exec(_megdnn_tensor_in src, _megdnn_tensor_out dst, | |||||
| } | } | ||||
| #if __ARM_FEATURE_FP16_VECTOR_ARITHMETIC | #if __ARM_FEATURE_FP16_VECTOR_ARITHMETIC | ||||
| if (src.layout.dtype.enumv() == DTypeEnum::Float16) { | if (src.layout.dtype.enumv() == DTypeEnum::Float16) { | ||||
| MEGDNN_INC_FLOAT16(DISPATCH_MODE_FLOAT(__fp16, __fp16, __fp16)); | |||||
| DNN_INC_FLOAT16(DISPATCH_MODE_FLOAT(__fp16, __fp16, __fp16)); | |||||
| } | } | ||||
| #endif | #endif | ||||
| } | } | ||||
| @@ -2044,7 +2044,7 @@ void megdnn::arm_common::resize_cv_exec( | |||||
| } | } | ||||
| MIDOUT_END(); | MIDOUT_END(); | ||||
| } else { | } else { | ||||
| megdnn_throw(megdnn_mangle("Unsupported datatype of resize optr.")); | |||||
| megdnn_throw("Unsupported datatype of resize optr."); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -285,7 +285,7 @@ void megdnn::arm_common::warp_affine_cv_exec( | |||||
| DISPATCH_IMODE(imode, bmode, ch, cb) | DISPATCH_IMODE(imode, bmode, ch, cb) | ||||
| #undef cb | #undef cb | ||||
| } else { | } else { | ||||
| megdnn_throw(megdnn_mangle("Unsupported datatype of WarpAffine optr.")); | |||||
| megdnn_throw("Unsupported datatype of WarpAffine optr."); | |||||
| } | } | ||||
| } | } | ||||
| @@ -229,7 +229,7 @@ void megdnn::arm_common::warp_perspective_cv_exec( | |||||
| DISPATCH_IMODE(imode, bmode, ch, cb) | DISPATCH_IMODE(imode, bmode, ch, cb) | ||||
| #undef cb | #undef cb | ||||
| } else { | } else { | ||||
| megdnn_throw(megdnn_mangle("Unsupported datatype of WarpAffine optr.")); | |||||
| megdnn_throw("Unsupported datatype of WarpAffine optr."); | |||||
| } | } | ||||
| } | } | ||||
| @@ -53,7 +53,7 @@ void CambriconComputingContext::memcpy(void* dst, const void* src, | |||||
| dir = CNRT_MEM_TRANS_DIR_DEV2DEV; | dir = CNRT_MEM_TRANS_DIR_DEV2DEV; | ||||
| break; | break; | ||||
| default: | default: | ||||
| megdnn_throw(megdnn_mangle("bad cnrt mem trans dir")); | |||||
| megdnn_throw("bad cnrt mem trans dir"); | |||||
| } | } | ||||
| if (kind == megcoreMemcpyDeviceToDevice) { | if (kind == megcoreMemcpyDeviceToDevice) { | ||||
| cnrt_check(cnrtSyncQueue(context_.queue)); | cnrt_check(cnrtSyncQueue(context_.queue)); | ||||
| @@ -120,16 +120,15 @@ typename Opr::Algorithm* get_reproducible_algo( | |||||
| MEGDNN_MARK_USED_VAR(name); | MEGDNN_MARK_USED_VAR(name); | ||||
| if (available_but_limited_by_workspace) { | if (available_but_limited_by_workspace) { | ||||
| megdnn_throw(megdnn_mangle(ssprintf( | |||||
| megdnn_throw(ssprintf( | |||||
| "no reproducible %s algorithm: %s workspace limit %zu is " | "no reproducible %s algorithm: %s workspace limit %zu is " | ||||
| "less than mini workspace limit %zu", | "less than mini workspace limit %zu", | ||||
| name, args.to_string().c_str(), workspace_limit_in_bytes, | name, args.to_string().c_str(), workspace_limit_in_bytes, | ||||
| min_workspace_limit_in_bytes))); | |||||
| min_workspace_limit_in_bytes)); | |||||
| } else if (available_but_not_reproducible) { | } else if (available_but_not_reproducible) { | ||||
| megdnn_throw( | |||||
| megdnn_mangle(ssprintf("no reproducible %s algorithm", name))); | |||||
| megdnn_throw(ssprintf("no reproducible %s algorithm", name)); | |||||
| } else { | } else { | ||||
| megdnn_throw(megdnn_mangle(ssprintf("no usable %s algorithm", name))); | |||||
| megdnn_throw(ssprintf("no usable %s algorithm", name)); | |||||
| } | } | ||||
| } | } | ||||
| @@ -154,13 +153,13 @@ typename Opr::Algorithm* get_usable_algo( | |||||
| MEGDNN_MARK_USED_VAR(name); | MEGDNN_MARK_USED_VAR(name); | ||||
| if (available_but_limited_by_workspace) { | if (available_but_limited_by_workspace) { | ||||
| megdnn_throw(megdnn_mangle(ssprintf( | |||||
| megdnn_throw(ssprintf( | |||||
| "no usable %s algorithm: %s workspace limit %zu is " | "no usable %s algorithm: %s workspace limit %zu is " | ||||
| "less than mini workspace limit %zu", | "less than mini workspace limit %zu", | ||||
| name, args.to_string().c_str(), workspace_limit_in_bytes, | name, args.to_string().c_str(), workspace_limit_in_bytes, | ||||
| min_workspace_limit_in_bytes))); | |||||
| min_workspace_limit_in_bytes)); | |||||
| } else { | } else { | ||||
| megdnn_throw(megdnn_mangle(ssprintf("no usable %s algorithm", name))); | |||||
| megdnn_throw(ssprintf("no usable %s algorithm", name)); | |||||
| } | } | ||||
| } | } | ||||
| @@ -413,7 +413,7 @@ TensorLayout::Span TensorLayout::span() const { | |||||
| TensorLayout TensorLayout::broadcast(const TensorShape& tshape) const { | TensorLayout TensorLayout::broadcast(const TensorShape& tshape) const { | ||||
| megdnn_throw_if(!ndim || !tshape.ndim, tensor_reshape_error, | megdnn_throw_if(!ndim || !tshape.ndim, tensor_reshape_error, | ||||
| megdnn_mangle("broadcast involves empty tensor")); | |||||
| "broadcast involves empty tensor"); | |||||
| if (is_scalar()) { | if (is_scalar()) { | ||||
| TensorLayout result{dtype, format}; | TensorLayout result{dtype, format}; | ||||
| @@ -426,10 +426,9 @@ TensorLayout TensorLayout::broadcast(const TensorShape& tshape) const { | |||||
| } | } | ||||
| megdnn_throw_if(tshape.ndim < ndim, tensor_reshape_error, | megdnn_throw_if(tshape.ndim < ndim, tensor_reshape_error, | ||||
| megdnn_mangle(ssprintf( | |||||
| "dimension for broadcast less than " | |||||
| "dst_shape: src_shape=%s dst_shape=%s", | |||||
| to_string().c_str(), tshape.to_string().c_str()))); | |||||
| ssprintf("dimension for broadcast less than " | |||||
| "dst_shape: src_shape=%s dst_shape=%s", | |||||
| to_string().c_str(), tshape.to_string().c_str())); | |||||
| TensorLayout result{dtype, format}; | TensorLayout result{dtype, format}; | ||||
| for (size_t i = 0; i < tshape.ndim; ++i) { | for (size_t i = 0; i < tshape.ndim; ++i) { | ||||
| int target_idx = tshape.ndim - i - 1; | int target_idx = tshape.ndim - i - 1; | ||||
| @@ -439,10 +438,9 @@ TensorLayout TensorLayout::broadcast(const TensorShape& tshape) const { | |||||
| if (tshape.shape[target_idx] != cur_shape) { | if (tshape.shape[target_idx] != cur_shape) { | ||||
| megdnn_throw_if( | megdnn_throw_if( | ||||
| cur_shape != 1 && cur_stride != 0, tensor_reshape_error, | cur_shape != 1 && cur_stride != 0, tensor_reshape_error, | ||||
| megdnn_mangle(ssprintf( | |||||
| "broadcast on dim with shape not equal to 1: " | |||||
| "src_shape=%s dst_shape=%s", | |||||
| to_string().c_str(), tshape.to_string().c_str()))); | |||||
| ssprintf("broadcast on dim with shape not equal to 1: " | |||||
| "src_shape=%s dst_shape=%s", | |||||
| to_string().c_str(), tshape.to_string().c_str())); | |||||
| result.shape[target_idx] = tshape.shape[target_idx]; | result.shape[target_idx] = tshape.shape[target_idx]; | ||||
| result.stride[target_idx] = 0; | result.stride[target_idx] = 0; | ||||
| } else { | } else { | ||||
| @@ -461,9 +459,9 @@ bool TensorLayout::try_reshape(TensorLayout& result, | |||||
| bool is_empty_shape = false; | bool is_empty_shape = false; | ||||
| for (size_t i = 0; i < tshp.ndim; ++i) { | for (size_t i = 0; i < tshp.ndim; ++i) { | ||||
| if (!tshp.shape[i]) { | if (!tshp.shape[i]) { | ||||
| megdnn_throw_if(!format.is_default(), tensor_reshape_error, | |||||
| megdnn_mangle(ssprintf("bad target tshp: %s", | |||||
| tshp.to_string().c_str()))); | |||||
| megdnn_throw_if( | |||||
| !format.is_default(), tensor_reshape_error, | |||||
| ssprintf("bad target tshp: %s", tshp.to_string().c_str())); | |||||
| is_empty_shape = true; | is_empty_shape = true; | ||||
| break; | break; | ||||
| } | } | ||||
| @@ -472,11 +470,10 @@ bool TensorLayout::try_reshape(TensorLayout& result, | |||||
| megdnn_throw_if( | megdnn_throw_if( | ||||
| !tshp.ndim || total_nr_elems() != tshp.total_nr_elems(), | !tshp.ndim || total_nr_elems() != tshp.total_nr_elems(), | ||||
| tensor_reshape_error, | tensor_reshape_error, | ||||
| megdnn_mangle(ssprintf( | |||||
| "number of elements do not match " | |||||
| "in reshape: src=%s dest=%s", | |||||
| static_cast<const TensorShape&>(*this).to_string().c_str(), | |||||
| tshp.to_string().c_str()))); | |||||
| ssprintf("number of elements do not match " | |||||
| "in reshape: src=%s dest=%s", | |||||
| static_cast<const TensorShape&>(*this).to_string().c_str(), | |||||
| tshp.to_string().c_str())); | |||||
| auto cont = collapse_contiguous(); | auto cont = collapse_contiguous(); | ||||
| result.dtype = this->dtype; | result.dtype = this->dtype; | ||||
| @@ -516,9 +513,8 @@ TensorLayout TensorLayout::reshape(const TensorShape& shape) const { | |||||
| TensorLayout ret; | TensorLayout ret; | ||||
| auto succ = try_reshape(ret, shape); | auto succ = try_reshape(ret, shape); | ||||
| megdnn_throw_if(!succ, tensor_reshape_error, | megdnn_throw_if(!succ, tensor_reshape_error, | ||||
| megdnn_mangle(ssprintf("can not reshape from %s to %s", | |||||
| to_string().c_str(), | |||||
| shape.to_string().c_str()))); | |||||
| ssprintf("can not reshape from %s to %s", | |||||
| to_string().c_str(), shape.to_string().c_str())); | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| @@ -39,15 +39,15 @@ void BatchedMatrixMulForward::deduce_layout(const TensorLayout& A, | |||||
| TensorLayout& C) { | TensorLayout& C) { | ||||
| auto errmsg = [&]() { | auto errmsg = [&]() { | ||||
| std::string msg; | std::string msg; | ||||
| msg.append(megdnn_mangle("A=")); | |||||
| msg.append("A="); | |||||
| msg.append(A.to_string()); | msg.append(A.to_string()); | ||||
| msg.append(megdnn_mangle(", B=")); | |||||
| msg.append(", B="); | |||||
| msg.append(B.to_string()); | msg.append(B.to_string()); | ||||
| msg.append(megdnn_mangle(", C=")); | |||||
| msg.append(", C="); | |||||
| msg.append(C.to_string()); | msg.append(C.to_string()); | ||||
| msg.append(megdnn_mangle(", transposeA=")); | |||||
| msg.append(", transposeA="); | |||||
| msg.append(std::to_string(m_param.transposeA)); | msg.append(std::to_string(m_param.transposeA)); | ||||
| msg.append(megdnn_mangle(", transposeB=")); | |||||
| msg.append(", transposeB="); | |||||
| msg.append(std::to_string(m_param.transposeB)); | msg.append(std::to_string(m_param.transposeB)); | ||||
| return msg; | return msg; | ||||
| }; | }; | ||||
| @@ -41,8 +41,8 @@ void ConcatSplitBase::check_layout_common(const TensorLayoutArray &srcs, | |||||
| megdnn_assert_eq_size_t(src.ndim, ndim); | megdnn_assert_eq_size_t(src.ndim, ndim); | ||||
| } | } | ||||
| // ensure param().axis is correct | // ensure param().axis is correct | ||||
| auto errmsg = megdnn_mangle("param().axis=") + | |||||
| std::to_string(param().axis) + megdnn_mangle(", ndim=") + | |||||
| auto errmsg = "param().axis=" + | |||||
| std::to_string(param().axis) + ", ndim=" + | |||||
| std::to_string(ndim); | std::to_string(ndim); | ||||
| MEGDNN_MARK_USED_VAR(errmsg); | MEGDNN_MARK_USED_VAR(errmsg); | ||||
| megdnn_assert(param().axis < static_cast<int32_t>(ndim), "%s", | megdnn_assert(param().axis < static_cast<int32_t>(ndim), "%s", | ||||
| @@ -23,17 +23,17 @@ std::string get_errmsg(const TensorLayout& src, const TensorLayout& filter, | |||||
| MEGDNN_MARK_USED_VAR(filter); | MEGDNN_MARK_USED_VAR(filter); | ||||
| MEGDNN_MARK_USED_VAR(dst); | MEGDNN_MARK_USED_VAR(dst); | ||||
| return megdnn_layout_msg(src) + ", " + megdnn_layout_msg(filter) + ", " + | return megdnn_layout_msg(src) + ", " + megdnn_layout_msg(filter) + ", " + | ||||
| megdnn_layout_msg(dst) + ", " + megdnn_mangle("is_nchw=") + | |||||
| megdnn_layout_msg(dst) + ", " + "is_nchw=" + | |||||
| std::to_string(param.format == param::Convolution::Format::NCHW) + | std::to_string(param.format == param::Convolution::Format::NCHW) + | ||||
| ", " + +megdnn_mangle("is_xcorr=") + | |||||
| ", " + "is_xcorr=" + | |||||
| std::to_string( | std::to_string( | ||||
| (param.mode == Convolution::Mode::CROSS_CORRELATION)) + | (param.mode == Convolution::Mode::CROSS_CORRELATION)) + | ||||
| ", " + megdnn_mangle("pad_h=") + std::to_string(param.pad_h) + ", " + | |||||
| megdnn_mangle("pad_w=") + std::to_string(param.pad_w) + ", " + | |||||
| megdnn_mangle("stride_h=") + std::to_string(param.stride_h) + ", " + | |||||
| megdnn_mangle("stride_w=") + std::to_string(param.stride_w) + ", " + | |||||
| megdnn_mangle("dilate_h=") + std::to_string(param.dilate_h) + ", " + | |||||
| megdnn_mangle("dilate_w=") + std::to_string(param.dilate_w); | |||||
| ", " + "pad_h=" + std::to_string(param.pad_h) + ", " + | |||||
| "pad_w=" + std::to_string(param.pad_w) + ", " + | |||||
| "stride_h=" + std::to_string(param.stride_h) + ", " + | |||||
| "stride_w=" + std::to_string(param.stride_w) + ", " + | |||||
| "dilate_h=" + std::to_string(param.dilate_h) + ", " + | |||||
| "dilate_w=" + std::to_string(param.dilate_w); | |||||
| } | } | ||||
| template <typename Param, typename Param::Format> | template <typename Param, typename Param::Format> | ||||
| @@ -22,20 +22,20 @@ std::string get_errmsg(const TensorLayout& src, const TensorLayout& filter, | |||||
| MEGDNN_MARK_USED_VAR(filter); | MEGDNN_MARK_USED_VAR(filter); | ||||
| MEGDNN_MARK_USED_VAR(dst); | MEGDNN_MARK_USED_VAR(dst); | ||||
| return megdnn_layout_msg(src) + ", " + megdnn_layout_msg(filter) + ", " + | return megdnn_layout_msg(src) + ", " + megdnn_layout_msg(filter) + ", " + | ||||
| megdnn_layout_msg(dst) + ", " + megdnn_mangle("is_ncdhw=") + | |||||
| megdnn_layout_msg(dst) + ", " + "is_ncdhw=" + | |||||
| std::to_string(param.format == param::Convolution3D::Format::NCDHW) + | std::to_string(param.format == param::Convolution3D::Format::NCDHW) + | ||||
| ", " + +megdnn_mangle("is_xcorr=") + | |||||
| ", " + "is_xcorr=" + | |||||
| std::to_string( | std::to_string( | ||||
| (param.mode == Convolution3D::Mode::CROSS_CORRELATION)) + | (param.mode == Convolution3D::Mode::CROSS_CORRELATION)) + | ||||
| ", " + megdnn_mangle("pad_d=") + std::to_string(param.pad_d) + ", " + | |||||
| megdnn_mangle("pad_h=") + std::to_string(param.pad_h) + ", " + | |||||
| megdnn_mangle("pad_w=") + std::to_string(param.pad_w) + ", " + | |||||
| megdnn_mangle("stride_d=") + std::to_string(param.stride_d) + ", " + | |||||
| megdnn_mangle("stride_h=") + std::to_string(param.stride_h) + ", " + | |||||
| megdnn_mangle("stride_w=") + std::to_string(param.stride_w) + ", " + | |||||
| megdnn_mangle("dilate_d=") + std::to_string(param.dilate_d) + ", " + | |||||
| megdnn_mangle("dilate_h=") + std::to_string(param.dilate_h) + ", " + | |||||
| megdnn_mangle("dilate_w=") + std::to_string(param.dilate_w); | |||||
| ", " + "pad_d=" + std::to_string(param.pad_d) + ", " + | |||||
| "pad_h=" + std::to_string(param.pad_h) + ", " + | |||||
| "pad_w=" + std::to_string(param.pad_w) + ", " + | |||||
| "stride_d=" + std::to_string(param.stride_d) + ", " + | |||||
| "stride_h=" + std::to_string(param.stride_h) + ", " + | |||||
| "stride_w=" + std::to_string(param.stride_w) + ", " + | |||||
| "dilate_d=" + std::to_string(param.dilate_d) + ", " + | |||||
| "dilate_h=" + std::to_string(param.dilate_h) + ", " + | |||||
| "dilate_w=" + std::to_string(param.dilate_w); | |||||
| } | } | ||||
| } // namespace | } // namespace | ||||
| @@ -127,15 +127,15 @@ Convolution3DBase::CanonizedFilterMeta Convolution3DBase::deduce_layout_fwd( | |||||
| megdnn_assert(src.ndim >= 5_z, "%s", errmsg().c_str()); | megdnn_assert(src.ndim >= 5_z, "%s", errmsg().c_str()); | ||||
| megdnn_assert(src.dtype == filter.dtype, "%s", errmsg().c_str()); | megdnn_assert(src.dtype == filter.dtype, "%s", errmsg().c_str()); | ||||
| if (param().data_type == Param::DataType::FLOAT) { | if (param().data_type == Param::DataType::FLOAT) { | ||||
| megdnn_assert(src.dtype == dtype::Float32() MEGDNN_INC_FLOAT16( | |||||
| megdnn_assert(src.dtype == dtype::Float32() DNN_INC_FLOAT16( | |||||
| || src.dtype == dtype::Float16()), | || src.dtype == dtype::Float16()), | ||||
| "invalid src dtype for conv: %s", src.dtype.name()); | "invalid src dtype for conv: %s", src.dtype.name()); | ||||
| dst.dtype = src.dtype; | dst.dtype = src.dtype; | ||||
| } else { | } else { | ||||
| megdnn_assert(param().data_type == Param::DataType::FLOAT_IO16xC32); | megdnn_assert(param().data_type == Param::DataType::FLOAT_IO16xC32); | ||||
| MEGDNN_INC_FLOAT16(megdnn_assert(src.dtype == dtype::Float16(), | |||||
| DNN_INC_FLOAT16(megdnn_assert(src.dtype == dtype::Float16(), | |||||
| "invalid src dtype for conv: %s", src.dtype.name())); | "invalid src dtype for conv: %s", src.dtype.name())); | ||||
| MEGDNN_INC_FLOAT16(dst.dtype = dtype::Float16()); | |||||
| DNN_INC_FLOAT16(dst.dtype = dtype::Float16()); | |||||
| } | } | ||||
| auto img_dim = src.ndim - 2; | auto img_dim = src.ndim - 2; | ||||
| megdnn_assert(img_dim == 3, "this is the convolution for 3D image"); | megdnn_assert(img_dim == 3, "this is the convolution for 3D image"); | ||||
| @@ -77,9 +77,9 @@ | |||||
| #include <xmmintrin.h> | #include <xmmintrin.h> | ||||
| #endif | #endif | ||||
| #define MegCVException(expr) \ | |||||
| do { \ | |||||
| megdnn_throw(megdnn_mangle(#expr)); \ | |||||
| #define MegCVException(expr) \ | |||||
| do { \ | |||||
| megdnn_throw(#expr); \ | |||||
| } while (0) | } while (0) | ||||
| namespace megdnn { | namespace megdnn { | ||||
| @@ -27,16 +27,15 @@ std::string get_errmsg(const TensorLayout& src, const TensorLayout& filter, | |||||
| MEGDNN_MARK_USED_VAR(dst); | MEGDNN_MARK_USED_VAR(dst); | ||||
| return megdnn_layout_msg(src) + ", " + megdnn_layout_msg(filter) + ", " + | return megdnn_layout_msg(src) + ", " + megdnn_layout_msg(filter) + ", " + | ||||
| megdnn_layout_msg(offset) + ", " + megdnn_layout_msg(mask) + ", " + | megdnn_layout_msg(offset) + ", " + megdnn_layout_msg(mask) + ", " + | ||||
| megdnn_layout_msg(dst) + ", " + megdnn_mangle("only support nchw") + | |||||
| ", " + megdnn_mangle("group=") + std::to_string(param.group) + ", " + | |||||
| megdnn_mangle("deformable_group=") + | |||||
| std::to_string(param.deformable_group) + ", " + | |||||
| megdnn_mangle("pad_h=") + std::to_string(param.pad_h) + ", " + | |||||
| megdnn_mangle("pad_w=") + std::to_string(param.pad_w) + ", " + | |||||
| megdnn_mangle("stride_h=") + std::to_string(param.stride_h) + ", " + | |||||
| megdnn_mangle("stride_w=") + std::to_string(param.stride_w) + ", " + | |||||
| megdnn_mangle("dilate_h=") + std::to_string(param.dilate_h) + ", " + | |||||
| megdnn_mangle("dilate_w=") + std::to_string(param.dilate_w); | |||||
| megdnn_layout_msg(dst) + ", " + "only support nchw" + ", " + | |||||
| "group=" + std::to_string(param.group) + ", " + | |||||
| "deformable_group=" + std::to_string(param.deformable_group) + ", " + | |||||
| "pad_h=" + std::to_string(param.pad_h) + ", " + | |||||
| "pad_w=" + std::to_string(param.pad_w) + ", " + | |||||
| "stride_h=" + std::to_string(param.stride_h) + ", " + | |||||
| "stride_w=" + std::to_string(param.stride_w) + ", " + | |||||
| "dilate_h=" + std::to_string(param.dilate_h) + ", " + | |||||
| "dilate_w=" + std::to_string(param.dilate_w); | |||||
| } | } | ||||
| template <typename Param> | template <typename Param> | ||||
| @@ -42,15 +42,13 @@ MEGDNN_FOREACH_PARAMETERIZED_DTYPE(TEMPLATED_IMPL) | |||||
| #undef IMPL | #undef IMPL | ||||
| void DType::on_assert_is_failed(const char *rname) const { | void DType::on_assert_is_failed(const char *rname) const { | ||||
| megdnn_throw(megdnn_mangle( | |||||
| ssprintf("attempt to access dtype %s as %s", | |||||
| name(), rname).c_str())); | |||||
| megdnn_throw(ssprintf("attempt to access dtype %s as %s", name(), rname) | |||||
| .c_str()); | |||||
| MEGDNN_MARK_USED_VAR(rname); | MEGDNN_MARK_USED_VAR(rname); | ||||
| } | } | ||||
| void DType::on_request_lowbit_size() const { | void DType::on_request_lowbit_size() const { | ||||
| megdnn_throw(megdnn_mangle( | |||||
| ssprintf("attempt to get size of lowbit dtype %s", name()))); | |||||
| megdnn_throw(ssprintf("attempt to get size of lowbit dtype %s", name())); | |||||
| } | } | ||||
| DType DType::from_enum(DTypeEnum ev) { | DType DType::from_enum(DTypeEnum ev) { | ||||
| @@ -60,11 +58,11 @@ DType DType::from_enum(DTypeEnum ev) { | |||||
| #undef cb | #undef cb | ||||
| #define cb(_dt) case DTypeEnum::_dt: | #define cb(_dt) case DTypeEnum::_dt: | ||||
| MEGDNN_FOREACH_PARAMETERIZED_DTYPE(cb) | MEGDNN_FOREACH_PARAMETERIZED_DTYPE(cb) | ||||
| megdnn_throw(megdnn_mangle( | |||||
| "cannot construct parameterized DType via DType::from_enum")); | |||||
| megdnn_throw( | |||||
| "cannot construct parameterized DType via DType::from_enum"); | |||||
| #undef cb | #undef cb | ||||
| } | } | ||||
| megdnn_throw(megdnn_mangle("bad DTypeEnum value")); | |||||
| megdnn_throw("bad DTypeEnum value"); | |||||
| } | } | ||||
| template <DTypeEnum type_enum> | template <DTypeEnum type_enum> | ||||
| @@ -87,8 +87,8 @@ namespace megdnn { | |||||
| //! define kernel for all float types | //! define kernel for all float types | ||||
| #define DEF_KERN_FLOAT(_mode, _imp) \ | #define DEF_KERN_FLOAT(_mode, _imp) \ | ||||
| DEF_KERN(dt_float32, _mode, _imp); \ | DEF_KERN(dt_float32, _mode, _imp); \ | ||||
| MEGDNN_INC_FLOAT16(DEF_KERN(dt_float16, _mode, _imp);) \ | |||||
| MEGDNN_INC_FLOAT16(DEF_KERN(dt_bfloat16, _mode, _imp);) | |||||
| DNN_INC_FLOAT16(DEF_KERN(dt_float16, _mode, _imp);) \ | |||||
| DNN_INC_FLOAT16(DEF_KERN(dt_bfloat16, _mode, _imp);) | |||||
| //! define kernel for all int types | //! define kernel for all int types | ||||
| #define DEF_KERN_INT(_mode, _imp) \ | #define DEF_KERN_INT(_mode, _imp) \ | ||||
| @@ -85,7 +85,7 @@ const ModeTrait& ModeTrait::from_mode(Mode mode) { | |||||
| MIDOUT_BEGIN(megdnn_common_elemwise, midout_iv(Mode::_m)) { \ | MIDOUT_BEGIN(megdnn_common_elemwise, midout_iv(Mode::_m)) { \ | ||||
| auto&& t = get(Mode::_m); \ | auto&& t = get(Mode::_m); \ | ||||
| t.arity = _a; \ | t.arity = _a; \ | ||||
| t.name = megdnn_mangle(#_m); \ | |||||
| t.name = (#_m); \ | |||||
| } \ | } \ | ||||
| MIDOUT_END(); | MIDOUT_END(); | ||||
| #define _a 1 | #define _a 1 | ||||
| @@ -111,7 +111,7 @@ const ModeTrait& ModeTrait::from_mode(Mode mode) { | |||||
| t.allow_float = true; \ | t.allow_float = true; \ | ||||
| t.allow_bool = true; \ | t.allow_bool = true; \ | ||||
| t.arity = _arity; \ | t.arity = _arity; \ | ||||
| t.name = megdnn_mangle(#_m); \ | |||||
| t.name = (#_m); \ | |||||
| } \ | } \ | ||||
| MIDOUT_END(); | MIDOUT_END(); | ||||
| FUSE(FUSE_MUL_ADD3, 3); | FUSE(FUSE_MUL_ADD3, 3); | ||||
| @@ -159,14 +159,13 @@ const ModeTrait& ModeTrait::from_mode(Mode mode) { | |||||
| void ElemwiseForward::deduce_shape(const TensorShapeArray& src, | void ElemwiseForward::deduce_shape(const TensorShapeArray& src, | ||||
| TensorShape& dst) { | TensorShape& dst) { | ||||
| auto err = [&]() { | auto err = [&]() { | ||||
| std::string msg( | |||||
| megdnn_mangle("bad input shape for polyadic operator: ")); | |||||
| std::string msg("bad input shape for polyadic operator: "); | |||||
| bool first = true; | bool first = true; | ||||
| for (auto&& i : src) { | for (auto&& i : src) { | ||||
| if (first) | if (first) | ||||
| first = false; | first = false; | ||||
| else | else | ||||
| msg.append(megdnn_mangle(", ")); | |||||
| msg.append(", "); | |||||
| msg.append(i.to_string()); | msg.append(i.to_string()); | ||||
| } | } | ||||
| megdnn_throw(msg); | megdnn_throw(msg); | ||||
| @@ -158,7 +158,7 @@ const ModeTrait& ModeTrait::from_mode(Mode mode) { | |||||
| #define SET(f, m) \ | #define SET(f, m) \ | ||||
| MIDOUT_BEGIN(megdnn_common_elemwise_multi_type, midout_iv(Mode::m)) { \ | MIDOUT_BEGIN(megdnn_common_elemwise_multi_type, midout_iv(Mode::m)) { \ | ||||
| f(traits[static_cast<int>(Mode::m)], megdnn_mangle(#m)); \ | |||||
| f(traits[static_cast<int>(Mode::m)], (#m)); \ | |||||
| } \ | } \ | ||||
| MIDOUT_END(); | MIDOUT_END(); | ||||
| SET(init_fma3_int16x32x32x32, FUSE_MUL_ADD3_INT16x32x32x32); | SET(init_fma3_int16x32x32x32, FUSE_MUL_ADD3_INT16x32x32x32); | ||||
| @@ -19,13 +19,12 @@ void GroupLocalBase::deduce_layout_fwd(const TensorLayout &src, | |||||
| TensorLayout &dst) | TensorLayout &dst) | ||||
| { | { | ||||
| auto errmsg = [&]() { | auto errmsg = [&]() { | ||||
| return megdnn_layout_msg(src) + ", " | |||||
| + megdnn_layout_msg(filter) + ", " | |||||
| + megdnn_layout_msg(dst) + ", " | |||||
| + megdnn_mangle("pad_h=") + std::to_string(param().pad_h) + ", " | |||||
| + megdnn_mangle("pad_w=") + std::to_string(param().pad_w) + ", " | |||||
| + megdnn_mangle("stride_h=") + std::to_string(param().stride_h) + ", " | |||||
| + megdnn_mangle("stride_w=") + std::to_string(param().stride_w); | |||||
| return megdnn_layout_msg(src) + ", " + megdnn_layout_msg(filter) + | |||||
| ", " + megdnn_layout_msg(dst) + ", " + | |||||
| "pad_h=" + std::to_string(param().pad_h) + ", " + | |||||
| "pad_w=" + std::to_string(param().pad_w) + ", " + | |||||
| "stride_h=" + std::to_string(param().stride_h) + ", " + | |||||
| "stride_w=" + std::to_string(param().stride_w); | |||||
| }; | }; | ||||
| MEGDNN_MARK_USED_VAR(errmsg); | MEGDNN_MARK_USED_VAR(errmsg); | ||||
| megdnn_assert_contiguous(src); | megdnn_assert_contiguous(src); | ||||
| @@ -66,7 +65,7 @@ void GroupLocalBase::check_layout_fwd(const TensorLayout &src, | |||||
| megdnn_assert_eq_dtype(src, dst); | megdnn_assert_eq_dtype(src, dst); | ||||
| deduce_layout_fwd(src, filter, dst_expected); | deduce_layout_fwd(src, filter, dst_expected); | ||||
| megdnn_assert_eq_layout(dst_expected, dst); | megdnn_assert_eq_layout(dst_expected, dst); | ||||
| megdnn_assert(src.dtype == dtype::Float32() || MEGDNN_FLOAT16_SELECT(src.dtype == dtype::Float16(), true)); | |||||
| megdnn_assert(src.dtype == dtype::Float32() || DNN_FLOAT16_SELECT(src.dtype == dtype::Float16(), true)); | |||||
| } | } | ||||
| void GroupLocalForward::check_exec(const TensorLayout &src, | void GroupLocalForward::check_exec(const TensorLayout &src, | ||||
| @@ -87,7 +87,7 @@ std::unique_ptr<Handle> Handle::make(megcoreComputingHandle_t computing_handle, | |||||
| } else if (debug_level == 2) { | } else if (debug_level == 2) { | ||||
| return make_unique<naive::HandleImpl>(computing_handle); | return make_unique<naive::HandleImpl>(computing_handle); | ||||
| } else { | } else { | ||||
| megdnn_throw(megdnn_mangle("Debug level must be 0/1/2.")); | |||||
| megdnn_throw("Debug level must be 0/1/2."); | |||||
| } | } | ||||
| } | } | ||||
| MIDOUT_END(); | MIDOUT_END(); | ||||
| @@ -116,7 +116,8 @@ std::unique_ptr<Handle> Handle::make(megcoreComputingHandle_t computing_handle, | |||||
| } | } | ||||
| else { | else { | ||||
| // CUDA | // CUDA | ||||
| megdnn_assert_internal(platform == megcorePlatformCUDA); | |||||
| megdnn_throw_if(platform != megcorePlatformCUDA, megdnn_error, | |||||
| "platform should be CUDA Platform"); | |||||
| #if MEGDNN_WITH_CUDA | #if MEGDNN_WITH_CUDA | ||||
| return make_unique<cuda::HandleImpl>(computing_handle); | return make_unique<cuda::HandleImpl>(computing_handle); | ||||
| #else | #else | ||||
| @@ -216,7 +217,7 @@ std::unique_ptr<Handle> Handle::make(megcoreComputingHandle_t computing_handle, | |||||
| CASE(CAMBRICON, cambricon); | CASE(CAMBRICON, cambricon); | ||||
| #endif | #endif | ||||
| default: | default: | ||||
| megdnn_throw(megdnn_mangle("bad handle type")); | |||||
| megdnn_throw("bad handle type"); | |||||
| } | } | ||||
| #undef CASE | #undef CASE | ||||
| } | } | ||||
| @@ -19,16 +19,12 @@ void Images2NeibsBase::deduce_layout_fwd(const TensorLayout &src, | |||||
| { | { | ||||
| auto errmsg = [&]() { | auto errmsg = [&]() { | ||||
| return megdnn_layout_msg(src) + ", " + | return megdnn_layout_msg(src) + ", " + | ||||
| megdnn_mangle("pad_h=") + std::to_string(param().pad_h) + ", " + | |||||
| megdnn_mangle("pad_w=") + std::to_string(param().pad_w) + ", " + | |||||
| megdnn_mangle("stride_h=") + | |||||
| std::to_string(param().stride_h) + ", " + | |||||
| megdnn_mangle("stride_w=") + | |||||
| std::to_string(param().stride_w) + ", " + | |||||
| megdnn_mangle("window_h=") + | |||||
| std::to_string(param().window_h) + ", " + | |||||
| megdnn_mangle("window_w=") + | |||||
| std::to_string(param().window_w); | |||||
| "pad_h=" + std::to_string(param().pad_h) + ", " + | |||||
| "pad_w=" + std::to_string(param().pad_w) + ", " + | |||||
| "stride_h=" + std::to_string(param().stride_h) + ", " + | |||||
| "stride_w=" + std::to_string(param().stride_w) + ", " + | |||||
| "window_h=" + std::to_string(param().window_h) + ", " + | |||||
| "window_w=" + std::to_string(param().window_w); | |||||
| }; | }; | ||||
| MEGDNN_MARK_USED_VAR(errmsg); | MEGDNN_MARK_USED_VAR(errmsg); | ||||
| megdnn_assert_contiguous(src); | megdnn_assert_contiguous(src); | ||||
| @@ -32,10 +32,11 @@ void IndexingOneHotBase::check_layout_fwd( | |||||
| const TensorLayout &src, const TensorLayout &index, | const TensorLayout &src, const TensorLayout &index, | ||||
| const TensorLayout &dst) { | const TensorLayout &dst) { | ||||
| auto errmsg = [&]() -> std::string { | auto errmsg = [&]() -> std::string { | ||||
| return megdnn_mangle(ssprintf("bad layout for IndexingOneHot: " | |||||
| "src=%s index=%s dst=%s axis=%d", | |||||
| src.to_string().c_str(), index.to_string().c_str(), | |||||
| dst.to_string().c_str(), m_param.axis)); | |||||
| return ssprintf( | |||||
| "bad layout for IndexingOneHot: " | |||||
| "src=%s index=%s dst=%s axis=%d", | |||||
| src.to_string().c_str(), index.to_string().c_str(), | |||||
| dst.to_string().c_str(), m_param.axis); | |||||
| }; | }; | ||||
| MEGDNN_MARK_USED_VAR(errmsg); | MEGDNN_MARK_USED_VAR(errmsg); | ||||
| megdnn_assert_eq_dtype(src, dst); | megdnn_assert_eq_dtype(src, dst); | ||||
| @@ -17,15 +17,13 @@ namespace megdnn { | |||||
| void LocalBase::deduce_layout_fwd(const TensorLayout &src, | void LocalBase::deduce_layout_fwd(const TensorLayout &src, | ||||
| const TensorLayout &filter, TensorLayout &dst) | const TensorLayout &filter, TensorLayout &dst) | ||||
| { | { | ||||
| auto errmsg = megdnn_layout_msg(src) + ", " | |||||
| + megdnn_layout_msg(filter) + ", " | |||||
| + megdnn_layout_msg(dst) + ", " | |||||
| + megdnn_mangle("is_xcorr=") | |||||
| + std::to_string((param().mode == Mode::CROSS_CORRELATION)) + ", " | |||||
| + megdnn_mangle("pad_h=") + std::to_string(param().pad_h) + ", " | |||||
| + megdnn_mangle("pad_w=") + std::to_string(param().pad_w) + ", " | |||||
| + megdnn_mangle("stride_h=") + std::to_string(param().stride_h) + ", " | |||||
| + megdnn_mangle("stride_w=") + std::to_string(param().stride_w) ; | |||||
| auto errmsg = megdnn_layout_msg(src) + ", " + megdnn_layout_msg(filter) + | |||||
| ", " + megdnn_layout_msg(dst) + ", " + "is_xcorr=" + | |||||
| std::to_string((param().mode == Mode::CROSS_CORRELATION)) + | |||||
| ", " + "pad_h=" + std::to_string(param().pad_h) + ", " + | |||||
| "pad_w=" + std::to_string(param().pad_w) + ", " + | |||||
| "stride_h=" + std::to_string(param().stride_h) + ", " + | |||||
| "stride_w=" + std::to_string(param().stride_w); | |||||
| auto errmsg_c = errmsg.c_str(); | auto errmsg_c = errmsg.c_str(); | ||||
| MEGDNN_MARK_USED_VAR(errmsg_c); | MEGDNN_MARK_USED_VAR(errmsg_c); | ||||
| @@ -77,7 +75,7 @@ void LocalBase::check_layout_fwd(const TensorLayout &src, | |||||
| megdnn_assert(src.dtype == filter.dtype && src.dtype == dst.dtype); | megdnn_assert(src.dtype == filter.dtype && src.dtype == dst.dtype); | ||||
| megdnn_assert(src.dtype == dtype::Float32() || | megdnn_assert(src.dtype == dtype::Float32() || | ||||
| MEGDNN_FLOAT16_SELECT(src.dtype == dtype::Float16(), true)); | |||||
| DNN_FLOAT16_SELECT(src.dtype == dtype::Float16(), true)); | |||||
| } | } | ||||
| void LocalForward::deduce_layout(const TensorLayout &src, | void LocalForward::deduce_layout(const TensorLayout &src, | ||||
| @@ -19,20 +19,17 @@ void LocalShareBase::deduce_layout_fwd(const TensorLayout& src, | |||||
| using Mode = LocalShare::Param::Mode; | using Mode = LocalShare::Param::Mode; | ||||
| auto errmsg = | auto errmsg = | ||||
| megdnn_layout_msg(src) + ", " + megdnn_layout_msg(filter) + ", " + | megdnn_layout_msg(src) + ", " + megdnn_layout_msg(filter) + ", " + | ||||
| megdnn_layout_msg(dst) + ", " + megdnn_mangle("is_xcorr=") + | |||||
| megdnn_layout_msg(dst) + ", " + "is_xcorr=" + | |||||
| std::to_string((param().mode == Mode::CROSS_CORRELATION)) + ", " + | std::to_string((param().mode == Mode::CROSS_CORRELATION)) + ", " + | ||||
| megdnn_mangle("pad_h=") + std::to_string(param().pad_h) + ", " + | |||||
| megdnn_mangle("pad_w=") + std::to_string(param().pad_w) + ", " + | |||||
| megdnn_mangle("stride_h=") + std::to_string(param().stride_h) + | |||||
| ", " + megdnn_mangle("stride_w=") + | |||||
| std::to_string(param().stride_w) + ", " + | |||||
| megdnn_mangle("dilate_h=") + std::to_string(param().dilate_h) + | |||||
| ", " + megdnn_mangle("dilate_w=") + | |||||
| std::to_string(param().dilate_w) + ", " + | |||||
| megdnn_mangle("spatial_groups_h=") + | |||||
| std::to_string(param().spatial_groups_h) + ", " + | |||||
| megdnn_mangle("spatial_groups_w=") + | |||||
| std::to_string(param().spatial_groups_w); | |||||
| "pad_h=" + std::to_string(param().pad_h) + ", " + | |||||
| "pad_w=" + std::to_string(param().pad_w) + ", " + | |||||
| "stride_h=" + std::to_string(param().stride_h) + ", " + | |||||
| "stride_w=" + std::to_string(param().stride_w) + ", " + | |||||
| "dilate_h=" + std::to_string(param().dilate_h) + ", " + | |||||
| "dilate_w=" + std::to_string(param().dilate_w) + ", " + | |||||
| "spatial_groups_h=" + std::to_string(param().spatial_groups_h) + | |||||
| ", " + | |||||
| "spatial_groups_w=" + std::to_string(param().spatial_groups_w); | |||||
| auto errmsg_c = errmsg.c_str(); | auto errmsg_c = errmsg.c_str(); | ||||
| MEGDNN_MARK_USED_VAR(errmsg_c); | MEGDNN_MARK_USED_VAR(errmsg_c); | ||||
| @@ -118,20 +115,17 @@ void LocalShareBackwardData::deduce_layout(const TensorLayout& filter, | |||||
| using Mode = LocalShare::Param::Mode; | using Mode = LocalShare::Param::Mode; | ||||
| auto errmsg = | auto errmsg = | ||||
| megdnn_layout_msg(filter) + ", " + megdnn_layout_msg(diff) + ", " + | megdnn_layout_msg(filter) + ", " + megdnn_layout_msg(diff) + ", " + | ||||
| megdnn_layout_msg(grad) + ", " + megdnn_mangle("is_xcorr=") + | |||||
| megdnn_layout_msg(grad) + ", " + "is_xcorr=" + | |||||
| std::to_string((param().mode == Mode::CROSS_CORRELATION)) + ", " + | std::to_string((param().mode == Mode::CROSS_CORRELATION)) + ", " + | ||||
| megdnn_mangle("pad_h=") + std::to_string(param().pad_h) + ", " + | |||||
| megdnn_mangle("pad_w=") + std::to_string(param().pad_w) + ", " + | |||||
| megdnn_mangle("stride_h=") + std::to_string(param().stride_h) + | |||||
| ", " + megdnn_mangle("stride_w=") + | |||||
| std::to_string(param().stride_w) + ", " + | |||||
| megdnn_mangle("dilate_h=") + std::to_string(param().dilate_h) + | |||||
| ", " + megdnn_mangle("dilate_w=") + | |||||
| std::to_string(param().dilate_w) + ", " + | |||||
| megdnn_mangle("spatial_groups_h=") + | |||||
| std::to_string(param().spatial_groups_h) + ", " + | |||||
| megdnn_mangle("spatial_groups_w=") + | |||||
| std::to_string(param().spatial_groups_w); | |||||
| "pad_h=" + std::to_string(param().pad_h) + ", " + | |||||
| "pad_w=" + std::to_string(param().pad_w) + ", " + | |||||
| "stride_h=" + std::to_string(param().stride_h) + ", " + | |||||
| "stride_w=" + std::to_string(param().stride_w) + ", " + | |||||
| "dilate_h=" + std::to_string(param().dilate_h) + ", " + | |||||
| "dilate_w=" + std::to_string(param().dilate_w) + ", " + | |||||
| "spatial_groups_h=" + std::to_string(param().spatial_groups_h) + | |||||
| ", " + | |||||
| "spatial_groups_w=" + std::to_string(param().spatial_groups_w); | |||||
| auto errmsg_c = errmsg.c_str(); | auto errmsg_c = errmsg.c_str(); | ||||
| MEGDNN_MARK_USED_VAR(errmsg_c); | MEGDNN_MARK_USED_VAR(errmsg_c); | ||||
| @@ -34,10 +34,9 @@ void MatrixInverse::canonize_params(const TensorLayout& layout, size_t* batch, | |||||
| layout[layout.ndim - 2] == layout[layout.ndim - 1], | layout[layout.ndim - 2] == layout[layout.ndim - 1], | ||||
| "invalid MatrixInverse layout: %s", | "invalid MatrixInverse layout: %s", | ||||
| layout.to_string().c_str()); | layout.to_string().c_str()); | ||||
| megdnn_assert( | |||||
| MEGDNN_FLOAT16_SELECT(layout.dtype == dtype::Float16(), false) || | |||||
| layout.dtype == dtype::Float32(), | |||||
| "MatrixInverse only supports f16 & f32"); | |||||
| megdnn_assert(DNN_FLOAT16_SELECT(layout.dtype == dtype::Float16(), false) || | |||||
| layout.dtype == dtype::Float32(), | |||||
| "MatrixInverse only supports f16 & f32"); | |||||
| if (batch) { | if (batch) { | ||||
| *batch = 1; | *batch = 1; | ||||
| for (size_t i = 0; i < layout.ndim - 2; ++i) { | for (size_t i = 0; i < layout.ndim - 2; ++i) { | ||||
| @@ -100,15 +100,15 @@ void MatrixMulForward::check_exec(const TensorLayout& A, const TensorLayout& B, | |||||
| size_t workspace_in_bytes) { | size_t workspace_in_bytes) { | ||||
| auto errmsg = [&]() { | auto errmsg = [&]() { | ||||
| std::string msg; | std::string msg; | ||||
| msg.append(megdnn_mangle("A=")); | |||||
| msg.append("A="); | |||||
| msg.append(A.to_string()); | msg.append(A.to_string()); | ||||
| msg.append(megdnn_mangle(", B=")); | |||||
| msg.append(", B="); | |||||
| msg.append(B.to_string()); | msg.append(B.to_string()); | ||||
| msg.append(megdnn_mangle(", C=")); | |||||
| msg.append(", C="); | |||||
| msg.append(C.to_string()); | msg.append(C.to_string()); | ||||
| msg.append(megdnn_mangle(", transposeA=")); | |||||
| msg.append(", transposeA="); | |||||
| msg.append(std::to_string(param().transposeA)); | msg.append(std::to_string(param().transposeA)); | ||||
| msg.append(megdnn_mangle(", transposeB=")); | |||||
| msg.append(", transposeB="); | |||||
| msg.append(std::to_string(param().transposeB)); | msg.append(std::to_string(param().transposeB)); | ||||
| return msg; | return msg; | ||||
| }; | }; | ||||
| @@ -175,7 +175,7 @@ void MatrixMulForward::check_exec(const TensorLayout& A, const TensorLayout& B, | |||||
| megdnn_assert(C.dtype.enumv() == DTypeEnum::QuantizedS16); | megdnn_assert(C.dtype.enumv() == DTypeEnum::QuantizedS16); | ||||
| } | } | ||||
| megdnn_assert(param().compute_mode != | megdnn_assert(param().compute_mode != | ||||
| Param::ComputeMode::FLOAT32 MEGDNN_INC_FLOAT16( | |||||
| Param::ComputeMode::FLOAT32 DNN_INC_FLOAT16( | |||||
| || A.dtype == dtype::Float16() || | || A.dtype == dtype::Float16() || | ||||
| A.dtype == dtype::BFloat16()), | A.dtype == dtype::BFloat16()), | ||||
| "ComputeMode::FLOAT32 is only available for Float16/BFloat16 " | "ComputeMode::FLOAT32 is only available for Float16/BFloat16 " | ||||
| @@ -195,7 +195,7 @@ size_t MatrixMulForward::pack_size(const Param::Format format) { | |||||
| case Param::Format::MK8: | case Param::Format::MK8: | ||||
| return 8; | return 8; | ||||
| default: | default: | ||||
| megdnn_throw(megdnn_mangle("Unknown matmul format.")); | |||||
| megdnn_throw("Unknown matmul format."); | |||||
| } | } | ||||
| } | } | ||||
| @@ -40,7 +40,8 @@ CPUDispatcher* megcoreGetCPUDispatcher(megcoreComputingHandle_t handle) { | |||||
| megcoreDeviceHandle_t dev_handle = H->content->dev_handle(); | megcoreDeviceHandle_t dev_handle = H->content->dev_handle(); | ||||
| megcorePlatform_t platform; | megcorePlatform_t platform; | ||||
| megcoreGetPlatform(dev_handle, &platform); | megcoreGetPlatform(dev_handle, &platform); | ||||
| megdnn_assert(platform &megcorePlatformCPU); | |||||
| megdnn_throw_if(!(platform & megcorePlatformCPU), megdnn_error, | |||||
| "can not be default ComputingContext"); | |||||
| auto context = static_cast<megcore::cpu::DefaultComputingContext*>( | auto context = static_cast<megcore::cpu::DefaultComputingContext*>( | ||||
| H->content.get()); | H->content.get()); | ||||
| return context->get_dispatcher(); | return context->get_dispatcher(); | ||||
| @@ -41,7 +41,8 @@ DefaultComputingContext::DefaultComputingContext( | |||||
| { | { | ||||
| megcorePlatform_t platform; | megcorePlatform_t platform; | ||||
| megcoreGetPlatform(dev_handle, &platform); | megcoreGetPlatform(dev_handle, &platform); | ||||
| megdnn_assert(platform & megcorePlatformCPU); | |||||
| megdnn_throw_if(!(platform & megcorePlatformCPU), megdnn_error, | |||||
| "can not be default ComputingContext"); | |||||
| } | } | ||||
| DefaultComputingContext::~DefaultComputingContext() noexcept = default; | DefaultComputingContext::~DefaultComputingContext() noexcept = default; | ||||
| @@ -13,7 +13,7 @@ | |||||
| const char *megcoreGetErrorName(megcoreStatus_t status) | const char *megcoreGetErrorName(megcoreStatus_t status) | ||||
| { | { | ||||
| #define CASE(x) case x: return megdnn_mangle(#x) | |||||
| #define CASE(x) case x: return (#x) | |||||
| switch (status) { | switch (status) { | ||||
| CASE(megcoreSuccess); | CASE(megcoreSuccess); | ||||
| CASE(megcoreErrorMemoryAllocation); | CASE(megcoreErrorMemoryAllocation); | ||||
| @@ -22,7 +22,7 @@ const char *megcoreGetErrorName(megcoreStatus_t status) | |||||
| CASE(megcoreErrorInternalError); | CASE(megcoreErrorInternalError); | ||||
| CASE(megcoreErrorInvalidComputingHandle); | CASE(megcoreErrorInvalidComputingHandle); | ||||
| default: | default: | ||||
| return megdnn_mangle("<Unknown MegCore Error>"); | |||||
| return "<Unknown MegCore Error>"; | |||||
| } | } | ||||
| #undef CASE | #undef CASE | ||||
| } | } | ||||
| @@ -19,18 +19,15 @@ void PoolingBase::deduce_layout_fwd(const TensorLayout& src, | |||||
| TensorLayout& dst) { | TensorLayout& dst) { | ||||
| auto errmsg = | auto errmsg = | ||||
| megdnn_layout_msg(src) + ", " + megdnn_layout_msg(dst) + ", " + | megdnn_layout_msg(src) + ", " + megdnn_layout_msg(dst) + ", " + | ||||
| megdnn_mangle("pad_h=") + std::to_string(param().pad_h) + ", " + | |||||
| megdnn_mangle("pad_w=") + std::to_string(param().pad_w) + ", " + | |||||
| megdnn_mangle("stride_h=") + std::to_string(param().stride_h) + | |||||
| ", " + megdnn_mangle("stride_w=") + | |||||
| std::to_string(param().stride_w) + ", " + | |||||
| megdnn_mangle("window_h=") + std::to_string(param().window_h) + | |||||
| ", " + megdnn_mangle("window_w=") + | |||||
| std::to_string(param().window_w) + ", " + megdnn_mangle("is_max=") + | |||||
| std::to_string(param().mode == Mode::MAX) + ", " + | |||||
| megdnn_mangle("is_nhwc=") + | |||||
| std::to_string(param().format == Param::Format::NHWC) + ", " + | |||||
| megdnn_mangle("is_nhwcd4=") + | |||||
| "pad_h=" + std::to_string(param().pad_h) + ", " + | |||||
| "pad_w=" + std::to_string(param().pad_w) + ", " + | |||||
| "stride_h=" + std::to_string(param().stride_h) + ", " + | |||||
| "stride_w=" + std::to_string(param().stride_w) + ", " + | |||||
| "window_h=" + std::to_string(param().window_h) + ", " + | |||||
| "window_w=" + std::to_string(param().window_w) + ", " + | |||||
| "is_max=" + std::to_string(param().mode == Mode::MAX) + ", " + | |||||
| "is_nhwc=" + std::to_string(param().format == Param::Format::NHWC) + | |||||
| ", " + "is_nhwcd4=" + | |||||
| std::to_string(param().format == Param::Format::NHWCD4); | std::to_string(param().format == Param::Format::NHWCD4); | ||||
| auto errmsg_c = errmsg.c_str(); | auto errmsg_c = errmsg.c_str(); | ||||
| @@ -361,11 +361,18 @@ void RelayoutFormat::deduce_format(TensorFormat src, TensorFormat& dst) { | |||||
| if (!dst.is_default() && | if (!dst.is_default() && | ||||
| ( | ( | ||||
| handle()->type() != Handle::HandleType::NAIVE)) { | handle()->type() != Handle::HandleType::NAIVE)) { | ||||
| #if MEGDNN_ENABLE_MANGLING | |||||
| megdnn_throw( | |||||
| "Only naive and opencl handle support " | |||||
| "Image2DPack4TensorFormat, try build with debug for get more " | |||||
| "info"); | |||||
| #else | |||||
| megdnn_throw( | megdnn_throw( | ||||
| "Only naive and opencl handle support " | "Only naive and opencl handle support " | ||||
| "Image2DPack4TensorFormat, try to export MGB_USE_MEGDNN_DBG=2 " | "Image2DPack4TensorFormat, try to export MGB_USE_MEGDNN_DBG=2 " | ||||
| "and also export CUDA_VISIBLE_DEVICES=\'\' at CUDA env" | "and also export CUDA_VISIBLE_DEVICES=\'\' at CUDA env" | ||||
| "to enable naive handle"); | "to enable naive handle"); | ||||
| #endif | |||||
| } | } | ||||
| #undef CHECK_SRC | #undef CHECK_SRC | ||||
| } | } | ||||
| @@ -69,8 +69,8 @@ void RemapBase::check_layout_fwd(const TensorLayout& src, | |||||
| "%s", errmsg().c_str()); | "%s", errmsg().c_str()); | ||||
| } else { | } else { | ||||
| megdnn_throw( | megdnn_throw( | ||||
| "megdnn currently do not support other param.format except " | |||||
| "NHWC and NCHW"); | |||||
| "currently do not support other param.format except NHWC and " | |||||
| "NCHW"); | |||||
| } | } | ||||
| } | } | ||||
| @@ -91,7 +91,7 @@ void RemapBackwardData::check_exec(const TensorLayout& map_xy, | |||||
| const TensorLayout& grad, | const TensorLayout& grad, | ||||
| size_t workspace_in_bytes) { | size_t workspace_in_bytes) { | ||||
| check_layout_fwd(grad, map_xy, diff); | check_layout_fwd(grad, map_xy, diff); | ||||
| megdnn_assert(grad.dtype == dtype::Float32() MEGDNN_INC_FLOAT16( | |||||
| megdnn_assert(grad.dtype == dtype::Float32() DNN_INC_FLOAT16( | |||||
| || grad.dtype == dtype::BFloat16()), | || grad.dtype == dtype::BFloat16()), | ||||
| "Backward Remap only supports Float32/BFloat16."); | "Backward Remap only supports Float32/BFloat16."); | ||||
| auto required_workspace_in_bytes = | auto required_workspace_in_bytes = | ||||
| @@ -106,7 +106,7 @@ void RemapBackwardMat::check_exec(const TensorLayout& src, | |||||
| size_t workspace_in_bytes) { | size_t workspace_in_bytes) { | ||||
| check_layout_fwd(src, map_xy, diff); | check_layout_fwd(src, map_xy, diff); | ||||
| megdnn_assert_eq_layout(map_xy, grad); | megdnn_assert_eq_layout(map_xy, grad); | ||||
| megdnn_assert(grad.dtype == dtype::Float32() MEGDNN_INC_FLOAT16( | |||||
| megdnn_assert(grad.dtype == dtype::Float32() DNN_INC_FLOAT16( | |||||
| || grad.dtype == dtype::BFloat16()), | || grad.dtype == dtype::BFloat16()), | ||||
| "Backward Remap only supports Float32/BFloat16."); | "Backward Remap only supports Float32/BFloat16."); | ||||
| auto required_workspace_in_bytes = | auto required_workspace_in_bytes = | ||||
| @@ -20,17 +20,15 @@ void SeparableConvBase::deduce_layout_fwd(const TensorLayout &src, | |||||
| TensorLayout &dst) | TensorLayout &dst) | ||||
| { | { | ||||
| auto errmsg = [&]() { | auto errmsg = [&]() { | ||||
| return megdnn_layout_msg(src) + ", " | |||||
| + megdnn_layout_msg(filter_x) + ", " | |||||
| + megdnn_layout_msg(dst) + ", " | |||||
| + megdnn_mangle("is_xcorr=") | |||||
| + megdnn_mangle("borderMode=") | |||||
| + std::to_string((param().mode == Mode::CROSS_CORRELATION)) + ", " | |||||
| + std::to_string((int)(param().borderMode)) + ", " | |||||
| + megdnn_mangle("pad_h=") + std::to_string(param().pad_h) + ", " | |||||
| + megdnn_mangle("pad_w=") + std::to_string(param().pad_w) + ", " | |||||
| + megdnn_mangle("stride_h=") + std::to_string(param().stride_h) + ", " | |||||
| + megdnn_mangle("stride_w=") + std::to_string(param().stride_w); | |||||
| return megdnn_layout_msg(src) + ", " + megdnn_layout_msg(filter_x) + | |||||
| ", " + megdnn_layout_msg(dst) + ", " + | |||||
| "is_xcorr=" + "borderMode=" + | |||||
| std::to_string((param().mode == Mode::CROSS_CORRELATION)) + | |||||
| ", " + std::to_string((int)(param().borderMode)) + ", " + | |||||
| "pad_h=" + std::to_string(param().pad_h) + ", " + | |||||
| "pad_w=" + std::to_string(param().pad_w) + ", " + | |||||
| "stride_h=" + std::to_string(param().stride_h) + ", " + | |||||
| "stride_w=" + std::to_string(param().stride_w); | |||||
| }; | }; | ||||
| MEGDNN_MARK_USED_VAR(errmsg); | MEGDNN_MARK_USED_VAR(errmsg); | ||||
| megdnn_assert_contiguous(src); | megdnn_assert_contiguous(src); | ||||
| @@ -21,14 +21,11 @@ void SeparableFilterBase::deduce_layout_fwd(const TensorLayout& src, | |||||
| auto errmsg = [&]() { | auto errmsg = [&]() { | ||||
| return megdnn_layout_msg(src) + ", " + megdnn_layout_msg(filter_x) + | return megdnn_layout_msg(src) + ", " + megdnn_layout_msg(filter_x) + | ||||
| ", " + megdnn_layout_msg(dst) + ", " + | ", " + megdnn_layout_msg(dst) + ", " + | ||||
| megdnn_mangle("borderMode=") + | |||||
| std::to_string((int)(param().borderMode)) + ", " + | |||||
| megdnn_mangle("ksize_h=") + std::to_string(param().ksize_h) + | |||||
| ", " + megdnn_mangle("ksize_w=") + | |||||
| std::to_string(param().ksize_w) + ", " + | |||||
| megdnn_mangle("anchor_h=") + std::to_string(param().anchor_h) + | |||||
| ", " + megdnn_mangle("anchor_w=") + | |||||
| std::to_string(param().anchor_w); | |||||
| "borderMode=" + std::to_string((int)(param().borderMode)) + | |||||
| ", " + "ksize_h=" + std::to_string(param().ksize_h) + ", " + | |||||
| "ksize_w=" + std::to_string(param().ksize_w) + ", " + | |||||
| "anchor_h=" + std::to_string(param().anchor_h) + ", " + | |||||
| "anchor_w=" + std::to_string(param().anchor_w); | |||||
| }; | }; | ||||
| MEGDNN_MARK_USED_VAR(errmsg); | MEGDNN_MARK_USED_VAR(errmsg); | ||||
| megdnn_assert_contiguous(src); | megdnn_assert_contiguous(src); | ||||
| @@ -81,21 +81,21 @@ bool megdnn::get_next_addr(size_t* idx, const size_t* shp, size_t n, | |||||
| size_t stride) { | size_t stride) { | ||||
| auto errmsg = [&]() { | auto errmsg = [&]() { | ||||
| std::string res; | std::string res; | ||||
| res.append(megdnn_mangle("idx={")); | |||||
| res.append("idx={"); | |||||
| for (size_t i = 0; i < n; ++i) { | for (size_t i = 0; i < n; ++i) { | ||||
| res.append(std::to_string(idx[i])); | res.append(std::to_string(idx[i])); | ||||
| if (i + 1 < n) | if (i + 1 < n) | ||||
| res.append(megdnn_mangle(",")); | |||||
| res.append(","); | |||||
| } | } | ||||
| res.append(megdnn_mangle("}, shp={")); | |||||
| res.append("}, shp={"); | |||||
| for (size_t i = 0; i < n; ++i) { | for (size_t i = 0; i < n; ++i) { | ||||
| res.append(std::to_string(shp[i])); | res.append(std::to_string(shp[i])); | ||||
| if (i + 1 < n) | if (i + 1 < n) | ||||
| res.append(megdnn_mangle(",")); | |||||
| res.append(","); | |||||
| } | } | ||||
| res.append(megdnn_mangle("}, n=")); | |||||
| res.append("}, n="); | |||||
| res.append(std::to_string(n)); | res.append(std::to_string(n)); | ||||
| res.append(megdnn_mangle(", stride=")); | |||||
| res.append(", stride="); | |||||
| res.append(std::to_string(stride)); | res.append(std::to_string(stride)); | ||||
| return res; | return res; | ||||
| }; | }; | ||||
| @@ -13,43 +13,55 @@ | |||||
| #include "megdnn/arch.h" | #include "megdnn/arch.h" | ||||
| //! a comma to be used in macro for template params | //! a comma to be used in macro for template params | ||||
| #define MEGDNN_COMMA , | |||||
| #define MEGDNN_COMMA , | |||||
| #define MEGDNN_MARK_USED_VAR(v) static_cast<void>(v) | #define MEGDNN_MARK_USED_VAR(v) static_cast<void>(v) | ||||
| #if MEGDNN_ENABLE_MANGLING | |||||
| #define megdnn_mangle(x) ("") | |||||
| #if MEGDNN_ENABLE_LOGGING | |||||
| #define megdnn_message_strip(x) (x) | |||||
| #else | #else | ||||
| #define megdnn_mangle(x) (x) | |||||
| #endif // MEGDNN_ENABLE_MANGLING | |||||
| #define megdnn_message_strip(x) ("") | |||||
| #endif // MEGDNN_ENABLE_LOGGING | |||||
| #define megdnn_throw(msg) ::megdnn::ErrorHandler::on_megdnn_error( \ | |||||
| megdnn_mangle(msg)) | |||||
| #define megdnn_throw_if(cond, err_type, msg) do { \ | |||||
| if (megdnn_unlikely(cond)) { \ | |||||
| ::megdnn::ErrorHandler::on_##err_type(megdnn_mangle(msg)); \ | |||||
| } \ | |||||
| } while(0) | |||||
| #define megdnn_throw(msg) \ | |||||
| ::megdnn::ErrorHandler::on_megdnn_error(megdnn_message_strip(msg)) | |||||
| #define megdnn_throw_if(cond, err_type, msg) \ | |||||
| do { \ | |||||
| if (megdnn_unlikely(cond)) { \ | |||||
| ::megdnn::ErrorHandler::on_##err_type(megdnn_message_strip(msg)); \ | |||||
| } \ | |||||
| } while (0) | |||||
| //! megdnn_assert | //! megdnn_assert | ||||
| #if MEGDNN_ENABLE_LOGGING | |||||
| #if MEGDNN_ENABLE_MANGLING | #if MEGDNN_ENABLE_MANGLING | ||||
| #define megdnn_assert(expr, ...) \ | |||||
| do { \ | |||||
| if (megdnn_unlikely(!(expr))) { \ | |||||
| ::megdnn::__assert_fail__(NULL, 0, NULL, NULL, NULL); \ | |||||
| } \ | |||||
| #define megdnn_assert(expr, ...) \ | |||||
| do { \ | |||||
| if (megdnn_unlikely(!(expr))) { \ | |||||
| ::megdnn::__assert_fail__( \ | |||||
| "about location info, please build with debug", __LINE__, \ | |||||
| NULL, #expr, ##__VA_ARGS__); \ | |||||
| } \ | |||||
| } while (0) | } while (0) | ||||
| #else | #else | ||||
| #define megdnn_assert(expr, ...) \ | |||||
| do { \ | |||||
| if (megdnn_unlikely(!(expr))) { \ | |||||
| ::megdnn::__assert_fail__(__FILE__, __LINE__, \ | |||||
| __PRETTY_FUNCTION__, # expr, ## __VA_ARGS__); \ | |||||
| } \ | |||||
| #define megdnn_assert(expr, ...) \ | |||||
| do { \ | |||||
| if (megdnn_unlikely(!(expr))) { \ | |||||
| ::megdnn::__assert_fail__(__FILE__, __LINE__, __PRETTY_FUNCTION__, \ | |||||
| #expr, ##__VA_ARGS__); \ | |||||
| } \ | |||||
| } while (0) | |||||
| #endif // MEGDNN_ENABLE_MANGLING | |||||
| #else | |||||
| #define megdnn_assert(expr, ...) \ | |||||
| do { \ | |||||
| if (megdnn_unlikely(!(expr))) { \ | |||||
| ::megdnn::__assert_fail__(NULL, 0, NULL, NULL, NULL); \ | |||||
| } \ | |||||
| } while (0) | } while (0) | ||||
| #endif // MEGDNN_ENABLE_MANGLING | |||||
| #endif // MEGDNN_ENABLE_LOGGING | |||||
| #define megdnn_assert_internal(expr) \ | |||||
| do { \ | |||||
| #define megdnn_assert_internal(expr) \ | |||||
| do { \ | |||||
| megdnn_assert(expr, "Impossible: internal error."); \ | megdnn_assert(expr, "Impossible: internal error."); \ | ||||
| } while (0) | } while (0) | ||||
| @@ -116,7 +116,7 @@ | |||||
| } while (0) | } while (0) | ||||
| #define megdnn_layout_msg(layout) \ | #define megdnn_layout_msg(layout) \ | ||||
| std::string(megdnn_mangle(#layout "=" + (layout).to_string())) | |||||
| std::string(#layout "=" + (layout).to_string()) | |||||
| #define MEGDNN_LOCK_GUARD(var) \ | #define MEGDNN_LOCK_GUARD(var) \ | ||||
| std::lock_guard<std::remove_cv_t<decltype(var)>> _lock_guard_##var { var } | std::lock_guard<std::remove_cv_t<decltype(var)>> _lock_guard_##var { var } | ||||
| @@ -124,6 +124,16 @@ | |||||
| namespace megdnn { | namespace megdnn { | ||||
| /* ================ logging ================ */ | /* ================ logging ================ */ | ||||
| #if MEGDNN_ENABLE_MANGLING | |||||
| #define megdnn_log_debug(fmt...) \ | |||||
| _megdnn_do_log(::megdnn::LogLevel::DEBUG, "", "", __LINE__, fmt) | |||||
| #define megdnn_log(fmt...) \ | |||||
| _megdnn_do_log(::megdnn::LogLevel::INFO, "", "", __LINE__, fmt) | |||||
| #define megdnn_log_warn(fmt...) \ | |||||
| _megdnn_do_log(::megdnn::LogLevel::WARN, "", "", __LINE__, fmt) | |||||
| #define megdnn_log_error(fmt...) \ | |||||
| _megdnn_do_log(::megdnn::LogLevel::ERROR, "", "", __LINE__, fmt) | |||||
| #else | |||||
| #define megdnn_log_debug(fmt...) \ | #define megdnn_log_debug(fmt...) \ | ||||
| _megdnn_do_log(::megdnn::LogLevel::DEBUG, __FILE__, __func__, __LINE__, fmt) | _megdnn_do_log(::megdnn::LogLevel::DEBUG, __FILE__, __func__, __LINE__, fmt) | ||||
| #define megdnn_log(fmt...) \ | #define megdnn_log(fmt...) \ | ||||
| @@ -132,6 +142,7 @@ namespace megdnn { | |||||
| _megdnn_do_log(::megdnn::LogLevel::WARN, __FILE__, __func__, __LINE__, fmt) | _megdnn_do_log(::megdnn::LogLevel::WARN, __FILE__, __func__, __LINE__, fmt) | ||||
| #define megdnn_log_error(fmt...) \ | #define megdnn_log_error(fmt...) \ | ||||
| _megdnn_do_log(::megdnn::LogLevel::ERROR, __FILE__, __func__, __LINE__, fmt) | _megdnn_do_log(::megdnn::LogLevel::ERROR, __FILE__, __func__, __LINE__, fmt) | ||||
| #endif | |||||
| #if MEGDNN_ENABLE_LOGGING | #if MEGDNN_ENABLE_LOGGING | ||||
| void __log__(LogLevel level, const char* file, const char* func, int line, | void __log__(LogLevel level, const char* file, const char* func, int line, | ||||
| @@ -34,7 +34,7 @@ void WarpAffineBase::check_layout_fwd(const TensorLayout& src, | |||||
| megdnn_assert(src.ndim == 4_z, "%s", errmsg().c_str()); | megdnn_assert(src.ndim == 4_z, "%s", errmsg().c_str()); | ||||
| megdnn_assert(dst.ndim == 4_z, "%s", errmsg().c_str()); | megdnn_assert(dst.ndim == 4_z, "%s", errmsg().c_str()); | ||||
| megdnn_assert(src.dtype.enumv() == DTypeEnum::Float32 || | megdnn_assert(src.dtype.enumv() == DTypeEnum::Float32 || | ||||
| MEGDNN_FLOAT16_SELECT( | |||||
| DNN_FLOAT16_SELECT( | |||||
| src.dtype.enumv() == DTypeEnum::Float16, | src.dtype.enumv() == DTypeEnum::Float16, | ||||
| false) || | false) || | ||||
| src.dtype.enumv() == DTypeEnum::Int8 || | src.dtype.enumv() == DTypeEnum::Int8 || | ||||
| @@ -42,7 +42,7 @@ void WarpAffineBase::check_layout_fwd(const TensorLayout& src, | |||||
| (src.dtype.enumv() == DTypeEnum::QuantizedS8 || | (src.dtype.enumv() == DTypeEnum::QuantizedS8 || | ||||
| src.dtype.enumv() == DTypeEnum::Quantized8Asymm), | src.dtype.enumv() == DTypeEnum::Quantized8Asymm), | ||||
| "WarpAffine NCHW input dtype should be " | "WarpAffine NCHW input dtype should be " | ||||
| "Float32/Int8/Uint8/QInt8/QUint8" MEGDNN_FLOAT16_SELECT( | |||||
| "Float32/Int8/Uint8/QInt8/QUint8" DNN_FLOAT16_SELECT( | |||||
| "/Float16", "") "."); | "/Float16", "") "."); | ||||
| megdnn_assert( | megdnn_assert( | ||||
| (src.dtype.category() == DTypeCategory::FLOAT && | (src.dtype.category() == DTypeCategory::FLOAT && | ||||
| @@ -95,46 +95,46 @@ void WarpAffine::check_exec(const TensorLayout& src, const TensorLayout& mat, | |||||
| std::string WarpAffineBase::param_msg() const { | std::string WarpAffineBase::param_msg() const { | ||||
| std::string res; | std::string res; | ||||
| res.append(megdnn_mangle("imode=")); | |||||
| res.append("imode="); | |||||
| switch (param().imode) { | switch (param().imode) { | ||||
| case InterpolationMode::NEAREST: | case InterpolationMode::NEAREST: | ||||
| res.append(megdnn_mangle("NEAREST")); | |||||
| res.append("NEAREST"); | |||||
| break; | break; | ||||
| case InterpolationMode::LINEAR: | case InterpolationMode::LINEAR: | ||||
| res.append(megdnn_mangle("LINEAR")); | |||||
| res.append("LINEAR"); | |||||
| break; | break; | ||||
| case InterpolationMode::AREA: | case InterpolationMode::AREA: | ||||
| res.append(megdnn_mangle("AREA")); | |||||
| res.append("AREA"); | |||||
| break; | break; | ||||
| case InterpolationMode::CUBIC: | case InterpolationMode::CUBIC: | ||||
| res.append(megdnn_mangle("CUBIC")); | |||||
| res.append("CUBIC"); | |||||
| break; | break; | ||||
| case InterpolationMode::LANCZOS4: | case InterpolationMode::LANCZOS4: | ||||
| res.append(megdnn_mangle("LANCZOS4")); | |||||
| res.append("LANCZOS4"); | |||||
| break; | break; | ||||
| } | } | ||||
| res.append(megdnn_mangle("bmode=")); | |||||
| res.append("bmode="); | |||||
| switch (param().border_mode) { | switch (param().border_mode) { | ||||
| case BorderMode::WRAP: | case BorderMode::WRAP: | ||||
| res.append(megdnn_mangle("WRAP")); | |||||
| res.append("WRAP"); | |||||
| break; | break; | ||||
| case BorderMode::CONSTANT: | case BorderMode::CONSTANT: | ||||
| res.append(megdnn_mangle("CONSTANT")); | |||||
| res.append("CONSTANT"); | |||||
| break; | break; | ||||
| case BorderMode::REFLECT: | case BorderMode::REFLECT: | ||||
| res.append(megdnn_mangle("REFLECT")); | |||||
| res.append("REFLECT"); | |||||
| break; | break; | ||||
| case BorderMode::REFLECT_101: | case BorderMode::REFLECT_101: | ||||
| res.append(megdnn_mangle("REFLECT_101")); | |||||
| res.append("REFLECT_101"); | |||||
| break; | break; | ||||
| case BorderMode::REPLICATE: | case BorderMode::REPLICATE: | ||||
| res.append(megdnn_mangle("REPLICATE")); | |||||
| res.append("REPLICATE"); | |||||
| break; | break; | ||||
| case BorderMode::TRANSPARENT: | case BorderMode::TRANSPARENT: | ||||
| res.append(megdnn_mangle("TRANSPARENT")); | |||||
| res.append("TRANSPARENT"); | |||||
| break; | break; | ||||
| case BorderMode::ISOLATED: | case BorderMode::ISOLATED: | ||||
| res.append(megdnn_mangle("ISOLATED")); | |||||
| res.append("ISOLATED"); | |||||
| break; | break; | ||||
| } | } | ||||
| if (param().border_mode == BorderMode::CONSTANT) { | if (param().border_mode == BorderMode::CONSTANT) { | ||||
| @@ -64,7 +64,7 @@ void WarpPerspectiveBase::check_layout_fwd(const TensorLayout& src, | |||||
| if (param().format == param::WarpPerspective::Format::NCHW) { | if (param().format == param::WarpPerspective::Format::NCHW) { | ||||
| megdnn_assert( | megdnn_assert( | ||||
| src.dtype.enumv() == DTypeEnum::Float32 || | src.dtype.enumv() == DTypeEnum::Float32 || | ||||
| MEGDNN_FLOAT16_SELECT( | |||||
| DNN_FLOAT16_SELECT( | |||||
| (src.dtype.enumv() == DTypeEnum::Float16 || | (src.dtype.enumv() == DTypeEnum::Float16 || | ||||
| src.dtype.enumv() == DTypeEnum::BFloat16), | src.dtype.enumv() == DTypeEnum::BFloat16), | ||||
| false) || | false) || | ||||
| @@ -73,7 +73,7 @@ void WarpPerspectiveBase::check_layout_fwd(const TensorLayout& src, | |||||
| (src.dtype.enumv() == DTypeEnum::QuantizedS8 || | (src.dtype.enumv() == DTypeEnum::QuantizedS8 || | ||||
| src.dtype.enumv() == DTypeEnum::Quantized8Asymm), | src.dtype.enumv() == DTypeEnum::Quantized8Asymm), | ||||
| "WarpPerspective NCHW input dtype should be " | "WarpPerspective NCHW input dtype should be " | ||||
| "Float32/Int8/Uint8/QInt8/QUint8" MEGDNN_FLOAT16_SELECT( | |||||
| "Float32/Int8/Uint8/QInt8/QUint8" DNN_FLOAT16_SELECT( | |||||
| "/Float16/BFloat16", "") "."); | "/Float16/BFloat16", "") "."); | ||||
| megdnn_assert( | megdnn_assert( | ||||
| (src.dtype.category() == DTypeCategory::FLOAT && | (src.dtype.category() == DTypeCategory::FLOAT && | ||||
| @@ -120,14 +120,13 @@ void WarpPerspectiveBase::check_layout_fwd(const TensorLayout& src, | |||||
| param::WarpPerspective::Format::NHWCD4); | param::WarpPerspective::Format::NHWCD4); | ||||
| megdnn_assert( | megdnn_assert( | ||||
| src.dtype == dtype::Float32() || | src.dtype == dtype::Float32() || | ||||
| MEGDNN_FLOAT16_SELECT( | |||||
| (src.dtype == dtype::Float16() || | |||||
| src.dtype == dtype::BFloat16()), | |||||
| false) || | |||||
| DNN_FLOAT16_SELECT((src.dtype == dtype::Float16() || | |||||
| src.dtype == dtype::BFloat16()), | |||||
| false) || | |||||
| src.dtype.enumv() == DTypeEnum::QuantizedS8 || | src.dtype.enumv() == DTypeEnum::QuantizedS8 || | ||||
| src.dtype.enumv() == DTypeEnum::Quantized8Asymm, | src.dtype.enumv() == DTypeEnum::Quantized8Asymm, | ||||
| "WarpPerspective NHWCD4 input dtype should be " | "WarpPerspective NHWCD4 input dtype should be " | ||||
| "Float32" MEGDNN_FLOAT16_SELECT( | |||||
| "Float32" DNN_FLOAT16_SELECT( | |||||
| "/Float16/BFloat16", | "/Float16/BFloat16", | ||||
| "") ",QunatizedS8, Quantized8Asymm."); | "") ",QunatizedS8, Quantized8Asymm."); | ||||
| megdnn_assert( | megdnn_assert( | ||||
| @@ -189,46 +188,46 @@ void WarpPerspectiveBase::check_layout_fwd(const TensorLayout& src, | |||||
| std::string WarpPerspectiveBase::param_msg() const { | std::string WarpPerspectiveBase::param_msg() const { | ||||
| std::string res; | std::string res; | ||||
| res.append(megdnn_mangle("imode=")); | |||||
| res.append("imode="); | |||||
| switch (param().imode) { | switch (param().imode) { | ||||
| case InterpolationMode::NEAREST: | case InterpolationMode::NEAREST: | ||||
| res.append(megdnn_mangle("NEAREST")); | |||||
| res.append("NEAREST"); | |||||
| break; | break; | ||||
| case InterpolationMode::LINEAR: | case InterpolationMode::LINEAR: | ||||
| res.append(megdnn_mangle("LINEAR")); | |||||
| res.append("LINEAR"); | |||||
| break; | break; | ||||
| case InterpolationMode::AREA: | case InterpolationMode::AREA: | ||||
| res.append(megdnn_mangle("AREA")); | |||||
| res.append("AREA"); | |||||
| break; | break; | ||||
| case InterpolationMode::CUBIC: | case InterpolationMode::CUBIC: | ||||
| res.append(megdnn_mangle("CUBIC")); | |||||
| res.append("CUBIC"); | |||||
| break; | break; | ||||
| case InterpolationMode::LANCZOS4: | case InterpolationMode::LANCZOS4: | ||||
| res.append(megdnn_mangle("LANCZOS4")); | |||||
| res.append("LANCZOS4"); | |||||
| break; | break; | ||||
| } | } | ||||
| res.append(megdnn_mangle("bmode=")); | |||||
| res.append("bmode="); | |||||
| switch (param().bmode) { | switch (param().bmode) { | ||||
| case BorderMode::WRAP: | case BorderMode::WRAP: | ||||
| res.append(megdnn_mangle("WRAP")); | |||||
| res.append("WRAP"); | |||||
| break; | break; | ||||
| case BorderMode::CONSTANT: | case BorderMode::CONSTANT: | ||||
| res.append(megdnn_mangle("CONSTANT")); | |||||
| res.append("CONSTANT"); | |||||
| break; | break; | ||||
| case BorderMode::REFLECT: | case BorderMode::REFLECT: | ||||
| res.append(megdnn_mangle("REFLECT")); | |||||
| res.append("REFLECT"); | |||||
| break; | break; | ||||
| case BorderMode::REFLECT_101: | case BorderMode::REFLECT_101: | ||||
| res.append(megdnn_mangle("REFLECT_101")); | |||||
| res.append("REFLECT_101"); | |||||
| break; | break; | ||||
| case BorderMode::REPLICATE: | case BorderMode::REPLICATE: | ||||
| res.append(megdnn_mangle("REPLICATE")); | |||||
| res.append("REPLICATE"); | |||||
| break; | break; | ||||
| case BorderMode::TRANSPARENT: | case BorderMode::TRANSPARENT: | ||||
| res.append(megdnn_mangle("TRANSPARENT")); | |||||
| res.append("TRANSPARENT"); | |||||
| break; | break; | ||||
| case BorderMode::ISOLATED: | case BorderMode::ISOLATED: | ||||
| res.append(megdnn_mangle("ISOLATED")); | |||||
| res.append("ISOLATED"); | |||||
| break; | break; | ||||
| } | } | ||||
| if (param().bmode == BorderMode::CONSTANT) { | if (param().bmode == BorderMode::CONSTANT) { | ||||
| @@ -301,7 +300,7 @@ void WarpPerspectiveBackwardData::check_exec(const TensorLayout& mat, | |||||
| const TensorLayout& grad, | const TensorLayout& grad, | ||||
| size_t workspace_in_bytes) { | size_t workspace_in_bytes) { | ||||
| check_layout_fwd(grad, mat, mat_idx, diff); | check_layout_fwd(grad, mat, mat_idx, diff); | ||||
| megdnn_assert(grad.dtype == dtype::Float32() MEGDNN_INC_FLOAT16( | |||||
| megdnn_assert(grad.dtype == dtype::Float32() DNN_INC_FLOAT16( | |||||
| || grad.dtype == dtype::BFloat16()), | || grad.dtype == dtype::BFloat16()), | ||||
| "Backward WarpPerspective only supports Float32/BFloat16."); | "Backward WarpPerspective only supports Float32/BFloat16."); | ||||
| auto required_workspace_in_bytes = | auto required_workspace_in_bytes = | ||||
| @@ -317,7 +316,7 @@ void WarpPerspectiveBackwardMat::check_exec(const TensorLayout& src, | |||||
| size_t workspace_in_bytes) { | size_t workspace_in_bytes) { | ||||
| check_layout_fwd(src, mat, mat_idx, diff); | check_layout_fwd(src, mat, mat_idx, diff); | ||||
| megdnn_assert_eq_layout(mat, grad); | megdnn_assert_eq_layout(mat, grad); | ||||
| megdnn_assert(grad.dtype == dtype::Float32() MEGDNN_INC_FLOAT16( | |||||
| megdnn_assert(grad.dtype == dtype::Float32() DNN_INC_FLOAT16( | |||||
| || grad.dtype == dtype::BFloat16()), | || grad.dtype == dtype::BFloat16()), | ||||
| "Backward WarpPerspective only supports Float32/BFloat16."); | "Backward WarpPerspective only supports Float32/BFloat16."); | ||||
| auto required_workspace_in_bytes = | auto required_workspace_in_bytes = | ||||
| @@ -353,7 +353,7 @@ void StrategyHelper< | |||||
| _output_compute_type>; | _output_compute_type>; | ||||
| INST(float, float, float, float) | INST(float, float, float, float) | ||||
| MEGDNN_INC_FLOAT16(INST(dt_float16, dt_float16, dt_float16, dt_float16)) | |||||
| DNN_INC_FLOAT16(INST(dt_float16, dt_float16, dt_float16, dt_float16)) | |||||
| INST(int8_t, int8_t, int16_t, int) | INST(int8_t, int8_t, int16_t, int) | ||||
| INST(uint8_t, uint8_t, int16_t, int) | INST(uint8_t, uint8_t, int16_t, int) | ||||
| #undef INST | #undef INST | ||||
| @@ -376,7 +376,7 @@ INST(int8_t, int8_t, float, float, param::ConvBias::Format::NCHW44) | |||||
| INST(int8_t, int8_t, int16_t, int, param::ConvBias::Format::NCHW) | INST(int8_t, int8_t, int16_t, int, param::ConvBias::Format::NCHW) | ||||
| INST(int8_t, int8_t, int16_t, int, param::ConvBias::Format::NCHW44) | INST(int8_t, int8_t, int16_t, int, param::ConvBias::Format::NCHW44) | ||||
| INST(float, float, float, float, param::ConvBias::Format::NCHW88) | INST(float, float, float, float, param::ConvBias::Format::NCHW88) | ||||
| MEGDNN_INC_FLOAT16(INST(dt_float16, dt_float16, dt_float16, dt_float16, | |||||
| DNN_INC_FLOAT16(INST(dt_float16, dt_float16, dt_float16, dt_float16, | |||||
| param::ConvBias::Format::NCHW)) | param::ConvBias::Format::NCHW)) | ||||
| #undef INST | #undef INST | ||||
| } // namespace winograd | } // namespace winograd | ||||
| @@ -39,7 +39,7 @@ void AddUpdateForwardImpl::exec( | |||||
| #undef cb | #undef cb | ||||
| default: | default: | ||||
| megdnn_throw(megdnn_mangle("unsupported dtype for AddUpdate")); | |||||
| megdnn_throw("unsupported dtype for AddUpdate"); | |||||
| } | } | ||||
| } | } | ||||
| @@ -59,7 +59,7 @@ void AddUpdateForwardImpl::exec_noncontig( | |||||
| #undef cb | #undef cb | ||||
| default: | default: | ||||
| megdnn_throw(megdnn_mangle("unsupported dtype for AddUpdate")); | |||||
| megdnn_throw("unsupported dtype for AddUpdate"); | |||||
| } | } | ||||
| } | } | ||||
| @@ -55,7 +55,7 @@ BatchConvBiasForwardImpl::AlgoBase::ExecArgs::ExecArgs( | |||||
| std::string BatchConvBiasForwardImpl::AlgoBase::SizeArgs::to_string() const { | std::string BatchConvBiasForwardImpl::AlgoBase::SizeArgs::to_string() const { | ||||
| auto&& param = opr->param(); | auto&& param = opr->param(); | ||||
| MEGDNN_MARK_USED_VAR(param); | MEGDNN_MARK_USED_VAR(param); | ||||
| return megdnn_mangle(ssprintf( | |||||
| return ssprintf( | |||||
| "src=%s, filter=%s, bias=%s, z=%s, dst=%s, " | "src=%s, filter=%s, bias=%s, z=%s, dst=%s, " | ||||
| "pad=%ux%u, stride=%ux%u, dilate=%ux%u, xcorr=%d, " | "pad=%ux%u, stride=%ux%u, dilate=%ux%u, xcorr=%d, " | ||||
| "dtype=(%s(src),%s(flt),%s(bias),%s(z))->(%s(dst))", | "dtype=(%s(src),%s(flt),%s(bias),%s(z))->(%s(dst))", | ||||
| @@ -65,7 +65,7 @@ std::string BatchConvBiasForwardImpl::AlgoBase::SizeArgs::to_string() const { | |||||
| param.stride_h, param.stride_w, param.dilate_h, param.dilate_w, | param.stride_h, param.stride_w, param.dilate_h, param.dilate_w, | ||||
| static_cast<int>(param.mode), src_layout.dtype.name(), | static_cast<int>(param.mode), src_layout.dtype.name(), | ||||
| filter_layout.dtype.name(), bias_layout.dtype.name(), | filter_layout.dtype.name(), bias_layout.dtype.name(), | ||||
| z_layout.dtype.name(), dst_layout.dtype.name())); | |||||
| z_layout.dtype.name(), dst_layout.dtype.name()); | |||||
| } | } | ||||
| // vim: syntax=cpp.doxygen | // vim: syntax=cpp.doxygen | ||||
| @@ -32,11 +32,11 @@ BatchConvBiasForwardImpl::get_algorithm_heuristic( | |||||
| args, reproducible, workspace_limit_in_bytes)) { | args, reproducible, workspace_limit_in_bytes)) { | ||||
| return &sm_algo_pack.int8_nchw4_implicit_gemm_dotprod; | return &sm_algo_pack.int8_nchw4_implicit_gemm_dotprod; | ||||
| } | } | ||||
| megdnn_throw(megdnn_mangle( | |||||
| megdnn_throw( | |||||
| ssprintf("no %s batch conv bias algorithm with args(%s) and " | ssprintf("no %s batch conv bias algorithm with args(%s) and " | ||||
| "workspace limit (%zu bytes)", | "workspace limit (%zu bytes)", | ||||
| reproducible ? "reproducible" : "usable", | reproducible ? "reproducible" : "usable", | ||||
| args.to_string().c_str(), workspace_limit_in_bytes))); | |||||
| args.to_string().c_str(), workspace_limit_in_bytes)); | |||||
| } | } | ||||
| std::vector<BatchConvBiasForwardImpl::Algorithm*> | std::vector<BatchConvBiasForwardImpl::Algorithm*> | ||||
| @@ -35,8 +35,7 @@ void BNTensorDescHolder::setup(const TensorLayout& x, | |||||
| bn_mode = CUDNN_BATCHNORM_SPATIAL; | bn_mode = CUDNN_BATCHNORM_SPATIAL; | ||||
| break; | break; | ||||
| default: | default: | ||||
| megdnn_throw(megdnn_mangle( | |||||
| "Unknown param dim type of batch normalization.")); | |||||
| megdnn_throw("Unknown param dim type of batch normalization."); | |||||
| } | } | ||||
| xy_desc.set(TensorLayout(xy_shape, x.dtype)); | xy_desc.set(TensorLayout(xy_shape, x.dtype)); | ||||
| param_desc.set(xy_desc.desc, bn_mode); | param_desc.set(xy_desc.desc, bn_mode); | ||||
| @@ -83,8 +82,7 @@ void BNForwardImpl::exec(_megdnn_tensor_in src, _megdnn_tensor_in bn_scale, | |||||
| m_param.epsilon)); | m_param.epsilon)); | ||||
| break; | break; | ||||
| default: | default: | ||||
| megdnn_throw(megdnn_mangle( | |||||
| "Unknown forward mode type of batch normalization.")); | |||||
| megdnn_throw("Unknown forward mode type of batch normalization."); | |||||
| } | } | ||||
| } | } | ||||
| @@ -27,11 +27,11 @@ std::string BatchedMatrixMulForwardImpl::AlgoBase::SizeArgs::to_string() const { | |||||
| MEGDNN_MARK_USED_VAR(m); | MEGDNN_MARK_USED_VAR(m); | ||||
| MEGDNN_MARK_USED_VAR(n); | MEGDNN_MARK_USED_VAR(n); | ||||
| MEGDNN_MARK_USED_VAR(k); | MEGDNN_MARK_USED_VAR(k); | ||||
| return megdnn_mangle(ssprintf( | |||||
| return ssprintf( | |||||
| "A={%zux%zu},B={%zux%zu},C={%zux%zu},Transpose A=%d,Transpose " | "A={%zux%zu},B={%zux%zu},C={%zux%zu},Transpose A=%d,Transpose " | ||||
| "B=%d,ldA=%zu,ldB=%zu,ldC=%zu", | "B=%d,ldA=%zu,ldB=%zu,ldC=%zu", | ||||
| m, k, k, n, m, n, param.transposeA, param.transposeB, | m, k, k, n, m, n, param.transposeA, param.transposeB, | ||||
| layout_a.stride[0], layout_b.stride[0], layout_c.stride[0])); | |||||
| layout_a.stride[0], layout_b.stride[0], layout_c.stride[0]); | |||||
| } | } | ||||
| BatchedMatrixMulForwardImpl::AlgoBase::SizeArgs::SizeArgs( | BatchedMatrixMulForwardImpl::AlgoBase::SizeArgs::SizeArgs( | ||||
| @@ -145,8 +145,7 @@ void BatchedMatrixMulForwardImpl::AlgoCublasLt::exec( | |||||
| } else if (desc.dt_compute == CUBLAS_COMPUTE_32F) { | } else if (desc.dt_compute == CUBLAS_COMPUTE_32F) { | ||||
| batched_sgemm(); | batched_sgemm(); | ||||
| } else { | } else { | ||||
| megdnn_throw( | |||||
| megdnn_mangle("compute_type must be int32/float16/float32")); | |||||
| megdnn_throw("compute_type must be int32/float16/float32"); | |||||
| } | } | ||||
| #else | #else | ||||
| if (desc.dt_compute == CUDA_R_32I) { | if (desc.dt_compute == CUDA_R_32I) { | ||||
| @@ -156,8 +155,7 @@ void BatchedMatrixMulForwardImpl::AlgoCublasLt::exec( | |||||
| } else if (desc.dt_compute == CUDA_R_32F) { | } else if (desc.dt_compute == CUDA_R_32F) { | ||||
| batched_sgemm(); | batched_sgemm(); | ||||
| } else { | } else { | ||||
| megdnn_throw( | |||||
| megdnn_mangle("compute_type must be int32/float16/float32")); | |||||
| megdnn_throw("compute_type must be int32/float16/float32"); | |||||
| } | } | ||||
| #endif | #endif | ||||
| } | } | ||||
| @@ -163,7 +163,7 @@ std::string ConvBiasForwardImpl::AlgoBase::SizeArgs::to_string() const { | |||||
| default: | default: | ||||
| megdnn_throw("invalid conv bias nonlinear mode"); | megdnn_throw("invalid conv bias nonlinear mode"); | ||||
| } | } | ||||
| return megdnn_mangle(ssprintf( | |||||
| return ssprintf( | |||||
| "src=%s, filter=%u{%u,%u,%u,%u}, bias=%s, z=%s, dst=%s, " | "src=%s, filter=%u{%u,%u,%u,%u}, bias=%s, z=%s, dst=%s, " | ||||
| "pad=%ux%u, stride=%ux%u, dilate=%ux%u, xcorr=%d, dtype=%s,%s, " | "pad=%ux%u, stride=%ux%u, dilate=%ux%u, xcorr=%d, dtype=%s,%s, " | ||||
| "nonlinear_mode=%s", | "nonlinear_mode=%s", | ||||
| @@ -173,7 +173,7 @@ std::string ConvBiasForwardImpl::AlgoBase::SizeArgs::to_string() const { | |||||
| fm.padding[0], fm.padding[1], fm.stride[0], fm.stride[1], | fm.padding[0], fm.padding[1], fm.stride[0], fm.stride[1], | ||||
| fm.dilation[0], fm.dilation[1], !fm.should_flip, | fm.dilation[0], fm.dilation[1], !fm.should_flip, | ||||
| src_layout->dtype.name(), dst_layout->dtype.name(), | src_layout->dtype.name(), dst_layout->dtype.name(), | ||||
| nonlinear_mode_str.c_str())); | |||||
| nonlinear_mode_str.c_str()); | |||||
| } | } | ||||
| void ConvBiasForwardImpl::AlgoPack::fill_cudnn_algos() { | void ConvBiasForwardImpl::AlgoPack::fill_cudnn_algos() { | ||||
| @@ -253,9 +253,8 @@ ConvBiasForwardImpl::AlgoPack::cudnn_conv_from_enum( | |||||
| if (i.cudnn_enum() == algo) | if (i.cudnn_enum() == algo) | ||||
| return &i; | return &i; | ||||
| } | } | ||||
| megdnn_throw( | |||||
| megdnn_mangle(ssprintf("can not find cudnn conv fwd algorithm %d", | |||||
| static_cast<int>(algo)))); | |||||
| megdnn_throw(ssprintf("can not find cudnn conv fwd algorithm %d", | |||||
| static_cast<int>(algo))); | |||||
| } | } | ||||
| ConvBiasForwardImpl::AlgoBase* | ConvBiasForwardImpl::AlgoBase* | ||||
| @@ -265,9 +264,8 @@ ConvBiasForwardImpl::AlgoPack::cudnn_conv_bias_act_from_enum( | |||||
| if (i.cudnn_enum() == algo) | if (i.cudnn_enum() == algo) | ||||
| return &i; | return &i; | ||||
| } | } | ||||
| megdnn_throw(megdnn_mangle( | |||||
| ssprintf("can not find cudnn conv bias act algorithm %d", | |||||
| static_cast<int>(algo)))); | |||||
| megdnn_throw(ssprintf("can not find cudnn conv bias act algorithm %d", | |||||
| static_cast<int>(algo))); | |||||
| } | } | ||||
| // vim: syntax=cpp.doxygen | // vim: syntax=cpp.doxygen | ||||
| @@ -104,7 +104,7 @@ bool ConvBiasForwardImpl::AlgoCUDNNConvBiasActivation::is_available( | |||||
| break; | break; | ||||
| return false; | return false; | ||||
| default: | default: | ||||
| megdnn_throw(megdnn_mangle("unsupported NonlineMode")); | |||||
| megdnn_throw("unsupported NonlineMode"); | |||||
| } | } | ||||
| size_t workspace_size; | size_t workspace_size; | ||||
| auto status = cudnnGetConvolutionForwardWorkspaceSize( | auto status = cudnnGetConvolutionForwardWorkspaceSize( | ||||
| @@ -139,7 +139,7 @@ size_t ConvBiasForwardImpl::AlgoCUDNNConvBiasActivation::get_workspace_in_bytes( | |||||
| void ConvBiasForwardImpl::AlgoCUDNNConvBiasActivation::exec( | void ConvBiasForwardImpl::AlgoCUDNNConvBiasActivation::exec( | ||||
| const ExecArgs& args) const { | const ExecArgs& args) const { | ||||
| #if CUDNN_MAJOR < 7 | #if CUDNN_MAJOR < 7 | ||||
| megdnn_throw(megdnn_mangle("ConvBias require cudnn 7.0 or higher")); | |||||
| megdnn_throw("ConvBias require cudnn 7.0 or higher"); | |||||
| #else | #else | ||||
| megdnn_assert(cudnnGetVersion() >= 7401); | megdnn_assert(cudnnGetVersion() >= 7401); | ||||
| CUDNNForwardDescs D; | CUDNNForwardDescs D; | ||||
| @@ -269,7 +269,7 @@ void ConvBiasForwardImpl::AlgoCUDNNConvBiasActivation::exec( | |||||
| break; | break; | ||||
| } | } | ||||
| default: | default: | ||||
| megdnn_throw(megdnn_mangle("unsupported NonlineMode")); | |||||
| megdnn_throw("unsupported NonlineMode"); | |||||
| } | } | ||||
| #endif | #endif | ||||
| } | } | ||||
| @@ -31,8 +31,8 @@ ConvBiasDesc::~ConvBiasDesc() { | |||||
| void ConvBiasDesc::set_conv_bias(DType data_type, const param::ConvBias& param, | void ConvBiasDesc::set_conv_bias(DType data_type, const param::ConvBias& param, | ||||
| size_t nr_group) { | size_t nr_group) { | ||||
| #if CUDNN_VERSION < 7100 | #if CUDNN_VERSION < 7100 | ||||
| megdnn_throw(megdnn_mangle( | |||||
| "ConvBias(CUDNN_ACTIVATION_IDENTITY) require cudnn 7.1 or higher")); | |||||
| megdnn_throw( | |||||
| "ConvBias(CUDNN_ACTIVATION_IDENTITY) require cudnn 7.1 or higher"); | |||||
| #else | #else | ||||
| cudnnConvolutionMode_t mode; | cudnnConvolutionMode_t mode; | ||||
| using Param = param::ConvBias; | using Param = param::ConvBias; | ||||
| @@ -44,7 +44,7 @@ void ConvBiasDesc::set_conv_bias(DType data_type, const param::ConvBias& param, | |||||
| mode = CUDNN_CONVOLUTION; | mode = CUDNN_CONVOLUTION; | ||||
| break; | break; | ||||
| default: | default: | ||||
| megdnn_throw(megdnn_mangle("conv mode must be conv or xcorr.")); | |||||
| megdnn_throw("conv mode must be conv or xcorr."); | |||||
| } | } | ||||
| cudnn_check(cudnnSetConvolutionGroupCount(conv_desc, nr_group)); | cudnn_check(cudnnSetConvolutionGroupCount(conv_desc, nr_group)); | ||||
| cudnnDataType_t compute_type; | cudnnDataType_t compute_type; | ||||
| @@ -57,7 +57,7 @@ void ConvBiasDesc::set_conv_bias(DType data_type, const param::ConvBias& param, | |||||
| compute_type = CUDNN_DATA_INT32; | compute_type = CUDNN_DATA_INT32; | ||||
| break; | break; | ||||
| default: | default: | ||||
| megdnn_throw(megdnn_mangle("unspport data type for conv bias")); | |||||
| megdnn_throw("unspport data type for conv bias"); | |||||
| } | } | ||||
| if (data_type.enumv() == DTypeEnum::Float16) { | if (data_type.enumv() == DTypeEnum::Float16) { | ||||
| auto comp_mode = param.compute_mode; | auto comp_mode = param.compute_mode; | ||||
| @@ -81,7 +81,7 @@ void ConvBiasDesc::set_conv_bias(DType data_type, const param::ConvBias& param, | |||||
| 0)); | 0)); | ||||
| break; | break; | ||||
| default: | default: | ||||
| megdnn_throw(megdnn_mangle("unsupported non linear mode")); | |||||
| megdnn_throw("unsupported non linear mode"); | |||||
| } | } | ||||
| #endif | #endif | ||||
| } | } | ||||
| @@ -98,7 +98,7 @@ void ConvBiasDesc::set_conv(DType data_type, const param::ConvBias& param, | |||||
| mode = CUDNN_CONVOLUTION; | mode = CUDNN_CONVOLUTION; | ||||
| break; | break; | ||||
| default: | default: | ||||
| megdnn_throw(megdnn_mangle("conv mode must be conv or xcorr.")); | |||||
| megdnn_throw("conv mode must be conv or xcorr."); | |||||
| } | } | ||||
| cudnnDataType_t compute_type; | cudnnDataType_t compute_type; | ||||
| MEGDNN_MARK_USED_VAR(compute_type); | MEGDNN_MARK_USED_VAR(compute_type); | ||||
| @@ -114,7 +114,7 @@ void ConvBiasDesc::set_conv(DType data_type, const param::ConvBias& param, | |||||
| compute_type = CUDNN_DATA_INT32; | compute_type = CUDNN_DATA_INT32; | ||||
| #endif | #endif | ||||
| } else { | } else { | ||||
| megdnn_throw(megdnn_mangle("unspport data type for conv bias")); | |||||
| megdnn_throw("unspport data type for conv bias"); | |||||
| } | } | ||||
| #if CUDNN_MAJOR >= 7 | #if CUDNN_MAJOR >= 7 | ||||
| cudnn_check(cudnnSetConvolutionGroupCount(conv_desc, nr_group)); | cudnn_check(cudnnSetConvolutionGroupCount(conv_desc, nr_group)); | ||||
| @@ -73,9 +73,8 @@ ConvolutionBackwardDataImpl::AlgoPack::cudnn_from_enum( | |||||
| if (i.cudnn_enum() == algo) | if (i.cudnn_enum() == algo) | ||||
| return &i; | return &i; | ||||
| } | } | ||||
| megdnn_throw( | |||||
| megdnn_mangle(ssprintf("can not find cudnn bwd_data algorithm %d", | |||||
| static_cast<int>(algo)))); | |||||
| megdnn_throw(ssprintf("can not find cudnn bwd_data algorithm %d", | |||||
| static_cast<int>(algo))); | |||||
| } | } | ||||
| ConvolutionBackwardDataImpl::AlgoPack ConvolutionBackwardDataImpl::sm_algo_pack; | ConvolutionBackwardDataImpl::AlgoPack ConvolutionBackwardDataImpl::sm_algo_pack; | ||||
| @@ -110,14 +109,14 @@ ConvolutionBackwardDataImpl::AlgoBase::ExecArgs::ExecArgs( | |||||
| std::string ConvolutionBackwardDataImpl::AlgoBase::SizeArgs::to_string() const { | std::string ConvolutionBackwardDataImpl::AlgoBase::SizeArgs::to_string() const { | ||||
| auto&& fm = filter_meta; | auto&& fm = filter_meta; | ||||
| MEGDNN_MARK_USED_VAR(fm); | MEGDNN_MARK_USED_VAR(fm); | ||||
| return megdnn_mangle(ssprintf( | |||||
| return ssprintf( | |||||
| "filter=%u{%u,%u,%u,%u}, diff=%s, grad=%s, " | "filter=%u{%u,%u,%u,%u}, diff=%s, grad=%s, " | ||||
| "pad=%ux%u, stride=%ux%u, dilate=%ux%u, xcorr=%d, dtype=%s,%s", | "pad=%ux%u, stride=%ux%u, dilate=%ux%u, xcorr=%d, dtype=%s,%s", | ||||
| fm.group, fm.ocpg, fm.icpg, fm.spatial[0], fm.spatial[1], | fm.group, fm.ocpg, fm.icpg, fm.spatial[0], fm.spatial[1], | ||||
| diff_layout->to_string().c_str(), grad_layout->to_string().c_str(), | diff_layout->to_string().c_str(), grad_layout->to_string().c_str(), | ||||
| fm.padding[0], fm.padding[1], fm.stride[0], fm.stride[1], | fm.padding[0], fm.padding[1], fm.stride[0], fm.stride[1], | ||||
| fm.dilation[0], fm.dilation[1], !fm.should_flip, | fm.dilation[0], fm.dilation[1], !fm.should_flip, | ||||
| diff_layout->dtype.name(), grad_layout->dtype.name())); | |||||
| diff_layout->dtype.name(), grad_layout->dtype.name()); | |||||
| } | } | ||||
| // vim: syntax=cpp.doxygen | // vim: syntax=cpp.doxygen | ||||
| @@ -60,9 +60,8 @@ ConvolutionBackwardFilterImpl::AlgoPack::cudnn_from_enum( | |||||
| if (i.cudnn_enum() == algo) | if (i.cudnn_enum() == algo) | ||||
| return &i; | return &i; | ||||
| } | } | ||||
| megdnn_throw(megdnn_mangle(ssprintf( | |||||
| "can not find cudnn bwd_filter algorithm %d", | |||||
| static_cast<int>(algo)))); | |||||
| megdnn_throw(ssprintf("can not find cudnn bwd_filter algorithm %d", | |||||
| static_cast<int>(algo))); | |||||
| } | } | ||||
| ConvolutionBackwardFilterImpl::AlgoPack | ConvolutionBackwardFilterImpl::AlgoPack | ||||
| @@ -103,16 +102,14 @@ std::string | |||||
| ConvolutionBackwardFilterImpl::AlgoBase::SizeArgs::to_string() const { | ConvolutionBackwardFilterImpl::AlgoBase::SizeArgs::to_string() const { | ||||
| auto &&fm = grad_filter_meta; | auto &&fm = grad_filter_meta; | ||||
| MEGDNN_MARK_USED_VAR(fm); | MEGDNN_MARK_USED_VAR(fm); | ||||
| return megdnn_mangle(ssprintf( | |||||
| "src=%s diff=%s grad_filter=%u{%u,%u,%u,%u}, " | |||||
| "pad=%ux%u, stride=%ux%u, dilate=%ux%u, xcorr=%d, dtype=%s,%s", | |||||
| src_layout->to_string().c_str(), | |||||
| diff_layout->to_string().c_str(), | |||||
| fm.group, fm.ocpg, fm.icpg, fm.spatial[0], fm.spatial[1], | |||||
| fm.padding[0], fm.padding[1], fm.stride[0], fm.stride[1], | |||||
| fm.dilation[0], fm.dilation[1], | |||||
| !fm.should_flip, | |||||
| src_layout->dtype.name(), diff_layout->dtype.name())); | |||||
| return ssprintf( | |||||
| "src=%s diff=%s grad_filter=%u{%u,%u,%u,%u}, " | |||||
| "pad=%ux%u, stride=%ux%u, dilate=%ux%u, xcorr=%d, dtype=%s,%s", | |||||
| src_layout->to_string().c_str(), diff_layout->to_string().c_str(), | |||||
| fm.group, fm.ocpg, fm.icpg, fm.spatial[0], fm.spatial[1], | |||||
| fm.padding[0], fm.padding[1], fm.stride[0], fm.stride[1], | |||||
| fm.dilation[0], fm.dilation[1], !fm.should_flip, | |||||
| src_layout->dtype.name(), diff_layout->dtype.name()); | |||||
| } | } | ||||
| // vim: syntax=cpp.doxygen | // vim: syntax=cpp.doxygen | ||||
| @@ -110,10 +110,10 @@ ConvolutionForwardImpl::AlgoBase::ExecArgs::ExecArgs( | |||||
| workspace{workspace} {} | workspace{workspace} {} | ||||
| std::string ConvolutionForwardImpl::AlgoBase::SizeArgs::to_string() const { | std::string ConvolutionForwardImpl::AlgoBase::SizeArgs::to_string() const { | ||||
| return megdnn_mangle(ssprintf("src=%s, filter=%s, dst=%s", | |||||
| layout_src->to_string().c_str(), | |||||
| layout_filter->to_string().c_str(), | |||||
| layout_dst->to_string().c_str())); | |||||
| return ssprintf("src=%s, filter=%s, dst=%s", | |||||
| layout_src->to_string().c_str(), | |||||
| layout_filter->to_string().c_str(), | |||||
| layout_dst->to_string().c_str()); | |||||
| } | } | ||||
| /* ===================== default algo ===================== */ | /* ===================== default algo ===================== */ | ||||
| @@ -54,9 +54,8 @@ Convolution3DBackwardDataImpl::AlgoPack::cudnn_from_enum( | |||||
| if (i.cudnn_enum() == algo) | if (i.cudnn_enum() == algo) | ||||
| return &i; | return &i; | ||||
| } | } | ||||
| megdnn_throw(megdnn_mangle(ssprintf( | |||||
| "can not find cudnn bwd_data algorithm %d", | |||||
| static_cast<int>(algo)))); | |||||
| megdnn_throw(ssprintf("can not find cudnn bwd_data algorithm %d", | |||||
| static_cast<int>(algo))); | |||||
| } | } | ||||
| Convolution3DBackwardDataImpl::AlgoPack Convolution3DBackwardDataImpl::sm_algo_pack; | Convolution3DBackwardDataImpl::AlgoPack Convolution3DBackwardDataImpl::sm_algo_pack; | ||||
| @@ -96,17 +95,16 @@ Convolution3DBackwardDataImpl::AlgoBase::ExecArgs::ExecArgs( | |||||
| std::string Convolution3DBackwardDataImpl::AlgoBase::SizeArgs::to_string() const { | std::string Convolution3DBackwardDataImpl::AlgoBase::SizeArgs::to_string() const { | ||||
| auto &&fm = filter_meta; | auto &&fm = filter_meta; | ||||
| MEGDNN_MARK_USED_VAR(fm); | MEGDNN_MARK_USED_VAR(fm); | ||||
| return megdnn_mangle(ssprintf( | |||||
| "filter=%u{%u,%u,%u,%u,%u}, diff=%s, grad=%s, " | |||||
| "pad=%ux%ux%u, stride=%ux%ux%u, dilate=%ux%ux%u, xcorr=%d, dtype=%s,%s", | |||||
| fm.group, fm.ocpg, fm.icpg, fm.spatial[0], fm.spatial[1], fm.spatial[2], | |||||
| diff_layout->to_string().c_str(), | |||||
| grad_layout->to_string().c_str(), | |||||
| fm.padding[0], fm.padding[1], fm.padding[2], | |||||
| fm.stride[0], fm.stride[1], fm.stride[2], | |||||
| fm.dilation[0], fm.dilation[1] ,fm.dilation[2], | |||||
| !fm.should_flip, | |||||
| diff_layout->dtype.name(), grad_layout->dtype.name())); | |||||
| return ssprintf( | |||||
| "filter=%u{%u,%u,%u,%u,%u}, diff=%s, grad=%s, " | |||||
| "pad=%ux%ux%u, stride=%ux%ux%u, dilate=%ux%ux%u, xcorr=%d, " | |||||
| "dtype=%s,%s", | |||||
| fm.group, fm.ocpg, fm.icpg, fm.spatial[0], fm.spatial[1], | |||||
| fm.spatial[2], diff_layout->to_string().c_str(), | |||||
| grad_layout->to_string().c_str(), fm.padding[0], fm.padding[1], | |||||
| fm.padding[2], fm.stride[0], fm.stride[1], fm.stride[2], | |||||
| fm.dilation[0], fm.dilation[1], fm.dilation[2], !fm.should_flip, | |||||
| diff_layout->dtype.name(), grad_layout->dtype.name()); | |||||
| } | } | ||||
| // vim: syntax=cpp.doxygen | // vim: syntax=cpp.doxygen | ||||
| @@ -56,9 +56,8 @@ Convolution3DBackwardFilterImpl::AlgoPack::cudnn_from_enum( | |||||
| if (i.cudnn_enum() == algo) | if (i.cudnn_enum() == algo) | ||||
| return &i; | return &i; | ||||
| } | } | ||||
| megdnn_throw(megdnn_mangle(ssprintf( | |||||
| "can not find cudnn bwd_filter algorithm %d", | |||||
| static_cast<int>(algo)))); | |||||
| megdnn_throw(ssprintf("can not find cudnn bwd_filter algorithm %d", | |||||
| static_cast<int>(algo))); | |||||
| } | } | ||||
| Convolution3DBackwardFilterImpl::AlgoPack | Convolution3DBackwardFilterImpl::AlgoPack | ||||
| @@ -100,18 +99,16 @@ std::string | |||||
| Convolution3DBackwardFilterImpl::AlgoBase::SizeArgs::to_string() const { | Convolution3DBackwardFilterImpl::AlgoBase::SizeArgs::to_string() const { | ||||
| auto &&fm = grad_filter_meta; | auto &&fm = grad_filter_meta; | ||||
| MEGDNN_MARK_USED_VAR(fm); | MEGDNN_MARK_USED_VAR(fm); | ||||
| return megdnn_mangle(ssprintf( | |||||
| "src=%s diff=%s grad_filter=%u{%u,%u,%u,%u,%u}, " | |||||
| "pad=%ux%ux%u, stride=%ux%ux%u, dilate=%ux%ux%u, xcorr=%d, dtype=%s,%s", | |||||
| src_layout->to_string().c_str(), | |||||
| diff_layout->to_string().c_str(), | |||||
| fm.group, fm.ocpg, fm.icpg, | |||||
| fm.spatial[0], fm.spatial[1], fm.spatial[2], | |||||
| fm.padding[0], fm.padding[1], fm.padding[2], | |||||
| fm.stride[0], fm.stride[1], fm.stride[2], | |||||
| fm.dilation[0], fm.dilation[1], fm.dilation[2], | |||||
| !fm.should_flip, | |||||
| src_layout->dtype.name(), diff_layout->dtype.name())); | |||||
| return ssprintf( | |||||
| "src=%s diff=%s grad_filter=%u{%u,%u,%u,%u,%u}, " | |||||
| "pad=%ux%ux%u, stride=%ux%ux%u, dilate=%ux%ux%u, xcorr=%d, " | |||||
| "dtype=%s,%s", | |||||
| src_layout->to_string().c_str(), diff_layout->to_string().c_str(), | |||||
| fm.group, fm.ocpg, fm.icpg, fm.spatial[0], fm.spatial[1], | |||||
| fm.spatial[2], fm.padding[0], fm.padding[1], fm.padding[2], | |||||
| fm.stride[0], fm.stride[1], fm.stride[2], fm.dilation[0], | |||||
| fm.dilation[1], fm.dilation[2], !fm.should_flip, | |||||
| src_layout->dtype.name(), diff_layout->dtype.name()); | |||||
| } | } | ||||
| // vim: syntax=cpp.doxygen | // vim: syntax=cpp.doxygen | ||||
| @@ -59,8 +59,8 @@ Convolution3DForwardImpl::AlgoPack::cudnn_from_enum( | |||||
| if (i.cudnn_enum() == algo) | if (i.cudnn_enum() == algo) | ||||
| return &i; | return &i; | ||||
| } | } | ||||
| megdnn_throw(megdnn_mangle(ssprintf("can not find cudnn fwd algorithm %d", | |||||
| static_cast<int>(algo)))); | |||||
| megdnn_throw(ssprintf("can not find cudnn fwd algorithm %d", | |||||
| static_cast<int>(algo))); | |||||
| } | } | ||||
| Convolution3DForwardImpl::AlgoPack Convolution3DForwardImpl::sm_algo_pack; | Convolution3DForwardImpl::AlgoPack Convolution3DForwardImpl::sm_algo_pack; | ||||
| @@ -101,18 +101,16 @@ Convolution3DForwardImpl::AlgoBase::ExecArgs::ExecArgs( | |||||
| std::string Convolution3DForwardImpl::AlgoBase::SizeArgs::to_string() const { | std::string Convolution3DForwardImpl::AlgoBase::SizeArgs::to_string() const { | ||||
| auto &&fm = filter_meta; | auto &&fm = filter_meta; | ||||
| MEGDNN_MARK_USED_VAR(fm); | MEGDNN_MARK_USED_VAR(fm); | ||||
| return megdnn_mangle(ssprintf( | |||||
| "src=%s, filter=%u{%u,%u,%u,%u,%u}, dst=%s, " | |||||
| "pad=%ux%ux%u, stride=%ux%ux%u, dilate=%ux%ux%u, xcorr=%d, dtype=%s,%s", | |||||
| src_layout->to_string().c_str(), | |||||
| fm.group, fm.ocpg, fm.icpg, | |||||
| fm.spatial[0], fm.spatial[1], fm.spatial[2], | |||||
| dst_layout->to_string().c_str(), | |||||
| fm.padding[0], fm.padding[1], fm.padding[2], | |||||
| fm.stride[0], fm.stride[1], fm.stride[2], | |||||
| fm.dilation[0], fm.dilation[1], fm.dilation[2], | |||||
| !fm.should_flip, | |||||
| src_layout->dtype.name(), dst_layout->dtype.name())); | |||||
| return ssprintf( | |||||
| "src=%s, filter=%u{%u,%u,%u,%u,%u}, dst=%s, " | |||||
| "pad=%ux%ux%u, stride=%ux%ux%u, dilate=%ux%ux%u, xcorr=%d, " | |||||
| "dtype=%s,%s", | |||||
| src_layout->to_string().c_str(), fm.group, fm.ocpg, fm.icpg, | |||||
| fm.spatial[0], fm.spatial[1], fm.spatial[2], | |||||
| dst_layout->to_string().c_str(), fm.padding[0], fm.padding[1], | |||||
| fm.padding[2], fm.stride[0], fm.stride[1], fm.stride[2], | |||||
| fm.dilation[0], fm.dilation[1], fm.dilation[2], !fm.should_flip, | |||||
| src_layout->dtype.name(), dst_layout->dtype.name()); | |||||
| } | } | ||||
| // vim: syntax=cpp.doxygen | // vim: syntax=cpp.doxygen | ||||
| @@ -54,9 +54,9 @@ cudnnDataType_t to_cudnn_dtype(DType type, | |||||
| #endif | #endif | ||||
| default: | default: | ||||
| #if CUDNN_MAJOR >= 6 | #if CUDNN_MAJOR >= 6 | ||||
| megdnn_throw(megdnn_mangle("dtype must be float16/float32/int8/int32")); | |||||
| megdnn_throw("dtype must be float16/float32/int8/int32"); | |||||
| #else | #else | ||||
| megdnn_throw(megdnn_mangle("dtype must be float16/float32")); | |||||
| megdnn_throw("dtype must be float16/float32"); | |||||
| #endif | #endif | ||||
| } | } | ||||
| @@ -259,7 +259,7 @@ void ConvDesc::set(DType data_type, const param::Convolution& param, | |||||
| mode = CUDNN_CONVOLUTION; | mode = CUDNN_CONVOLUTION; | ||||
| break; | break; | ||||
| default: | default: | ||||
| megdnn_throw(megdnn_mangle("conv mode must be conv or xcorr.")); | |||||
| megdnn_throw("conv mode must be conv or xcorr."); | |||||
| } | } | ||||
| cudnnDataType_t compute_type; | cudnnDataType_t compute_type; | ||||
| MEGDNN_MARK_USED_VAR(compute_type); | MEGDNN_MARK_USED_VAR(compute_type); | ||||
| @@ -275,7 +275,7 @@ void ConvDesc::set(DType data_type, const param::Convolution& param, | |||||
| compute_type = CUDNN_DATA_INT32; | compute_type = CUDNN_DATA_INT32; | ||||
| #endif | #endif | ||||
| } else { | } else { | ||||
| megdnn_throw(megdnn_mangle("unspport data type for conv bias")); | |||||
| megdnn_throw("unspport data type for conv bias"); | |||||
| } | } | ||||
| #if CUDNN_MAJOR >= 7 | #if CUDNN_MAJOR >= 7 | ||||
| cudnn_check(cudnnSetConvolutionGroupCount(desc, nr_group)); | cudnn_check(cudnnSetConvolutionGroupCount(desc, nr_group)); | ||||
| @@ -445,7 +445,7 @@ void Conv3DDesc::set(const param::Convolution3D& param, const size_t nr_group) { | |||||
| mode = CUDNN_CONVOLUTION; | mode = CUDNN_CONVOLUTION; | ||||
| break; | break; | ||||
| default: | default: | ||||
| megdnn_throw(megdnn_mangle("conv mode must be conv or xcorr.")); | |||||
| megdnn_throw("conv mode must be conv or xcorr."); | |||||
| } | } | ||||
| #if CUDNN_MAJOR >= 7 | #if CUDNN_MAJOR >= 7 | ||||
| cudnn_check(cudnnSetConvolutionGroupCount(desc, nr_group)); | cudnn_check(cudnnSetConvolutionGroupCount(desc, nr_group)); | ||||
| @@ -62,7 +62,7 @@ uint32_t cumsum::get_workspace_bytes_for_cub_1d(uint32_t nr_item, | |||||
| CASE(8, uint64_t); | CASE(8, uint64_t); | ||||
| #undef CASE | #undef CASE | ||||
| default: | default: | ||||
| report_error(megdnn_mangle("unsupported item size in cumsum")); | |||||
| report_error("unsupported item size in cumsum"); | |||||
| } | } | ||||
| } | } | ||||
| @@ -77,11 +77,11 @@ AlgoFwd* Fwd::get_algorithm_heuristic(const TensorLayout& im, | |||||
| args, reproducible, workspace_limit_in_bytes)) { | args, reproducible, workspace_limit_in_bytes)) { | ||||
| return &sm_algo_pack.algo_matmul; | return &sm_algo_pack.algo_matmul; | ||||
| } | } | ||||
| megdnn_throw(megdnn_mangle( | |||||
| megdnn_throw( | |||||
| ssprintf("no %s deformable conv fwd algorithm with args(%s) and " | ssprintf("no %s deformable conv fwd algorithm with args(%s) and " | ||||
| "workspace limit (%zu bytes)", | "workspace limit (%zu bytes)", | ||||
| reproducible ? "reproducible" : "usable", | reproducible ? "reproducible" : "usable", | ||||
| args.to_string().c_str(), workspace_limit_in_bytes))); | |||||
| args.to_string().c_str(), workspace_limit_in_bytes)); | |||||
| } | } | ||||
| const char* Fwd::get_algorithm_set_name() const { | const char* Fwd::get_algorithm_set_name() const { | ||||
| @@ -131,11 +131,11 @@ AlgoBwdFlt* BwdFlt::get_algorithm_heuristic( | |||||
| args, reproducible, workspace_limit_in_bytes)) { | args, reproducible, workspace_limit_in_bytes)) { | ||||
| return &sm_algo_pack.algo_matmul; | return &sm_algo_pack.algo_matmul; | ||||
| } | } | ||||
| megdnn_throw(megdnn_mangle(ssprintf( | |||||
| megdnn_throw(ssprintf( | |||||
| "no %s deformable conv bwd filter algorithm with args(%s) and " | "no %s deformable conv bwd filter algorithm with args(%s) and " | ||||
| "workspace limit (%zu bytes)", | "workspace limit (%zu bytes)", | ||||
| reproducible ? "reproducible" : "usable", args.to_string().c_str(), | reproducible ? "reproducible" : "usable", args.to_string().c_str(), | ||||
| workspace_limit_in_bytes))); | |||||
| workspace_limit_in_bytes)); | |||||
| } | } | ||||
| size_t BwdFlt::get_workspace_in_bytes( | size_t BwdFlt::get_workspace_in_bytes( | ||||
| @@ -194,11 +194,11 @@ AlgoBwdData* BwdData::get_algorithm_heuristic( | |||||
| args, reproducible, workspace_limit_in_bytes)) { | args, reproducible, workspace_limit_in_bytes)) { | ||||
| return &sm_algo_pack.algo_matmul; | return &sm_algo_pack.algo_matmul; | ||||
| } | } | ||||
| megdnn_throw(megdnn_mangle(ssprintf( | |||||
| megdnn_throw(ssprintf( | |||||
| "no %s deformable conv bwd data algorithm with args(%s) and " | "no %s deformable conv bwd data algorithm with args(%s) and " | ||||
| "workspace limit (%zu bytes)", | "workspace limit (%zu bytes)", | ||||
| reproducible ? "reproducible" : "usable", args.to_string().c_str(), | reproducible ? "reproducible" : "usable", args.to_string().c_str(), | ||||
| workspace_limit_in_bytes))); | |||||
| workspace_limit_in_bytes)); | |||||
| } | } | ||||
| size_t BwdData::get_workspace_in_bytes( | size_t BwdData::get_workspace_in_bytes( | ||||
| @@ -199,7 +199,7 @@ size_t IndexingIncrMultiAxisVecImpl::get_workspace_in_bytes( | |||||
| void IndexingIncrMultiAxisVecImpl::exec( | void IndexingIncrMultiAxisVecImpl::exec( | ||||
| _megdnn_tensor_inout data, _megdnn_tensor_in value, | _megdnn_tensor_inout data, _megdnn_tensor_in value, | ||||
| const IndexDesc &index, _megdnn_workspace workspace) { | const IndexDesc &index, _megdnn_workspace workspace) { | ||||
| MEGDNN_INC_FLOAT16( | |||||
| DNN_INC_FLOAT16( | |||||
| megdnn_assert(data.layout.dtype != dtype::Float16(), | megdnn_assert(data.layout.dtype != dtype::Float16(), | ||||
| "float16 incr on cuda currently not supported")); | "float16 incr on cuda currently not supported")); | ||||
| auto info = check_exec(data.layout, value.layout, index, workspace.size); | auto info = check_exec(data.layout, value.layout, index, workspace.size); | ||||
| @@ -53,7 +53,7 @@ void IndexingOneHotForwardImpl::exec( | |||||
| switch (src.layout.dtype.enumv()) { | switch (src.layout.dtype.enumv()) { | ||||
| MEGDNN_FOREACH_COMPUTING_DTYPE(cb) | MEGDNN_FOREACH_COMPUTING_DTYPE(cb) | ||||
| default: | default: | ||||
| megdnn_throw(megdnn_mangle("bad dtype")); | |||||
| megdnn_throw("bad dtype"); | |||||
| } | } | ||||
| #undef cb | #undef cb | ||||
| } | } | ||||
| @@ -80,7 +80,7 @@ void IndexingSetOneHotForwardImpl::exec( | |||||
| switch (data.layout.dtype.enumv()) { | switch (data.layout.dtype.enumv()) { | ||||
| MEGDNN_FOREACH_COMPUTING_DTYPE(cb) | MEGDNN_FOREACH_COMPUTING_DTYPE(cb) | ||||
| default: | default: | ||||
| megdnn_throw(megdnn_mangle("bad dtype")); | |||||
| megdnn_throw("bad dtype"); | |||||
| } | } | ||||
| #undef cb | #undef cb | ||||
| } | } | ||||
| @@ -47,14 +47,14 @@ LocalShareBackwardDataImpl::AlgoBase::ExecArgs::ExecArgs(LocalShareBackwardDataI | |||||
| std::string LocalShareBackwardDataImpl::AlgoBase::SizeArgs::to_string() const { | std::string LocalShareBackwardDataImpl::AlgoBase::SizeArgs::to_string() const { | ||||
| auto&& param = opr->param(); | auto&& param = opr->param(); | ||||
| MEGDNN_MARK_USED_VAR(param); | MEGDNN_MARK_USED_VAR(param); | ||||
| return megdnn_mangle(ssprintf( | |||||
| return ssprintf( | |||||
| "filter=%s, diff=%s, grad=%s, " | "filter=%s, diff=%s, grad=%s, " | ||||
| "pad=%ux%u, stride=%ux%u, dilate=%ux%u, xcorr=%d, dtype=%s,%s->%s", | "pad=%ux%u, stride=%ux%u, dilate=%ux%u, xcorr=%d, dtype=%s,%s->%s", | ||||
| filter_layout.to_string().c_str(), diff_layout.to_string().c_str(), | filter_layout.to_string().c_str(), diff_layout.to_string().c_str(), | ||||
| grad_layout.to_string().c_str(), param.pad_h, param.pad_w, | grad_layout.to_string().c_str(), param.pad_h, param.pad_w, | ||||
| param.stride_h, param.stride_w, param.dilate_h, param.dilate_w, | param.stride_h, param.stride_w, param.dilate_h, param.dilate_w, | ||||
| static_cast<int>(param.mode), filter_layout.dtype.name(), | static_cast<int>(param.mode), filter_layout.dtype.name(), | ||||
| diff_layout.dtype.name(), grad_layout.dtype.name())); | |||||
| diff_layout.dtype.name(), grad_layout.dtype.name()); | |||||
| } | } | ||||
| // vim: syntax=cpp.doxygen | // vim: syntax=cpp.doxygen | ||||
| @@ -48,14 +48,14 @@ std::string LocalShareBackwardFilterImpl::AlgoBase::SizeArgs::to_string() | |||||
| const { | const { | ||||
| auto&& param = opr->param(); | auto&& param = opr->param(); | ||||
| MEGDNN_MARK_USED_VAR(param); | MEGDNN_MARK_USED_VAR(param); | ||||
| return megdnn_mangle(ssprintf( | |||||
| return ssprintf( | |||||
| "src=%s, diff=%s, grad=%s, " | "src=%s, diff=%s, grad=%s, " | ||||
| "pad=%ux%u, stride=%ux%u, dilate=%ux%u, xcorr=%d, dtype=%s,%s->%s", | "pad=%ux%u, stride=%ux%u, dilate=%ux%u, xcorr=%d, dtype=%s,%s->%s", | ||||
| src_layout.to_string().c_str(), diff_layout.to_string().c_str(), | src_layout.to_string().c_str(), diff_layout.to_string().c_str(), | ||||
| grad_layout.to_string().c_str(), param.pad_h, param.pad_w, | grad_layout.to_string().c_str(), param.pad_h, param.pad_w, | ||||
| param.stride_h, param.stride_w, param.dilate_h, param.dilate_w, | param.stride_h, param.stride_w, param.dilate_h, param.dilate_w, | ||||
| static_cast<int>(param.mode), src_layout.dtype.name(), | static_cast<int>(param.mode), src_layout.dtype.name(), | ||||
| diff_layout.dtype.name(), grad_layout.dtype.name())); | |||||
| diff_layout.dtype.name(), grad_layout.dtype.name()); | |||||
| } | } | ||||
| // vim: syntax=cpp.doxygen | // vim: syntax=cpp.doxygen | ||||
| @@ -49,14 +49,14 @@ LocalShareForwardImpl::AlgoBase::ExecArgs::ExecArgs(LocalShareForwardImpl* opr, | |||||
| std::string LocalShareForwardImpl::AlgoBase::SizeArgs::to_string() const { | std::string LocalShareForwardImpl::AlgoBase::SizeArgs::to_string() const { | ||||
| auto&& param = opr->param(); | auto&& param = opr->param(); | ||||
| MEGDNN_MARK_USED_VAR(param); | MEGDNN_MARK_USED_VAR(param); | ||||
| return megdnn_mangle(ssprintf( | |||||
| return ssprintf( | |||||
| "src=%s, filter=%s, dst=%s, " | "src=%s, filter=%s, dst=%s, " | ||||
| "pad=%ux%u, stride=%ux%u, dilate=%ux%u, xcorr=%d, dtype=%s,%s", | "pad=%ux%u, stride=%ux%u, dilate=%ux%u, xcorr=%d, dtype=%s,%s", | ||||
| src_layout.to_string().c_str(), filter_layout.to_string().c_str(), | src_layout.to_string().c_str(), filter_layout.to_string().c_str(), | ||||
| dst_layout.to_string().c_str(), param.pad_h, param.pad_w, | dst_layout.to_string().c_str(), param.pad_h, param.pad_w, | ||||
| param.stride_h, param.stride_w, param.dilate_h, param.dilate_w, | param.stride_h, param.stride_w, param.dilate_h, param.dilate_w, | ||||
| static_cast<int>(param.mode), src_layout.dtype.name(), | static_cast<int>(param.mode), src_layout.dtype.name(), | ||||
| dst_layout.dtype.name())); | |||||
| dst_layout.dtype.name()); | |||||
| } | } | ||||
| // vim: syntax=cpp.doxygen | // vim: syntax=cpp.doxygen | ||||
| @@ -39,11 +39,11 @@ LocalShareForwardImpl::get_algorithm_heuristic(const TensorLayout& src, | |||||
| args, reproducible, workspace_limit_in_bytes)) { | args, reproducible, workspace_limit_in_bytes)) { | ||||
| return &sm_algo_pack.batched_matmul; | return &sm_algo_pack.batched_matmul; | ||||
| } | } | ||||
| megdnn_throw(megdnn_mangle( | |||||
| megdnn_throw( | |||||
| ssprintf("no %s local share conv algorithm with args(%s) and " | ssprintf("no %s local share conv algorithm with args(%s) and " | ||||
| "workspace limit (%zu bytes)", | "workspace limit (%zu bytes)", | ||||
| reproducible ? "reproducible" : "usable", | reproducible ? "reproducible" : "usable", | ||||
| args.to_string().c_str(), workspace_limit_in_bytes))); | |||||
| args.to_string().c_str(), workspace_limit_in_bytes)); | |||||
| } | } | ||||
| std::vector<LocalShareForwardImpl::Algorithm*> | std::vector<LocalShareForwardImpl::Algorithm*> | ||||
| @@ -89,11 +89,11 @@ LocalShareBackwardDataImpl::get_algorithm_heuristic( | |||||
| args, reproducible, workspace_limit_in_bytes)) { | args, reproducible, workspace_limit_in_bytes)) { | ||||
| return &sm_algo_pack.batched_matmul; | return &sm_algo_pack.batched_matmul; | ||||
| } | } | ||||
| megdnn_throw(megdnn_mangle( | |||||
| megdnn_throw( | |||||
| ssprintf("no %s local share bwd data algorithm with args(%s) and " | ssprintf("no %s local share bwd data algorithm with args(%s) and " | ||||
| "workspace limit (%zu bytes)", | "workspace limit (%zu bytes)", | ||||
| reproducible ? "reproducible" : "usable", | reproducible ? "reproducible" : "usable", | ||||
| args.to_string().c_str(), workspace_limit_in_bytes))); | |||||
| args.to_string().c_str(), workspace_limit_in_bytes)); | |||||
| } | } | ||||
| std::vector<LocalShareBackwardDataImpl::Algorithm*> | std::vector<LocalShareBackwardDataImpl::Algorithm*> | ||||
| @@ -139,11 +139,11 @@ LocalShareBackwardFilterImpl::get_algorithm_heuristic( | |||||
| args, reproducible, workspace_limit_in_bytes)) { | args, reproducible, workspace_limit_in_bytes)) { | ||||
| return &sm_algo_pack.batched_matmul; | return &sm_algo_pack.batched_matmul; | ||||
| } | } | ||||
| megdnn_throw(megdnn_mangle( | |||||
| megdnn_throw( | |||||
| ssprintf("no %s local share bwd filter algorithm with args(%s) and " | ssprintf("no %s local share bwd filter algorithm with args(%s) and " | ||||
| "workspace limit (%zu bytes)", | "workspace limit (%zu bytes)", | ||||
| reproducible ? "reproducible" : "usable", | reproducible ? "reproducible" : "usable", | ||||
| args.to_string().c_str(), workspace_limit_in_bytes))); | |||||
| args.to_string().c_str(), workspace_limit_in_bytes)); | |||||
| } | } | ||||
| std::vector<LocalShareBackwardFilterImpl::Algorithm*> | std::vector<LocalShareBackwardFilterImpl::Algorithm*> | ||||
| @@ -122,11 +122,11 @@ std::string MatrixMulForwardImpl::AlgoBase::SizeArgs::to_string() const { | |||||
| MEGDNN_MARK_USED_VAR(m); | MEGDNN_MARK_USED_VAR(m); | ||||
| MEGDNN_MARK_USED_VAR(n); | MEGDNN_MARK_USED_VAR(n); | ||||
| MEGDNN_MARK_USED_VAR(k); | MEGDNN_MARK_USED_VAR(k); | ||||
| return megdnn_mangle(ssprintf( | |||||
| return ssprintf( | |||||
| "A={%zux%zu},B={%zux%zu},C={%zux%zu},Transpose A=%d,Transpose " | "A={%zux%zu},B={%zux%zu},C={%zux%zu},Transpose A=%d,Transpose " | ||||
| "B=%d,ldA=%zu,ldB=%zu,ldC=%zu", | "B=%d,ldA=%zu,ldB=%zu,ldC=%zu", | ||||
| m, k, k, n, m, n, param.transposeA, param.transposeB, | m, k, k, n, m, n, param.transposeA, param.transposeB, | ||||
| layout_a.stride[0], layout_b.stride[0], layout_c.stride[0])); | |||||
| layout_a.stride[0], layout_b.stride[0], layout_c.stride[0]); | |||||
| } | } | ||||
| // vim: syntax=cpp.doxygen | // vim: syntax=cpp.doxygen | ||||
| @@ -29,8 +29,7 @@ static cudaDataType_t to_cuda_dtype(DType tp) { | |||||
| case DTypeEnum::QuantizedS32: | case DTypeEnum::QuantizedS32: | ||||
| return CUDA_R_32I; | return CUDA_R_32I; | ||||
| default: | default: | ||||
| megdnn_throw(megdnn_mangle( | |||||
| "dtype must be float16/float32/int8/qs8/int32")); | |||||
| megdnn_throw("dtype must be float16/float32/int8/qs8/int32"); | |||||
| } | } | ||||
| } | } | ||||
| @@ -45,8 +44,7 @@ static cublasComputeType_t to_cublas_compute_type(DType tp) { | |||||
| case DTypeEnum::QuantizedS32: | case DTypeEnum::QuantizedS32: | ||||
| return CUBLAS_COMPUTE_32I; | return CUBLAS_COMPUTE_32I; | ||||
| default: | default: | ||||
| megdnn_throw( | |||||
| megdnn_mangle("dtype must be float16/float32/int32/Qs32")); | |||||
| megdnn_throw("dtype must be float16/float32/int32/Qs32"); | |||||
| } | } | ||||
| } | } | ||||
| #endif | #endif | ||||
| @@ -62,8 +60,7 @@ static const char* cuda_type_to_str(cudaDataType_t tp) { | |||||
| case CUDA_R_32I: | case CUDA_R_32I: | ||||
| return "CUDA_R_32I"; | return "CUDA_R_32I"; | ||||
| default: | default: | ||||
| megdnn_throw( | |||||
| megdnn_mangle("dtype must be float16/float32/int8/int32")); | |||||
| megdnn_throw("dtype must be float16/float32/int8/int32"); | |||||
| } | } | ||||
| } | } | ||||
| @@ -77,8 +74,7 @@ static size_t cuda_dtype_size(cudaDataType_t dt) { | |||||
| case CUDA_R_32I: | case CUDA_R_32I: | ||||
| return 4_z; | return 4_z; | ||||
| default: | default: | ||||
| megdnn_throw( | |||||
| megdnn_mangle("dtype must be float16/float32/int8/int32")); | |||||
| megdnn_throw("dtype must be float16/float32/int8/int32"); | |||||
| } | } | ||||
| } | } | ||||
| @@ -140,8 +140,7 @@ void MatrixMulForwardImpl::AlgoCuBlasLt::exec(const ExecArgs& args) const { | |||||
| igemm(); | igemm(); | ||||
| break; | break; | ||||
| default: | default: | ||||
| megdnn_throw(megdnn_mangle( | |||||
| "compute type must be float16/float32/int32")); | |||||
| megdnn_throw("compute type must be float16/float32/int32"); | |||||
| } | } | ||||
| #else | #else | ||||
| switch (desc.dt_compute) { | switch (desc.dt_compute) { | ||||
| @@ -155,8 +154,7 @@ void MatrixMulForwardImpl::AlgoCuBlasLt::exec(const ExecArgs& args) const { | |||||
| igemm(); | igemm(); | ||||
| break; | break; | ||||
| default: | default: | ||||
| megdnn_throw(megdnn_mangle( | |||||
| "compute type must be float16/float32/int32")); | |||||
| megdnn_throw("compute type must be float16/float32/int32"); | |||||
| } | } | ||||
| #endif | #endif | ||||
| } | } | ||||
| @@ -27,7 +27,8 @@ CUDAComputingContext::CUDAComputingContext(megcoreDeviceHandle_t dev_handle, | |||||
| { | { | ||||
| megcorePlatform_t platform; | megcorePlatform_t platform; | ||||
| megcoreGetPlatform(dev_handle, &platform); | megcoreGetPlatform(dev_handle, &platform); | ||||
| megdnn_assert(platform == megcorePlatformCUDA); | |||||
| megdnn_throw_if(platform != megcorePlatformCUDA, megdnn_error, | |||||
| "platform should be CUDA Platform"); | |||||
| if (own_stream_) { | if (own_stream_) { | ||||
| cuda_check(cudaStreamCreateWithFlags(&context_.stream, | cuda_check(cudaStreamCreateWithFlags(&context_.stream, | ||||
| cudaStreamNonBlocking)); | cudaStreamNonBlocking)); | ||||
| @@ -38,9 +38,10 @@ megcoreStatus_t megcore::getCUDAContext(megcoreComputingHandle_t handle, | |||||
| megcoreDeviceHandle_t dev_handle = H->content->dev_handle(); | megcoreDeviceHandle_t dev_handle = H->content->dev_handle(); | ||||
| megcorePlatform_t platform; | megcorePlatform_t platform; | ||||
| megcoreGetPlatform(dev_handle, &platform); | megcoreGetPlatform(dev_handle, &platform); | ||||
| megdnn_assert(platform == megcorePlatformCUDA); | |||||
| auto context = static_cast<megcore::cuda::CUDAComputingContext *>( | |||||
| H->content.get()); | |||||
| megdnn_throw_if(platform != megcorePlatformCUDA, megdnn_error, | |||||
| "platform should be CUDA Platform"); | |||||
| auto context = | |||||
| static_cast<megcore::cuda::CUDAComputingContext*>(H->content.get()); | |||||
| *ctx = context->context(); | *ctx = context->context(); | ||||
| return megcoreSuccess; | return megcoreSuccess; | ||||
| } | } | ||||
| @@ -194,8 +194,8 @@ void RelayoutForwardImpl::exec(_megdnn_tensor_in src, _megdnn_tensor_out dst, | |||||
| megcoreGetDeviceHandle(src_handle->megcore_computing_handle(), &dev); | megcoreGetDeviceHandle(src_handle->megcore_computing_handle(), &dev); | ||||
| megcorePlatform_t plat; | megcorePlatform_t plat; | ||||
| megcoreGetPlatform(dev, &plat); | megcoreGetPlatform(dev, &plat); | ||||
| megdnn_assert(plat == megcorePlatformCUDA, | |||||
| "only relayout between cuda devices are supported"); | |||||
| megdnn_throw_if(plat != megcorePlatformCUDA, megdnn_error, | |||||
| "only relayout between cuda devices are supported"); | |||||
| int dst_dev_id = -1, src_dev_id = -1; | int dst_dev_id = -1, src_dev_id = -1; | ||||
| megcoreGetDeviceID(dev, &src_dev_id); | megcoreGetDeviceID(dev, &src_dev_id); | ||||
| @@ -157,7 +157,7 @@ void backwarddata_proxy(ctype* grad, const float* map_xy, const ctype* diff, | |||||
| INST(ctype, NCHW, BORDER_WRAP) | INST(ctype, NCHW, BORDER_WRAP) | ||||
| FOR_FORMAT_BMODE(float) | FOR_FORMAT_BMODE(float) | ||||
| MEGDNN_INC_FLOAT16(FOR_FORMAT_BMODE(dt_bfloat16)) | |||||
| DNN_INC_FLOAT16(FOR_FORMAT_BMODE(dt_bfloat16)) | |||||
| #undef FOR_FORMAT_BMODE | #undef FOR_FORMAT_BMODE | ||||
| #undef INST | #undef INST | ||||
| @@ -158,7 +158,7 @@ void backwardmat_proxy(const ctype* src, const float* map_xy, const ctype* diff, | |||||
| INST(ctype, NCHW, BORDER_WRAP) | INST(ctype, NCHW, BORDER_WRAP) | ||||
| FOR_FORMAT_BMODE(float) | FOR_FORMAT_BMODE(float) | ||||
| MEGDNN_INC_FLOAT16(FOR_FORMAT_BMODE(dt_bfloat16)) | |||||
| DNN_INC_FLOAT16(FOR_FORMAT_BMODE(dt_bfloat16)) | |||||
| #undef FOR_FORMAT_BMODE | #undef FOR_FORMAT_BMODE | ||||
| #undef INST | #undef INST | ||||
| @@ -76,8 +76,8 @@ void RemapImpl::exec(_megdnn_tensor_in src, _megdnn_tensor_out map_xy, | |||||
| switch (src.layout.dtype.enumv()) { | switch (src.layout.dtype.enumv()) { | ||||
| support_dtype(dtype::Float32); | support_dtype(dtype::Float32); | ||||
| MEGDNN_INC_FLOAT16(support_dtype(dtype::Float16)); | |||||
| MEGDNN_INC_FLOAT16(support_dtype(dtype::BFloat16)); | |||||
| DNN_INC_FLOAT16(support_dtype(dtype::Float16)); | |||||
| DNN_INC_FLOAT16(support_dtype(dtype::BFloat16)); | |||||
| support_dtype(dtype::Int8); | support_dtype(dtype::Int8); | ||||
| support_dtype(dtype::Uint8); | support_dtype(dtype::Uint8); | ||||
| default: | default: | ||||
| @@ -209,8 +209,8 @@ void forward_proxy(const ctype* src, const float* map_xy, ctype* dst, int N, | |||||
| INST(ctype, NHWC, BORDER_WRAP) | INST(ctype, NHWC, BORDER_WRAP) | ||||
| FOR_FORMAT_BMODE(float) | FOR_FORMAT_BMODE(float) | ||||
| MEGDNN_INC_FLOAT16(FOR_FORMAT_BMODE(dt_float16)) | |||||
| MEGDNN_INC_FLOAT16(FOR_FORMAT_BMODE(dt_bfloat16)) | |||||
| DNN_INC_FLOAT16(FOR_FORMAT_BMODE(dt_float16)) | |||||
| DNN_INC_FLOAT16(FOR_FORMAT_BMODE(dt_bfloat16)) | |||||
| FOR_FORMAT_BMODE(int8_t) | FOR_FORMAT_BMODE(int8_t) | ||||
| FOR_FORMAT_BMODE(uint8_t) | FOR_FORMAT_BMODE(uint8_t) | ||||
| @@ -43,8 +43,7 @@ void resize_cv_proxy(_megdnn_tensor_in src, _megdnn_tensor_out dst, | |||||
| src_mat.step(), dst_mat.step(), src_mat.channels(), imode, | src_mat.step(), dst_mat.step(), src_mat.channels(), imode, | ||||
| workspace, stream); | workspace, stream); | ||||
| } else { | } else { | ||||
| megdnn_throw( | |||||
| megdnn_mangle("Unsupported datatype of WarpAffine optr.")); | |||||
| megdnn_throw("Unsupported datatype of WarpAffine optr."); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -73,8 +73,7 @@ void warp_affine_cv_exec(_megdnn_tensor_in src, _megdnn_tensor_in mat, | |||||
| } | } | ||||
| } else { | } else { | ||||
| megdnn_throw( | |||||
| megdnn_mangle("Unsupported datatype of Warpaffine optr.")); | |||||
| megdnn_throw("Unsupported datatype of Warpaffine optr."); | |||||
| } | } | ||||
| trans_ptr += 2 * 3; | trans_ptr += 2 * 3; | ||||
| @@ -75,8 +75,7 @@ void warp_perspective_cv_exec(_megdnn_tensor_in src, _megdnn_tensor_in mat, | |||||
| } | } | ||||
| } else { | } else { | ||||
| megdnn_throw(megdnn_mangle( | |||||
| "Unsupported datatype of WarpPerspective optr.")); | |||||
| megdnn_throw("Unsupported datatype of WarpPerspective optr."); | |||||
| } | } | ||||
| trans_ptr += 3 * 3; | trans_ptr += 3 * 3; | ||||
| @@ -215,7 +214,7 @@ void WarpPerspectiveForwardImpl::exec(_megdnn_tensor_in ssrc, | |||||
| C, IH, IW, OH, OW, bval, bmode, | C, IH, IW, OH, OW, bval, bmode, | ||||
| async_error_info(handle()), m_error_tracker, | async_error_info(handle()), m_error_tracker, | ||||
| stream); | stream); | ||||
| } else if (MEGDNN_FLOAT16_SELECT( | |||||
| } else if (DNN_FLOAT16_SELECT( | |||||
| src.layout.dtype == dtype::Float16(), | src.layout.dtype == dtype::Float16(), | ||||
| false)) { | false)) { | ||||
| #ifndef MEGDNN_DISABLE_FLOAT16 | #ifndef MEGDNN_DISABLE_FLOAT16 | ||||
| @@ -50,11 +50,13 @@ std::string BatchedMatrixMulForwardImpl::AlgoBase::SizeArgs::to_string() const { | |||||
| MEGDNN_MARK_USED_VAR(m); | MEGDNN_MARK_USED_VAR(m); | ||||
| MEGDNN_MARK_USED_VAR(n); | MEGDNN_MARK_USED_VAR(n); | ||||
| MEGDNN_MARK_USED_VAR(k); | MEGDNN_MARK_USED_VAR(k); | ||||
| return megdnn_mangle(ssprintf( | |||||
| return ssprintf( | |||||
| "A={%zux%zu},B={%zux%zu},C={%zux%zu},Transpose A=%d,Transpose " | "A={%zux%zu},B={%zux%zu},C={%zux%zu},Transpose A=%d,Transpose " | ||||
| "B=%d,ldA=%zu,ldB=%zu,ldC=%zu", | "B=%d,ldA=%zu,ldB=%zu,ldC=%zu", | ||||
| m, k, k, n, m, n, param.transposeA, param.transposeB, | m, k, k, n, m, n, param.transposeA, param.transposeB, | ||||
| layout_a.stride[0], layout_b.stride[0], layout_c.stride[0])); | |||||
| static_cast<size_t>(layout_a.stride[0]), | |||||
| static_cast<size_t>(layout_b.stride[0]), | |||||
| static_cast<size_t>(layout_c.stride[0])); | |||||
| } | } | ||||
| /* ===================== default algo ===================== */ | /* ===================== default algo ===================== */ | ||||
| @@ -295,7 +295,7 @@ SmallVector<ConvolutionImpl::NCBKern> ConvolutionImpl::AlgoNaive::dispatch_kern( | |||||
| cb(dtype::Int8, dtype::Int32); | cb(dtype::Int8, dtype::Int32); | ||||
| cb(dtype::Quantized8Asymm, dtype::QuantizedS32); | cb(dtype::Quantized8Asymm, dtype::QuantizedS32); | ||||
| cb(dtype::QuantizedS8, dtype::QuantizedS32); | cb(dtype::QuantizedS8, dtype::QuantizedS32); | ||||
| megdnn_throw(megdnn_mangle("unknown convolution data type")); | |||||
| megdnn_throw("unknown convolution data type"); | |||||
| #undef cb | #undef cb | ||||
| } | } | ||||
| @@ -596,8 +596,8 @@ ConvolutionBackwardDataImpl::AlgoMatrixMul::dispatch_kern( | |||||
| } \ | } \ | ||||
| } while (0); | } while (0); | ||||
| cb(dtype::Float32, "FLOAT"_hash); | cb(dtype::Float32, "FLOAT"_hash); | ||||
| MEGDNN_INC_FLOAT16(cb(dtype::Float16, "FLOAT16"_hash)); | |||||
| MEGDNN_INC_FLOAT16(cb(dtype::BFloat16, "BFLOAT16"_hash)); | |||||
| DNN_INC_FLOAT16(cb(dtype::Float16, "FLOAT16"_hash)); | |||||
| DNN_INC_FLOAT16(cb(dtype::BFloat16, "BFLOAT16"_hash)); | |||||
| #undef cb | #undef cb | ||||
| #define cb(dt_src, dt_dst, midout_tag) \ | #define cb(dt_src, dt_dst, midout_tag) \ | ||||
| @@ -432,7 +432,7 @@ ConvolutionImpl::NCBKernSizeParam::deduce_algo_data_type() const { | |||||
| } else if (src_type.enumv() == DTypeEnum::Quantized8Asymm) { | } else if (src_type.enumv() == DTypeEnum::Quantized8Asymm) { | ||||
| return ConvolutionImpl::AlgoDataType::QUINT8X8X32; | return ConvolutionImpl::AlgoDataType::QUINT8X8X32; | ||||
| } else { | } else { | ||||
| megdnn_throw(ssprintf("megdnn not support data type of %s * %s -> %s\n", | |||||
| megdnn_throw(ssprintf("not support data type of %s * %s -> %s\n", | |||||
| src_type.name(), filter_type.name(), | src_type.name(), filter_type.name(), | ||||
| dst_type.name())); | dst_type.name())); | ||||
| } | } | ||||
| @@ -697,8 +697,7 @@ ConvolutionBackwardDataImpl::ncb_1g_dispatch_kern( | |||||
| return static_cast<AlgoBase*>(algo)->dispatch_kern(this, param); | return static_cast<AlgoBase*>(algo)->dispatch_kern(this, param); | ||||
| } | } | ||||
| megdnn_throw( | |||||
| megdnn_mangle("no suitable ConvolutionBackwardData algorithm")); | |||||
| megdnn_throw("no suitable ConvolutionBackwardData algorithm"); | |||||
| } | } | ||||
| bool ConvolutionBackwardDataImpl::is_matrix_mul_preferred( | bool ConvolutionBackwardDataImpl::is_matrix_mul_preferred( | ||||
| @@ -134,8 +134,7 @@ void run_xcorr_single_channel_templated( | |||||
| DISPATCH(6) | DISPATCH(6) | ||||
| DISPATCH(7) | DISPATCH(7) | ||||
| #undef DISPATCH | #undef DISPATCH | ||||
| megdnn_throw(megdnn_mangle( | |||||
| "internal error in conv template dispatching: impossible")); | |||||
| megdnn_throw("internal error in conv template dispatching: impossible"); | |||||
| } | } | ||||
| void run_xcorr_single_channel_nontemplated( | void run_xcorr_single_channel_nontemplated( | ||||
| @@ -339,8 +338,7 @@ void conv_backdata_single_channel_templated( | |||||
| DISPATCH(7) | DISPATCH(7) | ||||
| #undef DISPATCH | #undef DISPATCH | ||||
| megdnn_throw( | megdnn_throw( | ||||
| megdnn_mangle("internal error in conv_backdata template " | |||||
| "dispatching: impossible")); | |||||
| "internal error in conv_backdata template dispatching: impossible"); | |||||
| } | } | ||||
| void conv_backdata_single_channel_nontemplated( | void conv_backdata_single_channel_nontemplated( | ||||
| @@ -165,7 +165,7 @@ MatrixMulImpl::kern_t MatrixMulImpl::AlgoGemv::get_kern( | |||||
| } | } | ||||
| DISPATCH(Float32, Float32, (gemm_gemv_like<dt_float32, dt_float32>), 0); | DISPATCH(Float32, Float32, (gemm_gemv_like<dt_float32, dt_float32>), 0); | ||||
| MEGDNN_INC_FLOAT16(DISPATCH(Float16, Float16, | |||||
| DNN_INC_FLOAT16(DISPATCH(Float16, Float16, | |||||
| (gemm_gemv_like<dt_float16, dt_float16>), 1)); | (gemm_gemv_like<dt_float16, dt_float16>), 1)); | ||||
| DISPATCH(Int8, Int16, (gemm_gemv_like<dt_int8, dt_int16>), 2); | DISPATCH(Int8, Int16, (gemm_gemv_like<dt_int8, dt_int16>), 2); | ||||
| DISPATCH(Quantized8Asymm, QuantizedS32, | DISPATCH(Quantized8Asymm, QuantizedS32, | ||||
| @@ -263,9 +263,8 @@ MatrixMulImpl::KernSizeParam::deduce_algo_data_type() const { | |||||
| } else if (A_type.enumv() == DTypeEnum::Int16) { | } else if (A_type.enumv() == DTypeEnum::Int16) { | ||||
| return MatrixMulImpl::AlgoDataType::INT16X16X32; | return MatrixMulImpl::AlgoDataType::INT16X16X32; | ||||
| } else { | } else { | ||||
| megdnn_throw(ssprintf( | |||||
| "megdnn matmul not support data type of %s * %s -> %s\n", | |||||
| A_type.name(), B_type.name(), C_type.name())); | |||||
| megdnn_throw(ssprintf("matmul not support data type of %s * %s -> %s\n", | |||||
| A_type.name(), B_type.name(), C_type.name())); | |||||
| } | } | ||||
| } | } | ||||
| @@ -262,10 +262,10 @@ void PowCImpl::do_exec(_megdnn_tensor_in src, _megdnn_tensor_out dst, | |||||
| #if !MEGDNN_DISABLE_FLOAT16 | #if !MEGDNN_DISABLE_FLOAT16 | ||||
| case DTypeTrait<dtype::Float16>::enumv: | case DTypeTrait<dtype::Float16>::enumv: | ||||
| #if __ARM_FEATURE_FP16_VECTOR_ARITHMETIC | #if __ARM_FEATURE_FP16_VECTOR_ARITHMETIC | ||||
| return MEGDNN_INC_FLOAT16( | |||||
| return DNN_INC_FLOAT16( | |||||
| do_exec_ct<__fp16>(src, dst, exp_f, exp_i)); | do_exec_ct<__fp16>(src, dst, exp_f, exp_i)); | ||||
| #else | #else | ||||
| return MEGDNN_INC_FLOAT16( | |||||
| return DNN_INC_FLOAT16( | |||||
| do_exec_ct<dt_float16>(src, dst, exp_f, exp_i)); | do_exec_ct<dt_float16>(src, dst, exp_f, exp_i)); | ||||
| #endif | #endif | ||||
| #endif | #endif | ||||
| @@ -133,7 +133,7 @@ void ResizeImpl::exec(_megdnn_tensor_in src, _megdnn_tensor_in dst, | |||||
| switch (src.layout.dtype.enumv()) { | switch (src.layout.dtype.enumv()) { | ||||
| cb(dtype::Float32, float); | cb(dtype::Float32, float); | ||||
| MEGDNN_INC_FLOAT16(cb(dtype::Float16, dt_float16)); | |||||
| DNN_INC_FLOAT16(cb(dtype::Float16, dt_float16)); | |||||
| cb(dtype::Int8, int8_t); | cb(dtype::Int8, int8_t); | ||||
| cb(dtype::QuantizedS8, int8_t); | cb(dtype::QuantizedS8, int8_t); | ||||
| cb(dtype::Uint8, uint8_t); | cb(dtype::Uint8, uint8_t); | ||||
| @@ -93,7 +93,7 @@ void WarpPerspectiveImpl::exec(_megdnn_tensor_in src, _megdnn_tensor_in mat, | |||||
| switch (src.layout.dtype.enumv()) { | switch (src.layout.dtype.enumv()) { | ||||
| cb(dtype::Float32, float, float); | cb(dtype::Float32, float, float); | ||||
| MEGDNN_INC_FLOAT16(cb(dtype::Float16, dt_float16, float)); | |||||
| DNN_INC_FLOAT16(cb(dtype::Float16, dt_float16, float)); | |||||
| cb(dtype::Int8, int8_t, float); | cb(dtype::Int8, int8_t, float); | ||||
| cb(dtype::QuantizedS8, int8_t, float); | cb(dtype::QuantizedS8, int8_t, float); | ||||
| cb(dtype::Uint8, uint8_t, float); | cb(dtype::Uint8, uint8_t, float); | ||||
| @@ -224,7 +224,7 @@ void BNForwardImpl::exec(_megdnn_tensor_in src, _megdnn_tensor_in bn_scale, | |||||
| variance.layout, batch_mean.layout, batch_inv_variance.layout, | variance.layout, batch_mean.layout, batch_inv_variance.layout, | ||||
| dst.layout, workspace.size); | dst.layout, workspace.size); | ||||
| MEGDNN_INC_FLOAT16(if (src.layout.dtype == dtype::Float16() && | |||||
| DNN_INC_FLOAT16(if (src.layout.dtype == dtype::Float16() && | |||||
| bn_scale.layout.dtype == dtype::Float32()) { | bn_scale.layout.dtype == dtype::Float32()) { | ||||
| MEGDNN_DISPATCH_CPU_KERN_OPR(({ | MEGDNN_DISPATCH_CPU_KERN_OPR(({ | ||||
| using T0 = typename DTypeTrait<dtype::Float16>::ctype; | using T0 = typename DTypeTrait<dtype::Float16>::ctype; | ||||
| @@ -285,7 +285,7 @@ void BNBackwardImpl::exec(_megdnn_tensor_in x_in, _megdnn_tensor_in dy_in, | |||||
| bn_scale.layout.total_nr_elems(), | bn_scale.layout.total_nr_elems(), | ||||
| workspace.raw_ptr); | workspace.raw_ptr); | ||||
| MEGDNN_INC_FLOAT16(if (x_in.layout.dtype == dtype::Float16() && | |||||
| DNN_INC_FLOAT16(if (x_in.layout.dtype == dtype::Float16() && | |||||
| bn_scale.layout.dtype == dtype::Float32()) { | bn_scale.layout.dtype == dtype::Float32()) { | ||||
| MEGDNN_DISPATCH_CPU_KERN_OPR(({ | MEGDNN_DISPATCH_CPU_KERN_OPR(({ | ||||
| using T0 = typename DTypeTrait<dtype::Float16>::ctype; | using T0 = typename DTypeTrait<dtype::Float16>::ctype; | ||||
| @@ -56,10 +56,10 @@ void ConvolutionForwardImpl::exec(_megdnn_tensor_in src, | |||||
| DISPATCH(Int8, Int16, dt_int8, dt_int16, dt_int16); | DISPATCH(Int8, Int16, dt_int8, dt_int16, dt_int16); | ||||
| DISPATCH(Int8, Int32, dt_int8, dt_int32, dt_int32); | DISPATCH(Int8, Int32, dt_int8, dt_int32, dt_int32); | ||||
| DISPATCH(QuantizedS8, QuantizedS32, dt_int8, dt_int32, dt_int32); | DISPATCH(QuantizedS8, QuantizedS32, dt_int8, dt_int32, dt_int32); | ||||
| MEGDNN_INC_FLOAT16(DISPATCH_CMODE(Float16, Float16, dt_float16, | |||||
| DNN_INC_FLOAT16(DISPATCH_CMODE(Float16, Float16, dt_float16, | |||||
| dt_float16, dt_float32, | dt_float16, dt_float32, | ||||
| ComputeMode::FLOAT32)); | ComputeMode::FLOAT32)); | ||||
| MEGDNN_INC_FLOAT16(DISPATCH_CMODE(BFloat16, BFloat16, dt_bfloat16, | |||||
| DNN_INC_FLOAT16(DISPATCH_CMODE(BFloat16, BFloat16, dt_bfloat16, | |||||
| dt_bfloat16, dt_float32, | dt_bfloat16, dt_float32, | ||||
| ComputeMode::FLOAT32)); | ComputeMode::FLOAT32)); | ||||
| DISPATCH(Quantized8Asymm, QuantizedS32, dt_quint8, dt_qint32, | DISPATCH(Quantized8Asymm, QuantizedS32, dt_quint8, dt_qint32, | ||||
| @@ -49,7 +49,7 @@ void Convolution3DForwardImpl::exec(_megdnn_tensor_in src, | |||||
| #undef cb | #undef cb | ||||
| break; | break; | ||||
| case Param::DataType::FLOAT_IO16xC32: | case Param::DataType::FLOAT_IO16xC32: | ||||
| MEGDNN_INC_FLOAT16(MEGDNN_DISPATCH_CPU_KERN( | |||||
| DNN_INC_FLOAT16(MEGDNN_DISPATCH_CPU_KERN( | |||||
| static_cast<HandleImpl*>(handle()), | static_cast<HandleImpl*>(handle()), | ||||
| convolution3d::forward< | convolution3d::forward< | ||||
| dt_float16 MEGDNN_COMMA dt_float16 MEGDNN_COMMA | dt_float16 MEGDNN_COMMA dt_float16 MEGDNN_COMMA | ||||
| @@ -149,19 +149,19 @@ void GroupLocalForwardImpl::exec(_megdnn_tensor_in src, | |||||
| dst.ptr<dt_float32>(), N, IC, IH, IW, FH, FW, OC, OH, | dst.ptr<dt_float32>(), N, IC, IH, IW, FH, FW, OC, OH, | ||||
| OW, group, param().pad_h, param().pad_w, | OW, group, param().pad_h, param().pad_w, | ||||
| param().stride_h, param().stride_w)); | param().stride_h, param().stride_w)); | ||||
| } else if (MEGDNN_FLOAT16_SELECT( | |||||
| } else if (DNN_FLOAT16_SELECT( | |||||
| src.layout.dtype == dtype::Float16() && | src.layout.dtype == dtype::Float16() && | ||||
| filter.layout.dtype == dtype::Float16() && | filter.layout.dtype == dtype::Float16() && | ||||
| dst.layout.dtype == dtype::Float16(), | dst.layout.dtype == dtype::Float16(), | ||||
| false)) { | false)) { | ||||
| MEGDNN_INC_FLOAT16(MEGDNN_DISPATCH_CPU_KERN_OPR(forward( | |||||
| DNN_INC_FLOAT16(MEGDNN_DISPATCH_CPU_KERN_OPR(forward( | |||||
| src.ptr<dt_float16>(), filter.ptr<dt_float16>(), | src.ptr<dt_float16>(), filter.ptr<dt_float16>(), | ||||
| dst.ptr<dt_float16>(), N, IC, IH, IW, FH, FW, OC, OH, OW, group, | dst.ptr<dt_float16>(), N, IC, IH, IW, FH, FW, OC, OH, OW, group, | ||||
| param().pad_h, param().pad_w, param().stride_h, | param().pad_h, param().pad_w, param().stride_h, | ||||
| param().stride_w));); | param().stride_w));); | ||||
| } else { | } else { | ||||
| megdnn_assert_internal(false); | |||||
| megdnn_assert_internal(false); | |||||
| } | } | ||||
| } | } | ||||
| @@ -90,7 +90,7 @@ void dispatch_exec(HandleImpl *handle, | |||||
| MEGDNN_FOREACH_COMPUTING_DTYPE(cb) | MEGDNN_FOREACH_COMPUTING_DTYPE(cb) | ||||
| cb(::megdnn::dtype::Bool) | cb(::megdnn::dtype::Bool) | ||||
| default: | default: | ||||
| megdnn_throw(megdnn_mangle("bad dtype")); | |||||
| megdnn_throw("bad dtype"); | |||||
| } | } | ||||
| #undef cb | #undef cb | ||||
| } | } | ||||
| @@ -99,7 +99,7 @@ void IndexingOneHotForwardImpl::exec( | |||||
| MEGDNN_FOREACH_COMPUTING_DTYPE(cb) | MEGDNN_FOREACH_COMPUTING_DTYPE(cb) | ||||
| cb(megdnn::dtype::Quantized8Asymm) | cb(megdnn::dtype::Quantized8Asymm) | ||||
| default: | default: | ||||
| megdnn_throw(megdnn_mangle("bad dtype")); | |||||
| megdnn_throw("bad dtype"); | |||||
| } | } | ||||
| #undef cb | #undef cb | ||||
| } | } | ||||
| @@ -122,7 +122,7 @@ void IndexingSetOneHotForwardImpl::exec( | |||||
| MEGDNN_FOREACH_COMPUTING_DTYPE(cb) | MEGDNN_FOREACH_COMPUTING_DTYPE(cb) | ||||
| cb(megdnn::dtype::Quantized8Asymm) | cb(megdnn::dtype::Quantized8Asymm) | ||||
| default: | default: | ||||
| megdnn_throw(megdnn_mangle("bad dtype")); | |||||
| megdnn_throw("bad dtype"); | |||||
| } | } | ||||
| #undef cb | #undef cb | ||||
| } | } | ||||