Skip to content

Commit ecfa542

Browse files
move input declarations to global scope to reduce stack usage, use float specific functions
1 parent 4ccbbf1 commit ecfa542

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

keras2c/make_test_suite.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ def make_test_suite(model, function_name, malloc_vars, num_tests=10, stateful=Fa
7373
s += 'float maxabs(k2c_tensor *tensor1, k2c_tensor *tensor2);\n'
7474
s += 'struct timeval GetTimeStamp(); \n \n'
7575
file.write(s)
76-
s = 'int main(){\n'
77-
file.write(s)
7876
for i in range(num_tests):
7977
if i == num_tests//2 and stateful:
8078
model.reset_states()
@@ -109,6 +107,9 @@ def make_test_suite(model, function_name, malloc_vars, num_tests=10, stateful=Fa
109107
model_outputs[j] + '_test' + str(i+1)))
110108
file.write(Weights2C.array2c(np.zeros(output.shape), 'c_' +
111109
model_outputs[j] + '_test' + str(i+1)))
110+
s = 'int main(){\n'
111+
file.write(s)
112+
112113
s = ' float errors[' + str(num_tests*num_outputs) + '];\n'
113114
s += ' size_t num_tests = ' + str(num_tests) + '; \n'
114115
s += 'size_t num_outputs = ' + str(num_outputs) + '; \n'
@@ -169,7 +170,7 @@ def make_test_suite(model, function_name, malloc_vars, num_tests=10, stateful=Fa
169170
float x = 0; \n
170171
float y = 0; \n
171172
for(size_t i=0; i<tensor1->numel; i++){\n
172-
y = fabs(tensor1->array[i]-tensor2->array[i]);
173+
y = fabsf(tensor1->array[i]-tensor2->array[i]);
173174
if (y>x) {x=y;}}
174175
return x;}\n\n"""
175176
file.write(s)

0 commit comments

Comments
 (0)