提交 331567af 编写于 作者: M Megvii Engine Team

fix(opencl/ci): misc opt and fix:

 1: fix megbrain test failed on mali 2.1 devices
 2: reduce ci time (about reduce 20min)

GitOrigin-RevId: 4dcdcd48a6f60da2fc84f8597db9ae2ad6e4fc2f
上级 ff6a3bb8
......@@ -603,8 +603,9 @@ TensorFormat Image2DPack4TensorFormat::make_raw(
std::max(align_axis, align_size_in_elements) <=
std::numeric_limits<uint32_t>::max());
MEGDNN_LOCK_GUARD(mtx);
auto&& ptr =
cache[(static_cast<uint64_t>(align_axis) << 32) | align_size_in_elements];
auto key = (static_cast<uint64_t>(align_axis) << 32) |
align_size_in_elements << 16 | (static_cast<size_t>(vendor_type));
auto&& ptr = cache[key];
if (!ptr) {
ptr.reset(new Image2DPack4TensorFormat{
align_axis, align_size_in_elements, vendor_type});
......
......@@ -94,10 +94,12 @@
#include "src/naive/warp_affine/opr_impl.h"
#include "src/naive/warp_perspective/opr_impl.h"
static size_t g_image2d_pitch_alignment = 1;
namespace megdnn {
namespace naive {
//! always for ci
static size_t g_image2d_pitch_alignment = 1;
static HandleImpl::HandleVendorType g_image2d_pitch_vendor =
HandleImpl::HandleVendorType::NOT_SPEC;
DefaultConvolutionForwardAlgorithm HandleImpl::m_default_conv_fwd_algo;
DefaultConvolutionBackwardDataAlgorithm HandleImpl::m_default_conv_bwd_data_algo;
......@@ -128,7 +130,7 @@ size_t HandleImpl::image2d_pitch_alignment() const {
}
HandleImpl::HandleVendorType HandleImpl::vendor_type() const {
return HandleVendorType::NOT_SPEC;
return g_image2d_pitch_vendor;
}
size_t HandleImpl::exchange_image2d_pitch_alignment(size_t alignment) {
......@@ -137,6 +139,13 @@ size_t HandleImpl::exchange_image2d_pitch_alignment(size_t alignment) {
return ret;
}
HandleImpl::HandleVendorType HandleImpl::exchange_image2d_vendor(
HandleImpl::HandleVendorType vendor) {
auto ret = g_image2d_pitch_vendor;
g_image2d_pitch_vendor = vendor;
return ret;
}
MEGDNN_FOREACH_OPR_CLASS(MEGDNN_SPECIALIZE_CREATE_OPERATOR)
} // namespace naive
......
......@@ -175,6 +175,17 @@ public:
* \param alignment the new alignment value to set
*/
static size_t exchange_image2d_pitch_alignment(size_t alignment);
/*!
* \brief set the value of HandleVendorType and return original
* setting
*
* This is only used in test cases where we need to use a naive impl on
* specific tensor format.
*
* \param vendor the new vendor type to set
*/
static HandleImpl::HandleVendorType exchange_image2d_vendor(
HandleImpl::HandleVendorType vendor);
HandleVendorType vendor_type() const override;
};
......
......@@ -142,13 +142,18 @@ std::shared_ptr<void> DynOutMallocPolicyImpl::make_output_refholder(
return {out.raw_ptr(), deleter};
}
NaivePitchAlignmentScope::NaivePitchAlignmentScope(size_t alignment)
NaivePitchAlignmentScope::NaivePitchAlignmentScope(
size_t alignment, megdnn::Handle::HandleVendorType vendor)
: m_orig_val{naive::HandleImpl::exchange_image2d_pitch_alignment(alignment)},
m_new_val{alignment} {}
m_new_val{alignment},
m_orig_vendor{naive::HandleImpl::exchange_image2d_vendor(vendor)},
m_new_vendor{vendor} {}
NaivePitchAlignmentScope::~NaivePitchAlignmentScope() {
auto r = naive::HandleImpl::exchange_image2d_pitch_alignment(m_orig_val);
megdnn_assert(r == m_new_val);
auto v = naive::HandleImpl::exchange_image2d_vendor(m_orig_vendor);
megdnn_assert(v == m_new_vendor);
}
size_t test::get_cpu_count() {
......
......@@ -399,9 +399,10 @@ static inline std::ostream& operator<<(std::ostream& ostr, const TensorLayout& l
//! change the image2d_pitch_alignment of naive handle in this scope
class NaivePitchAlignmentScope {
size_t m_orig_val, m_new_val;
megdnn::Handle::HandleVendorType m_orig_vendor, m_new_vendor;
public:
NaivePitchAlignmentScope(size_t alignment);
NaivePitchAlignmentScope(size_t alignment, megdnn::Handle::HandleVendorType vendor);
~NaivePitchAlignmentScope();
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册