From 9cc732f82d70ed507f12c409b7921e2e99d52ec6 Mon Sep 17 00:00:00 2001 From: Megvii Engine Team Date: Thu, 4 Feb 2021 15:01:28 +0800 Subject: [PATCH] fix(opencl): fix opencl search algo negative stride support GitOrigin-RevId: 0642d1718d056337a8a68c7c940955de9f1bfa88 --- dnn/src/common/utils.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/dnn/src/common/utils.h b/dnn/src/common/utils.h index 5a6a7454..5f1877a8 100644 --- a/dnn/src/common/utils.h +++ b/dnn/src/common/utils.h @@ -667,6 +667,22 @@ struct CompTypeCvter { return m_workspace_bundle->get_workspace(m_workspace_idx); } }; + +/*! + * \brief get TensorND raw_ptr+low_byte pointer. + */ +inline dt_byte* get_low_ptr(const TensorND* tensor) { + return static_cast(tensor->raw_ptr) + + tensor->layout.span().low_byte; +} + +/*! + * \brief get the zero element pointer of TensorND. + */ +inline void* get_origin_ptr(const TensorND* tensor, void* ptr) { + return static_cast(static_cast(ptr) - + tensor->layout.span().low_byte); +} } // namespace megdnn // vim: syntax=cpp.doxygen -- GitLab