Change 64-bit integers to pointer-sized ints at a few places.
PiperOrigin-RevId: 276358885 Change-Id: I0d240c73af8fde2a8bb2a963a83eb997995a1436
This commit is contained in:
parent
d2fac81efc
commit
7a2e4a4f68
@ -13,6 +13,8 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==============================================================================*/
|
||||
#include "tensorflow/lite/arena_planner.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <utility>
|
||||
|
||||
namespace tflite {
|
||||
@ -40,7 +42,7 @@ ArenaPlanner::ArenaPlanner(TfLiteContext* context,
|
||||
|
||||
ArenaPlanner::~ArenaPlanner() {}
|
||||
|
||||
int64_t ArenaPlanner::BasePointer(TfLiteAllocationType type) {
|
||||
std::intptr_t ArenaPlanner::BasePointer(TfLiteAllocationType type) {
|
||||
if (type == kTfLiteArenaRwPersistent) {
|
||||
return persistent_arena_.BasePointer();
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ limitations under the License.
|
||||
#ifndef TENSORFLOW_LITE_ARENA_PLANNER_H_
|
||||
#define TENSORFLOW_LITE_ARENA_PLANNER_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
@ -67,7 +68,7 @@ class ArenaPlanner : public MemoryPlanner {
|
||||
TfLiteStatus ExecuteAllocations(int first_node, int last_node) override;
|
||||
|
||||
// Returns the base arena location for a given allocation type.
|
||||
int64_t BasePointer(TfLiteAllocationType type);
|
||||
std::intptr_t BasePointer(TfLiteAllocationType type);
|
||||
|
||||
private:
|
||||
// Make sure all the arenas have reserved enough memory to store all their
|
||||
|
@ -15,11 +15,12 @@ limitations under the License.
|
||||
#include "tensorflow/lite/arena_planner.h"
|
||||
|
||||
#include <cstdarg>
|
||||
#include <cstdint>
|
||||
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include "tensorflow/lite/testing/util.h"
|
||||
#include "tensorflow/core/platform/logging.h"
|
||||
#include "tensorflow/lite/testing/util.h"
|
||||
|
||||
namespace tflite {
|
||||
namespace {
|
||||
@ -183,16 +184,16 @@ class ArenaPlannerTest : public ::testing::Test {
|
||||
|
||||
// Returns the actual offset of a given tensor, relative to the start of its
|
||||
// arena.
|
||||
int64_t GetOffset(int tensor_index) {
|
||||
std::ptrdiff_t GetOffset(int tensor_index) {
|
||||
const TfLiteTensor& tensor = (*graph_->tensors())[tensor_index];
|
||||
return reinterpret_cast<int64_t>(tensor.data.raw) -
|
||||
return reinterpret_cast<std::intptr_t>(tensor.data.raw) -
|
||||
planner_->BasePointer(tensor.allocation_type);
|
||||
}
|
||||
|
||||
// Returns the first aligned offset after a given tensor.
|
||||
int64_t GetOffsetAfter(int tensor_index) {
|
||||
std::ptrdiff_t GetOffsetAfter(int tensor_index) {
|
||||
const TfLiteTensor& tensor = (*graph_->tensors())[tensor_index];
|
||||
int64_t offset = GetOffset(tensor_index) + tensor.bytes;
|
||||
std::ptrdiff_t offset = GetOffset(tensor_index) + tensor.bytes;
|
||||
// We must make sure the offset is aligned to kDefaultArenaAlignment.
|
||||
if (offset % kTensorAlignment != 0) {
|
||||
offset += kTensorAlignment - offset % kTensorAlignment;
|
||||
|
@ -15,8 +15,10 @@ limitations under the License.
|
||||
#ifndef TENSORFLOW_LITE_SIMPLE_MEMORY_ARENA_H_
|
||||
#define TENSORFLOW_LITE_SIMPLE_MEMORY_ARENA_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
|
||||
#include "tensorflow/lite/c/c_api_internal.h"
|
||||
|
||||
namespace tflite {
|
||||
@ -69,8 +71,8 @@ class SimpleMemoryArena {
|
||||
|
||||
TfLiteStatus Clear();
|
||||
|
||||
int64_t BasePointer() const {
|
||||
return reinterpret_cast<int64_t>(underlying_buffer_aligned_ptr_);
|
||||
std::intptr_t BasePointer() const {
|
||||
return reinterpret_cast<std::intptr_t>(underlying_buffer_aligned_ptr_);
|
||||
}
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user