Skip to content

Commit

Permalink
r536: fixed a memory issue
Browse files Browse the repository at this point in the history
when winding back to an internal node
  • Loading branch information
lh3 committed Apr 2, 2017
1 parent 9cefa4a commit 04b9258
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions kann.c
Expand Up @@ -211,14 +211,19 @@ void kann_rnn_start(kann_t *a)
kad_node_t *q = p->pre;
if (q->x) memcpy(p->x, q->x, kad_len(p) * sizeof(float));
else memset(p->x, 0, kad_len(p) * sizeof(float));
if (q->n_child > 0) free(q->x);
q->x = p->x;
}
}
}

void kann_rnn_end(kann_t *a)
{
int i;
kad_ext_sync(a->n, a->v, a->x, a->g, a->c);
for (i = 0; i < a->n; ++i)
if (a->v[i]->pre && a->v[i]->pre->n_child > 0)
a->v[i]->pre->x = (float*)calloc(kad_len(a->v[i]->pre), sizeof(float));
}

static int kann_class_error_core(const kann_t *ann, int *base)
Expand Down
2 changes: 1 addition & 1 deletion kann.h
Expand Up @@ -27,7 +27,7 @@
#ifndef KANN_H
#define KANN_H

#define KANN_VERSION "r535"
#define KANN_VERSION "r536"

#define KANN_F_IN 0x1 /* input */
#define KANN_F_OUT 0x2 /* output */
Expand Down

0 comments on commit 04b9258

Please sign in to comment.