Remove map/unmap overhead for input/output accessor when using DummyAccessor

Don't map/unmap when the tensor data is not accessed in the input or output accessor.
This is so to avoid measuring CPU overhead when benchmarking on the GPU backend.

Resolve COMPMID-4712

Change-Id: I5baba1b93e7a51fe13525bcce6c0cfdecb14493e
Signed-off-by: Giorgio Arena <giorgio.arena@arm.com>
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/6140
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
diff --git a/src/graph/Tensor.cpp b/src/graph/Tensor.cpp
index f69d49d..3d47234 100644
--- a/src/graph/Tensor.cpp
+++ b/src/graph/Tensor.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018-2019 Arm Limited.
+ * Copyright (c) 2018-2019,2021 Arm Limited.
  *
  * SPDX-License-Identifier: MIT
  *
@@ -80,20 +80,28 @@
         return false;
     }
 
-    // Map tensor
-    _handle->map(true);
+    const bool access_data = _accessor->access_tensor_data();
 
-    // Return in case of null backend buffer
-    if(_handle->tensor().buffer() == nullptr)
+    if(access_data)
     {
-        return false;
+        // Map tensor
+        _handle->map(true);
+
+        // Return in case of null backend buffer
+        if(_handle->tensor().buffer() == nullptr)
+        {
+            return false;
+        }
     }
 
     // Call accessor
     bool retval = _accessor->access_tensor(_handle->tensor());
 
-    // Unmap tensor
-    _handle->unmap();
+    if(access_data)
+    {
+        // Unmap tensor
+        _handle->unmap();
+    }
 
     return retval;
 }