output Tensor data pointer is NULL before calling Invoke()
The behavior you are seeing where the data pointer of the output tensor is null before calling Invoke() is expected.

When you call interpreter_->AllocateTensors() it allocates the memory for input and output tensors, but it doesn't fill it with any data. So, the data pointer of the output tensor will be null until you run the model using Invoke().

After calling Invoke(), the output tensor should have valid data. In your code, you can see that the output tensor data pointer is not null after calling Invoke().

So, you can proceed with running your model after calling Invoke(). Hello,

Here I'm displaying the address of the input tensor data and output tensor data, I know that I put no data in the input tensor but what I want to understand is if it is normal to have the address of the tensor data changed dynamically.

If you look closely even the input tensor data address is changed:
Before Invoke inputTensor= **0x56253a528800** outputTensor= 0
After Invoke inputTensor= **0x56253ab84d00** outputTensor= 0x56253ab84e00

Here is an example with another model;
Before Invoke inputTensor= 0x557794e44700 outputTensor= 0x557794e44a00
After Invoke inputTensor= 0x557794e44700 outputTensor= 0x557794e44a00

The addresses are not changed, after the Invoke() call.

I also made a test by adding a loop of 10 runs and the addresses are only changed on the first run:
Before Invoke inputTensor= 0x559539f2c800 outputTensor= 0
After Invoke inputTensor= 0x55953a588d00 outputTensor= 0x55953a588e00
Before Invoke inputTensor= 0x55953a588d00 outputTensor= 0x55953a588e00
After Invoke inputTensor= 0x55953a588d00 outputTensor= 0x55953a588e00
Before Invoke inputTensor= 0x55953a588d00 outputTensor= 0x55953a588e00
After Invoke inputTensor= 0x55953a588d00 outputTensor= 0x55953a588e00
Before Invoke inputTensor= 0x55953a588d00 outputTensor= 0x55953a588e00
After Invoke inputTensor= 0x55953a588d00 outputTensor= 0x55953a588e00
Before Invoke inputTensor= 0x55953a588d00 outputTensor= 0x55953a588e00
After Invoke inputTensor= 0x55953a588d00 outputTensor= 0x55953a588e00
Before Invoke inputTensor= 0x55953a588d00 outputTensor= 0x55953a588e00
After Invoke inputTensor= 0x55953a588d00 outputTensor= 0x55953a588e00
Before Invoke inputTensor= 0x55953a588d00 outputTensor= 0x55953a588e00
After Invoke inputTensor= 0x55953a588d00 outputTensor= 0x55953a588e00
Before Invoke inputTensor= 0x55953a588d00 outputTensor= 0x55953a588e00
After Invoke inputTensor= 0x55953a588d00 outputTensor= 0x55953a588e00
Before Invoke inputTensor= 0x55953a588d00 outputTensor= 0x55953a588e00
After Invoke inputTensor= 0x55953a588d00 outputTensor= 0x55953a588e00
Before Invoke inputTensor= 0x55953a588d00 outputTensor= 0x55953a588e00
After Invoke inputTensor= 0x55953a588d00 outputTensor= 0x55953a588e00

code with loop:
```
bool ModelTfLite::Invoke()
{
    TfLiteStatus status;

    interpreter_->AllocateTensors();

    for(int i = 0; i < 10; i++) {
        void* inputTensor = interpreter_->input_tensor(0)->data.data;
        void* outputTensor = interpreter_->output_tensor(0)->data.data;
        std::cout << "Before Invoke inputTensor= " << inputTensor << " outputTensor= " << outputTensor << "\n";

        status = interpreter_->Invoke();

        inputTensor = interpreter_->input_tensor(0)->data.data;
        outputTensor = interpreter_->output_tensor(0)->data.data;
        std::cout << "After Invoke inputTensor= " << inputTensor << " outputTensor= " << outputTensor << "\n";

        if(status != kTfLiteOk) {
            std::cout << "Failed to run Invoke(): " << status << "\n" ;
            return false;
        }
    }
    return true;
}
```

So my question is it expected to have the data tensor pointer dynamically changed even if I never call AllocateTensors again? It is normal for the memory addresses of the input and output tensors to change dynamically during the runtime of the program. When you call interpreter_->AllocateTensors(), the interpreter allocates memory for the input and output tensors. The memory allocation may cause the memory addresses to change, as the interpreter may allocate memory in a different location.

