-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Function Adds some properties #1216
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,7 +153,36 @@ class FunctionBase { | |
|
||
virtual void calc(const BufferArgs& inputs, const BufferArgs& outputs) {} | ||
|
||
// This member function is used to check whether the BufferType and shape of | ||
// the inputs and outputs arguments of the Function are correct. | ||
// General calc function which will call this check to do arguments check. | ||
// And before the calc called, the caller can also check their own arguments. | ||
virtual void check(const BufferArgs& inputs, const BufferArgs& outputs) {} | ||
|
||
// Calculate the number of floating-point operations of this Function. | ||
// The inputs and outputs arguments do not need to contain the actual data, | ||
// only the shape. | ||
// And some Functions have the same input and output shapes, | ||
// so you may not need to enter the complete number of arguments. | ||
// But entering the full arguments is always correct for this interface. | ||
virtual size_t ops(const BufferArgs& inputs, const BufferArgs& outputs) { | ||
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. Can we use timestamp to measure the running time of the operators? 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. 嗯,后续再考虑如何获取运行实现,这里先描述operators数。 |
||
return 0; | ||
} | ||
|
||
int getNumInputs() const { return numInputs_; } | ||
|
||
int getNumOutputs() const { return numOutputs_; } | ||
|
||
static ClassRegistrar<FunctionBase> funcRegistrar_; | ||
|
||
protected: | ||
// numInputs_ and numOutputs_ represents the maximum | ||
// input and output supported by Function. | ||
// Some functions are optimized for input and output, | ||
// so when comparing the number of arguments, for these functions | ||
// inputs.size() <= numInputs_ or outputs.size() <= numOutputs_ | ||
size_t numInputs_; | ||
size_t numOutputs_; | ||
}; | ||
|
||
#define FUNC_NAME(typeName, deviceName) #typeName "-" #deviceName | ||
|
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.
I think we can move the CHECK of argType into check funciton.
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.
我觉得先放calc里面吧,API的参数可能跟ASSIGN_TO/ADD_TO有关,放这里会清楚一些。