Skip to content

Remove remaining unnecessary zeroing-out in backend code #382

@lukstafi

Description

@lukstafi

I noticed this when updating the introductory slides:

 void scalar_loss_forward_and_gradient_then_gd_update(
    const uint32_t i1,
    const uint32_t i2,
    float *b1,
    float *b2,
    float *learning_rate,
    float *moons_classes,
    float *moons_flat,
    float *scalar_loss,
    float *w1,
    float *w2,
    float *w3) {

  /* Local declarations and initialization. */
...
  float w3_grad[16] = {0};
  float w1_grad[32] = {0};
  float n35[160] = {0};

  /* Main logic. */
  /* scalar_loss forward and gradient update */
  for (uint32_t i161 = 0; i161 <= 9; ++i161) {
    for (uint32_t i162 = 0; i162 <= 15; ++i162) {
      n35[(i161) * 16 + i162] = (float)(0);
    }
  }
  for (uint32_t i52 = 0; i52 <= 9; ++i52) {
    for (uint32_t i53 = 0; i53 <= 15; ++i53) {
      for (uint32_t i54 = 0; i54 <= 1; ++i54) {
        n35[(i52) * 16 + i53] =
            fmaf(w1[(i53) * 2 + i54], moons_flat[((i1) * 10 + i52) * 2 + i54], n35[(i52) * 16 + i53]);
      }
    }
  }
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions