aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/lite/arena_planner.cc
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-07-17 21:02:37 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-07-17 21:06:35 -0700
commit37cf4e0783ad06e6cfc94c98a77a48734190ed48 (patch)
tree64efa2e7a0c7ee49c319a72c6d3fba29465f1489 /tensorflow/contrib/lite/arena_planner.cc
parent527a5eb1759d682810f8155b9767bcc7984d3b3e (diff)
Automated rollback of commit ff4945f86e04d403cdf46c19392b2041bc75c2ad
PiperOrigin-RevId: 205022167
Diffstat (limited to 'tensorflow/contrib/lite/arena_planner.cc')
-rw-r--r--tensorflow/contrib/lite/arena_planner.cc25
1 files changed, 16 insertions, 9 deletions
diff --git a/tensorflow/contrib/lite/arena_planner.cc b/tensorflow/contrib/lite/arena_planner.cc
index 02442575b3..16a0e71624 100644
--- a/tensorflow/contrib/lite/arena_planner.cc
+++ b/tensorflow/contrib/lite/arena_planner.cc
@@ -17,6 +17,14 @@ limitations under the License.
namespace tflite {
+namespace {
+
+// Memory allocation tuning
+constexpr const int kDefaultArenaAlignment = 64;
+constexpr const int kDefaultTensorAlignment = 4;
+
+} // namespace
+
struct AllocationInfo {
// The node index requesting this allocation.
int node;
@@ -28,16 +36,13 @@ struct AllocationInfo {
ArenaPlanner::ArenaPlanner(TfLiteContext* context,
std::unique_ptr<GraphInfo> graph_info,
- bool preserve_inputs, bool preserve_intermediates,
- int tensor_alignment)
+ bool preserve_inputs, bool preserve_intermediates)
: context_(context),
graph_info_(std::move(graph_info)),
arena_(kDefaultArenaAlignment),
persistent_arena_(kDefaultArenaAlignment),
preserve_inputs_(preserve_inputs),
- preserve_intermediates_(preserve_intermediates),
- tensor_alignment_(tensor_alignment) {}
-
+ preserve_intermediates_(preserve_intermediates) {}
ArenaPlanner::~ArenaPlanner() {}
int64_t ArenaPlanner::BasePointer(TfLiteAllocationType type) {
@@ -259,12 +264,14 @@ TfLiteStatus ArenaPlanner::ResolveTensorAllocation(int tensor_index) {
TfLiteStatus ArenaPlanner::CalculateTensorAllocation(int tensor_index) {
TfLiteTensor& tensor = *graph_info_->tensor(tensor_index);
if (tensor.allocation_type == kTfLiteArenaRw) {
- TF_LITE_ENSURE_STATUS(arena_.Allocate(
- context_, tensor_alignment_, tensor.bytes, &allocs_[tensor_index]));
+ TF_LITE_ENSURE_STATUS(arena_.Allocate(context_, kDefaultTensorAlignment,
+ tensor.bytes,
+ &allocs_[tensor_index]));
}
if (tensor.allocation_type == kTfLiteArenaRwPersistent) {
- TF_LITE_ENSURE_STATUS(persistent_arena_.Allocate(
- context_, tensor_alignment_, tensor.bytes, &allocs_[tensor_index]));
+ TF_LITE_ENSURE_STATUS(
+ persistent_arena_.Allocate(context_, kDefaultTensorAlignment,
+ tensor.bytes, &allocs_[tensor_index]));
}
return kTfLiteOk;
}