Commit 09706d86 authored by Nishant Patel's avatar Nishant Patel Committed by adstraw

Change the call frame order (#711)

parent ff6c525a
......@@ -135,7 +135,7 @@ def binary_op_exec(op_str):
result_arr = np.array([[0, 0], [0, 0]], dtype=np.float32)
result.write(util.numpy_to_c(result_arr), 0, 16)
cf.call([a, b], [result])
cf.call([result], [a, b])
result.read(util.numpy_to_c(result_arr), 0, 16)
a_arr = np.array([[1, 6], [7, 4]], dtype=np.float32)
......@@ -164,7 +164,7 @@ def binary_op_comparison(op_str):
result_arr = np.array([[False, False], [False, False]], dtype=np.bool)
result.write(util.numpy_to_c(result_arr), 0, 4)
cf.call([a, b], [result])
cf.call([result], [a, b])
result.read(util.numpy_to_c(result_arr), 0, 4)
a_arr = np.array([[1, 5], [3, 2]], dtype=np.float32)
......@@ -276,7 +276,7 @@ def test_add_with_mul():
result_arr = np.array([0, 0, 0, 0], dtype=np.float32)
result.write(util.numpy_to_c(result_arr), 0, 16)
cf.call([a, b, c], [result])
cf.call([result], [a, b, c])
result.read(util.numpy_to_c(result_arr), 0, 16)
a_arr = np.array([1, 2, 3, 4], dtype=np.float32)
......@@ -384,7 +384,7 @@ def unary_op_exec(op_str, input_list):
result_arr = np.zeros(shape_np, dtype=np.float32)
result.write(util.numpy_to_c(result_arr), 0, 16)
cf.call([a], [result])
cf.call([result], [a])
result.read(util.numpy_to_c(result_arr), 0, 16)
a_arr = np.array(input_list, dtype=np.float32)
......@@ -535,7 +535,7 @@ def test_not():
result_arr = np.array([False, False], dtype=np.bool)
result.write(util.numpy_to_c(result_arr), 0, 2)
cf.call([a], [result])
cf.call([result], [a])
result.read(util.numpy_to_c(result_arr), 0, 2)
a_arr = np.array([True, False], dtype=np.bool)
......@@ -561,7 +561,7 @@ def test_sum():
result_arr = np.array([0], dtype=np.float32)
result.write(util.numpy_to_c(result_arr), 0, 4)
cf.call([a], [result])
cf.call([result], [a])
result.read(util.numpy_to_c(result_arr), 0, 4)
a_arr = np.array([1, 2, 3, 4], dtype=np.float32)
......@@ -587,7 +587,7 @@ def test_reshape():
result_arr = np.array([[0, 0], [0, 0], [0, 0]], dtype=np.float32)
result.write(util.numpy_to_c(result_arr), 0, 24)
cf.call([a], [result])
cf.call([result], [a])
result.read(util.numpy_to_c(result_arr), 0, 24)
a_arr = np.array([[1, 2, 3], [4, 5, 6]], dtype=np.float32)
......@@ -614,7 +614,7 @@ def test_convert():
result_arr = np.array([False, False, False], dtype=np.bool)
result.write(util.numpy_to_c(result_arr), 0, 3)
cf.call([a], [result])
cf.call([result], [a])
result.read(util.numpy_to_c(result_arr), 0, 3)
a_arr = np.array([1, 5, 3], dtype=np.float32)
......@@ -631,7 +631,7 @@ def test_convert():
result_arr = np.array([0, 0, 0], dtype=np.int32)
result.write(util.numpy_to_c(result_arr), 0, 12)
cf.call([a], [result])
cf.call([result], [a])
result.read(util.numpy_to_c(result_arr), 0, 12)
a_arr = np.array([1.4, 5.4, 3.9], dtype=np.float32)
......@@ -656,7 +656,7 @@ def test_broadcast():
result_arr = np.zeros((3, 3), dtype=np.float32)
result.write(util.numpy_to_c(result_arr), 0, 36)
cf.call([a], [result])
cf.call([result], [a])
result.read(util.numpy_to_c(result_arr), 0, 36)
a_arr = np.array([[0], [0], [0]], dtype=np.float32)
......@@ -679,7 +679,7 @@ def test_constant():
result_arr = np.zeros((3, 3), dtype=np.float32)
result.write(util.numpy_to_c(result_arr), 0, 36)
cf.call([], [result])
cf.call([result], [])
result.read(util.numpy_to_c(result_arr), 0, 36)
result_arr_ref = np.arange(9).reshape(3, 3)
......@@ -712,7 +712,7 @@ def test_reduce():
result_arr = np.zeros((2, 2), dtype=np.float32)
result.write(util.numpy_to_c(result_arr), 0, 16)
cf.call([a], [result])
cf.call([result], [a])
result.read(util.numpy_to_c(result_arr), 0, 16)
a_arr = np.arange(8).reshape(2, 2, 2)
......@@ -737,7 +737,7 @@ def test_onehot():
result_arr = np.zeros((3, 3), dtype=np.float32)
result.write(util.numpy_to_c(result_arr), 0, 36)
cf.call([a], [result])
cf.call([result], [a])
result.read(util.numpy_to_c(result_arr), 0, 36)
a_arr = np.array([1, 0, 2])
......@@ -769,7 +769,7 @@ def test_concat():
result_arr = np.zeros(6, dtype=np.float32).reshape(3, 2)
result.write(util.numpy_to_c(result_arr), 0, 24)
cf.call([a, b, c], [result])
cf.call([result], [a, b, c])
result.read(util.numpy_to_c(result_arr), 0, 24)
a_arr = np.array([[1, 2]], dtype=np.float32)
......@@ -803,7 +803,7 @@ def test_select():
result_arr = np.array([[0, 0]], dtype=np.float32)
result.write(util.numpy_to_c(result_arr), 0, 8)
cf.call([a, b, c], [result])
cf.call([result], [a, b, c])
result.read(util.numpy_to_c(result_arr), 0, 8)
result_arr_ref = np.array([[5, 8]])
......@@ -834,7 +834,7 @@ def test_slice():
result_arr = np.zeros(16, dtype=np.float32).reshape(4, 4)
result.write(util.numpy_to_c(result_arr), 0, 16*4)
cf.call([a], [result])
cf.call([result], [a])
result.read(util.numpy_to_c(result_arr), 0, 64)
result_arr_ref = input_arr[lower_bounds[0]:upper_bounds[0], lower_bounds[1]:upper_bounds[1]]
......@@ -853,7 +853,7 @@ def test_slice():
result_arr = np.zeros(8, dtype=np.float32).reshape(4, 2)
result.write(util.numpy_to_c(result_arr), 0, 8*4)
cf.call([a], [result])
cf.call([result], [a])
result.read(util.numpy_to_c(result_arr), 0, 32)
result_arr_ref = result_arr_ref[::strides[0], ::strides[1]]
......@@ -887,7 +887,7 @@ def test_replace_slice():
result_arr = np.zeros(24, dtype=np.float32).reshape(6, 4)
result.write(util.numpy_to_c(result_arr), 0, 24*4)
cf.call([a, b], [result])
cf.call([result], [a, b])
result.read(util.numpy_to_c(result_arr), 0, 24*4)
result_arr_ref = np.copy(input_arr_a)
......@@ -905,7 +905,7 @@ def test_replace_slice():
parameter_list, 'test')
backend, cf = make_backend_call_frame(function)
cf.call([a, b], [result])
cf.call([result], [a, b])
result.read(util.numpy_to_c(result_arr), 0, 24*4)
result_arr_ref = np.copy(input_arr_a)
......@@ -936,7 +936,7 @@ def test_max_pool():
result_arr = np.zeros(8, dtype=np.float32).reshape(1, 1, 8)
result.write(util.numpy_to_c(result_arr), 0, 8*4)
cf.call([a], [result])
cf.call([result], [a])
result.read(util.numpy_to_c(result_arr), 0, 32)
result_arr_ref = (np.arange(8) + 2).reshape(1, 1, 8)
......@@ -953,7 +953,7 @@ def test_max_pool():
result_arr = np.zeros(size, dtype=np.float32).reshape(1, 1, size)
result.write(util.numpy_to_c(result_arr), 0, size*4)
cf.call([a], [result])
cf.call([result], [a])
result.read(util.numpy_to_c(result_arr), 0, size*4)
result_arr_ref = ((np.arange(size) + 1) * 2).reshape(1, 1, size)
......@@ -978,7 +978,7 @@ def test_max_pool():
result_arr = np.zeros(64, dtype=np.float32).reshape(1, 1, 8, 8)
result.write(util.numpy_to_c(result_arr), 0, 8*8*4)
cf.call([a], [result])
cf.call([result], [a])
result.read(util.numpy_to_c(result_arr), 0, 8*8*4)
result_arr_ref = ((np.arange(100).reshape(10, 10))[2:, 2:]).reshape(1, 1, 8, 8)
......@@ -995,7 +995,7 @@ def test_max_pool():
result_arr = np.zeros(size*size, dtype=np.float32).reshape(1, 1, size, size)
result.write(util.numpy_to_c(result_arr), 0, size*size*4)
cf.call([a], [result])
cf.call([result], [a])
result.read(util.numpy_to_c(result_arr), 0, size*size*4)
result_arr_ref = ((np.arange(100).reshape(10, 10))[2::2, 2::2]).reshape(1, 1, size, size)
......@@ -1075,7 +1075,7 @@ def test_convolution():
result = backend.make_primary_tensor_view(element_type, Shape([1, 1, 14, 14]))
result.write(util.numpy_to_c(result_arr), 0, 14*14*4)
cf.call([a, b], [result])
cf.call([result], [a, b])
result.read(util.numpy_to_c(result_arr), 0, 14*14*4)
result_arr_ref = convolution2d(image_arr[0][0], filter_arr[0][0]).reshape(1, 1, 14, 14)
......@@ -1109,7 +1109,7 @@ def test_convolution_with_strides():
result_arr = np.zeros(16, dtype=np.float32).reshape(1, 1, 4, 4)
result = backend.make_primary_tensor_view(element_type, Shape([1, 1, 4, 4]))
result.write(util.numpy_to_c(result_arr), 0, 4*4*4)
cf.call([a, b], [result])
cf.call([result], [a, b])
result.read(util.numpy_to_c(result_arr), 0, 4*4*4)
result_arr_ref = convolution2d(image_arr[0][0], filter_arr[0][0], strides).reshape(1, 1, 4, 4)
......@@ -1143,7 +1143,7 @@ def test_convolution_with_filter_dilation():
result_arr = np.zeros(36, dtype=np.float32).reshape(1, 1, 6, 6)
result = backend.make_primary_tensor_view(element_type, Shape([1, 1, 6, 6]))
result.write(util.numpy_to_c(result_arr), 0, 6*6*4)
cf.call([a, b], [result])
cf.call([result], [a, b])
result.read(util.numpy_to_c(result_arr), 0, 6*6*4)
result_arr_ref = convolution2d(image_arr[0][0], filter_arr[0][0], strides,
......@@ -1183,7 +1183,7 @@ def test_convolution_with_padding():
result_arr = np.zeros(36, dtype=np.float32).reshape(1, 1, 6, 6)
result = backend.make_primary_tensor_view(element_type, Shape([1, 1, 6, 6]))
result.write(util.numpy_to_c(result_arr), 0, 6*6*4)
cf.call([a, b], [result])
cf.call([result], [a, b])
result.read(util.numpy_to_c(result_arr), 0, 6*6*4)
result_arr_ref = convolution2d(image_arr[0][0], filter_arr[0][0], strides,
......@@ -1221,7 +1221,7 @@ def test_convolution_with_padding():
result_arr = np.zeros(81, dtype=np.float32).reshape(1, 1, 9, 9)
result = backend.make_primary_tensor_view(element_type, Shape([1, 1, 9, 9]))
result.write(util.numpy_to_c(result_arr), 0, 9*9*4)
cf.call([a, b], [result])
cf.call([result], [a, b])
result.read(util.numpy_to_c(result_arr), 0, 9*9*4)
result_arr_ref = convolution2d(image_arr[0][0], filter_arr[0][0], strides,
......@@ -1262,7 +1262,7 @@ def test_convolution_with_data_dilation():
result_arr = np.zeros(17*17, dtype=np.float32).reshape(1, 1, 17, 17)
result = backend.make_primary_tensor_view(element_type, Shape([1, 1, 17, 17]))
result.write(util.numpy_to_c(result_arr), 0, 17*17*4)
cf.call([a, b], [result])
cf.call([result], [a, b])
result.read(util.numpy_to_c(result_arr), 0, 17*17*4)
result_arr_ref = convolution2d(image_arr[0][0], filter_arr[0][0], strides,
......@@ -1309,7 +1309,7 @@ def test_convolutionBackpropData():
result_arr = np.zeros(10*10, dtype=np.float32).reshape(1, 1, 10, 10)
result = backend.make_primary_tensor_view(element_type, Shape([1, 1, 10, 10]))
result.write(util.numpy_to_c(result_arr), 0, 10*10*4)
cf.call([a, b], [result])
cf.call([result], [a, b])
result.read(util.numpy_to_c(result_arr), 0, 10*10*4)
result_arr_ref = np.array(
......@@ -1364,7 +1364,7 @@ def test_convolutionBackpropFilters():
result_arr = np.zeros(3*3, dtype=np.float32).reshape(1, 1, 3, 3)
result = backend.make_primary_tensor_view(element_type, Shape([1, 1, 3, 3]))
result.write(util.numpy_to_c(result_arr), 0, 3*3*4)
cf.call([a, b], [result])
cf.call([result], [a, b])
result.read(util.numpy_to_c(result_arr), 0, 3*3*4)
result_arr_ref = np.array(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment