-
Notifications
You must be signed in to change notification settings - Fork 177
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
Autocast #1235
Draft
haytham2597
wants to merge
29
commits into
dotnet:main
Choose a base branch
from
haytham2597:main
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.
Draft
Autocast #1235
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
51d1d95
Autocast
haytham2597 29b4900
Added some features
haytham2597 defd582
Fix mistake gitignore
haytham2597 d532402
AMP
haytham2597 0b839db
Add Print Modules Still in progress
haytham2597 98cabfa
Add some printing module
haytham2597 669b4fa
Fix some dotnet build. Need fix tests
haytham2597 3940414
Fast tensor accessor for ToArray()
haytham2597 3469d7a
Update local
haytham2597 5062339
fix local build dotnet
haytham2597 3a467af
Fast ToArray() TensorAccessor
haytham2597 18c7528
Fast tensor accesor
haytham2597 728c9fb
fix accesor for every types
haytham2597 a9a611a
GradScaler
haytham2597 4a406ec
Trying fix build for azure
haytham2597 280c8d5
Range sequential
haytham2597 3c42a87
AMPManager
haytham2597 7cd7f9c
Amp
haytham2597 1293483
update
haytham2597 0c2769a
fix azure devops?
haytham2597 eafdd1e
fix test?
haytham2597 c0883d9
fix mac test?
haytham2597 9ac78bd
AMP Problem outscope
haytham2597 d6a0c28
gradscale, device cuda properties, etc.
haytham2597 21ce055
some gradscaler. Need grad_scale and found_inf attr in optimizer
haytham2597 e9f34c8
Merge branch 'main' of https://github.com/dotnet/TorchSharp
haytham2597 c70b523
update v2.4.0
haytham2597 36b79b9
some advance
haytham2597 376f4fb
Improve autocastmode
haytham2597 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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using System; | ||
using static TorchSharp.PInvoke.NativeMethods; | ||
|
||
namespace TorchSharp | ||
{ | ||
public static partial class torch | ||
{ | ||
public static bool is_autocast_cache_enabled() | ||
{ | ||
return THSTorch_is_autocast_cache_enabled(); | ||
} | ||
public static bool is_autocast_cpu_enabled() | ||
{ | ||
return THSTorch_is_autocast_cpu_enabled(); | ||
} | ||
public static bool is_autocast_gpu_enabled() | ||
{ | ||
return THSTorch_is_autocast_gpu_enabled(); | ||
} | ||
public static bool is_autocast_xpu_enabled() | ||
{ | ||
return THSTorch_is_autocast_xpu_enabled(); | ||
} | ||
public static bool is_autocast_hpu_enabled() | ||
{ | ||
return THSTorch_is_autocast_hpu_enabled(); | ||
} | ||
|
||
public static ScalarType get_autocast_cpu_dtype() | ||
{ | ||
return (ScalarType)THSTorch_get_autocast_cpu_dtype(); | ||
} | ||
public static ScalarType get_autocast_gpu_dtype() | ||
{ | ||
return (ScalarType)THSTorch_get_autocast_gpu_dtype(); | ||
} | ||
public static ScalarType get_autocast_xpu_dtype() | ||
{ | ||
return (ScalarType)THSTorch_get_autocast_xpu_dtype(); | ||
} | ||
|
||
public static int autocast_increment_nesting() | ||
{ | ||
return THSTorch_autocast_increment_nesting(); | ||
} | ||
|
||
public static int autocast_decrement_nesting() | ||
{ | ||
return THSTorch_autocast_decrement_nesting(); | ||
} | ||
|
||
public static void set_autocast_enabled(bool enabled) | ||
{ | ||
THSTorch_set_autocast_enabled(enabled); | ||
} | ||
public static void set_autocast_cache_enabled(bool enabled) | ||
{ | ||
THSTorch_set_autocast_cache_enabled(enabled); | ||
} | ||
|
||
public static void set_autocast_cpu_dtype(ScalarType dtype) | ||
{ | ||
THSTorch_set_autocast_cpu_dtype((sbyte)dtype); | ||
} | ||
public static void set_autocast_gpu_dtype(ScalarType dtype) | ||
{ | ||
THSTorch_set_autocast_gpu_dtype((sbyte)dtype); | ||
} | ||
public static void set_autocast_xpu_dtype(ScalarType dtype) | ||
{ | ||
THSTorch_set_autocast_xpu_dtype((sbyte)dtype); | ||
} | ||
|
||
public static void clear_autocast_cache() | ||
{ | ||
THSTorch_clear_autocast_cache(); | ||
} | ||
} | ||
} |
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.
Is this a work-in-progress PR, or something you're submitting for approval and merging? If the latter, then please create an issue to track "to do" items and add some unit tests.
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.
U can merging this if you want, this dont break anything (far as I know). But may useful for someone who want use that autocast function manually. My idea and plan is to make AMP, GradScaler, these modules use the functions I added.
Thank, I will try take into account about issue "to do" and unit tests. Sorry.