Additionally, when you call interpreter_->Invoke(), the interpreter may perform some internal operations that could change the memory addresses of the input and output tensors. However, this should not cause any issues as long as you access the tensors using the interpreter_->input_tensor() and interpreter_->output_tensor() functions, as these functions will return the correct pointers to the input and output tensors regardless of their memory addresses.

Therefore, it is expected that the memory addresses of the input and output tensors may change dynamically during the runtime of your program. Ok, I see, thanks for the explanation.
So if I have understood correctly, this should be the nominal way of using tensors:

```
bool ModelTfLite::Invoke()
{
    TfLiteStatus status;

    interpreter_->AllocateTensors();

    for(int i = 0; i < 10; i++) {

        void* inputTensor = interpreter_->input_tensor(0)->data.data;

        // fill input data

        status = interpreter_->Invoke();

        if(status != kTfLiteOk) {
            std::cout << "Failed to run Invoke(): " << status << "\n" ;
            return false;
        }

        void* outputTensor = interpreter_->output_tensor(0)->data.data;

        // use output data

    }
    return true;
}
```

 interpreter_->input_tensor(0)->data.data or interpreter_->output_tensor(0)->data.data should never be saved in some other variables Yeah that's correct.  Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/60247">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/60247">No</a>

<details><summary>Click to expand!</summary> 
 
 ### Issue Type

Bug

### Have you reproduced the bug with TF nightly?

Yes

### Source

source

### Tensorflow Version

tf2.10

### Custom Code

Yes

### OS Platform and Distribution

Ubuntu 20.04.4 LTS

### Mobile device

_No response_

### Python version

Python 3.8.10

### Bazel version

bazel 6.1.1

### GCC/Compiler version

gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current Behaviour?

```shell
Hello,

I run into the following issue, I try to retrieve the data pointer from the output tensor of my tensorflow lite model before running Invoke() and it is NULL.

Is it the expected behavior?

I would have supposed that after calling AllocateTensors() the tensors could be used.
```


### Standalone code to reproduce the issue

```shell
I run the following code:
class ModelTfLite
{
public:
    ModelTfLite(const std::string& path);
    ~ModelTfLite() = default;

    bool Invoke();

private:
    std::unique_ptr<tflite::FlatBufferModel> model_;
    tflite::ops::builtin::BuiltinOpResolver resolver_;
    std::unique_ptr<tflite::Interpreter> interpreter_;
};

ModelTfLite::ModelTfLite(const std::string& path)
{
    model_ = tflite::FlatBufferModel::BuildFromFile(path.c_str());
    assert(model_ != nullptr);

    tflite::InterpreterBuilder builder(*model_, resolver_);
    builder(&interpreter_);
    assert(interpreter_ != nullptr);
}

bool ModelTfLite::Invoke()
{
    TfLiteStatus status;

    interpreter_->AllocateTensors();

    void* inputTensor = interpreter_->input_tensor(0)->data.data;
    void* outputTensor = interpreter_->output_tensor(0)->data.data;
    std::cout << "Before Invoke inputTensor= " << inputTensor << " outputTensor= " << outputTensor << "\n" ;

    status = interpreter_->Invoke();

    inputTensor = interpreter_->input_tensor(0)->data.data;
    outputTensor = interpreter_->output_tensor(0)->data.data;
    std::cout << "After Invoke inputTensor= " << inputTensor << " outputTensor= " << outputTensor << "\n" ;

    if(status != kTfLiteOk) {
        std::cout << "Failed to run Invoke(): " << status << "\n" ;
        return false;
    }
    return true;
}

main:
int main(int argc, char* argv[]) {
    if (argc != 2) {
        fprintf(stderr, "testmodel <tflite model>\n");
        return 1;
    }
    const char* filename = argv[1];

    ModelTfLite m(filename);

    m.Invoke();
    return 0;
}
```


### Relevant log output

```shell
Before Invoke inputTensor= 0x56253a528800 outputTensor= 0
After Invoke inputTensor= 0x56253ab84d00 outputTensor= 0x56253ab84e00
```
</details>