This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
MXNET-1447 [Perl] Runtime features and large tensor support. #17610
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3033775
[Perl] MXNET-1447 Runtime features and large tensor support.
sergeykolychev ce5b1a9
MXNET-1447 fixed test, corrected module version.
sergeykolychev 7e1f686
Merge remote-tracking branch 'dev/master' into MXNET-1447
sergeykolychev 42e7206
miscellaneous cleanups.
sergeykolychev 778a562
Merge remote-tracking branch 'dev/master' into MXNET-1447
sergeykolychev 09301f7
added missing file.
sergeykolychev b1f7dae
Merge remote-tracking branch 'dev/master' into MXNET-1447
sergeykolychev 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
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
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,116 @@ | ||
# 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. | ||
|
||
package AI::MXNet::RunTime; | ||
use strict; | ||
use warnings; | ||
use AI::MXNet::NS; | ||
use AI::MXNet::Base; | ||
use AI::MXNet::Function::Parameters; | ||
use Mouse; | ||
|
||
=head1 NAME | ||
|
||
AI::MXNet::RunTime - Runtime querying of compile time features in the native library. | ||
=cut | ||
|
||
=head1 DESCRIPTION | ||
|
||
With this module you can check at runtime which libraries and features were compiled in the library. | ||
|
||
Example usage: | ||
|
||
use AI::MXNet qw(mx); | ||
my $features = mx->runtime->Features(); | ||
|
||
print $features->is_enabled("CUDNN"); | ||
0 | ||
|
||
print $features->is_enabled("CPU_SSE"); | ||
1 | ||
|
||
print Dumper($features->features); | ||
$VAR1 = { | ||
'LAPACK' => 1, | ||
'F16C' => 1, | ||
'CPU_SSE2' => 1, | ||
'BLAS_MKL' => 0, | ||
'CXX14' => 0, | ||
'DIST_KVSTORE' => 0, | ||
'NCCL' => 0, | ||
'OPENMP' => 1, | ||
'CUDNN' => 0, | ||
'CPU_AVX' => 1, | ||
'CUDA_RTC' => 0, | ||
'BLAS_OPEN' => 1, | ||
'CPU_SSE4_2' => 1, | ||
'CPU_SSE4A' => 0, | ||
'TVM_OP' => 0, | ||
'MKLDNN' => 0, | ||
'TENSORRT' => 0, | ||
'JEMALLOC' => 1, | ||
'SSE' => 0, | ||
'PROFILER' => 0, | ||
'DEBUG' => 0, | ||
'BLAS_APPLE' => 0, | ||
'CPU_SSE3' => 1, | ||
'INT64_TENSOR_SIZE' => 0, | ||
'CPU_SSE4_1' => 1, | ||
'CUDA' => 0, | ||
'OPENCV' => 1, | ||
'CPU_SSE' => 1, | ||
'SIGNAL_HANDLER' => 0, | ||
'BLAS_ATLAS' => 0, | ||
'CAFFE' => 0, | ||
'CPU_AVX2' => 0 | ||
}; | ||
|
||
print $features; | ||
[✖ CUDA, ✖ CUDNN, ✖ NCCL, ✖ CUDA_RTC, ✖ TENSORRT, ✔ CPU_SSE, ✔ CPU_SSE2, ✔ CPU_SSE3, | ||
✔ CPU_SSE4_1, ✔ CPU_SSE4_2, ✖ CPU_SSE4A, ✔ CPU_AVX, ✖ CPU_AVX2, ✔ OPENMP, ✖ SSE, | ||
✔ F16C, ✔ JEMALLOC, ✔ BLAS_OPEN, ✖ BLAS_ATLAS, ✖ BLAS_MKL, ✖ BLAS_APPLE, ✔ LAPACK, | ||
✖ MKLDNN, ✔ OPENCV, ✖ CAFFE, ✖ PROFILER, ✖ DIST_KVSTORE, ✖ CXX14, ✖ INT64_TENSOR_SIZE, | ||
✔ SIGNAL_HANDLER, ✔ DEBUG, ✖ TVM_OP] | ||
|
||
=cut | ||
use overload '""' => sub { | ||
my $self = shift; | ||
my $s = join(', ', map { | ||
sprintf("%s %s", $self->features->{ $_ } ? '✔' : '✖', $_) | ||
} sort keys %{ $self->features }); | ||
return "[$s]"; | ||
}; | ||
|
||
has 'features' => (is => 'rw', init_arg => undef, default => sub { | ||
return scalar(check_call(AI::MXNetCAPI::LibInfoFeatures())); | ||
}); | ||
|
||
method is_enabled(Str $feature) | ||
{ | ||
confess("Feature $feature does not exist") | ||
unless exists $self->features->{ $feature }; | ||
return $self->features->{ $feature }; | ||
} | ||
|
||
my $features; | ||
method Features() | ||
{ | ||
$features //= __PACKAGE__->new; | ||
return $features; | ||
} | ||
|
||
1; |
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
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.
It seems a little awkward to put the caller in charge of checking the
INT64_TENSOR_SIZE
compile setting. Would it make sense to makeAI::MXNetCAPI::NDArraySlice()
and friends responsible for checking the flag and deferring to theNDArray*64()
variants when appropriate?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.
@tlby On python side the switch is made in the caller space. The c api has two functions defined for each task, one with
(u)?int32_t
input/output and another with(u)?int64_t
I don't know how to combine these two functions via the swig space.
Looks like a task for you to complete later the line.
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.
If that's how things are done in Python, then no need to diverge from this pattern. Thanks!