 feat(bazel/windows/xp/sp2/inference): implement inference on windows xp
(os vesion >= sp2) build with bazel
* bazel build support(define __DEPLOY_ON_XP_SP2__ when deploy on xp sp2):
(dbg)./bazel build //brain/megbrain:load_and_run --cpu='x86_windows_xp'
--compiler='clang_cl' -c dbg --copt "-D__DEPLOY_ON_XP_SP2__=1"
(opt)./bazel build //brain/megbrain:load_and_run --cpu='x86_windows_xp'
--compiler='clang_cl' -c opt --copt "-D__DEPLOY_ON_XP_SP2__=1"
* internal behavior:
will define MGB_HAVE_THREAD=0 when enable __DEPLOY_ON_XP_SP2__
* refer to
https://docs.microsoft.com/en-us/cpp/build/configuring-programs-for-windows-xp?view=msvc-160
xp sp2(x86) do not support vc runtime fully, casused by KERNEL32.dll do not
implement some base apis for c++ std function, for example,
std::mutex/std::thread/std::condition_variable as a workround, we will
disable some MegEngine features on xp sp2 env, for exampe, multi-thread etc!
* about DNN_MUTEX/MGB_MUTEX, if your code will build in inference
code (even CPU backends), please replace std::mutex to DNN_MUTEX/MGB_MUTEX,
* about multi-thread, if you code need multi-thread support, please
enable it when MGB_HAVE_THREAD=1
* about test build env status
1: Visual Studio 2019(MSVC version <= 14.26.28801)---- pass
2: Visual Studio 2019(MSVC version > 14.26.28801) ---- failed
caused by this 'new' version will put VCR depends on win7
KERNEL32.DLL, this may be fixed at Visual Studio 2019 later version
but we do not test at this MR merge point
3: Visual Studio 2017 ---------- pass
4: Visual Studio 2014 ---------- pass
GitOrigin-RevId: 65ac48b95e99f2c510fe5db449cc8182d682e113
3 years ago  feat(bazel/windows/xp/sp2/inference): implement inference on windows xp
(os vesion >= sp2) build with bazel
* bazel build support(define __DEPLOY_ON_XP_SP2__ when deploy on xp sp2):
(dbg)./bazel build //brain/megbrain:load_and_run --cpu='x86_windows_xp'
--compiler='clang_cl' -c dbg --copt "-D__DEPLOY_ON_XP_SP2__=1"
(opt)./bazel build //brain/megbrain:load_and_run --cpu='x86_windows_xp'
--compiler='clang_cl' -c opt --copt "-D__DEPLOY_ON_XP_SP2__=1"
* internal behavior:
will define MGB_HAVE_THREAD=0 when enable __DEPLOY_ON_XP_SP2__
* refer to
https://docs.microsoft.com/en-us/cpp/build/configuring-programs-for-windows-xp?view=msvc-160
xp sp2(x86) do not support vc runtime fully, casused by KERNEL32.dll do not
implement some base apis for c++ std function, for example,
std::mutex/std::thread/std::condition_variable as a workround, we will
disable some MegEngine features on xp sp2 env, for exampe, multi-thread etc!
* about DNN_MUTEX/MGB_MUTEX, if your code will build in inference
code (even CPU backends), please replace std::mutex to DNN_MUTEX/MGB_MUTEX,
* about multi-thread, if you code need multi-thread support, please
enable it when MGB_HAVE_THREAD=1
* about test build env status
1: Visual Studio 2019(MSVC version <= 14.26.28801)---- pass
2: Visual Studio 2019(MSVC version > 14.26.28801) ---- failed
caused by this 'new' version will put VCR depends on win7
KERNEL32.DLL, this may be fixed at Visual Studio 2019 later version
but we do not test at this MR merge point
3: Visual Studio 2017 ---------- pass
4: Visual Studio 2014 ---------- pass
GitOrigin-RevId: 65ac48b95e99f2c510fe5db449cc8182d682e113
3 years ago |
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- /**
- * \file dnn/src/common/handle_impl.h
- * MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
- *
- * Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- */
-
- #pragma once
-
- #include "megdnn/handle.h"
- #include "megdnn/oprs.h"
-
- #include "src/common/utils.h"
-
- #include <mutex>
-
- #include "midout.h"
-
- MIDOUT_DECL(dnn_src_common_handle_impl)
-
- namespace megdnn {
-
- class HandleImplHelper : public Handle {
- public:
- using Handle::Handle;
-
- //! global matmul opr
- virtual MatrixMul* matmul_opr() { megdnn_throw("Unimplement matmul opr.\n"); }
-
- //! global matmul opr with first operand transposed
- virtual MatrixMul* matmul_aT_opr() { megdnn_throw("Unimplement matmul_aT opr.\n"); }
-
- //! global matmul opr with second operand transposed
- virtual MatrixMul* matmul_bT_opr() { megdnn_throw("Unimplement matmul_bT opr.\n"); }
-
- //! global matmul opr with both operand transposed
- virtual MatrixMul* matmul_aT_bT_opr() {
- megdnn_throw("Unimplement matmul_aT_bT opr.\n");
- }
-
- //! global relayout opr
- virtual Relayout* relayout_opr() { megdnn_throw("Unimplement Relayout opr.\n"); }
-
- virtual Checksum* checksum_opr() { megdnn_throw("Unimplement Checksum opr.\n"); }
-
- virtual MaxTensorDiff* max_tensor_diff_opr() {
- megdnn_throw("Unimplement MaxTensorDiff opr.\n");
- }
-
- protected:
- static constexpr size_t NR_HELPER_OPRS = 7;
-
- template <class Opr, size_t idx, class Self>
- static Opr* get_helper_opr(Self self, const typename Opr::Param& param = {}) {
- MIDOUT_BEGIN(dnn_src_common_handle_impl, Opr, idx) {
- static_assert(idx < NR_HELPER_OPRS, "invalid idx");
- if (!self->m_helper_oprs[idx]) {
- MEGDNN_LOCK_GUARD(self->m_helper_oprs_mtx);
- if (!self->m_helper_oprs[idx]) {
- self->m_helper_oprs[idx] = self->template create_operator<Opr>();
- auto ret = static_cast<Opr*>(self->m_helper_oprs[idx].get());
- ret->param() = param;
- megdnn_assert(ret->is_thread_safe());
- return ret;
- }
- }
- return static_cast<Opr*>(self->m_helper_oprs[idx].get());
- }
- MIDOUT_END();
- }
-
- private:
- std::array<std::unique_ptr<OperatorBase>, NR_HELPER_OPRS> m_helper_oprs;
- DNN_MUTEX m_helper_oprs_mtx;
- };
-
- } // namespace megdnn
- /*!
- * \brief iterate though each operator class name; useful for explicit
- * instantialization of create_operator<> templates
- */
- // clang-format off
- #define MEGDNN_FOREACH_OPR_CLASS(cb) \
- cb(ConvolutionForward) \
- cb(ConvolutionBackwardData) \
- cb(ConvolutionBackwardFilter) \
- cb(ConvPoolingForward) \
- cb(ConvBiasForward) \
- cb(Images2NeibsForward) \
- cb(Images2NeibsBackward) \
- cb(SlidingWindowTransposeForward) \
- cb(SlidingWindowTransposeBackward) \
- cb(ElemwiseForward) \
- cb(ElemwiseMultiType) \
- cb(AddUpdateForward) \
- cb(RelayoutForward) \
- cb(PoolingForward) \
- cb(PoolingBackward) \
- cb(LocalForward) \
- cb(LocalBackwardData) \
- cb(LocalBackwardFilter) \
- cb(LRNForward) \
- cb(LRNBackward) \
- cb(ROIPoolingForward) \
- cb(ROIPoolingBackward) \
- cb(WarpPerspectiveForward) \
- cb(WarpPerspectiveBackwardData) \
- cb(WarpPerspectiveBackwardMat) \
- cb(DotForward) \
- cb(MatrixInverse) \
- cb(MatrixMulForward) \
- cb(BatchedMatrixMulForward) \
- cb(SVDForward) \
- cb(ReduceForward) \
- cb(CondTake) \
- cb(CumsumForward) \
- cb(ArgmaxForward) \
- cb(ArgminForward) \
- cb(TransposeForward) \
- cb(ConcatForward) \
- cb(SplitForward) \
- cb(TileForward) \
- cb(TileBackward) \
- cb(RepeatForward) \
- cb(RepeatBackward) \
- cb(ArgsortForward) \
- cb(ArgsortBackward) \
- cb(TypeCvt) \
- cb(IndexingRemapForward) \
- cb(IndexingRemapBackward) \
- cb(ChecksumForward) \
- cb(IndexingOneHotForward) \
- cb(IndexingSetOneHotForward) \
- cb(IndexingMultiAxisVec) \
- cb(IndexingSetMultiAxisVec) \
- cb(IndexingIncrMultiAxisVec) \
- cb(MeshIndexing) \
- cb(IncrMeshIndexing) \
- cb(SetMeshIndexing) \
- cb(BatchedMeshIndexing) \
- cb(BatchedIncrMeshIndexing) \
- cb(BatchedSetMeshIndexing) \
- cb(Linspace) \
- cb(Eye) \
- cb(SleepForward) \
- cb(UniformRNG) \
- cb(GaussianRNG) \
- cb(GammaRNG) \
- cb(BetaRNG) \
- cb(PoissonRNG) \
- cb(PermutationRNG) \
- cb(ShuffleRNGForward) \
- cb(ShuffleRNGBackward) \
- cb(SeparableConvForward) \
- cb(SeparableFilterForward) \
- cb(BNForward) \
- cb(BNBackward) \
- cb(GroupLocalForward) \
- cb(GroupLocalBackwardData) \
- cb(GroupLocalBackwardFilter) \
- cb(Flip) \
- cb(Rotate) \
- cb(ROICopy) \
- cb(CvtColor) \
- cb(WarpAffine) \
- cb(GaussianBlur) \
- cb(Resize) \
- cb(ResizeBackward) \
- cb(ParamPackConcat) \
- cb(MaxTensorDiff) \
- cb(MaskConvForward) \
- cb(MaskPropagate) \
- cb(Convolution3DForward) \
- cb(Convolution3DBackwardData) \
- cb(Convolution3DBackwardFilter) \
- cb(DeformableConvForward) \
- cb(DeformableConvBackwardFilter) \
- cb(DeformableConvBackwardData) \
- cb(DeformablePSROIPoolingForward) \
- cb(DeformablePSROIPoolingBackward) \
- cb(RelayoutFormat) \
- cb(TopK) \
- cb(PowC) \
- cb(LocalShareForward) \
- cb(LocalShareBackwardData) \
- cb(LocalShareBackwardFilter) \
- cb(ROIAlignForward) \
- cb(ROIAlignBackward) \
- cb(CorrelationForward) \
- cb(CorrelationBackwardData1) \
- cb(CorrelationBackwardData2) \
- cb(BatchConvBiasForward) \
- cb(Remap) \
- cb(RemapBackwardData) \
- cb(RemapBackwardMat) \
- cb(AdaptivePoolingForward) \
- cb(AdaptivePoolingBackward) \
- cb(DctChannelSelectForward) \
- cb(FakeQuantForward) \
- cb(FakeQuantBackward) \
- cb(TQTForward) \
- cb(TQTBackward) \
- cb(CheckNonFinite) \
- cb(LSQForward) \
- cb(LSQBackward) \
- cb(Fill) \
- cb(PaddingForward) \
- cb(PaddingBackward)
- // clang-format on
-
- /*!
- * \brief specialize HandleImpl::create_operator for a single opr type;
- * implemented by <opr>Impl class
- */
- #define MEGDNN_SPECIALIZE_CREATE_OPERATOR(opr) \
- template <> \
- std::unique_ptr<megdnn::opr> HandleImpl::create_operator() { \
- return megdnn::make_unique<opr##Impl>(this); \
- }
-
- /*!
- * \brief for explicit instantiation for HandleImpl::create_operator methods
- */
- #define MEGDNN_INST_CREATE_OPERATOR(opr) \
- template std::unique_ptr<megdnn::opr> HandleImpl::create_operator();
-
- // vim: syntax=cpp.doxygen
|