-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor diagnostic to avoid circular dependencies #6692
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d73742a
Refactor diag to avoid circular dependencies
rkimball 45a6972
Fix formatting
rkimball 4fc5cd8
Add missing include
rkimball 2492c42
Address review comment
rkimball 32c0f0e
Move stuff around a bit more
rkimball 4c18a48
Fix global string
rkimball 4a7bb0c
Revert diagnostic.* filenames
rkimball 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
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
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
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
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,74 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
/*! | ||
* \file diagnostic.h | ||
* \brief A new diagnostic interface for TVM error reporting. | ||
* | ||
* A prototype of the new diagnostic reporting interface for TVM. | ||
* | ||
* Eventually we hope to promote this file to the top-level and | ||
* replace the existing errors.h. | ||
*/ | ||
|
||
#ifndef TVM_IR_DIAGNOSTIC_H_ | ||
#define TVM_IR_DIAGNOSTIC_H_ | ||
|
||
#include <dmlc/logging.h> | ||
|
||
namespace tvm { | ||
|
||
extern const char* kTVM_INTERNAL_ERROR_MESSAGE; | ||
|
||
#define ICHECK_INDENT " " | ||
|
||
#define ICHECK_BINARY_OP(name, op, x, y) \ | ||
if (dmlc::LogCheckError _check_err = dmlc::LogCheck##name(x, y)) \ | ||
dmlc::LogMessageFatal(__FILE__, __LINE__).stream() \ | ||
<< kTVM_INTERNAL_ERROR_MESSAGE << std::endl \ | ||
<< ICHECK_INDENT << "Check failed: " << #x " " #op " " #y << *(_check_err.str) << ": " | ||
|
||
#define ICHECK(x) \ | ||
if (!(x)) \ | ||
dmlc::LogMessageFatal(__FILE__, __LINE__).stream() \ | ||
<< kTVM_INTERNAL_ERROR_MESSAGE << ICHECK_INDENT << "Check failed: " #x << " == false: " | ||
|
||
#define ICHECK_LT(x, y) ICHECK_BINARY_OP(_LT, <, x, y) | ||
#define ICHECK_GT(x, y) ICHECK_BINARY_OP(_GT, >, x, y) | ||
#define ICHECK_LE(x, y) ICHECK_BINARY_OP(_LE, <=, x, y) | ||
#define ICHECK_GE(x, y) ICHECK_BINARY_OP(_GE, >=, x, y) | ||
#define ICHECK_EQ(x, y) ICHECK_BINARY_OP(_EQ, ==, x, y) | ||
#define ICHECK_NE(x, y) ICHECK_BINARY_OP(_NE, !=, x, y) | ||
#define ICHECK_NOTNULL(x) \ | ||
((x) == nullptr ? dmlc::LogMessageFatal(__FILE__, __LINE__).stream() \ | ||
<< kTVM_INTERNAL_ERROR_MESSAGE << __INDENT << "Check not null: " #x \ | ||
<< ' ', \ | ||
(x) : (x)) // NOLINT(*) | ||
|
||
/*! \brief The diagnostic level, controls the printing of the message. */ | ||
enum class DiagnosticLevel : int { | ||
kBug = 10, | ||
kError = 20, | ||
kWarning = 30, | ||
kNote = 40, | ||
kHelp = 50, | ||
}; | ||
|
||
} // namespace tvm | ||
#endif // TVM_IR_DIAGNOSTIC_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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,62 +27,20 @@ | |
* replace the existing errors.h. | ||
*/ | ||
|
||
#ifndef TVM_IR_DIAGNOSTIC_H_ | ||
#define TVM_IR_DIAGNOSTIC_H_ | ||
#ifndef TVM_IR_DIAGNOSTIC_CONTEXT_H_ | ||
#define TVM_IR_DIAGNOSTIC_CONTEXT_H_ | ||
|
||
#include <tvm/ir/module.h> | ||
#include <tvm/ir/span.h> | ||
#include <tvm/parser/source_map.h> | ||
#include <tvm/runtime/container.h> | ||
#include <tvm/runtime/object.h> | ||
#include <tvm/support/logging.h> | ||
|
||
#include <fstream> | ||
#include <sstream> | ||
#include <string> | ||
#include <utility> | ||
#include <vector> | ||
|
||
namespace tvm { | ||
|
||
using tvm::parser::SourceMap; | ||
using tvm::runtime::TypedPackedFunc; | ||
|
||
extern const char* kTVM_INTERNAL_ERROR_MESSAGE; | ||
|
||
#define ICHECK_INDENT " " | ||
|
||
#define ICHECK_BINARY_OP(name, op, x, y) \ | ||
if (dmlc::LogCheckError _check_err = dmlc::LogCheck##name(x, y)) \ | ||
dmlc::LogMessageFatal(__FILE__, __LINE__).stream() \ | ||
<< kTVM_INTERNAL_ERROR_MESSAGE << std::endl \ | ||
<< ICHECK_INDENT << "Check failed: " << #x " " #op " " #y << *(_check_err.str) << ": " | ||
|
||
#define ICHECK(x) \ | ||
if (!(x)) \ | ||
dmlc::LogMessageFatal(__FILE__, __LINE__).stream() \ | ||
<< kTVM_INTERNAL_ERROR_MESSAGE << ICHECK_INDENT << "Check failed: " #x << " == false: " | ||
|
||
#define ICHECK_LT(x, y) ICHECK_BINARY_OP(_LT, <, x, y) | ||
#define ICHECK_GT(x, y) ICHECK_BINARY_OP(_GT, >, x, y) | ||
#define ICHECK_LE(x, y) ICHECK_BINARY_OP(_LE, <=, x, y) | ||
#define ICHECK_GE(x, y) ICHECK_BINARY_OP(_GE, >=, x, y) | ||
#define ICHECK_EQ(x, y) ICHECK_BINARY_OP(_EQ, ==, x, y) | ||
#define ICHECK_NE(x, y) ICHECK_BINARY_OP(_NE, !=, x, y) | ||
#define ICHECK_NOTNULL(x) \ | ||
((x) == nullptr ? dmlc::LogMessageFatal(__FILE__, __LINE__).stream() \ | ||
<< kTVM_INTERNAL_ERROR_MESSAGE << __INDENT << "Check not null: " #x \ | ||
<< ' ', \ | ||
(x) : (x)) // NOLINT(*) | ||
|
||
/*! \brief The diagnostic level, controls the printing of the message. */ | ||
enum class DiagnosticLevel : int { | ||
kBug = 10, | ||
kError = 20, | ||
kWarning = 30, | ||
kNote = 40, | ||
kHelp = 50, | ||
}; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. diagnostic context should not be part of support, because right now it brings large amount of dep related to IR. keep it as in include/tvm/ir/diagnostic.h |
||
class DiagnosticBuilder; | ||
|
||
/*! \brief A compiler diagnostic. */ | ||
|
@@ -259,4 +217,4 @@ class DiagnosticContext : public ObjectRef { | |
DiagnosticRenderer TerminalRenderer(std::ostream& ostream); | ||
|
||
} // namespace tvm | ||
#endif // TVM_IR_DIAGNOSTIC_H_ | ||
#endif // TVM_IR_DIAGNOSTIC_CONTEXT_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
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
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
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
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.
Merge this file content with tvm/support/logging.h as previous content are already there