forked from microsoft/TileFusion
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(kernels): Add dispatch macros. (microsoft#45)
* add dispatch macros. * move unittests to the correct directory.
- Loading branch information
Showing
10 changed files
with
103 additions
and
72 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#pragma once | ||
|
||
#define DISPATCH_TYPE_CASE(TYPE, NV_TYPE, ...) \ | ||
case TYPE: { \ | ||
using scalar_t = NV_TYPE; \ | ||
return __VA_ARGS__(); \ | ||
} | ||
|
||
#define TILEFUSION_DISPATCH_ALL_TYPES(TYPE, ...) \ | ||
c10::ScalarType _type = TYPE; \ | ||
[&] { \ | ||
switch (_type) { \ | ||
DISPATCH_TYPE_CASE(c10::ScalarType::Float, float, __VA_ARGS__) \ | ||
DISPATCH_TYPE_CASE(c10::ScalarType::Half, __half, __VA_ARGS__) \ | ||
DISPATCH_TYPE_CASE(c10::ScalarType::BFloat16, __bfloat16, \ | ||
__VA_ARGS__) \ | ||
default: \ | ||
AT_ERROR("Dispatch is not implemented for type: '", \ | ||
toString(_type), "'"); \ | ||
} \ | ||
}(); |
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
File renamed without changes.
File renamed without changes.
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