-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[COLLAGE] Add more customization to support more targets #13450
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
38 commits
Select commit
Hold shift + click to select a range
3fcc2c1
[COLLAGE] Add more customization to support more targets
krishnaraj36 8a8b622
Fix the lint errors
krishnaraj36 8c509c5
Fix the lint error whitespace
krishnaraj36 2c54172
Fix the lint error tabs
krishnaraj36 c707bd9
Fix the lint error tabs
krishnaraj36 1b4114b
Fix the lint error tabs
krishnaraj36 f8b6609
move the clml collage test case to test_clml
krishnaraj36 a61b5b0
Fix lint error whitespace
krishnaraj36 40bd214
Fix the import error
krishnaraj36 021e542
Fix the envirnoment var and import
krishnaraj36 4742574
Add comments
krishnaraj36 859845a
Add clml preprocess module in cost estimator
krishnaraj36 ecd6901
Fix whitespace lint error
krishnaraj36 30acd26
Fix whitespace lint error
krishnaraj36 7b3fdf3
Fix whitespace lint error
krishnaraj36 cd0e178
Fix the comments and removed unwanted code
krishnaraj36 5cbd53d
Fix whitespace error
krishnaraj36 0414eae
Merge branch 'main' into collage_update
krishnaraj36 9ef2cad
Removed Todo comments
krishnaraj36 a935ae9
Removed TODO comments
krishnaraj36 056885e
Updated naming convension
krishnaraj36 5804b08
Fix typo error
krishnaraj36 85b25cb
Fixe the typo error
krishnaraj36 d5e10f4
Corrected typo error
krishnaraj36 5f2bd89
Corrected typo error
krishnaraj36 fb2181d
Removed unused and fix typo error
krishnaraj36 bd42a90
Removed redundent code and optimize the code
krishnaraj36 b5ca5c0
Fix the lint error
krishnaraj36 513366a
Fix whitespace lint error
krishnaraj36 af47069
Removed Prints in file
krishnaraj36 2e840f1
Fix lint error
krishnaraj36 f02d639
Fix lint error
krishnaraj36 a72b61e
Removed runner template in test script
krishnaraj36 6951d46
Fix the lint error
krishnaraj36 7367a71
Fix lint error
krishnaraj36 d2a7274
Fix lint error
krishnaraj36 9330d4b
Fix the lint error
krishnaraj36 4a3d5a2
Fix the lint error
krishnaraj36 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,4 +21,5 @@ | |
| WARMUP_MIN_REPEAT_MS, | ||
| CostEstimator, | ||
| MockCostEstimator, | ||
| CustomCostEstimator, | ||
| ) | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| /* | ||
| * 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 src/relay/collage/custom_cost_estimator.cc | ||
| * \brief A custom CostEstimator to support alternative cost functions. | ||
| */ | ||
|
|
||
| #include "./custom_cost_estimator.h" | ||
|
|
||
| #include <tvm/relay/expr_functor.h> | ||
|
|
||
| namespace tvm { | ||
| namespace relay { | ||
| namespace collage { | ||
|
|
||
| TVM_REGISTER_OBJECT_TYPE(CustomCostEstimatorNode); | ||
|
|
||
| Cost CustomCostEstimatorNode::Estimate(const IRModule& mod, const Target& target) const { | ||
| static const runtime::PackedFunc* estimate_seconds = runtime::Registry::Get(py_fn_estimator_); | ||
| ICHECK(estimate_seconds); | ||
| const double value = (*estimate_seconds)(mod, target); | ||
| if (std::isinf(value)) { | ||
| return Cost::Invalid(); | ||
| } else if (std::isnan(value)) { | ||
| return Cost::Unknown(); | ||
| } else { | ||
| return Cost::Value(value); | ||
| } | ||
| } | ||
|
|
||
| CustomCostEstimator::CustomCostEstimator(String py_fn_estimator) { | ||
| auto node = make_object<CustomCostEstimatorNode>(); | ||
| node->py_fn_estimator_ = std::move(py_fn_estimator); | ||
| data_ = std::move(node); | ||
| } | ||
|
|
||
| TVM_REGISTER_GLOBAL("relay.collage.CustomCostEstimator").set_body_typed([](String py_fn_estimator) { | ||
| return CustomCostEstimator(std::move(py_fn_estimator)); | ||
| }); | ||
|
|
||
| } // namespace collage | ||
| } // namespace relay | ||
| } // namespace tvm |
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,67 @@ | ||
| /* | ||
| * 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 src/relay/collage/custom_cost_estimator.cc | ||
| * \brief A custom CostEstimator to support target-specific cost functions. | ||
| */ | ||
|
|
||
| #ifndef TVM_RELAY_COLLAGE_CUSTOM_COST_ESTIMATOR_H_ | ||
| #define TVM_RELAY_COLLAGE_CUSTOM_COST_ESTIMATOR_H_ | ||
|
|
||
| #include <tvm/relay/function.h> | ||
|
|
||
| #include "./cost.h" | ||
| #include "./cost_estimator.h" | ||
|
|
||
| namespace tvm { | ||
| namespace relay { | ||
| namespace collage { | ||
|
|
||
| /*! | ||
| * \brief A cost estimator that uses a target-specific cost function. | ||
| */ | ||
| class CustomCostEstimatorNode : public CostEstimatorNode { | ||
| public: | ||
| Cost Estimate(const IRModule& mod, const Target& target) const override; | ||
|
|
||
| static constexpr const char* _type_key = "relay.collage.CustomCostEstimator"; | ||
| TVM_DECLARE_FINAL_OBJECT_INFO(CustomCostEstimatorNode, CostEstimatorNode); | ||
|
|
||
| protected: | ||
| /*! | ||
| * \brief Python implemented cost function name. | ||
| */ | ||
| String py_fn_estimator_; | ||
|
|
||
| friend class CustomCostEstimator; | ||
| }; | ||
|
|
||
| class CustomCostEstimator : public CostEstimator { | ||
| public: | ||
| explicit CustomCostEstimator(String py_fn_estimator); | ||
|
|
||
| TVM_DEFINE_OBJECT_REF_METHODS(CustomCostEstimator, CostEstimator, CustomCostEstimatorNode); | ||
| }; | ||
|
|
||
| } // namespace collage | ||
| } // namespace relay | ||
| } // namespace tvm | ||
|
|
||
| #endif // TVM_RELAY_COLLAGE_CUSTOM_COST_ESTIMATOR_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
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.