This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
add extra header file to export #13795
Merged
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7abcca0
add extra header file to include
apeforest c401178
fix sanity check
apeforest bc849cc
fix sanity
apeforest 8c78edd
move c_api_common.h to include folder
apeforest c781e26
fix build error
apeforest 3d41c63
keep c_api_common.h internal
apeforest d15c998
strip out error handling API into a separate header
apeforest fb67cfe
consolidate comment into one paragraph per review
apeforest ca6bc22
remove unnecessary include
apeforest 771c33b
Merge remote-tracking branch 'upstream/master' into feature/horovod
apeforest File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
/*! | ||
* Copyright (c) 2018 by Contributors | ||
* \file c_api_error.h | ||
* \brief Error handling for C API. | ||
*/ | ||
#ifndef MXNET_C_API_ERROR_H_ | ||
#define MXNET_C_API_ERROR_H_ | ||
|
||
#include <dmlc/base.h> | ||
#include <dmlc/logging.h> | ||
#include <mxnet/c_api.h> | ||
#include <mxnet/base.h> | ||
|
||
using namespace mxnet; | ||
|
||
/*! | ||
* \brief Macros to guard beginning and end section of all functions | ||
* every function starts with API_BEGIN() | ||
* and finishes with API_END() or API_END_HANDLE_ERROR() | ||
* The finally clause contains procedure to cleanup states when an error happens. | ||
*/ | ||
#define MX_API_BEGIN() try { on_enter_api(__FUNCTION__); | ||
#define MX_API_END() } catch(dmlc::Error &_except_) { on_exit_api(); return MXAPIHandleException(_except_); } on_exit_api(); return 0; // NOLINT(*) | ||
#define MX_API_END_HANDLE_ERROR(Finalize) } catch(dmlc::Error &_except_) { Finalize; on_exit_api(); return MXAPIHandleException(_except_); } on_exit_api(); return 0; // NOLINT(*) | ||
/*! | ||
* \brief Set the last error message needed by C API | ||
* \param msg The error message to set. | ||
*/ | ||
void MXAPISetLastError(const char* msg); | ||
/*! | ||
* \brief handle exception throwed out | ||
* \param e the exception | ||
* \return the return value of API after exception is handled | ||
*/ | ||
inline int MXAPIHandleException(const dmlc::Error &e) { | ||
MXAPISetLastError(e.what()); | ||
return -1; | ||
} | ||
|
||
namespace mxnet { | ||
extern void on_enter_api(const char *function); | ||
extern void on_exit_api(); | ||
} | ||
#endif // MXNET_C_API_ERROR_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are all the headers needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch. removed unnecessary headers