Browse Source

Use AZ::IO::Path to represent filenames

Signed-off-by: kberg-amzn <[email protected]>
kberg-amzn 1 năm trước cách đây
mục cha
commit
7b10aec95f

+ 7 - 0
Gems/MachineLearning/CMakeLists.txt

@@ -1,3 +1,10 @@
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+#
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+#
 
 # Query the gem name from the gem.json file if possible
 # otherwise fallback to using MachineLearning

+ 1 - 1
Gems/MachineLearning/Code/Include/MachineLearning/ILabeledTrainingData.h

@@ -20,7 +20,7 @@ namespace MachineLearning
         virtual ~ILabeledTrainingData() = default;
 
         //! Loads the indicated label and data files.
-        virtual bool LoadArchive(const AZStd::string& imageFilename, const AZStd::string& labelFilename) = 0;
+        virtual bool LoadArchive(const AZ::IO::Path& imageFilename, const AZ::IO::Path& labelFilename) = 0;
 
         //! Returns the total number of samples contained in the training data set.
         virtual AZStd::size_t GetSampleCount() const = 0;

+ 5 - 5
Gems/MachineLearning/Code/Source/Assets/MnistDataLoader.cpp

@@ -18,7 +18,7 @@
 #include <AzCore/RTTI/BehaviorContext.h>
 #include <AzCore/Serialization/EditContext.h>
 #include <AzCore/Serialization/SerializeContext.h>
-#pragma optimize("", off)
+
 namespace MachineLearning
 {
     void MnistDataLoader::Reflect(AZ::ReflectContext* context)
@@ -50,7 +50,7 @@ namespace MachineLearning
         }
     }
 
-    bool MnistDataLoader::LoadArchive(const AZStd::string& imageFilename, const AZStd::string& labelFilename)
+    bool MnistDataLoader::LoadArchive(const AZ::IO::Path& imageFilename, const AZ::IO::Path& labelFilename)
     {
         return LoadImageFile(imageFilename) && LoadLabelFile(labelFilename);
     }
@@ -77,7 +77,7 @@ namespace MachineLearning
         return m_imageVector;
     }
 
-    bool MnistDataLoader::LoadImageFile(const AZStd::string& imageFilename)
+    bool MnistDataLoader::LoadImageFile(const AZ::IO::Path& imageFilename)
     {
         AZ::IO::FixedMaxPath filePathFixed = imageFilename.c_str();
         if (AZ::IO::FileIOBase* fileIOBase = AZ::IO::FileIOBase::GetInstance())
@@ -130,7 +130,7 @@ namespace MachineLearning
         return true;
     }
 
-    bool MnistDataLoader::LoadLabelFile(const AZStd::string& labelFilename)
+    bool MnistDataLoader::LoadLabelFile(const AZ::IO::Path& labelFilename)
     {
         AZ::IO::FixedMaxPath filePathFixed = labelFilename.c_str();
         if (AZ::IO::FileIOBase* fileIOBase = AZ::IO::FileIOBase::GetInstance())
@@ -195,4 +195,4 @@ namespace MachineLearning
         return true;
     }
 }
-#pragma optimize("", on)
+

+ 3 - 3
Gems/MachineLearning/Code/Source/Assets/MnistDataLoader.h

@@ -32,7 +32,7 @@ namespace MachineLearning
 
         //! ILabeledTrainingData interface
         //! @{
-        bool LoadArchive(const AZStd::string& imageFilename, const AZStd::string& labelFilename) override;
+        bool LoadArchive(const AZ::IO::Path& imageFilename, const AZ::IO::Path& labelFilename) override;
         AZStd::size_t GetSampleCount() const override;
         const AZ::VectorN& GetLabelByIndex(AZStd::size_t index) override;
         const AZ::VectorN& GetDataByIndex(AZStd::size_t index) override;
@@ -40,8 +40,8 @@ namespace MachineLearning
 
     private:
 
-        bool LoadImageFile(const AZStd::string& imageFilename);
-        bool LoadLabelFile(const AZStd::string& labelFilename);
+        bool LoadImageFile(const AZ::IO::Path& imageFilename);
+        bool LoadLabelFile(const AZ::IO::Path& labelFilename);
 
         struct MnistDataHeader
         {

+ 1 - 1
Gems/MachineLearning/Code/Source/Assets/TrainingDataView.cpp

@@ -52,7 +52,7 @@ namespace MachineLearning
         std::shuffle(m_indices.begin(), m_indices.end(), std::mt19937(std::random_device{}()));
     }
 
-    bool TrainingDataView::LoadArchive(const AZStd::string& imageFilename, const AZStd::string& labelFilename)
+    bool TrainingDataView::LoadArchive(const AZ::IO::Path& imageFilename, const AZ::IO::Path& labelFilename)
     {
         AZ_Assert(m_sourceData, "No datasource assigned to view");
         bool result = m_sourceData->LoadArchive(imageFilename, labelFilename);

+ 1 - 1
Gems/MachineLearning/Code/Source/Assets/TrainingDataView.h

@@ -38,7 +38,7 @@ namespace MachineLearning
 
         //! ILabeledTrainingData interface
         //! @{
-        bool LoadArchive(const AZStd::string& imageFilename, const AZStd::string& labelFilename) override;
+        bool LoadArchive(const AZ::IO::Path& imageFilename, const AZ::IO::Path& labelFilename) override;
         AZStd::size_t GetSampleCount() const override;
         const AZ::VectorN& GetLabelByIndex(AZStd::size_t index) override;
         const AZ::VectorN& GetDataByIndex(AZStd::size_t index) override;