# microresourcevariables

Allocate, read, assign and reset resource variables.

## tflite::MicroResourceVariables

`class` · `cpp`

```cpp
class MicroResourceVariables
```

Source: `tensorflow/lite/micro/micro_resource_variable.h:26`

### tflite::MicroResourceVariables::Create

`method` · `cpp`

```cpp
static MicroResourceVariables * tflite::MicroResourceVariables::Create(MicroAllocator *allocator, int num_variables)
```

Create.

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| allocator | MicroAllocator * | Required |  |
| num_variables | int | Required |  |

Source: `tensorflow/lite/micro/micro_resource_variable.h:29`

### tflite::MicroResourceVariables::CreateIdIfNoneFound

`method` · `cpp`

```cpp
int tflite::MicroResourceVariables::CreateIdIfNoneFound(const char *container, const char *shared_name)
```

Creates a resource variable if none is available for the given container and shared name pair. Returns the resource ID corresponding to the container and shared name pair. If allocation fails, the returned resource ID will be negative. The the container and shared_name must outlive this class.

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| container | const char * | Required |  |
| shared_name | const char * | Required |  |

Source: `tensorflow/lite/micro/micro_resource_variable.h:37`

### tflite::MicroResourceVariables::Read

`method` · `cpp`

```cpp
TfLiteStatus tflite::MicroResourceVariables::Read(int id, const TfLiteEvalTensor *tensor)
```

Read the resource buffer associated with the given ID into the given tensor.

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| id | int | Required |  |
| tensor | const TfLiteEvalTensor * | Required |  |

Source: `tensorflow/lite/micro/micro_resource_variable.h:41`

### tflite::MicroResourceVariables::Allocate

`method` · `cpp`

```cpp
TfLiteStatus tflite::MicroResourceVariables::Allocate(int id, TfLiteContext *context, const TfLiteTensor *tensor)
```

Allocates the resource buffer if none has been allocated, based on the length of the input tensor. Copies input tensor contents to the resource buffer.

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| id | int | Required |  |
| context | TfLiteContext * | Required |  |
| tensor | const TfLiteTensor * | Required |  |

Source: `tensorflow/lite/micro/micro_resource_variable.h:46`

### tflite::MicroResourceVariables::Assign

`method` · `cpp`

```cpp
TfLiteStatus tflite::MicroResourceVariables::Assign(int id, size_t count_bytes, const void *input_buffer)
```

Copies input_buffer contents to the resource buffer. AllocateResourceVariable with a TFLite tensor must have been called first in order to allocate the resource buffer.

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| id | int | Required |  |
| count_bytes | size_t | Required |  |
| input_buffer | const void * | Required |  |

Source: `tensorflow/lite/micro/micro_resource_variable.h:52`

### tflite::MicroResourceVariables::ResetAll

`method` · `cpp`

```cpp
TfLiteStatus tflite::MicroResourceVariables::ResetAll()
```

Zeros out all resource buffers.

Source: `tensorflow/lite/micro/micro_resource_variable.h:55`
