Skip to content
Snippets Groups Projects
Commit 82f68440 authored by Olivier BICHLER's avatar Olivier BICHLER
Browse files

Fixed reshape

parent 3811360d
No related branches found
No related tags found
2 merge requests!490.3.1,!45Fix export
Pipeline #73115 passed
......@@ -9,18 +9,18 @@ template<int M,
typename Input_T, typename Output_T>
__attribute__((always_inline)) inline
void reshape_forward (
const Input_T* __restrict, // First input is useless as it only dictate the resulting layout of the reshape
const Input_T* __restrict inputs2,
const Input_T* __restrict inputs,
const Input_T* __restrict /*shape*/,
Output_T* __restrict outputs)
{
// If inputs and outputs pointers are the same, the memory manager has already optimized this function so it is a no-op !
if (inputs2 == outputs)
if (inputs == outputs)
return;
// A reshape in c++ world should equal to a Noop
// We only need to copy the input buffer to the output
for (int m = 0; m < M; ++m) {
outputs[m] = inputs2[m];
outputs[m] = inputs[m];
}
}
......
......@@ -6,3 +6,5 @@
{% include "./_meminfo.jinja" %}
{# For layer configuration -#}
#define {{ name|upper }}_NB_ELTS {{ in_dims[0]|join('*') }}
#endif /* {{ name|upper }}_LAYER_H */
......@@ -427,12 +427,31 @@ class test_operator_export(unittest.TestCase):
def test_transpose(self):
print("Transpose")
model = aidge_core.sequential([
aidge_core.Producer([1, 2, 7, 8], name="producer"),
aidge_core.Transpose(output_dims_order=[0, 2, 3, 1], name="transpose")
])
self.unit_test_export(model, "Transpose", [[1, 7, 8, 2]])
def test_reshape(self):
print("Reshape")
model = aidge_core.sequential([
aidge_core.Reshape(name="reshape")
])
shape = aidge_core.Producer(aidge_core.Tensor(np.array([7, 2, 1, 8], dtype=np.int64)), name="shape")
shape.add_child(model.get_node("reshape"), 0, 1)
model.add(shape)
self.unit_test_export(model, "Reshape", [[1, 7, 8, 2]], random_weights=False)
def test_matmul(self):
print("MatMul")
model = aidge_core.sequential([
aidge_core.Producer([4, 8], name="producer"),
aidge_core.MatMul(name="matmul")
])
self.unit_test_export(model, "MatMul", [[8, 4]])
def test_concat_axis_2(self):
print("ConcatAxis2")
model = aidge_core.sequential([
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment