# Initialize weights as a constant array?

**URL:** <https://discuss.pytorch.org/t/initialize-weights-as-a-constant-array/79965>\
**Category:** glow\
**Created:** [May 6, 2020, 10:03am UTC](https://discuss.pytorch.org/t/initialize-weights-as-a-constant-array/79965 "2020-05-06T10:03:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![byersin](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/byersin/32/12702_2.png) [@byersin](https://discuss.pytorch.org/u/byersin)\
**Post date:** [May 6, 2020, 10:03am UTC](https://discuss.pytorch.org/t/initialize-weights-as-a-constant-array/79965/1 "2020-05-06T10:03:48Z")

</div>

I’m interested in using the Glow stand-alone bundles for microcontroller applications but I ran into the following memory issue. When declaring the constant weight array

```auto
uint8_t constantWeight[CONSTANT_MEM_SIZE] = {
#include "MODEL_NAME.weights.txt"
};

```

the array is not defined as constant. You cannot simply add a `const` keyword because the model entry function expects a non-constant format. This is a problem because non-constant variables are stored in the (too small) RAM segment instead of the flash. Is there a simple way to work around this problem?

---

<div class="post-metadata">

**Author:** ![srohit0](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/srohit0/32/19836_2.png) [@srohit0](https://discuss.pytorch.org/u/srohit0)\
**Post date:** [May 14, 2020, 4:14pm UTC](https://discuss.pytorch.org/t/initialize-weights-as-a-constant-array/79965/2 "2020-05-14T16:14:25Z")

</div>

Check out [bit.ly/deep-C](http://bit.ly/deep-C) for an easy approach to put pytorch & onnx models into microcontroller applications

---

<div class="post-metadata">

**Author:** ![jfix](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/jfix/32/21510_2.png) [@jfix](https://discuss.pytorch.org/u/jfix)\
**Post date:** [May 28, 2020, 9:48pm UTC](https://discuss.pytorch.org/t/initialize-weights-as-a-constant-array/79965/3 "2020-05-28T21:48:18Z")

</div>

I’m not sure I understand the issue. Why do you need to mark it as `const`? Your microcontroller application requires the weights to be `const`? Can you not just create a constant reference to use in APIs other than the model entry function?
