-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[Relay][AutoTVM] Relay op strategy #4644
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
Merged
Merged
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
42a8989
relay op strategy
icemelon 2786bf0
fix bugs
icemelon 11769f5
lint
icemelon fa77cb7
address comments
icemelon 9084221
add name to op implement
icemelon dfb9b2f
Modify topi tests (#9)
kevinthesun 1b94211
fix topi test
icemelon 3abc4ee
fix more topi test
icemelon 2df6a84
lint
icemelon 7908aa4
address comments
icemelon bde152d
x
icemelon ef20785
fix more tests & bugs
icemelon f9a41c6
Modify more tests (#10)
kevinthesun a7768bb
fix more test
icemelon 3f33c70
try to update vta using strategy
icemelon 8ef29b5
fix cpptest
icemelon 220c455
x
icemelon 2b29197
fix rebase err
icemelon ea85e73
Fix two tests (#11)
kevinthesun ca702e1
change autotvm log format
icemelon ea9720d
lint
icemelon 113a1fa
minor fix
icemelon b180456
try fix vta test
icemelon e3e7e72
fix rebase err
icemelon d872262
tweak
icemelon 58789f2
tmp hack for vta pass
icemelon fa6a9d7
fix tutorial
icemelon c1bf725
fix
icemelon 206c859
fix more tutorials
icemelon 0f36deb
fix vta tutorial
icemelon 0bf960b
minor
icemelon dd17aa1
address comments
icemelon e1669e3
fix
icemelon 5eee588
address comments
icemelon 2f3c719
fix cpptest
icemelon 0445e5a
fix docs
icemelon e496ae0
change data structure name and api
icemelon ea3dfaa
address comments
icemelon eb630ef
lint
icemelon 6cf45b5
fix rebase err
icemelon 8b0081a
updates
icemelon 3510177
fix winograd test
icemelon cf43e16
fix doc
icemelon f07d92a
rebase
icemelon 59bd399
upgrade tophub version number
icemelon 5338a57
fix bug
icemelon 24ae797
re-enable vta tsim test after tophub is upgraded
icemelon 4f1806a
fix vta test to use the correct args so the config can be found in to…
icemelon 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 hidden or 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 hidden or 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,164 @@ | ||
/* | ||
* 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 tvm/relay/op_strategy.h | ||
* \brief The Relay operator Strategy and related data structure. | ||
*/ | ||
|
||
#ifndef TVM_RELAY_OP_STRATEGY_H_ | ||
#define TVM_RELAY_OP_STRATEGY_H_ | ||
|
||
#include <tvm/te/tensor.h> | ||
#include <tvm/te/schedule.h> | ||
#include <tvm/relay/expr.h> | ||
#include <tvm/relay/op_attr_types.h> | ||
#include <tvm/target/target.h> | ||
#include <string> | ||
|
||
namespace tvm { | ||
namespace relay { | ||
|
||
/*! | ||
* \brief Operator implementation that includes compute and schedule function. | ||
*/ | ||
class OpImplementationNode : public Object { | ||
public: | ||
/*! \brief Compute function */ | ||
FTVMCompute fcompute; | ||
/*! \brief Schedule function */ | ||
FTVMSchedule fschedule; | ||
/*! \brief Name of the implementation */ | ||
std::string name; | ||
/*! \brief Priority level */ | ||
int plevel; | ||
|
||
void VisitAttrs(tvm::AttrVisitor* v) { | ||
v->Visit("name", &name); | ||
v->Visit("plevel", &plevel); | ||
} | ||
|
||
static constexpr const char* _type_key = "relay.OpImplementation"; | ||
TVM_DECLARE_FINAL_OBJECT_INFO(OpImplementationNode, Object); | ||
}; | ||
|
||
/*! | ||
* \brief Operator implementation class. | ||
*/ | ||
class OpImplementation : public ObjectRef { | ||
public: | ||
/*! | ||
* \brief Invoke the operator compute function. | ||
* \param attrs The attribute of the primitive | ||
* \param inputs The input tensors. | ||
* \param out_type The output type information. | ||
* \return The output compute description of the operator. | ||
*/ | ||
TVM_DLL Array<te::Tensor> Compute(const Attrs& attrs, | ||
const Array<te::Tensor>& inputs, | ||
const Type& out_type); | ||
/*! | ||
* \brief Build the computation schedule. | ||
* \param attrs The attribute of the node. | ||
* \param outs The output tensors. | ||
* \param target The build target. | ||
* \return The computation schedule. | ||
*/ | ||
TVM_DLL te::Schedule Schedule(const Attrs& attrs, | ||
const Array<te::Tensor>& outs, | ||
const Target& target); | ||
|
||
TVM_DEFINE_OBJECT_REF_METHODS(OpImplementation, ObjectRef, OpImplementationNode); | ||
}; | ||
|
||
/*! | ||
* \brief Specialized implementations for operators under certain conditions. | ||
*/ | ||
class OpSpecializationNode : public Object { | ||
public: | ||
/*! \brief List of implementations. */ | ||
Array<OpImplementation> implementations; | ||
/*! \brief Condition to enable the specialization. | ||
* Could be undefined to represent generic case. */ | ||
te::SpecializedCondition condition; | ||
|
||
void VisitAttrs(tvm::AttrVisitor* v) { | ||
v->Visit("condition", &condition); | ||
v->Visit("implementations", &implementations); | ||
} | ||
|
||
static constexpr const char* _type_key = "relay.OpSpecialization"; | ||
TVM_DECLARE_FINAL_OBJECT_INFO(OpSpecializationNode, ExprNode); | ||
}; | ||
|
||
/*! | ||
* \brief Operator specialization class. | ||
*/ | ||
class OpSpecialization : public ObjectRef { | ||
public: | ||
/*! | ||
* \brief Add an implementation. | ||
* \param fcompute Compute function | ||
* \param fschedule Schedule function | ||
* \param name Name of the implementation | ||
* \param plevel Priority level of the implementation | ||
*/ | ||
TVM_DLL void AddImplementation(FTVMCompute fcompute, FTVMSchedule fschedule, | ||
std::string name, int plevel); | ||
|
||
TVM_DEFINE_MUTABLE_OBJECT_REF_METHODS(OpSpecialization, ObjectRef, OpSpecializationNode); | ||
}; | ||
|
||
/*! | ||
* \brief Operator strategy to choose implementation. | ||
*/ | ||
class OpStrategyNode : public Object { | ||
public: | ||
/*! \brief List of operator specializations. */ | ||
Array<OpSpecialization> specializations; | ||
|
||
void VisitAttrs(tvm::AttrVisitor* v) { | ||
v->Visit("specializations", &specializations); | ||
} | ||
|
||
static constexpr const char* _type_key = "relay.OpStrategy"; | ||
TVM_DECLARE_FINAL_OBJECT_INFO(OpStrategyNode, ExprNode); | ||
}; | ||
|
||
/*! | ||
* \brief Operator strategy class. | ||
*/ | ||
class OpStrategy : public ObjectRef { | ||
public: | ||
/*! | ||
* \brief Add an implementation. | ||
* \param fcompute Compute function | ||
* \param fschedule Schedule function | ||
* \param name Name of the implementation | ||
* \param plevel Priority level of the implementation | ||
*/ | ||
TVM_DLL void AddImplementation(FTVMCompute fcompute, FTVMSchedule fschedule, | ||
std::string name, int plevel); | ||
|
||
TVM_DEFINE_MUTABLE_OBJECT_REF_METHODS(OpStrategy, ObjectRef, OpStrategyNode); | ||
}; | ||
|
||
} // namespace relay | ||
} // namespace tvm | ||
#endif // TVM_RELAY_OP_STRATEGY_H_ |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.