add the clip, dropout, batchnorm op

This commit is contained in:
zhengzhouheng 2021-04-06 18:22:37 +08:00 committed by Kainan Cha
parent 9dfcb5a230
commit 07fc3b9914
7 changed files with 273 additions and 3 deletions

45
include/tim/vx/ops/batchnorm.h Executable file
View File

@ -0,0 +1,45 @@
/****************************************************************************
*
* Copyright (c) 2020 Vivante Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#ifndef OVXLIBXX_OPERATIONS_BATCHNORM_H_
#define OVXLIBXX_OPERATIONS_BATCHNORM_H_
#include "tim/vx/operation.h"
namespace tim {
namespace vx {
namespace ops {
class BatchNorm : public Operation {
public:
BatchNorm(Graph* graph, float eps);
protected:
float eps_;
};
} // namespace ops
} // namespace vx
} // namespace tim
#endif /* OVXLIBXX_OPERATIONS_BATCHNORM_H_ */

47
include/tim/vx/ops/clip.h Executable file
View File

@ -0,0 +1,47 @@
/****************************************************************************
*
* Copyright (c) 2020 Vivante Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#ifndef OVXLIBXX_OPERATIONS_CLIP_H_
#define OVXLIBXX_OPERATIONS_CLIP_H_
#include "tim/vx/operation.h"
namespace tim {
namespace vx {
namespace ops {
class Clip : public Operation {
public:
Clip(Graph* graph, float min, float max);
protected:
float min_;
float max_;
};
} // namespace ops
} // namespace vx
} // namespace tim
#endif /* OVXLIBXX_OPERATIONS_CLIP_H_ */

47
include/tim/vx/ops/dropout.h Executable file
View File

@ -0,0 +1,47 @@
/****************************************************************************
*
* Copyright (c) 2020 Vivante Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#ifndef OVXLIBXX_OPERATIONS_DROPOUT_H_
#define OVXLIBXX_OPERATIONS_DROPOUT_H_
#include "tim/vx/operation.h"
namespace tim {
namespace vx {
namespace ops {
class Dropout : public Operation {
public:
Dropout(Graph* graph, float ratio);
protected:
float ratio_;
};
} // namespace ops
} // namespace vx
} // namespace tim
#endif /* OVXLIBXX_OPERATIONS_DROPOUT_H_ */

View File

@ -15,7 +15,7 @@ Concat|CONCAT|Mapped
Split|SPLIT|Mapped
||NOOP|Unmapped
||ROI_POOL|Unmapped
||BATCH_NORM|Unmapped
BatchNorm|BATCH_NORM|Mapped
||PROPOSAL|Unmapped
DeConv2d|DECONVOLUTION|Mapped
Reshape|RESHAPE|Mapped
@ -42,7 +42,7 @@ Sqrt|SQRT|Mapped
Rsqrt|RSQRT|Mapped
SoftRelu|SOFTRELU|Unmapped
Div|DIVIDE|Mapped
||DROPOUT|Unmapped
Dropout|DROPOUT|Mapped
||SHUFFLECHANNEL|Unmapped
Resize|RESIZE|Mapped
Reverse|REVERSE|Mapped
@ -94,7 +94,7 @@ Exp|EXP|Mapped
||EMBEDDING_LOOKUP|Unmapped
||LSH_PROJECTION|Unmapped
||RNN|Unmapped
||CLIP|Unmapped
Clip|CLIP|Mapped
||POST_PROCESS|Unmapped
||PRE_PROCESS_GRAY|Unmapped
||UNSTACK|Unmapped

43
src/tim/vx/ops/batchnorm.cc Executable file
View File

@ -0,0 +1,43 @@
/****************************************************************************
*
* Copyright (c) 2020 Vivante Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#include "tim/vx/ops/batchnorm.h"
#include "vsi_nn_pub.h"
#include "operation_private.h"
namespace tim {
namespace vx {
namespace ops {
BatchNorm::BatchNorm(Graph* graph, float eps)
: Operation(graph, VSI_NN_OP_BATCH_NORM),
eps_(eps) {
this->impl()->node()->nn_param.batch_norm.eps = eps_;
}
} // namespace ops
} // namespace vx
} // namespace tim

45
src/tim/vx/ops/clip.cc Executable file
View File

@ -0,0 +1,45 @@
/****************************************************************************
*
* Copyright (c) 2020 Vivante Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#include "tim/vx/ops/clip.h"
#include "vsi_nn_pub.h"
#include "operation_private.h"
namespace tim {
namespace vx {
namespace ops {
Clip::Clip(Graph* graph, float min, float max)
: Operation(graph, VSI_NN_OP_CLIP),
min_(min),
max_(max) {
this->impl()->node()->nn_param.clip.min = min_;
this->impl()->node()->nn_param.clip.max = max_;
}
} // namespace ops
} // namespace vx
} // namespace tim

43
src/tim/vx/ops/dropout.cc Executable file
View File

@ -0,0 +1,43 @@
/****************************************************************************
*
* Copyright (c) 2020 Vivante Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#include "tim/vx/ops/dropout.h"
#include "vsi_nn_pub.h"
#include "operation_private.h"
namespace tim {
namespace vx {
namespace ops {
Dropout::Dropout(Graph* graph, float ratio)
: Operation(graph, VSI_NN_OP_DROPOUT),
ratio_(ratio) {
this->impl()->node()->nn_param.dropout.ratio = ratio_;
}
} // namespace ops
} // namespace vx
} // namespace tim