[ layer ] Bugfix for enabling unittest_models on Android
authorskykongkong8 <ss.kong@samsung.com>
Thu, 30 May 2024 04:09:06 +0000 (13:09 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Fri, 21 Jun 2024 05:52:34 +0000 (14:52 +0900)
- This commit fixes unusual memory access on cross-compiled unittest executable on Android

Resolves:
> SIGSEGV : signal segmentation violation
- lldb | signal SIGSEGV: invalid address
- SIGILL : illegal instruction

**Self evaluation:**
1. Build test:     [X]Passed [ ]Failed [ ]Skipped
2. Run test:     [X]Passed [ ]Failed [ ]Skipped

Signed-off-by: skykongkong8 <ss.kong@samsung.com>
nntrainer/layers/layer_context.cpp
nntrainer/layers/layer_context.h

index 1a66aed3cd7f5c613c3fb6b52db2fb9ec7c667fa..015879cdf3c85d47ec991f0e7a080578bc64b757 100644 (file)
@@ -412,6 +412,34 @@ const std::string &RunLayerContext::getTensorName(unsigned int idx) const {
   return tensors[idx]->getName();
 }
 
+/**
+ * @brief Get the number of Outputs tensor objects
+ *
+ * @return unsigned int number of output tensors
+ */
+unsigned int RunLayerContext::getNumOutputs() const { return outputs.size(); }
+
+/**
+ * @brief Get the number of inputs tensor objects
+ *
+ * @return unsigned int number of input tensors
+ */
+unsigned int RunLayerContext::getNumInputs() const { return inputs.size(); }
+
+/**
+ * @brief Get the number of weights tensor objects
+ *
+ * @return unsigned int number of weight tensors
+ */
+unsigned int RunLayerContext::getNumWeights() const { return weights.size(); }
+
+/**
+ * @brief Get the number of requested tensors objects
+ *
+ * @return unsigned int number of requested tensors
+ */
+unsigned int RunLayerContext::getNumTensors() const { return tensors.size(); }
+
 /**
  * @brief Set the batch for the run context
  *
index 43e9d8eaf87f3bc86c94a31498443abb9d9c86ab..e0ed137c3c63ce0373eabcae1ae20ecf03cfbdde 100644 (file)
@@ -672,21 +672,21 @@ public:
    *
    * @return unsigned int number of output tensors
    */
-  unsigned int getNumOutputs() const { return outputs.size(); }
+  unsigned int getNumOutputs() const;
 
   /**
    * @brief Get the number of inputs tensor objects
    *
    * @return unsigned int number of input tensors
    */
-  unsigned int getNumInputs() const { return inputs.size(); }
+  unsigned int getNumInputs() const;
 
   /**
    * @brief Get the number of weights tensor objects
    *
    * @return unsigned int number of weight tensors
    */
-  unsigned int getNumWeights() const { return weights.size(); }
+  unsigned int getNumWeights() const;
 
   /**
    * @brief Get the Number of Weight Optimizer Variable tensor object
@@ -701,8 +701,7 @@ public:
    *
    * @return unsigned int number of requested tensors
    */
-  unsigned int getNumTensors() const { return tensors.size(); }
-
+  unsigned int getNumTensors() const;
   /**
    * @brief Set the batch for the run context
    *