From b42103fe648f56fd7608bdaa6cb9ccba75ce26ec Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Wed, 26 Jan 2022 19:18:46 -0500 Subject: [PATCH] [Perl] Updates mapping between PDL and MX types This removes the hardcoded values and uses PDL::Type instead. Upgrades minimum PDL dependency to PDL v2.064 which provides the int8 (PDL: sbyte) type. Fixes . --- perl-package/AI-MXNet/META.json | 2 +- perl-package/AI-MXNet/META.yml | 2 +- perl-package/AI-MXNet/Makefile.PL | 4 +-- perl-package/AI-MXNet/lib/AI/MXNet/Base.pm | 39 +++++++++++----------- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/perl-package/AI-MXNet/META.json b/perl-package/AI-MXNet/META.json index 02357d478095..ed4fd68536c5 100644 --- a/perl-package/AI-MXNet/META.json +++ b/perl-package/AI-MXNet/META.json @@ -36,7 +36,7 @@ "Hash::Ordered" : "0.012", "GraphViz" : "2.14", "Mouse" : "v2.1.0", - "PDL" : "2.007", + "PDL" : "2.064", "PDL::CCS" : "1.23.4", "Archive::Tar": "0", "Digest::SHA": "0", diff --git a/perl-package/AI-MXNet/META.yml b/perl-package/AI-MXNet/META.yml index b06b331ec4ae..ee3f8a61408b 100644 --- a/perl-package/AI-MXNet/META.yml +++ b/perl-package/AI-MXNet/META.yml @@ -40,7 +40,7 @@ requires: Hash::Ordered: '0.012' GraphViz: '2.14' Mouse: v2.1.0 - PDL: '2.007' + PDL: '2.064' PDL::CCS: '1.23.4' Archive::Tar: '0' Digest::SHA: '0' diff --git a/perl-package/AI-MXNet/Makefile.PL b/perl-package/AI-MXNet/Makefile.PL index 4a9016234ad6..17cfc01396d7 100644 --- a/perl-package/AI-MXNet/Makefile.PL +++ b/perl-package/AI-MXNet/Makefile.PL @@ -41,7 +41,7 @@ my %WriteMakefileArgs = ( "Function::Parameters" => "1.0705", "Hash::Ordered" => "0.012", "Mouse" => "v2.1.0", - "PDL" => "2.007", + "PDL" => "2.064", "PDL::CCS" => "1.23.4", "GraphViz" => "2.14" }, @@ -59,7 +59,7 @@ my %FallbackPrereqs = ( "Function::Parameters" => "1.0705", "Hash::Ordered" => "0.012", "Mouse" => "v2.1.0", - "PDL" => "2.007", + "PDL" => "2.064", "PDL::CCS" => "1.23.4", "GraphViz" => "2.14" ); diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/Base.pm b/perl-package/AI-MXNet/lib/AI/MXNet/Base.pm index 9ac917b57b41..d0a1aacae511 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/Base.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/Base.pm @@ -60,27 +60,28 @@ use constant DTYPE_MX_TO_STR => { 6 => 'int64' }; use constant DTYPE_MX_TO_PDL => { - 0 => 6, - 1 => 7, - 2 => 6, - 3 => 0, - 4 => 3, - 5 => 0, - 6 => 5, - float32 => 6, - float64 => 7, - float16 => 6, - uint8 => 0, - int32 => 3, - int8 => 0, - int64 => 5 + 0 => PDL::Type->new('float')->enum, + 1 => PDL::Type->new('double')->enum, + 2 => PDL::Type->new('float')->enum, + 3 => PDL::Type->new('byte')->enum, + 4 => PDL::Type->new('long')->enum, + 5 => PDL::Type->new('sbyte')->enum, + 6 => PDL::Type->new('longlong')->enum, + float32 => PDL::Type->new('float')->enum, + float64 => PDL::Type->new('double')->enum, + float16 => PDL::Type->new('float')->enum, + uint8 => PDL::Type->new('byte')->enum, + int32 => PDL::Type->new('long')->enum, + int8 => PDL::Type->new('sbyte')->enum, + int64 => PDL::Type->new('longlong')->enum, }; use constant DTYPE_PDL_TO_MX => { - 6 => 0, - 7 => 1, - 0 => 3, - 3 => 4, - 5 => 6 + PDL::Type->new('float')->enum => 0, + PDL::Type->new('double')->enum => 1, + PDL::Type->new('byte')->enum => 3, + PDL::Type->new('long')->enum => 4, + PDL::Type->new('sbyte')->enum => 5, + PDL::Type->new('longlong')->enum => 6, }; use constant DTYPE_MX_TO_PERL => { 0 => 'f',