提交 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( ...@@ -603,8 +603,9 @@ TensorFormat Image2DPack4TensorFormat::make_raw(
std::max(align_axis, align_size_in_elements) <= std::max(align_axis, align_size_in_elements) <=
std::numeric_limits<uint32_t>::max()); std::numeric_limits<uint32_t>::max());
MEGDNN_LOCK_GUARD(mtx); MEGDNN_LOCK_GUARD(mtx);
auto&& ptr = auto key = (static_cast<uint64_t>(align_axis) << 32) |
cache[(static_cast<uint64_t>(align_axis) << 32) | align_size_in_elements]; align_size_in_elements << 16 | (static_cast<size_t>(vendor_type));
auto&& ptr = cache[key];
if (!ptr) { if (!ptr) {
ptr.reset(new Image2DPack4TensorFormat{ ptr.reset(new Image2DPack4TensorFormat{
align_axis, align_size_in_elements, vendor_type}); align_axis, align_size_in_elements, vendor_type});
......
...@@ -94,10 +94,12 @@ ...@@ -94,10 +94,12 @@
#include "src/naive/warp_affine/opr_impl.h" #include "src/naive/warp_affine/opr_impl.h"
#include "src/naive/warp_perspective/opr_impl.h" #include "src/naive/warp_perspective/opr_impl.h"
static size_t g_image2d_pitch_alignment = 1;
namespace megdnn { namespace megdnn {
namespace naive { 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; DefaultConvolutionForwardAlgorithm HandleImpl::m_default_conv_fwd_algo;
DefaultConvolutionBackwardDataAlgorithm HandleImpl::m_default_conv_bwd_data_algo; DefaultConvolutionBackwardDataAlgorithm HandleImpl::m_default_conv_bwd_data_algo;
...@@ -128,7 +130,7 @@ size_t HandleImpl::image2d_pitch_alignment() const { ...@@ -128,7 +130,7 @@ size_t HandleImpl::image2d_pitch_alignment() const {
} }
HandleImpl::HandleVendorType HandleImpl::vendor_type() 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) { size_t HandleImpl::exchange_image2d_pitch_alignment(size_t alignment) {
...@@ -137,9 +139,16 @@ size_t HandleImpl::exchange_image2d_pitch_alignment(size_t alignment) { ...@@ -137,9 +139,16 @@ size_t HandleImpl::exchange_image2d_pitch_alignment(size_t alignment) {
return ret; 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) MEGDNN_FOREACH_OPR_CLASS(MEGDNN_SPECIALIZE_CREATE_OPERATOR)
} // namespace naive } // namespace naive
} // namespace megdnn } // namespace megdnn
// vim: syntax=cpp.doxygen // vim: syntax=cpp.doxygen
\ No newline at end of file
...@@ -175,6 +175,17 @@ public: ...@@ -175,6 +175,17 @@ public:
* \param alignment the new alignment value to set * \param alignment the new alignment value to set
*/ */
static size_t exchange_image2d_pitch_alignment(size_t alignment); 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; HandleVendorType vendor_type() const override;
}; };
......
...@@ -142,13 +142,18 @@ std::shared_ptr<void> DynOutMallocPolicyImpl::make_output_refholder( ...@@ -142,13 +142,18 @@ std::shared_ptr<void> DynOutMallocPolicyImpl::make_output_refholder(
return {out.raw_ptr(), deleter}; 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_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() { NaivePitchAlignmentScope::~NaivePitchAlignmentScope() {
auto r = naive::HandleImpl::exchange_image2d_pitch_alignment(m_orig_val); auto r = naive::HandleImpl::exchange_image2d_pitch_alignment(m_orig_val);
megdnn_assert(r == m_new_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() { size_t test::get_cpu_count() {
......
...@@ -399,9 +399,10 @@ static inline std::ostream& operator<<(std::ostream& ostr, const TensorLayout& l ...@@ -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 //! change the image2d_pitch_alignment of naive handle in this scope
class NaivePitchAlignmentScope { class NaivePitchAlignmentScope {
size_t m_orig_val, m_new_val; size_t m_orig_val, m_new_val;
megdnn::Handle::HandleVendorType m_orig_vendor, m_new_vendor;
public: public:
NaivePitchAlignmentScope(size_t alignment); NaivePitchAlignmentScope(size_t alignment, megdnn::Handle::HandleVendorType vendor);
~NaivePitchAlignmentScope(); ~NaivePitchAlignmentScope();
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册