!39997 replace SUPPORT_MSVC by _MSC_VER
Merge pull request !39997 from chenminmin/master
This commit is contained in:
commit
2803de7b27
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
#ifdef ENABLE_SSE
|
#ifdef ENABLE_SSE
|
||||||
#ifdef SUPPORT_MSVC
|
#ifdef _MSC_VER
|
||||||
#include <immintrin.h>
|
#include <immintrin.h>
|
||||||
#else
|
#else
|
||||||
#include <x86intrin.h>
|
#include <x86intrin.h>
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include "nnacl/fp32/pack_fp32.h"
|
#include "nnacl/fp32/pack_fp32.h"
|
||||||
#include "nnacl/intrinsics/ms_simd_instructions.h"
|
#include "nnacl/intrinsics/ms_simd_instructions.h"
|
||||||
|
|
||||||
#ifdef SUPPORT_MSVC
|
#ifdef _MSC_VER
|
||||||
void AddMatrix(const float *v1, float *v2, float beta, int row, int col, int stride) {
|
void AddMatrix(const float *v1, float *v2, float beta, int row, int col, int stride) {
|
||||||
#else
|
#else
|
||||||
void AddMatrix(const float *restrict v1, float *restrict v2, float beta, int row, int col, int stride) {
|
void AddMatrix(const float *restrict v1, float *restrict v2, float beta, int row, int col, int stride) {
|
||||||
|
|
|
@ -132,8 +132,8 @@ class RegisterHostDependsHelper {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Processes such as InferShape need to obtain some inputs value on the host
|
// Processes such as InferShape need to obtain some inputs value on the host
|
||||||
#define REGISTER_HOST_DEPENDS(name, depends...) \
|
#define REGISTER_HOST_DEPENDS(name, ...) \
|
||||||
static auto helper_host_depends_##name = abstract::RegisterHostDependsHelper(name, ##depends);
|
static auto helper_host_depends_##name = abstract::RegisterHostDependsHelper(name, __VA_ARGS__);
|
||||||
} // namespace abstract
|
} // namespace abstract
|
||||||
} // namespace mindspore
|
} // namespace mindspore
|
||||||
#endif // MINDSPORE_CORE_ABSTRACT_PRIMITIVE_INFER_MAP_H_
|
#endif // MINDSPORE_CORE_ABSTRACT_PRIMITIVE_INFER_MAP_H_
|
||||||
|
|
|
@ -444,20 +444,7 @@ void reset_id_with_offset() {
|
||||||
} // namespace id_generator
|
} // namespace id_generator
|
||||||
auto constexpr kTargetUnDefined = "kTargetUnDefined";
|
auto constexpr kTargetUnDefined = "kTargetUnDefined";
|
||||||
auto constexpr kPrimitiveTarget = "primitive_target";
|
auto constexpr kPrimitiveTarget = "primitive_target";
|
||||||
auto constexpr kNotSupportOpForDevice = "not_support_op_for_device";
|
|
||||||
namespace {
|
namespace {
|
||||||
__attribute__((unused)) void SetCNodeNotSupported(const CNodePtr &node, const std::string &device_name) {
|
|
||||||
MS_EXCEPTION_IF_NULL(node);
|
|
||||||
auto primitive = GetCNodePrimitive(node);
|
|
||||||
if (primitive != nullptr) {
|
|
||||||
auto value = MakeValue(device_name);
|
|
||||||
primitive->set_attr(kNotSupportOpForDevice, value);
|
|
||||||
} else {
|
|
||||||
MS_LOG(ERROR) << "Get cnode " << node->fullname_with_scope() << "'s primitive failed in device " << device_name;
|
|
||||||
}
|
|
||||||
MS_LOG(INFO) << "Cnode " << node->fullname_with_scope() << " is not supported for device " << device_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
PrimitivePtr GetPrimitiveFromValueNode(const AnfNodePtr &node) {
|
PrimitivePtr GetPrimitiveFromValueNode(const AnfNodePtr &node) {
|
||||||
auto value_node = dyn_cast_ptr<ValueNode>(node);
|
auto value_node = dyn_cast_ptr<ValueNode>(node);
|
||||||
if (value_node == nullptr) {
|
if (value_node == nullptr) {
|
||||||
|
|
|
@ -1191,8 +1191,6 @@ MS_CORE_API void reset_id_with_offset();
|
||||||
using TaggedNodeMap = mindspore::HashMap<AnfNodePtr, size_t>;
|
using TaggedNodeMap = mindspore::HashMap<AnfNodePtr, size_t>;
|
||||||
using TaggedGraph = std::pair<FuncGraphPtr, TaggedNodeMap>;
|
using TaggedGraph = std::pair<FuncGraphPtr, TaggedNodeMap>;
|
||||||
MS_CORE_API std::string GetCNodeTarget(const AnfNodePtr &node);
|
MS_CORE_API std::string GetCNodeTarget(const AnfNodePtr &node);
|
||||||
// mark Cnode as not support for specify device
|
|
||||||
MS_CORE_API void SetCNodeNotSupported(const CNodePtr &node, std::string device_name);
|
|
||||||
std::string GetOriginNodeTarget(const AnfNodePtr &node);
|
std::string GetOriginNodeTarget(const AnfNodePtr &node);
|
||||||
MS_CORE_API bool ContainMultiTarget(const std::vector<AnfNodePtr> &nodes);
|
MS_CORE_API bool ContainMultiTarget(const std::vector<AnfNodePtr> &nodes);
|
||||||
struct GraphSegment {
|
struct GraphSegment {
|
||||||
|
|
|
@ -27,7 +27,7 @@ void ActorWorker::CreateThread() { thread_ = std::thread(&ActorWorker::RunWithSp
|
||||||
|
|
||||||
void ActorWorker::RunWithSpin() {
|
void ActorWorker::RunWithSpin() {
|
||||||
SetAffinity();
|
SetAffinity();
|
||||||
#if !defined(__APPLE__) && !defined(SUPPORT_MSVC)
|
#if !defined(__APPLE__) && !defined(_MSC_VER)
|
||||||
static std::atomic_int index = {0};
|
static std::atomic_int index = {0};
|
||||||
(void)pthread_setname_np(pthread_self(), ("ActorThread_" + std::to_string(index++)).c_str());
|
(void)pthread_setname_np(pthread_self(), ("ActorThread_" + std::to_string(index++)).c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -27,7 +27,7 @@ void ParallelWorker::CreateThread() { thread_ = std::thread(&ParallelWorker::Run
|
||||||
|
|
||||||
void ParallelWorker::Run() {
|
void ParallelWorker::Run() {
|
||||||
SetAffinity();
|
SetAffinity();
|
||||||
#if !defined(__APPLE__) && !defined(SUPPORT_MSVC)
|
#if !defined(__APPLE__) && !defined(_MSC_VER)
|
||||||
(void)pthread_setname_np(pthread_self(), ("ParallelThread_" + std::to_string(worker_id_)).c_str());
|
(void)pthread_setname_np(pthread_self(), ("ParallelThread_" + std::to_string(worker_id_)).c_str());
|
||||||
#endif
|
#endif
|
||||||
#ifdef PLATFORM_86
|
#ifdef PLATFORM_86
|
||||||
|
|
|
@ -60,7 +60,7 @@ void Worker::SetAffinity() {
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
#else
|
#else
|
||||||
#if !defined(__APPLE__) && !defined(SUPPORT_MSVC)
|
#if !defined(__APPLE__) && !defined(_MSC_VER)
|
||||||
int ret = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &mask_);
|
int ret = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &mask_);
|
||||||
if (ret != THREAD_OK) {
|
if (ret != THREAD_OK) {
|
||||||
THREAD_ERROR("bind thread %lu to cpu failed. ERROR %d", pthread_self(), errno);
|
THREAD_ERROR("bind thread %lu to cpu failed. ERROR %d", pthread_self(), errno);
|
||||||
|
@ -91,7 +91,7 @@ void Worker::InitWorkerMask(const std::vector<int> &core_list, const size_t work
|
||||||
|
|
||||||
void Worker::Run() {
|
void Worker::Run() {
|
||||||
SetAffinity();
|
SetAffinity();
|
||||||
#if !defined(__APPLE__) && !defined(SUPPORT_MSVC)
|
#if !defined(__APPLE__) && !defined(_MSC_VER)
|
||||||
static std::atomic_int index = {0};
|
static std::atomic_int index = {0};
|
||||||
(void)pthread_setname_np(pthread_self(), ("KernelThread_" + std::to_string(index++)).c_str());
|
(void)pthread_setname_np(pthread_self(), ("KernelThread_" + std::to_string(index++)).c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#define HANDLER_DEFINE(return_type, name, args...) \
|
#define HANDLER_DEFINE(return_type, name, ...) \
|
||||||
public: \
|
public: \
|
||||||
template <typename... Args> \
|
template <typename... Args> \
|
||||||
static return_type name(const Args &... argss) { \
|
static return_type name(const Args &... argss) { \
|
||||||
|
@ -28,7 +28,7 @@
|
||||||
} \
|
} \
|
||||||
return name##_handler_(argss...); \
|
return name##_handler_(argss...); \
|
||||||
} \
|
} \
|
||||||
using name##Handler = std::function<decltype(name<args>)>; \
|
using name##Handler = std::function<decltype(name<__VA_ARGS__>)>; \
|
||||||
static void Set##name##Handler(name##Handler handler) { name##_handler_ = std::move(handler); } \
|
static void Set##name##Handler(name##Handler handler) { name##_handler_ = std::move(handler); } \
|
||||||
\
|
\
|
||||||
private: \
|
private: \
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
add_compile_definitions(SUPPORT_MSVC)
|
|
||||||
add_compile_definitions(_ENABLE_ATOMIC_ALIGNMENT_FIX)
|
add_compile_definitions(_ENABLE_ATOMIC_ALIGNMENT_FIX)
|
||||||
set(CMAKE_C_FLAGS "/O2 /EHsc /GS /Zi /utf-8")
|
set(CMAKE_C_FLAGS "/O2 /EHsc /GS /Zi /utf-8")
|
||||||
set(CMAKE_CXX_FLAGS "/O2 /EHsc /GS /Zi /utf-8 /std:c++17")
|
set(CMAKE_CXX_FLAGS "/O2 /EHsc /GS /Zi /utf-8 /std:c++17")
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
namespace mindspore {
|
namespace mindspore {
|
||||||
namespace lite {
|
namespace lite {
|
||||||
uint64_t GetTimeUs() {
|
uint64_t GetTimeUs() {
|
||||||
#ifdef SUPPORT_MSVC
|
#ifdef _MSC_VER
|
||||||
const int sec_to_us = 1000000;
|
const int sec_to_us = 1000000;
|
||||||
LARGE_INTEGER cur_time, frequency;
|
LARGE_INTEGER cur_time, frequency;
|
||||||
QueryPerformanceCounter(&cur_time);
|
QueryPerformanceCounter(&cur_time);
|
||||||
|
|
|
@ -577,7 +577,7 @@ int Model::Export(Model *model, const char *filename) {
|
||||||
ofs.seekp(0, std::ios::beg);
|
ofs.seekp(0, std::ios::beg);
|
||||||
ofs.write(liteModel->buf, liteModel->buf_size_);
|
ofs.write(liteModel->buf, liteModel->buf_size_);
|
||||||
ofs.close();
|
ofs.close();
|
||||||
#ifdef SUPPORT_MSVC
|
#ifdef _MSC_VER
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
#else
|
#else
|
||||||
return chmod(filename, S_IRUSR);
|
return chmod(filename, S_IRUSR);
|
||||||
|
|
Loading…
Reference in New Issue