add onnx pack
This commit is contained in:
27
components/ai/onnx/operator_int/relu.c
Normal file
27
components/ai/onnx/operator_int/relu.c
Normal file
@@ -0,0 +1,27 @@
|
||||
#include "onnx.h"
|
||||
|
||||
void relu(const int *input, uint32_t size, int* output)
|
||||
{
|
||||
uint32_t i;
|
||||
memcpy(output, input, sizeof(int) * size);
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
if (output[i] < 0)
|
||||
output[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int* relu_layer(Onnx__GraphProto* graph, const int *input, int64_t* shapeInput, int64_t* shapeOutput, const char* layer_name)
|
||||
{
|
||||
//assert(graph != NULL && input != NULL && layer_name != "" );
|
||||
|
||||
int64_t len = shapeInput[0] * shapeInput[1] * shapeInput[2];
|
||||
int* output = (int*) malloc(sizeof(int)*len);
|
||||
memset(output, 0, sizeof(sizeof(int)*len));
|
||||
|
||||
relu(input, len, output);
|
||||
|
||||
memcpy(shapeInput, shapeOutput, sizeof(int64_t)*3);
|
||||
|
||||
return output;
|
||||
}
|
Reference in New Issue
Block a user