Skip to content

Commit

Permalink
Added some tests for the ComputeGraph.
Browse files Browse the repository at this point in the history
  • Loading branch information
christophe0606 committed Mar 10, 2023
1 parent 5ca0d34 commit d760b35
Show file tree
Hide file tree
Showing 110 changed files with 11,393 additions and 7 deletions.
7 changes: 7 additions & 0 deletions ComputeGraph/FAQ.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# FAQ

## Table of contents

* [Alignment](#alignment)
* [Memory sharing](#memory-sharing-example)
* [Latencies](#latencies)
* [Performances](#performances)

## Alignment

When the `memoryOptimization` mode is enabled, the memory can be shared between different FIFOs (when the FIFOs are in fact used as simple arrays).
Expand Down
18 changes: 15 additions & 3 deletions ComputeGraph/cg/nodes/cpp/CFFT.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class CFFT<float32_t,inputSize,float32_t,inputSize>: public GenericNode<float32_
{
public:
CFFT(FIFOBase<float32_t> &src,FIFOBase<float32_t> &dst):GenericNode<float32_t,inputSize,float32_t,inputSize>(src,dst){
arm_status status;
status=arm_cfft_init_f32(&sfft,inputSize>>1);
};

Expand All @@ -57,6 +56,10 @@ class CFFT<float32_t,inputSize,float32_t,inputSize>: public GenericNode<float32_

int run() final
{
if (status!=ARM_MATH_SUCCESS)
{
return(CG_INIT_FAILURE);
}
float32_t *a=this->getReadBuffer();
float32_t *b=this->getWriteBuffer();
memcpy((void*)b,(void*)a,inputSize*sizeof(float32_t));
Expand All @@ -65,6 +68,7 @@ class CFFT<float32_t,inputSize,float32_t,inputSize>: public GenericNode<float32_
};

arm_cfft_instance_f32 sfft;
arm_status status;

};

Expand All @@ -79,7 +83,6 @@ class CFFT<float16_t,inputSize,float16_t,inputSize>: public GenericNode<float16_
{
public:
CFFT(FIFOBase<float16_t> &src,FIFOBase<float16_t> &dst):GenericNode<float16_t,inputSize,float16_t,inputSize>(src,dst){
arm_status status;
status=arm_cfft_init_f16(&sfft,inputSize>>1);
};

Expand All @@ -97,6 +100,10 @@ class CFFT<float16_t,inputSize,float16_t,inputSize>: public GenericNode<float16_

int run() final
{
if (status!=ARM_MATH_SUCCESS)
{
return(CG_INIT_FAILURE);
}
float16_t *a=this->getReadBuffer();
float16_t *b=this->getWriteBuffer();
memcpy((void*)b,(void*)a,inputSize*sizeof(float16_t));
Expand All @@ -105,6 +112,7 @@ class CFFT<float16_t,inputSize,float16_t,inputSize>: public GenericNode<float16_
};

arm_cfft_instance_f16 sfft;
arm_status status;

};
#endif
Expand All @@ -118,7 +126,6 @@ class CFFT<q15_t,inputSize,q15_t,inputSize>: public GenericNode<q15_t,inputSize,
{
public:
CFFT(FIFOBase<q15_t> &src,FIFOBase<q15_t> &dst):GenericNode<q15_t,inputSize,q15_t,inputSize>(src,dst){
arm_status status;
status=arm_cfft_init_q15(&sfft,inputSize>>1);
};

Expand All @@ -136,6 +143,10 @@ class CFFT<q15_t,inputSize,q15_t,inputSize>: public GenericNode<q15_t,inputSize,

int run() final
{
if (status!=ARM_MATH_SUCCESS)
{
return(CG_INIT_FAILURE);
}
q15_t *a=this->getReadBuffer();
q15_t *b=this->getWriteBuffer();
memcpy((void*)b,(void*)a,inputSize*sizeof(q15_t));
Expand All @@ -144,6 +155,7 @@ class CFFT<q15_t,inputSize,q15_t,inputSize>: public GenericNode<q15_t,inputSize,
};

arm_cfft_instance_q15 sfft;
arm_status status;

};

Expand Down
20 changes: 16 additions & 4 deletions ComputeGraph/cg/nodes/cpp/ICFFT.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class ICFFT<float32_t,inputSize,float32_t,inputSize>: public GenericNode<float32
{
public:
ICFFT(FIFOBase<float32_t> &src,FIFOBase<float32_t> &dst):GenericNode<float32_t,inputSize,float32_t,inputSize>(src,dst){
arm_status status;
status=arm_cfft_init_f32(&sifft,inputSize>>1);
};

Expand All @@ -57,6 +56,10 @@ class ICFFT<float32_t,inputSize,float32_t,inputSize>: public GenericNode<float32

int run() final
{
if (status!=ARM_MATH_SUCCESS)
{
return(CG_INIT_FAILURE);
}
float32_t *a=this->getReadBuffer();
float32_t *b=this->getWriteBuffer();
memcpy((void*)b,(void*)a,inputSize*sizeof(float32_t));
Expand All @@ -65,6 +68,7 @@ class ICFFT<float32_t,inputSize,float32_t,inputSize>: public GenericNode<float32
};

arm_cfft_instance_f32 sifft;
arm_status status;

};

Expand All @@ -79,7 +83,6 @@ class ICFFT<float16_t,inputSize,float16_t,inputSize>: public GenericNode<float16
{
public:
ICFFT(FIFOBase<float16_t> &src,FIFOBase<float16_t> &dst):GenericNode<float16_t,inputSize,float16_t,inputSize>(src,dst){
arm_status status;
status=arm_cfft_init_f16(&sifft,inputSize>>1);
};

Expand All @@ -97,6 +100,10 @@ class ICFFT<float16_t,inputSize,float16_t,inputSize>: public GenericNode<float16

int run() final
{
if (status!=ARM_MATH_SUCCESS)
{
return(CG_INIT_FAILURE);
}
float16_t *a=this->getReadBuffer();
float16_t *b=this->getWriteBuffer();
memcpy((void*)b,(void*)a,inputSize*sizeof(float16_t));
Expand All @@ -105,6 +112,7 @@ class ICFFT<float16_t,inputSize,float16_t,inputSize>: public GenericNode<float16
};

arm_cfft_instance_f16 sifft;
arm_status status;

};
#endif
Expand All @@ -119,7 +127,6 @@ class ICFFT<q15_t,inputSize,q15_t,inputSize>: public GenericNode<q15_t,inputSize
{
public:
ICFFT(FIFOBase<q15_t> &src,FIFOBase<q15_t> &dst):GenericNode<q15_t,inputSize,q15_t,inputSize>(src,dst){
arm_status status;
status=arm_cfft_init_q15(&sifft,inputSize>>1);
};

Expand All @@ -137,14 +144,19 @@ class ICFFT<q15_t,inputSize,q15_t,inputSize>: public GenericNode<q15_t,inputSize

int run() final
{
if (status!=ARM_MATH_SUCCESS)
{
return(CG_INIT_FAILURE);
}
q15_t *a=this->getReadBuffer();
q15_t *b=this->getWriteBuffer();
memcpy((void*)b,(void*)a,inputSize*sizeof(q15_t));
arm_cfft_q15(&sifft,b,1,1);
return(0);
};

arm_cfft_instance_f32 sifft;
arm_cfft_instance_q15 sifft;
arm_status status;

};
#endif
3 changes: 3 additions & 0 deletions ComputeGraph/tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cprj/out
cprj/tmp
__pycache__
9 changes: 9 additions & 0 deletions ComputeGraph/tests/ARMCM55_FP_MVE_config.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
core_clk.mul=50000000
mps3_board.visualisation.disable-visualisation=1
cpu0.semihosting-enable=0
cpu0.FPU=1
cpu0.MVE=2
cpu0.SAU=0
cpu0.SECEXT=1
cpu0.INITSVTOR=0
cpu0.INITNSVTOR=0
129 changes: 129 additions & 0 deletions ComputeGraph/tests/AppNodes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/* ----------------------------------------------------------------------
* Project: CMSIS DSP Library
* Title: AppNodes.h
* Description: Application nodes for Example simple
*
* Target Processor: Cortex-M and Cortex-A cores
* --------------------------------------------------------------------
*
* Copyright (C) 2021-2023 ARM Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _APPNODES_H_
#define _APPNODES_H_

#include <iostream>

template<typename IN, int inputSize>
class Sink: public GenericSink<IN, inputSize>
{
public:
Sink(FIFOBase<IN> &src):GenericSink<IN,inputSize>(src){};

int prepareForRunning() final
{
if (this->willUnderflow())
{
return(CG_SKIP_EXECUTION_ID_CODE); // Skip execution
}

return(0);
};

int run() final
{
IN *b=this->getReadBuffer();
printf("Sink\n");
for(int i=0;i<inputSize;i++)
{
std::cout << (int)b[i] << std::endl;
}
return(0);
};

};

template<typename OUT,int outputSize>
class Source: public GenericSource<OUT,outputSize>
{
public:
Source(FIFOBase<OUT> &dst):GenericSource<OUT,outputSize>(dst){};

int prepareForRunning() final
{
if (this->willOverflow())
{
return(CG_SKIP_EXECUTION_ID_CODE); // Skip execution
}

return(0);
};

int run() final{
OUT *b=this->getWriteBuffer();

printf("Source\n");
for(int i=0;i<outputSize;i++)
{
b[i] = (OUT)i;
}
return(0);
};

};


template<typename IN, int inputSize,
typename OUT, int outputSize>
class ProcessingNode;


template<typename IN, int inputOutputSize>
class ProcessingNode<IN,inputOutputSize,IN,inputOutputSize>: public GenericNode<IN,inputOutputSize,IN,inputOutputSize>
{
public:
ProcessingNode(FIFOBase<IN> &src,
FIFOBase<IN> &dst):GenericNode<IN,inputOutputSize,
IN,inputOutputSize>(src,dst){};

int prepareForRunning() final
{
if (this->willOverflow() ||
this->willUnderflow())
{
return(CG_SKIP_EXECUTION_ID_CODE); // Skip execution
}

return(0);
};

int run() final{
printf("ProcessingNode\n");
IN *a=this->getReadBuffer();
IN *b=this->getWriteBuffer();
for(int i=0;i<inputOutputSize;i++)
{
b[i] = a[i]+1;
}
return(0);
};

};




#endif
Loading

0 comments on commit d760b35

Please sign in to comment.