-
Notifications
You must be signed in to change notification settings - Fork 53
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
Initial resize scheduler #3556
Open
naoyam
wants to merge
31
commits into
main
Choose a base branch
from
resize_scheduler_initial_version
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Initial resize scheduler #3556
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
11f5dce
Always enable IdModel-based indexing when resize is used
naoyam 05ea88f
Don't run the tests without IdModel
naoyam 0ad9fea
fix
naoyam 4f14988
Allocation ordering fix
naoyam f3ce2d9
Merge remote-tracking branch 'origin/enable_id_model_for_resize' into…
naoyam 0d35147
rotation + residual
naoyam 7934e63
wip
naoyam 9e71bc5
move DomainMap to its own file
naoyam 57600bd
Use the reference finder of pointwise scheduler
naoyam 25ebe94
use the scheduler in the resize test
naoyam 55b8499
WIP
naoyam 791c85b
Merge remote-tracking branch 'origin/main' into resize_scheduler_init…
naoyam 839f23c
cleanup
naoyam 7a10f02
WAR
naoyam c80dd91
Fix the failed alias test thanks to @wujingyue
naoyam 9167cf0
cleanup
naoyam df63df2
cleanup
naoyam 52acb42
cleanup
naoyam 6363298
Merge branch 'main' into resize_scheduler_initial_version
naoyam ca09b93
Merge branch 'main' into resize_scheduler_initial_version
naoyam 0d0a4d6
PR feedback
naoyam be3aee9
fix
naoyam 4368e80
Rename DomainMap to PointwiseDomainMap
naoyam 2a6f059
Merge remote-tracking branch 'origin/main' into resize_scheduler_init…
naoyam 91e7d3e
Merge remote-tracking branch 'origin/main' into resize_scheduler_init…
naoyam 96ac0fa
merge fix
naoyam 7e9413a
python frontend fix
naoyam 40dd2c2
fix pattern match
naoyam 8056cfa
fix
naoyam b9415e1
test fix
naoyam aebfd51
Disable segmentation
naoyam 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,37 +29,6 @@ namespace { | |
// Unused at the moment, commenting for clang tidy | ||
constexpr int64_t kThreadX = 128; | ||
|
||
class DomainMap : public pointwise_utils::DomainMap { | ||
public: | ||
using pointwise_utils::DomainMap::DomainMap; | ||
|
||
// The pointwise scheduler heuristics requires a minimum number of axes. | ||
// The output reference tensor should respect this requirement. | ||
TensorView* findReferenceTensorView(int64_t minimum_num_axes = 0) const { | ||
TensorView* result = nullptr; | ||
int64_t max_dims = -1; | ||
for (auto output_tv : | ||
ir_utils::filterByType<TensorView>(fusion_->outputs())) { | ||
if (isValidReference(output_tv) && | ||
hasMinimumSize(output_tv, minimum_num_axes) && | ||
!output_tv->isFusionInput()) { | ||
int64_t n_dims = pointwise_utils::nRootDims(output_tv); | ||
if (n_dims > max_dims) { | ||
result = output_tv; | ||
max_dims = n_dims; | ||
} | ||
} | ||
} | ||
return result; | ||
} | ||
|
||
private: | ||
bool hasMinimumSize(TensorView* tv, int64_t num_axes) const { | ||
NVF_ERROR(tv != nullptr); | ||
return (num_axes == 0 || (int64_t)tv->getLogicalDomain().size() > num_axes); | ||
} | ||
}; | ||
|
||
} // namespace | ||
|
||
std::unique_ptr<PointwiseParams> getPointwiseHeuristics( | ||
|
@@ -79,14 +48,17 @@ std::unique_ptr<PointwiseParams> getPointwiseHeuristics( | |
|
||
auto domain_map_entry = | ||
HeuristicDataCacheEntry<HeuristicCompileTime::DomainMap>( | ||
data_cache, | ||
[fusion]() { return std::make_unique<DomainMap>(fusion); }); | ||
const auto& domain_map = dynamic_cast<DomainMap&>(domain_map_entry.get()); | ||
data_cache, [fusion]() { | ||
return std::make_unique<pointwise_utils::PointwiseDomainMap>( | ||
fusion); | ||
}); | ||
const auto& domain_map = dynamic_cast<pointwise_utils::PointwiseDomainMap&>( | ||
domain_map_entry.get()); | ||
|
||
auto largest_out_entry = | ||
HeuristicDataCacheEntry<HeuristicCompileTime::ReferenceTensors>( | ||
data_cache, [&domain_map]() { | ||
std::vector<TensorView*> data{domain_map.findReferenceTensorView()}; | ||
std::vector<TensorView*> data{domain_map.findReferenceTensor()}; | ||
return std::make_unique<std::vector<TensorView*>>(std::move(data)); | ||
}); | ||
TensorView* largest_out = largest_out_entry.get()[0]; | ||
|
@@ -432,19 +404,11 @@ std::unique_ptr<PointwiseParams> getPointwiseHeuristics( | |
return params; | ||
} | ||
|
||
// Return reference tensor view. | ||
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. Just moved to pointwise_utils |
||
TensorView* getReferenceTensorView(Fusion* fusion) { | ||
FusionGuard fg(fusion); | ||
DomainMap domain_map(fusion); | ||
auto reference_tv = domain_map.findReferenceTensorView(); | ||
return reference_tv; | ||
} | ||
|
||
//! Utility for canSchedule interface to check if this fusion has | ||
//! a fully broadcasted reference tensor, which is necessary for | ||
//! the pointwise scheduler. | ||
bool hasReferenceTensorView(Fusion* fusion) { | ||
return getReferenceTensorView(fusion) != nullptr; | ||
return pointwise_utils::getReferenceTensor(fusion) != nullptr; | ||
} | ||
|
||
bool PointWiseScheduler::canScheduleCompileTime(Fusion* fusion) { | ||
|
@@ -541,7 +505,7 @@ void schedulePointwise(Fusion* fusion, const PointwiseParams* pparams) { | |
return; | ||
} | ||
|
||
TensorView* reference_tv = getReferenceTensorView(fusion); | ||
TensorView* reference_tv = pointwise_utils::getReferenceTensor(fusion); | ||
|
||
NVF_ERROR( | ||
reference_tv != nullptr, | ||
|
Oops, something went wrong.
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.
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.
This part is moved to pointwise_utils.h so that it can be also used from the resize scheduler