Initial Commit for VERSION 1.1.28

Signed-off-by: Jiang Bo <bo.jiang@verisilicon.com>
This commit is contained in:
Jiang Bo 2021-01-11 18:16:03 +08:00
commit 7972af0697
971 changed files with 295216 additions and 0 deletions

51
BUILD.bazel Normal file
View File

@ -0,0 +1,51 @@
package(
default_visibility = ["//visibility:public"],
features = ["-parse_headers"],
)
cc_library(
name = "tim-vx_interface",
copts = ["-std=c++14", "-Werror", "-fvisibility=default"],
includes = [
"include",
"src/tim/vx",
],
hdrs = [
"include/tim/vx/context.h",
"include/tim/vx/graph.h",
"include/tim/vx/operation.h",
"include/tim/vx/tensor.h",
"include/tim/vx/types.h",
] + glob([
"include/tim/vx/ops/*.h"
]),
srcs = [
"src/tim/vx/context_private.h",
"src/tim/vx/context.cc",
"src/tim/vx/graph_private.h",
"src/tim/vx/graph.cc",
"src/tim/vx/operation.cc",
"src/tim/vx/operation_private.h",
"src/tim/vx/tensor.cc",
"src/tim/vx/tensor_private.h",
"src/tim/vx/type_utils.h",
"src/tim/vx/type_utils.cc",
] + glob([
"src/tim/vx/ops/*.cc"
]),
deps = [
"//src/tim/vx/internal:ovxlibimpl",
],
linkstatic = True,
strip_include_prefix = "include",
)
cc_binary(
name = "libtim-vx.so",
linkshared = True,
linkstatic = False,
deps = [
"tim-vx_interface",
],
)

23
LICENSE Normal file
View File

@ -0,0 +1,23 @@
/****************************************************************************
*
* 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.
*
*****************************************************************************/

36
README.md Normal file
View File

@ -0,0 +1,36 @@
# TIM-VX - Tensor Interface Module for OpenVX
TIM-VX is a software integration module provided by VeriSilicon to facilitate deployment of Neural-Networks on OpenVX enabled ML accelerators. It serves as the backend binding for runtime frameworks such as Android NN, Tensorflow-Lite, MLIR, TVM and more.
Main Features
- Over 130 internal operators with rich format support for both quantized and floating point
- Simplified binding API calls to create Tensors and Operations
- Dynamic graph construction and supports shape inferencing
- Built-in custom layer extensions
- A set of utility functions for debugging
## Roadmap
Roadmap of TIM-VX will be updated here in the future.
## Get started
### Build and Run
TIM-VX uses [bazel](https://bazel.build) build system by default. [Install bazel](https://docs.bazel.build/versions/master/install.html) first to get started.
TIM-VX needs to be compiled and linked against VeriSilicon OpenVX SDK which provides related header files and pre-compiled libraries. A default linux-x86_64 SDK is provided which contains the simulation environment on PC. Platform specific SDKs can be obtained from respective SoC vendors.
To build TIM-VX
```shell
bazel build libtim-vx.so
```
To run sample LeNet
```shell
bazel build //samples/lenet:lenet_asymu8_cc
bazel run //samples/lenet:lenet_asymu8_cc
```
### Get familiar with OpenVX spec
To development for TIM-VX, you first need to get familiar with [OpenVX API](https://www.khronos.org/openvx/) and [OpenVX NN Extension API](https://www.khronos.org/registry/vx). Please head over to [Khronos](https://www.khronos.org/) to read the spec.

1
VERSION Normal file
View File

@ -0,0 +1 @@
1.1.28

9
WORKSPACE Normal file
View File

@ -0,0 +1,9 @@
workspace(name = "TIM_VX")
local_repository(
name = 'TOOLCHAINS',
path = 'toolchains',
)
load("@TOOLCHAINS//:toolchains.bzl", "init_toolchains")
init_toolchains()

44
include/tim/vx/context.h Normal file
View File

@ -0,0 +1,44 @@
/****************************************************************************
*
* 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 TIM_VX_CONTEXT_H_
#define TIM_VX_CONTEXT_H_
#include <memory>
#include "tim/vx/graph.h"
namespace tim {
namespace vx {
class Context {
public:
virtual ~Context() {}
static std::shared_ptr<Context> Create();
virtual std::shared_ptr<Graph> CreateGraph() = 0;
};
} // namespace vx
} // namespace tim
#endif /* TIM_VX_CONTEXT_H_ */

61
include/tim/vx/graph.h Normal file
View File

@ -0,0 +1,61 @@
/****************************************************************************
*
* 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 TIM_VX_GRAPH_H_
#define TIM_VX_GRAPH_H_
#include <memory>
#include <vector>
#include "tim/vx/tensor.h"
namespace tim {
namespace vx {
class Graph {
public:
virtual ~Graph() {}
/// Create a tensor with given `TensorSpec`
virtual std::shared_ptr<Tensor> CreateTensor(const TensorSpec& spec,
const void* data = nullptr) = 0;
/// Create a placeholder tensor for optional inputs of operations
virtual std::shared_ptr<Tensor> CreateTensorPlaceHolder() = 0;
/// Freeze graph
virtual bool Compile() = 0;
/// Process the compiled graph
virtual bool Run() = 0;
template <typename OpType, typename... Params>
std::shared_ptr<OpType> CreateOperation(Params... parameters) {
return std::make_shared<OpType>(this, parameters...);
}
};
} // namespace vx
} // namespace tim
#endif /* TIM_VX_GRAPH_H_ */

View File

@ -0,0 +1,59 @@
/****************************************************************************
*
* 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 TIM_VX_OPERATION_H_
#define TIM_VX_OPERATION_H_
#include "tim/vx/graph.h"
#include "tim/vx/tensor.h"
namespace tim {
namespace vx {
class OperationImpl;
class Operation {
public:
Operation(Graph* graph, uint32_t operation_id, int input_cnt = 0,
int ouput_cnt = 0);
virtual ~Operation();
Operation& BindInput(const std::shared_ptr<Tensor>& tensor);
Operation& BindOutput(const std::shared_ptr<Tensor>& tensor);
Operation& BindInputs(const std::vector<std::shared_ptr<Tensor>>& tensors);
Operation& BindOutputs(const std::vector<std::shared_ptr<Tensor>>& tensors);
Operation& SetRoundingPolicy(
OverflowPolicy overflow_policy = OverflowPolicy::SATURATE,
RoundingPolicy rounding_policy = RoundingPolicy::TO_ZERO,
DownScaleSizeRounding down_scale_size_rounding =
DownScaleSizeRounding::FLOOR,
uint32_t accumulator_bits = 0);
std::unique_ptr<OperationImpl>& impl();
protected:
std::unique_ptr<OperationImpl> impl_;
};
} // namespace vx
} // namespace tim
#endif /* TIM_VX_OPERATION_H_ */

View File

@ -0,0 +1,60 @@
/****************************************************************************
*
* 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 TIM_VX_OPS_ACTIVATIONS_H_
#define TIM_VX_OPS_ACTIVATIONS_H_
#include "tim/vx/operation.h"
namespace tim {
namespace vx {
namespace ops {
#define DECLARE_NO_PARAMETER_ACTIVATION(NAME) \
class NAME : public Operation { \
public: \
NAME(Graph* graph); \
};
DECLARE_NO_PARAMETER_ACTIVATION(Relu);
DECLARE_NO_PARAMETER_ACTIVATION(Relu1);
DECLARE_NO_PARAMETER_ACTIVATION(Relu6);
DECLARE_NO_PARAMETER_ACTIVATION(Elu);
DECLARE_NO_PARAMETER_ACTIVATION(Tanh);
DECLARE_NO_PARAMETER_ACTIVATION(Sigmoid);
DECLARE_NO_PARAMETER_ACTIVATION(HardSwish);
#undef DEFINE_NO_PARAMETER_ACTIVATION
class Prelu : public Operation {
public:
Prelu(Graph* graph, int axis);
protected:
int axis_;
};
} // namespace ops
} // namespace vx
} // namespace tim
#endif /* TIM_VX_OPS_ACTIVATIONS_H_ */

41
include/tim/vx/ops/addn.h Normal file
View File

@ -0,0 +1,41 @@
/****************************************************************************
*
* 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 TIM_VX_OPS_ADDN_H_
#define TIM_VX_OPS_ADDN_H_
#include "tim/vx/operation.h"
namespace tim {
namespace vx {
namespace ops {
class AddN : public Operation {
public:
AddN(Graph* graph, uint32_t num_inputs);
};
} // namespace ops
} // namespace vx
} // namespace tim
#endif /* TIM_VX_OPS_ADDN_H_ */

View File

@ -0,0 +1,49 @@
/****************************************************************************
*
* 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 TIM_VX_OPS_BATCH2SPACE_H_
#define TIM_VX_OPS_BATCH2SPACE_H_
#include <vector>
#include "tim/vx/operation.h"
namespace tim {
namespace vx {
namespace ops {
class Batch2Space : public Operation {
public:
Batch2Space(Graph* graph, const std::vector<int>& block_size,
const std::vector<int>& crop);
protected:
std::vector<int> block_size_;
std::vector<int> crop_;
};
} // namespace ops
} // namespace vx
} // namespace tim
#endif

View File

@ -0,0 +1,44 @@
/****************************************************************************
*
* 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 TIM_VX_OPS_CONCAT_H_
#define TIM_VX_OPS_CONCAT_H_
#include "tim/vx/operation.h"
namespace tim {
namespace vx {
namespace ops {
class Concat : public Operation {
public:
Concat(Graph* graph, uint32_t axis, int input_cnt);
protected:
uint32_t axis_;
};
} // namespace ops
} // namespace vx
} // namespace tim
#endif /* TIM_VX_OPS_CONCAT_H_ */

View File

@ -0,0 +1,61 @@
/****************************************************************************
*
* 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 TIM_VX_OPS_CONV2D_H_
#define TIM_VX_OPS_CONV2D_H_
#include <array>
#include "tim/vx/operation.h"
namespace tim {
namespace vx {
namespace ops {
class Conv2d : public Operation {
public:
Conv2d(Graph* graph, int32_t weights, PadType padding,
const std::array<uint32_t, 2>& ksize,
const std::array<uint32_t, 2>& stride,
const std::array<uint32_t, 2>& dilation, int32_t multiplier = 0);
Conv2d(Graph* graph, int32_t weights, PadType padding,
const std::array<uint32_t, 2>& ksize,
const std::array<uint32_t, 2>& stride,
const std::array<uint32_t, 2>& dilation,
const std::array<uint32_t, 4>& pad, int32_t multiplier = 0);
protected:
const uint32_t weights_;
const PadType padding_;
const std::array<uint32_t, 2> ksize_;
const std::array<uint32_t, 2> stride_;
const std::array<uint32_t, 2> dilation_;
const std::array<uint32_t, 4> pad_;
const int32_t multiplier_;
};
} // namespace ops
} // namespace vx
} // namespace tim
#endif /* TIM_VX_OPS_CONV2D_H_ */

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 TIM_VX_OPS_DEPTH2SPACE_H_
#define TIM_VX_OPS_DEPTH2SPACE_H_
#include "tim/vx/operation.h"
namespace tim {
namespace vx {
namespace ops {
class DepthToSpace : public Operation {
public:
DepthToSpace(Graph* Graph, int block_size);
protected:
int block_size_;
};
} // namespace ops
} // namespace vx
} // namespace tim
#endif /* TIM_VX_OPS_DEPTH2SPACE_H_ */

View File

@ -0,0 +1,63 @@
/****************************************************************************
*
* 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 TIM_VX_OPS_ELEMENTWISE_H_
#define TIM_VX_OPS_ELEMENTWISE_H_
#include "tim/vx/operation.h"
namespace tim {
namespace vx {
namespace ops {
#define DELCATE_ELEMENTWISE_OP(NAME) \
class NAME : public Operation { \
public: \
NAME(Graph* graph); \
};
DELCATE_ELEMENTWISE_OP(Abs);
DELCATE_ELEMENTWISE_OP(Sin);
// TODO(jiangbo): enable it when ovxlib supports `Cos`
//DELCATE_ELEMENTWISE_OP(Cos);
DELCATE_ELEMENTWISE_OP(Exp);
DELCATE_ELEMENTWISE_OP(Log);
DELCATE_ELEMENTWISE_OP(Sqrt);
DELCATE_ELEMENTWISE_OP(Rsqrt);
DELCATE_ELEMENTWISE_OP(Square);
DELCATE_ELEMENTWISE_OP(LogicalNot);
DELCATE_ELEMENTWISE_OP(Minimum);
DELCATE_ELEMENTWISE_OP(Maximum);
DELCATE_ELEMENTWISE_OP(Add);
DELCATE_ELEMENTWISE_OP(Sub);
DELCATE_ELEMENTWISE_OP(Div);
DELCATE_ELEMENTWISE_OP(Multiply);
DELCATE_ELEMENTWISE_OP(Pow);
#undef DELCATE_ELEMENTWISE_OP
} // namespace ops
} // namespace vx
} // namespace tim
#endif /* TIM_VX_OPS_ELEMENTWISE_H_ */

View File

@ -0,0 +1,44 @@
/****************************************************************************
*
* 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 TIM_VX_OPS_FULLYCONNECTED_H_
#define TIM_VX_OPS_FULLYCONNECTED_H_
#include "tim/vx/operation.h"
namespace tim {
namespace vx {
namespace ops {
class FullyConnected : public Operation {
public:
FullyConnected(Graph* graph, uint32_t axis, uint32_t weights);
protected:
uint32_t axis_;
uint32_t weights_;
};
} // namespace ops
} // namespace vx
} // namespace tim
#endif /* TIM_VX_OPS_FULLYCONNECTED_H_ */

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 TIM_VX_OPS_GATHER_H_
#define TIM_VX_OPS_GATHER_H_
#include "tim/vx/operation.h"
namespace tim {
namespace vx {
namespace ops {
class Gather : public Operation {
public:
Gather(Graph* Graph, int axis);
protected:
int axis_;
};
} // namespace ops
} // namespace vx
} // namespace tim
#endif /* TIM_VX_OPS_GATHER_H_ */

View File

@ -0,0 +1,42 @@
/****************************************************************************
*
* 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 TIM_VX_OPS_L2NOMALIZATION_H_
#define TIM_VX_OPS_L2NOMALIZATION_H_
#include "tim/vx/operation.h"
namespace tim {
namespace vx {
namespace ops {
class L2Normalization : public Operation {
public:
L2Normalization(Graph* graph, int32_t axis);
protected:
int32_t axis_;
};
} // namespace ops
} // namespace vx
} // namespace tim
#endif

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 TIM_VX_OPS_LOCALRESPONSENORMALIZATION_H_
#define TIM_VX_OPS_LOCALRESPONSENORMALIZATION_H_
#include "tim/vx/operation.h"
namespace tim {
namespace vx {
namespace ops {
class LocalResponseNormalization : public Operation {
public:
LocalResponseNormalization(Graph* graph, uint32_t size, float alpha,
float beta, float bias, int32_t axis);
protected:
uint32_t size_;
float alpha_;
float beta_;
float bias_;
int32_t axis_;
};
} // namespace ops
} // namespace vx
} // namespace tim
#endif

44
include/tim/vx/ops/pad.h Normal file
View File

@ -0,0 +1,44 @@
/****************************************************************************
*
* 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 TIM_VX_OPERATION_PAD_H_
#define TIM_VX_OPERATION_PAD_H_
#include "tim/vx/operation.h"
namespace tim {
namespace vx {
namespace ops {
class Pad : public Operation {
public:
Pad(Graph* graph, const std::vector<uint32_t>& front_size,
const std::vector<uint32_t>& back_size, int32_t const_val);
protected:
std::vector<uint32_t> front_size_;
std::vector<uint32_t> back_size_;
int32_t const_val_;
};
} // namespace ops
} // namespace vx
} // namespace tim
#endif

View File

@ -0,0 +1,44 @@
/****************************************************************************
*
* 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 TIM_VX_OPS_PERMUTE_H_
#define TIM_VX_OPS_PERMUTE_H_
#include "tim/vx/operation.h"
namespace tim {
namespace vx {
namespace ops {
class Permute : public Operation {
public:
Permute(Graph* graph, const std::vector<uint32_t>& perm);
protected:
std::vector<uint32_t> perm_;
};
} // namespace ops
} // namespace vx
} // namespace tim
#endif /* TIM_VX_OPS_PERMUTE_H_ */

View File

@ -0,0 +1,55 @@
/****************************************************************************
*
* 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 TIM_VX_OPS_POOL2D_H_
#define TIM_VX_OPS_POOL2D_H_
#include <array>
#include "tim/vx/operation.h"
#include "tim/vx/types.h"
namespace tim {
namespace vx {
namespace ops {
class Pool2d : public Operation {
public:
Pool2d(Graph* graph, PoolType type, PadType padding,
const std::array<uint32_t, 2>& ksize,
const std::array<uint32_t, 2>& stride,
RoundType round_type = RoundType::CEILING);
protected:
const PoolType type_;
const PadType padding_;
const std::array<uint32_t, 2> ksize_;
const std::array<uint32_t, 2> stride_;
const RoundType round_type_;
};
} // namespace ops
} // namespace vx
} // namespace tim
#endif /* TIM_VX_OPS_POOL2D_H_ */

View File

@ -0,0 +1,55 @@
/****************************************************************************
*
* 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 TIM_VX_OPS_REDUCE_H_
#define TIM_VX_OPS_REDUCE_H_
#include "tim/vx/operation.h"
namespace tim {
namespace vx {
namespace ops {
#define DELCATE_REDUCE_OP(NAME) \
class Reduce##NAME : public Operation { \
public: \
Reduce##NAME(Graph* graph, const std::vector<int32_t>& axis, \
bool keep_dims); \
\
protected: \
std::vector<int32_t> axis_; \
bool keep_dims_; \
};
DELCATE_REDUCE_OP(Min);
DELCATE_REDUCE_OP(Max);
DELCATE_REDUCE_OP(Any);
DELCATE_REDUCE_OP(Prod);
DELCATE_REDUCE_OP(Mean);
#undef DEFINE_REDUCE_OP
} // namespace ops
} // namespace vx
} // namespace tim
#endif /* TIM_VX_OPS_ACTIVATIONS_H_ */

View File

@ -0,0 +1,44 @@
/****************************************************************************
*
* 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 TIM_VX_OPS_RESHAPE_H_
#define TIM_VX_OPS_RESHAPE_H_
#include "tim/vx/operation.h"
namespace tim {
namespace vx {
namespace ops {
class Reshape : public Operation {
public:
Reshape(Graph* graph, const std::vector<uint32_t>& perm);
protected:
std::vector<uint32_t> size_;
};
} // namespace ops
} // namespace vx
} // namespace tim
#endif /* TIM_VX_OPS_RESHAPE_H_ */

View File

@ -0,0 +1,50 @@
/****************************************************************************
*
* 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 TIM_VX_OPS_RESIZE_H_
#define TIM_VX_OPS_RESIZE_H_
#include "tim/vx/operation.h"
namespace tim {
namespace vx {
namespace ops {
class Resize : public Operation {
public:
Resize(Graph* graph, ResizeType type, float factor, bool align_corners,
bool half_pixel_centers, int target_height, int target_width);
protected:
const ResizeType type_;
const float factor_;
const bool align_corners_;
const bool half_pixel_centers_;
const int target_height_;
const int target_width_;
};
} // namespace ops
} // namespace vx
} // namespace tim
#endif /* TIM_VX_OPS_RESIZE_H_ */

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 TIM_VX_OPS_SIMPLE_OPERATIONS_H_
#define TIM_VX_OPS_SIMPLE_OPERATIONS_H_
#include "tim/vx/operation.h"
namespace tim {
namespace vx {
namespace ops {
#define DECLARE_SIMPLE_OP(NAME) \
class NAME : public Operation { \
public: \
NAME(Graph* graph); \
};
DECLARE_SIMPLE_OP(DataConvert)
DECLARE_SIMPLE_OP(Neg)
#undef DECLARE_SIMPLE_OP
} // namespace ops
} // namespace vx
} // namespace tim
#endif /* TIM_VX_OPS_SIMPLE_OPERATIONS_H_ */

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 TIM_VX_OPS_SOFTMAX_H_
#define TIM_VX_OPS_SOFTMAX_H_
#include "tim/vx/operation.h"
namespace tim {
namespace vx {
namespace ops {
class Softmax : public Operation {
public:
Softmax(Graph* graph, float beta, int32_t axis);
protected:
float beta_;
int32_t axis_;
};
} // namespace ops
} // namespace vx
} // namespace tim
#endif /* TIM_VX_OPS_SOFTMAX_H_ */

View File

@ -0,0 +1,49 @@
/****************************************************************************
*
* 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 TIM_VX_OPS_SPACE2BATCH_H_
#define TIM_VX_OPS_SPACE2BATCH_H_
#include <vector>
#include "tim/vx/operation.h"
namespace tim {
namespace vx {
namespace ops {
class Space2Batch : public Operation {
public:
Space2Batch(Graph* graph, const std::vector<int>& block_size,
const std::vector<int>& pad);
protected:
std::vector<int> block_size_;
std::vector<int> pad_;
};
} // namespace ops
} // namespace vx
} // namespace tim
#endif /* TIM_VX_OPS_SPACE2BATCH_H_ */

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 TIM_VX_OPS_SPACE2DEPTH_H_
#define TIM_VX_OPS_SPACE2DEPTH_H_
#include "tim/vx/operation.h"
namespace tim {
namespace vx {
namespace ops {
class SpaceToDepth : public Operation {
public:
SpaceToDepth(Graph* graph, std::vector<int> block_size);
protected:
std::vector<int> block_size_;
};
} // namespace ops
} // namespace vx
} // namespace tim
#endif /* TIM_VX_OPS_SPACE2DEPTH_H_ */

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 TIM_VX_OPS_SPLIT_H_
#define TIM_VX_OPS_SPLIT_H_
#include <vector>
#include "tim/vx/operation.h"
namespace tim {
namespace vx {
namespace ops {
class Split : public Operation {
public:
Split(Graph* graph, uint32_t axis, std::vector<uint32_t> slices);
protected:
uint32_t axis_;
std::vector<uint32_t> slices_;
};
} // namespace ops
} // namespace vx
} // namespace tim
#endif /* TIM_VX_OPS_SPLIT_H_ */

View File

@ -0,0 +1,52 @@
/****************************************************************************
*
* 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 TIM_VX_OPS_STRIDEDSLICE_H_
#define TIM_VX_OPS_STRIDEDSLICE_H_
#include "tim/vx/operation.h"
namespace tim {
namespace vx {
namespace ops {
class StridedSlice : public Operation {
public:
StridedSlice(Graph* graph, const std::vector<int32_t> begin_dims,
const std::vector<int32_t> end_dims,
const std::vector<int32_t> stride_dims, int32_t begin_mask,
int32_t end_mask, int32_t shrink_axis_mask);
protected:
std::vector<int32_t> begin_dims_;
std::vector<int32_t> end_dims_;
std::vector<int32_t> stride_dims_;
int32_t begin_mask_;
int32_t end_mask_;
int32_t shrink_axis_mask_;
};
} // namespace ops
} // namespace vx
} // namespace tim
#endif /* TIM_VX_OPS_STRIDEDSLICE_H_ */

141
include/tim/vx/tensor.h Normal file
View File

@ -0,0 +1,141 @@
/****************************************************************************
*
* 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 TIM_VX_TENSOR_H_
#define TIM_VX_TENSOR_H_
#include <cstdint>
#include <iostream>
#include <memory>
#include <vector>
#include "tim/vx/types.h"
namespace tim {
namespace vx {
using ShapeType = std::vector<uint32_t>;
class Quantization {
public:
Quantization() : type_(QuantType::NONE) {}
Quantization(QuantType type, float scale, int32_t zero_point)
: type_(type), scales_({scale}), zero_points_({zero_point}) {}
Quantization(QuantType type, int32_t channel_dim, std::vector<float> scales,
std::vector<int32_t> zero_points)
: type_(type),
channel_dim_(channel_dim),
scales_(std::move(scales)),
zero_points_(std::move(zero_points)) {}
QuantType Type() { return type_; }
Quantization& SetType(QuantType type) {
this->type_ = type;
return *this;
}
int32_t ChannelDim() { return this->channel_dim_; }
Quantization& SetChannelDim(int32_t channel_dim) {
this->channel_dim_ = channel_dim;
return *this;
}
std::vector<float>& Scales() { return this->scales_; }
Quantization& SetScales(std::vector<float> scales) {
this->scales_ = scales;
return *this;
}
std::vector<int32_t>& ZeroPoints() { return this->zero_points_; }
Quantization& SetZeroPoints(std::vector<int32_t> zero_points) {
this->zero_points_ = zero_points;
return *this;
}
protected:
QuantType type_{QuantType::NONE};
int32_t channel_dim_;
std::vector<float> scales_;
std::vector<int32_t> zero_points_;
};
struct TensorSpec {
TensorSpec() {}
TensorSpec(DataType datatype, const ShapeType& shape, TensorAttribute attr)
: datatype_(datatype), shape_(shape), attr_(attr) {}
TensorSpec(DataType datatype, const ShapeType& shape, TensorAttribute attr,
const Quantization& quantization)
: TensorSpec(datatype, shape, attr) {
this->quantization_ = quantization;
}
TensorSpec& SetDataType(DataType datatype) {
this->datatype_ = datatype;
return *this;
}
TensorSpec& SetShape(ShapeType& shape) {
this->shape_ = shape;
return *this;
}
TensorSpec& SetAttribute(TensorAttribute attr) {
this->attr_ = attr;
return *this;
}
TensorSpec& SetQuantization(Quantization& quantization) {
this->quantization_ = quantization;
return *this;
}
TensorSpec AsTransientSpec() const {
return TensorSpec(this->datatype_, ShapeType({}),
TensorAttribute::TRANSIENT, this->quantization_);
}
DataType datatype_;
ShapeType shape_;
TensorAttribute attr_;
Quantization quantization_;
};
class Tensor {
public:
virtual ~Tensor() {}
virtual const ShapeType& GetShape() = 0;
virtual DataType GetDataType() = 0;
virtual const Quantization& GetQuantization() = 0;
virtual const TensorSpec& GetSpec() = 0;
virtual uint32_t GetId() = 0;
virtual bool CopyDataToTensor(const void* data, uint32_t size = 0) = 0;
virtual bool CopyDataFromTensor(void* data) = 0;
virtual bool IsPlaceHolder() = 0;
virtual bool IsConstTensor() = 0;
};
} // namespace vx
} // namespace tim
#endif /* TIM_VX_TENSOR_H_ */

73
include/tim/vx/types.h Normal file
View File

@ -0,0 +1,73 @@
/****************************************************************************
*
* 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 TIM_VX_TYPES_H_
#define TIM_VX_TYPES_H_
namespace tim {
namespace vx {
enum class DataType {
UNKNOWN,
INT8,
UINT8,
INT16,
UINT16,
INT32,
UINT32,
FLOAT16,
FLOAT32
};
enum class QuantType { NONE, ASYMMETRIC, SYMMETRIC_PER_CHANNEL };
enum class TensorAttribute { CONSTANT, TRANSIENT, VARIABLE, INPUT, OUTPUT };
enum class PadType { NONE = -1, AUTO, VALID, SAME };
enum class PoolType { MAX, AVG, L2, AVG_ANDROID };
enum class RoundType { CEILING, FLOOR };
enum class OverflowPolicy { WRAP, SATURATE };
enum class RoundingPolicy { TO_ZERO, RTNE };
enum class DownScaleSizeRounding { FLOOR, CEILING };
enum class ActivationType {
NONE,
RELU,
RELU1,
RELU6,
TANH,
//SIGNBIT,
SIGMOID
};
enum class ResizeType { NEAREST_NEIGHBOR, BILINEAR, AREA };
} // namespace vx
} // namespace tim
#endif /* TIM_VX_TYPES_H_ */

13
prebuilt-sdk/BUILD Normal file
View File

@ -0,0 +1,13 @@
package(default_visibility = ["//visibility:public"])
config_setting(
name = "x86_64_linux",
values = {"define": "target_device=x86_64_linux"},
)
cc_library(
name = "VIV_SDK_LIB",
deps = select({
"//conditions:default": ["//prebuilt-sdk/x86_64_linux:VIV_SDK_LIB"],
}),
)

View File

@ -0,0 +1,21 @@
package(default_visibility = ["//visibility:public"])
filegroup(
name = "libs",
srcs = glob([
"lib/*.so",
"lib/*.so.*",
]),
)
cc_library(
name = "VIV_SDK_LIB",
hdrs = glob([
"include/**/*.h"
]),
srcs = select({
"//conditions:default": [":libs"],
}),
strip_include_prefix = "include",
)

View File

@ -0,0 +1 @@
D312513_A294074_R311680_T312233_O312045

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,216 @@
/****************************************************************************
*
* Copyright 2017 - 2020 Vivante Corporation, Santa Clara, California.
* All Rights Reserved.
*
* 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, sub license, 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 (including the
* next paragraph) 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 NON-INFRINGEMENT.
* IN NO EVENT SHALL VIVANTE AND/OR ITS SUPPLIERS 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 _VIV_NN_COMPATIBILITY_H_
#define _VIV_NN_COMPATIBILITY_H_
#include <VX/vx.h>
#include <VX/vx_khr_nn.h>
/* keep the backward compatibility with spec 1.1 for standard nn kernels */
#define VX_KERNEL_NN_SOFTMAX_LAYER VX_KERNEL_SOFTMAX_LAYER
#define VX_KERNEL_NN_NORMALIZATION_LAYER VX_KERNEL_NORMALIZATION_LAYER
#define VX_KERNEL_NN_POOLING_LAYER VX_KERNEL_POOLING_LAYER
#define VX_KERNEL_NN_FULLY_CONNECTED_LAYER VX_KERNEL_FULLY_CONNECTED_LAYER
#define VX_KERNEL_NN_ACTIVATION_LAYER VX_KERNEL_ACTIVATION_LAYER
#define VX_KERNEL_NN_ROIPOOL VX_KERNEL_ROI_POOLING_LAYER
#define VX_KERNEL_NN_CONVOLUTION_LAYER VX_KERNEL_CONVOLUTION_LAYER
#define VX_KERNEL_NN_DECONVOLUTION_LAYER VX_KERNEL_DECONVOLUTION_LAYER
/* keep the backward compatibility with spec 1.1 for vx_tensor_attribute_e */
#define VX_TENSOR_NUM_OF_DIMS VX_TENSOR_NUMBER_OF_DIMS
#define VX_TENSOR_FIXED_POINT_POS VX_TENSOR_FIXED_POINT_POSITION
/* keep the backward compatibility with spec 1.1 from vx_convolutional_network_rounding_type_e to vx_nn_rounding_type_e */
typedef enum vx_nn_rounding_type_e vx_convolutional_network_rounding_type_e;
#define VX_CONVOLUTIONAL_NETWORK_DS_SIZE_ROUNDING_FLOOR VX_NN_DS_SIZE_ROUNDING_FLOOR
#define VX_CONVOLUTIONAL_NETWORK_DS_SIZE_ROUNDING_CEILING VX_NN_DS_SIZE_ROUNDING_CEILING
/* keep the backward compatibility with spec 1.1 from vx_convolutional_network_pooling_type_e to vx_nn_pooling_type_e */
typedef enum vx_nn_pooling_type_e vx_convolutional_network_pooling_type_e;
#define VX_CONVOLUTIONAL_NETWORK_POOLING_MAX VX_NN_POOLING_MAX
#define VX_CONVOLUTIONAL_NETWORK_POOLING_AVG VX_NN_POOLING_AVG
#define VX_CONVOLUTIONAL_NETWORK_POOLING_L2 VX_NN_POOLING_L2
#define VX_CONVOLUTIONAL_NETWORK_POOLING_AVG_ANDROID VX_NN_POOLING_AVG_ANDROID
/* keep the backward compatibility with spec 1.1 from vx_convolutional_network_norm_type_e to vx_nn_norm_type_e */
typedef enum vx_nn_norm_type_e vx_convolutional_network_norm_type_e;
#define VX_CONVOLUTIONAL_NETWORK_NORM_SAME_MAP VX_NN_NORMALIZATION_SAME_MAP
#define VX_CONVOLUTIONAL_NETWORK_NORM_ACROSS_MAPS VX_NN_NORMALIZATION_ACROSS_MAPS
/* keep the backward compatibility with spec 1.1 from vx_convolutional_network_layer_type_e to vx_nn_layer_type_e */
typedef enum vx_nn_layer_type_e vx_convolutional_network_layer_type_e;
#define VX_CONVOLUTIONAL_NETWORK_CONVOLUTION_LAYER VX_NN_CONVOLUTION_LAYER
#define VX_CONVOLUTIONAL_NETWORK_FULLYCONNECTED_LAYER VX_NN_FULLYCONNECTED_LAYER
/* keep the backward compatibility with spec 1.1 from vx_convolutional_network_activation_func_e to vx_nn_activation_function_e */
typedef enum vx_nn_activation_function_e vx_convolutional_network_activation_func_e;
#define VX_CONVOLUTIONAL_NETWORK_ACTIVATION_LOGISTIC VX_NN_ACTIVATION_LOGISTIC
#define VX_CONVOLUTIONAL_NETWORK_ACTIVATION_HYPERBOLIC_TAN VX_NN_ACTIVATION_HYPERBOLIC_TAN
#define VX_CONVOLUTIONAL_NETWORK_ACTIVATION_RELU VX_NN_ACTIVATION_RELU
#define VX_CONVOLUTIONAL_NETWORK_ACTIVATION_BRELU VX_NN_ACTIVATION_BRELU
#define VX_CONVOLUTIONAL_NETWORK_ACTIVATION_SOFTRELU VX_NN_ACTIVATION_SOFTRELU
#define VX_CONVOLUTIONAL_NETWORK_ACTIVATION_ABS VX_NN_ACTIVATION_ABS
#define VX_CONVOLUTIONAL_NETWORK_ACTIVATION_SQUARE VX_NN_ACTIVATION_SQUARE
#define VX_CONVOLUTIONAL_NETWORK_ACTIVATION_SQRT VX_NN_ACTIVATION_SQRT
#define VX_CONVOLUTIONAL_NETWORK_ACTIVATION_LINEAR VX_NN_ACTIVATION_LINEAR
#define VX_CONVOLUTIONAL_NETWORK_ACTIVATION_LEAKYRELU VX_NN_ACTIVATION_LEAKYRELU
#define VX_CONVOLUTIONAL_NETWORK_ACTIVATION_RELU6 VX_NN_ACTIVATION_RELU6
#define VX_CONVOLUTIONAL_NETWORK_ACTIVATION_RELU1 VX_NN_ACTIVATION_RELU1
#define VX_CONVOLUTIONAL_NETWORK_ACTIVATION_RSQRT VX_NN_ACTIVATION_RSQRT
#define VX_CONVOLUTIONAL_NETWORK_ACTIVATION_LEAKYRELU_MAX_POOLING VX_NN_ACTIVATION_LEAKYRELU_MAX_POOLING
#define VX_CONVOLUTIONAL_NETWORK_ACTIVATION_NONE VX_NN_ACTIVATION_NONE
#ifdef __cplusplus
extern "C" {
#endif
/* keep the backward compatibility with spec 1.1 for vxCreateTensor */
VX_API_ENTRY vx_tensor VX_API_CALL
vxCreateTensor_11(
vx_context context,
vx_uint32 num_of_dims,
vx_uint32 *sizes,
vx_enum data_format,
vx_int8 fixed_point_pos
);
#define vxCreateTensor vxCreateTensor_11
/* keep the backward compatibility with spec 1.1 for vxCreateVirtualTensor */
VX_API_ENTRY vx_tensor VX_API_CALL
vxCreateVirtualTensor_11(
vx_graph graph,
vx_uint32 num_of_dims,
vx_uint32 *sizes,
vx_enum data_format,
vx_int8 fixed_point_pos
);
#define vxCreateVirtualTensor vxCreateVirtualTensor_11
/* keep the backward compatibility with spec 1.1 for vxCreateTensorFromView */
VX_API_ENTRY vx_tensor VX_API_CALL
vxCreateTensorFromView_11(
vx_tensor tensor,
vx_tensor_view view
);
#define vxCreateTensorFromView vxCreateTensorFromView_11
/* keep the backward compatibility with spec 1.1 for vxCopyTensorPatch */
VX_API_ENTRY vx_status VX_API_CALL
vxCopyTensorPatch_11(
vx_tensor tensor,
vx_tensor_view view,
vx_tensor_addressing user_addr,
void *user_ptr,
vx_enum usage,
vx_enum user_mem_type
);
#define vxCopyTensorPatch vxCopyTensorPatch_11
/* keep the backward compatibility with spec 1.1 for vxCreateImageObjectArrayFromTensor */
VX_API_ENTRY vx_object_array VX_API_CALL
vxCreateImageObjectArrayFromTensor_11(
vx_tensor tensor,
vx_rectangle_t rect,
vx_uint32 array_size,
vx_uint32 stride,
vx_df_image image_format
);
#define vxCreateImageObjectArrayFromTensor vxCreateImageObjectArrayFromTensor_11
/* keep the backward compatibility with spec 1.1 for vxFullyConnectedLayer */
VX_API_ENTRY vx_node VX_API_CALL
vxFullyConnectedLayer_11(
vx_graph graph,
vx_tensor inputs,
vx_tensor weights,
vx_tensor biases,
vx_uint32 pad,
vx_uint8 accumulator_bits,
vx_enum overflow_policy,
vx_enum rounding_policy,
vx_enum down_scale_size_rounding,
vx_tensor outputs
);
#define vxFullyConnectedLayer vxFullyConnectedLayer_11
/* keep the backward compatibility with spec 1.1 for vxActivationLayer */
VX_API_ENTRY vx_node VX_API_CALL
vxActivationLayer_11(
vx_graph graph,
vx_tensor inputs,
vx_enum func,
vx_int32 a,
vx_int32 b,
vx_tensor outputs
);
#define vxActivationLayer vxActivationLayer_11
/* keep the backward compatibility with spec 1.1 for vxPoolingLayer */
VX_API_ENTRY vx_node VX_API_CALL
vxPoolingLayer_11(
vx_graph graph,
vx_tensor inputs,
vx_enum pool_type,
vx_uint32 pool_size_x,
vx_uint32 pool_size_y,
vx_uint32 pool_pad_x,
vx_uint32 pool_pad_y,
vx_enum rounding,
vx_tensor outputs
);
#define vxPoolingLayer vxPoolingLayer_11
/* keep the backward compatibility with spec 1.1 for vxNormalizationLayer */
VX_API_ENTRY vx_node VX_API_CALL
vxNormalizationLayer_11(
vx_graph graph,
vx_tensor inputs,
vx_enum type,
vx_uint32 norm_size,
vx_float32 alpha,
vx_float32 beta,
vx_tensor outputs
);
#define vxNormalizationLayer vxNormalizationLayer_11
/* keep the backward compatibility with spec 1.1 for vxTensorTransposeNode */
VX_API_ENTRY vx_node VX_API_CALL
vxTensorTransposeNode_11(
vx_graph graph,
vx_tensor inputs,
vx_tensor outputs,
vx_uint32 dim1,
vx_uint32 dim2
);
#define vxTensorTransposeNode vxTensorTransposeNode_11
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,97 @@
/*
* Copyright (c) 2012-2020 The Khronos Group Inc.
*
* 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
*
* http://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.
*/
/*
* NOTE: Some safety-critical environments may enforce software development
* guidelines (for example MISRA C:2012) to facilitate code quality,
* safety, security, portability and reliability. In order to meet
* such guidelines, developers may modify OpenVX standard header files
* without deviating from the OpenVX specification.
*/
#ifndef _OPENVX_H_
#define _OPENVX_H_
/*!
* \file
* \brief The top level OpenVX Header.
*/
/*! \brief Defines the length of the implementation name string, including the trailing zero.
* \ingroup group_context
*/
#define VX_MAX_IMPLEMENTATION_NAME (64)
/*! \brief Defines the length of a kernel name string to be added to OpenVX, including the trailing zero.
* \ingroup group_kernel
*/
#define VX_MAX_KERNEL_NAME (256)
/*! \brief Defines the length of a message buffer to copy from the log, including the trailing zero.
* \ingroup group_basic_features
*/
#define VX_MAX_LOG_MESSAGE_LEN (1024)
/*! \brief Defines the length of the reference name string, including the trailing zero.
* \ingroup group_reference
* \see vxSetReferenceName
*/
#define VX_MAX_REFERENCE_NAME (64)
#include <VX/vx_vendors.h>
#include <VX/vx_types.h>
#include <VX/vx_kernels.h>
#include <VX/vx_api.h>
#include <VX/vx_nodes.h>
/*! \brief Defines the major version number macro.
* \ingroup group_basic_features
*/
#define VX_VERSION_MAJOR(x) ((x & 0xFFU) << 8)
/*! \brief Defines the minor version number macro.
* \ingroup group_basic_features
*/
#define VX_VERSION_MINOR(x) ((x & 0xFFU) << 0)
/*! \brief Defines the predefined version number for 1.0.
* \ingroup group_basic_features
*/
#define VX_VERSION_1_0 (VX_VERSION_MAJOR(1) | VX_VERSION_MINOR(0))
/*! \brief Defines the predefined version number for 1.1.
* \ingroup group_basic_features
*/
#define VX_VERSION_1_1 (VX_VERSION_MAJOR(1) | VX_VERSION_MINOR(1))
/*! \brief Defines the predefined version number for 1.2.
* \ingroup group_basic_features
*/
#define VX_VERSION_1_2 (VX_VERSION_MAJOR(1) | VX_VERSION_MINOR(2))
/*! \brief Defines the predefined version number for 1.3.
* \ingroup group_basic_features
*/
#define VX_VERSION_1_3 (VX_VERSION_MAJOR(1) | VX_VERSION_MINOR(3))
/*! \brief Defines the OpenVX Version Number.
* \ingroup group_basic_features
*/
#ifndef VX_VERSION
#define VX_VERSION (VX_VERSION_1_3)
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,253 @@
/*
* Copyright (c) 2012-2017 The Khronos Group Inc.
*
* 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
*
* http://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 VX_1_0_1_NAMING_COMPATIBILITY
#define VX_1_0_1_NAMING_COMPATIBILITY
#define VX_TYPE_SCALAR_MAX (VX_TYPE_BOOL + 1)
#define vx_border_mode_e vx_border_e
#define vx_border_mode_policy_e vx_border_policy_e
#define _vx_border_mode_t _vx_border_t
#define vx_border_mode_t vx_border_t
#define VX_ENUM_BORDER_MODE VX_ENUM_BORDER
#define VX_BORDER_MODE_POLICY VX_BORDER_POLICY
#define VX_BORDER_MODE_UNDEFINED VX_BORDER_UNDEFINED
#define VX_BORDER_MODE_CONSTANT VX_BORDER_CONSTANT
#define VX_BORDER_MODE_REPLICATE VX_BORDER_REPLICATE
#define VX_BORDER_MODE_UNSUPPORTED_POLICY_DEFAULT_TO_UNDEFINED VX_BORDER_POLICY_DEFAULT_TO_UNDEFINED
#define VX_BORDER_MODE_UNSUPPORTED_POLICY_RETURN_ERROR VX_BORDER_POLICY_RETURN_ERROR
#define VX_REF_ATTRIBUTE_COUNT VX_REFERENCE_COUNT
#define VX_REF_ATTRIBUTE_TYPE VX_REFERENCE_TYPE
#define VX_REF_ATTRIBUTE_NAME VX_REFERENCE_NAME
#define VX_CONTEXT_ATTRIBUTE_VENDOR_ID VX_CONTEXT_VENDOR_ID
#define VX_CONTEXT_ATTRIBUTE_VERSION VX_CONTEXT_VERSION
#define VX_CONTEXT_ATTRIBUTE_UNIQUE_KERNELS VX_CONTEXT_UNIQUE_KERNELS
#define VX_CONTEXT_ATTRIBUTE_MODULES VX_CONTEXT_MODULES
#define VX_CONTEXT_ATTRIBUTE_REFERENCES VX_CONTEXT_REFERENCES
#define VX_CONTEXT_ATTRIBUTE_IMPLEMENTATION VX_CONTEXT_IMPLEMENTATION
#define VX_CONTEXT_ATTRIBUTE_EXTENSIONS_SIZE VX_CONTEXT_EXTENSIONS_SIZE
#define VX_CONTEXT_ATTRIBUTE_EXTENSIONS VX_CONTEXT_EXTENSIONS
#define VX_CONTEXT_ATTRIBUTE_CONVOLUTION_MAXIMUM_DIMENSION VX_CONTEXT_CONVOLUTION_MAX_DIMENSION
#define VX_CONTEXT_ATTRIBUTE_OPTICAL_FLOW_WINDOW_MAXIMUM_DIMENSION VX_CONTEXT_OPTICAL_FLOW_MAX_WINDOW_DIMENSION
#define VX_CONTEXT_ATTRIBUTE_IMMEDIATE_BORDER_MODE VX_CONTEXT_IMMEDIATE_BORDER
#define VX_CONTEXT_ATTRIBUTE_UNIQUE_KERNEL_TABLE VX_CONTEXT_UNIQUE_KERNEL_TABLE
#define VX_KERNEL_ATTRIBUTE_PARAMETERS VX_KERNEL_PARAMETERS
#define VX_KERNEL_ATTRIBUTE_NAME VX_KERNEL_NAME
#define VX_KERNEL_ATTRIBUTE_ENUM VX_KERNEL_ENUM
#define VX_KERNEL_ATTRIBUTE_LOCAL_DATA_SIZE VX_KERNEL_LOCAL_DATA_SIZE
#define VX_KERNEL_ATTRIBUTE_LOCAL_DATA_PTR (VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_KERNEL) + 0x4)
#define VX_NODE_ATTRIBUTE_STATUS VX_NODE_STATUS
#define VX_NODE_ATTRIBUTE_PERFORMANCE VX_NODE_PERFORMANCE
#define VX_NODE_ATTRIBUTE_BORDER_MODE VX_NODE_BORDER
#define VX_NODE_ATTRIBUTE_LOCAL_DATA_SIZE VX_NODE_LOCAL_DATA_SIZE
#define VX_NODE_ATTRIBUTE_LOCAL_DATA_PTR VX_NODE_LOCAL_DATA_PTR
#define VX_PARAMETER_ATTRIBUTE_INDEX VX_PARAMETER_INDEX
#define VX_PARAMETER_ATTRIBUTE_DIRECTION VX_PARAMETER_DIRECTION
#define VX_PARAMETER_ATTRIBUTE_TYPE VX_PARAMETER_TYPE
#define VX_PARAMETER_ATTRIBUTE_STATE VX_PARAMETER_STATE
#define VX_PARAMETER_ATTRIBUTE_REF VX_PARAMETER_REF
#define VX_IMAGE_ATTRIBUTE_WIDTH VX_IMAGE_WIDTH
#define VX_IMAGE_ATTRIBUTE_HEIGHT VX_IMAGE_HEIGHT
#define VX_IMAGE_ATTRIBUTE_FORMAT VX_IMAGE_FORMAT
#define VX_IMAGE_ATTRIBUTE_PLANES VX_IMAGE_PLANES
#define VX_IMAGE_ATTRIBUTE_SPACE VX_IMAGE_SPACE
#define VX_IMAGE_ATTRIBUTE_RANGE VX_IMAGE_RANGE
#define VX_IMAGE_ATTRIBUTE_SIZE VX_IMAGE_SIZE
#define VX_SCALAR_ATTRIBUTE_TYPE VX_SCALAR_TYPE
#define VX_GRAPH_ATTRIBUTE_NUMNODES VX_GRAPH_NUMNODES
#define VX_GRAPH_ATTRIBUTE_STATUS (VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_GRAPH) + 0x1)
#define VX_GRAPH_ATTRIBUTE_PERFORMANCE VX_GRAPH_PERFORMANCE
#define VX_GRAPH_ATTRIBUTE_NUMPARAMETERS VX_GRAPH_NUMPARAMETERS
#define VX_LUT_ATTRIBUTE_TYPE VX_LUT_TYPE
#define VX_LUT_ATTRIBUTE_COUNT VX_LUT_COUNT
#define VX_LUT_ATTRIBUTE_SIZE VX_LUT_SIZE
#define VX_DISTRIBUTION_ATTRIBUTE_DIMENSIONS VX_DISTRIBUTION_DIMENSIONS
#define VX_DISTRIBUTION_ATTRIBUTE_OFFSET VX_DISTRIBUTION_OFFSET
#define VX_DISTRIBUTION_ATTRIBUTE_RANGE VX_DISTRIBUTION_RANGE
#define VX_DISTRIBUTION_ATTRIBUTE_BINS VX_DISTRIBUTION_BINS
#define VX_DISTRIBUTION_ATTRIBUTE_WINDOW VX_DISTRIBUTION_WINDOW
#define VX_DISTRIBUTION_ATTRIBUTE_SIZE VX_DISTRIBUTION_SIZE
#define VX_THRESHOLD_ATTRIBUTE_TYPE VX_THRESHOLD_TYPE
#define VX_THRESHOLD_ATTRIBUTE_THRESHOLD_VALUE VX_THRESHOLD_THRESHOLD_VALUE
#define VX_THRESHOLD_ATTRIBUTE_THRESHOLD_LOWER VX_THRESHOLD_THRESHOLD_LOWER
#define VX_THRESHOLD_ATTRIBUTE_THRESHOLD_UPPER VX_THRESHOLD_THRESHOLD_UPPER
#define VX_THRESHOLD_ATTRIBUTE_TRUE_VALUE VX_THRESHOLD_TRUE_VALUE
#define VX_THRESHOLD_ATTRIBUTE_FALSE_VALUE VX_THRESHOLD_FALSE_VALUE
#define VX_THRESHOLD_ATTRIBUTE_DATA_TYPE VX_THRESHOLD_DATA_TYPE
#define VX_MATRIX_ATTRIBUTE_TYPE VX_MATRIX_TYPE
#define VX_MATRIX_ATTRIBUTE_ROWS VX_MATRIX_ROWS
#define VX_MATRIX_ATTRIBUTE_COLUMNS VX_MATRIX_COLUMNS
#define VX_MATRIX_ATTRIBUTE_SIZE VX_MATRIX_SIZE
#define VX_CONVOLUTION_ATTRIBUTE_ROWS VX_CONVOLUTION_ROWS
#define VX_CONVOLUTION_ATTRIBUTE_COLUMNS VX_CONVOLUTION_COLUMNS
#define VX_CONVOLUTION_ATTRIBUTE_SCALE VX_CONVOLUTION_SCALE
#define VX_CONVOLUTION_ATTRIBUTE_SIZE VX_CONVOLUTION_SIZE
#define VX_PYRAMID_ATTRIBUTE_LEVELS VX_PYRAMID_LEVELS
#define VX_PYRAMID_ATTRIBUTE_SCALE VX_PYRAMID_SCALE
#define VX_PYRAMID_ATTRIBUTE_WIDTH VX_PYRAMID_WIDTH
#define VX_PYRAMID_ATTRIBUTE_HEIGHT VX_PYRAMID_HEIGHT
#define VX_PYRAMID_ATTRIBUTE_FORMAT VX_PYRAMID_FORMAT
#define VX_REMAP_ATTRIBUTE_SOURCE_WIDTH VX_REMAP_SOURCE_WIDTH
#define VX_REMAP_ATTRIBUTE_SOURCE_HEIGHT VX_REMAP_SOURCE_HEIGHT
#define VX_REMAP_ATTRIBUTE_DESTINATION_WIDTH VX_REMAP_DESTINATION_WIDTH
#define VX_REMAP_ATTRIBUTE_DESTINATION_HEIGHT VX_REMAP_DESTINATION_HEIGHT
#define VX_ARRAY_ATTRIBUTE_ITEMTYPE VX_ARRAY_ITEMTYPE
#define VX_ARRAY_ATTRIBUTE_NUMITEMS VX_ARRAY_NUMITEMS
#define VX_ARRAY_ATTRIBUTE_CAPACITY VX_ARRAY_CAPACITY
#define VX_ARRAY_ATTRIBUTE_ITEMSIZE VX_ARRAY_ITEMSIZE
#define VX_DELAY_ATTRIBUTE_TYPE VX_DELAY_TYPE
#define VX_DELAY_ATTRIBUTE_SLOTS VX_DELAY_SLOTS
#define VX_INTERPOLATION_TYPE_AREA VX_INTERPOLATION_AREA
#define VX_INTERPOLATION_TYPE_BILINEAR VX_INTERPOLATION_BILINEAR
#define VX_INTERPOLATION_TYPE_NEAREST_NEIGHBOR VX_INTERPOLATION_NEAREST_NEIGHBOR
#define VX_IMAGE_SIZE (VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_IMAGE) + 0x6)
#define VX_META_FORMAT_ATTRIBUTE_DELTA_RECTANGLE (VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_META_FORMAT) + 0x0)
#define VX_HINT_SERIALIZE (VX_ENUM_BASE(VX_ID_KHRONOS, VX_ENUM_HINT) + 0x0)
#define vx_import_type_e vx_memory_type_e
#define VX_ENUM_IMPORT_MEM VX_ENUM_MEMORY_TYPE
#define VX_IMPORT_TYPE_NONE VX_MEMORY_TYPE_NONE
#define VX_IMPORT_TYPE_HOST VX_MEMORY_TYPE_HOST
#define VX_TYPE_OBJECT_MAX (VX_TYPE_WEIGHTS_BIASES_PARAMETER_BASE + 1) /*TODO: check it for OpenVX 1.2*/
#define VX_TYPE_STRUCT_MAX VX_TYPE_KHRONOS_STRUCT_MAX
#define VX_KERNEL_INVALID (VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x0)
#define VX_KERNEL_ACCUMULATE (VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x16)
#define VX_KERNEL_ACCUMULATE_WEIGHTED (VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x17)
#define VX_KERNEL_ACCUMULATE_SQUARE (VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x18)
#define VX_THRESHOLD_THRESHOLD_VALUE (VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_THRESHOLD) + 0x1)
#define VX_THRESHOLD_THRESHOLD_LOWER (VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_THRESHOLD) + 0x2)
#define VX_THRESHOLD_THRESHOLD_UPPER (VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_THRESHOLD) + 0x3)
#define VX_THRESHOLD_TRUE_VALUE (VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_THRESHOLD) + 0x4)
#define VX_THRESHOLD_FALSE_VALUE (VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_THRESHOLD) + 0x5)
#define VX_THRESHOLD_DATA_TYPE (VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_THRESHOLD) + 0x6)
#define VX_BIDIRECTIONAL (VX_ENUM_BASE(VX_ID_KHRONOS, VX_ENUM_DIRECTION) + 0x2)
typedef vx_status(VX_CALLBACK *vx_kernel_input_validate_f)(vx_node node, vx_uint32 index);
typedef vx_status(VX_CALLBACK *vx_kernel_output_validate_f)(vx_node node, vx_uint32 index, vx_meta_format meta);
typedef struct _vx_delta_rectangle_t {
vx_int32 delta_start_x; /*!< \brief The change in the start x. */
vx_int32 delta_start_y; /*!< \brief The change in the start y. */
vx_int32 delta_end_x; /*!< \brief The change in the end x. */
vx_int32 delta_end_y; /*!< \brief The change in the end y. */
} vx_delta_rectangle_t;
#ifdef __cplusplus
extern "C" {
#endif
VX_API_ENTRY vx_kernel VX_API_CALL vxAddKernel(vx_context context,
const vx_char name[VX_MAX_KERNEL_NAME],
vx_enum enumeration,
vx_kernel_f func_ptr,
vx_uint32 numParams,
vx_kernel_input_validate_f input,
vx_kernel_output_validate_f output,
vx_kernel_initialize_f init,
vx_kernel_deinitialize_f deinit);
VX_API_ENTRY vx_size VX_API_CALL vxComputeImagePatchSize(vx_image image,
const vx_rectangle_t *rect,
vx_uint32 plane_index);
VX_API_ENTRY vx_status VX_API_CALL vxAccessImagePatch(vx_image image,
const vx_rectangle_t *rect,
vx_uint32 plane_index,
vx_imagepatch_addressing_t *addr,
void **ptr,
vx_enum usage);
VX_API_ENTRY vx_status VX_API_CALL vxCommitImagePatch(vx_image image,
const vx_rectangle_t *rect,
vx_uint32 plane_index,
const vx_imagepatch_addressing_t *addr,
const void *ptr);
VX_API_ENTRY vx_status VX_API_CALL vxAccessArrayRange(vx_array arr, vx_size start, vx_size end, vx_size *stride, void **ptr, vx_enum usage);
VX_API_ENTRY vx_status VX_API_CALL vxCommitArrayRange(vx_array arr, vx_size start, vx_size end, const void *ptr);
VX_API_ENTRY vx_status VX_API_CALL vxAccessDistribution(vx_distribution distribution, void **ptr, vx_enum usage);
VX_API_ENTRY vx_status VX_API_CALL vxCommitDistribution(vx_distribution distribution, const void * ptr);
VX_API_ENTRY vx_status VX_API_CALL vxAccessLUT(vx_lut lut, void **ptr, vx_enum usage);
VX_API_ENTRY vx_status VX_API_CALL vxCommitLUT(vx_lut lut, const void *ptr);
VX_API_ENTRY vx_status VX_API_CALL vxReadMatrix(vx_matrix mat, void *array);
VX_API_ENTRY vx_status VX_API_CALL vxWriteMatrix(vx_matrix mat, const void *array);
VX_API_ENTRY vx_status VX_API_CALL vxReadConvolutionCoefficients(vx_convolution conv, vx_int16 *array);
VX_API_ENTRY vx_status VX_API_CALL vxWriteConvolutionCoefficients(vx_convolution conv, const vx_int16 *array);
VX_API_ENTRY vx_status VX_API_CALL vxReadScalarValue(vx_scalar ref, void *ptr);
VX_API_ENTRY vx_status VX_API_CALL vxWriteScalarValue(vx_scalar ref, const void *ptr);
VX_API_ENTRY vx_status VX_API_CALL vxSetRemapPoint(vx_remap table, vx_uint32 dst_x, vx_uint32 dst_y, vx_float32 src_x,vx_float32 src_y);
VX_API_ENTRY vx_status VX_API_CALL vxGetRemapPoint(vx_remap table, vx_uint32 dst_x, vx_uint32 dst_y, vx_float32 *src_x, vx_float32 *src_y);
VX_API_ENTRY vx_threshold VX_API_CALL vxCreateThreshold(vx_context c, vx_enum thresh_type, vx_enum data_type);
VX_API_ENTRY vx_node VX_API_CALL vxAccumulateImageNode(vx_graph graph, vx_image input, vx_image accum);
VX_API_ENTRY vx_node VX_API_CALL vxAccumulateWeightedImageNode(vx_graph graph, vx_image input, vx_scalar alpha, vx_image accum);
VX_API_ENTRY vx_node VX_API_CALL vxAccumulateSquareImageNode(vx_graph graph, vx_image input, vx_scalar shift, vx_image accum);
VX_API_ENTRY vx_status VX_API_CALL vxuAccumulateImage(vx_context context, vx_image input, vx_image accum);
VX_API_ENTRY vx_status VX_API_CALL vxuAccumulateWeightedImage(vx_context context, vx_image input, vx_scalar alpha, vx_image accum);
VX_API_ENTRY vx_status VX_API_CALL vxuAccumulateSquareImage(vx_context context, vx_image input, vx_scalar shift, vx_image accum);
#ifdef __cplusplus
}
#endif
#endif /* VX_1_0_1_NAMING_COMPATIBILITY */

View File

@ -0,0 +1,195 @@
/****************************************************************************
*
* Copyright 2017 - 2020 Vivante Corporation, Santa Clara, California.
* All Rights Reserved.
*
* 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, sub license, 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 (including the
* next paragraph) 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 NON-INFRINGEMENT.
* IN NO EVENT SHALL VIVANTE AND/OR ITS SUPPLIERS 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 _VX_EXT_PROGRAM_H_
#define _VX_EXT_PROGRAM_H_
#include <VX/vx.h>
/***********************************************************************************/
#define VX_512BITS_DISABLE 0
#define VX_512BITS_ADD 0x1
#define VX_512BITS_SUBTRACT 0x2
#define VX_512BITS_ACCUMULATOR 0x3
#define VX_512BITS_TYPE_FLOAT32 0x0
#define VX_512BITS_TYPE_FLOAT16 0x1
#define VX_512BITS_TYPE_SIGNED32 0x2
#define VX_512BITS_TYPE_SIGNED16 0x3
#define VX_512BITS_TYPE_SIGNED8 0x4
#define VX_512BITS_TYPE_UNSIGNED32 0x5
#define VX_512BITS_TYPE_UNSIGNED16 0x6
#define VX_512BITS_TYPE_UNSIGNED8 0x7
#define VX_512BITS_SELECT_SRC0 0
#define VX_512BITS_SELECT_SRC1 1
#define VX_512BITS_SELECT_CONSTANTS 2
typedef union _vx_512bits_bin_t
{
vx_uint8 bin8[16];
vx_uint16 bin16[8];
vx_uint32 bin32[4];
}
vx_512bits_bin_t;
typedef union _vx_512bits_config_t
{
struct
{
vx_uint32 flag0 :2;
vx_uint32 flag1 :2;
vx_uint32 flag2 :2;
vx_uint32 flag3 :2;
vx_uint32 flag4 :2;
vx_uint32 flag5 :2;
vx_uint32 flag6 :2;
vx_uint32 flag7 :2;
vx_uint32 flag8 :2;
vx_uint32 flag9 :2;
vx_uint32 flag10:2;
vx_uint32 flag11:2;
vx_uint32 flag12:2;
vx_uint32 flag13:2;
vx_uint32 flag14:2;
vx_uint32 flag15:2;
}
bin2;
struct
{
vx_uint32 flag0 :4;
vx_uint32 flag1 :4;
vx_uint32 flag2 :4;
vx_uint32 flag3 :4;
vx_uint32 flag4 :4;
vx_uint32 flag5 :4;
vx_uint32 flag6 :4;
vx_uint32 flag7 :4;
}
bin4;
}
vx_512bits_config_t;
typedef struct _vx_512bits_miscconfig_t
{
vx_uint32 post_shift :5; /*[0:4]*/
vx_uint32 resolve1 :3; /*[5:7]*/
vx_uint32 constant_type :3; /*[8:10]*/
vx_uint32 resolve2 :1; /*[11:11]*/
vx_uint32 accu_type :3; /*[12:14]*/
vx_uint32 resolve3 :17;/*[15:31]*/
}
vx_512bits_miscconfig_t;
typedef struct _vx_512bits_t
{
vx_512bits_config_t termConfig;
vx_512bits_config_t aSelect;
vx_512bits_config_t aBin[2];
vx_512bits_config_t bSelect;
vx_512bits_config_t bBin[2];
vx_512bits_miscconfig_t miscConfig;
vx_512bits_bin_t bins[2];
}
vx_512bits_t;
/***********************************************************************************/
typedef enum vx_ext_program_type_e
{
VX_TYPE_PROGRAM = 0x900
}
vx_ext_program_type_e;
typedef enum vx_program_attribute_e
{
VX_PROGRAM_ATTRIBUTE_BUILD_LOG = VX_ATTRIBUTE_BASE(VX_ID_VIVANTE, VX_TYPE_PROGRAM) + 0x0,
}
vx_program_attribute_e;
typedef enum vx_ext_node_attribute_e
{
VX_NODE_ATTRIBUTE_KERNEL_EXECUTION_PARAMETERS = VX_ATTRIBUTE_BASE(VX_ID_VIVANTE, VX_TYPE_NODE) + 0x0,
}
vx_ext_node_attribute_e;
#define VX_MAX_WORK_ITEM_DIMENSIONS 3
typedef struct _vx_kernel_execution_parameters {
vx_uint32 workDim;
vx_size globalWorkOffset[VX_MAX_WORK_ITEM_DIMENSIONS];
vx_size globalWorkScale[VX_MAX_WORK_ITEM_DIMENSIONS];
vx_size localWorkSize[VX_MAX_WORK_ITEM_DIMENSIONS];
vx_size globalWorkSize[VX_MAX_WORK_ITEM_DIMENSIONS];
} vx_kernel_execution_parameters_t;
typedef struct _vx_program * vx_program;
#define VX_BUILD_SUCCESS 0
#define VX_BUILD_NONE -1
#define VX_BUILD_ERROR -2
#define VX_BUILD_IN_PROGRESS -3
#if defined(__cplusplus)
extern "C" {
#endif
VX_API_ENTRY vx_program VX_API_CALL vxCreateProgramWithSource(
vx_context context, vx_uint32 count, const vx_char * strings[], vx_size lengths[]);
VX_API_ENTRY vx_program VX_API_CALL vxCreateProgramWithBinary(
vx_context context, const vx_uint8 * binary, vx_size size);
VX_API_ENTRY vx_status VX_API_CALL vxReleaseProgram(vx_program *program);
VX_API_ENTRY vx_status VX_API_CALL vxBuildProgram(vx_program program, const vx_char * options);
VX_API_ENTRY vx_status VX_API_CALL vxQueryProgram(vx_program program, vx_enum attribute, void *ptr, vx_size size);
VX_API_ENTRY vx_kernel VX_API_CALL vxAddKernelInProgram(
vx_program program, vx_char name[VX_MAX_KERNEL_NAME], vx_enum enumeration, vx_uint32 num_params, vx_kernel_validate_f validate,
vx_kernel_initialize_f initialize, vx_kernel_deinitialize_f deinitialize);
VX_API_ENTRY vx_status VX_API_CALL vxSetNodeUniform(vx_node node, const vx_char * name, vx_size count, void * value);
VX_API_ENTRY vx_status VX_API_CALL vxSetChildGraphOfNode(vx_node node, vx_graph graph);
VX_API_ENTRY vx_graph VX_API_CALL vxGetChildGraphOfNode(vx_node node);
VX_API_ENTRY vx_status VX_API_CALL vxSetArrayAttribute(vx_array array, vx_enum attribute, void *ptr, vx_size size);
VX_API_ENTRY vx_status VX_API_CALL vxSelectKernelSubname(vx_node node, const vx_char * subname);
#if defined(__cplusplus)
}
#endif
#endif /* __GC_VX_PROGRAM_H__ */

View File

@ -0,0 +1,135 @@
/*
* Copyright (c) 2012-2017 The Khronos Group Inc.
*
* 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
*
* http://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 _VX_EXT_TARGET_H_
#define _VX_EXT_TARGET_H_
#include <VX/vx.h>
/*! \file
* \brief The OpenVX Target API Definition
*/
/*! \brief The extension name.
* \ingroup group_target
*/
#define OPENVX_EXT_TARGET "vx_ext_target"
/*! \brief Defines the maximum number of characters in a target string.
* \ingroup group_target
*/
#define VX_MAX_TARGET_NAME (64)
enum vx_ext_target_context_attribute_e {
/*! \brief Used to query the context for the number of active targets. Use a <tt>\ref vx_uint32</tt> parameter. */
VX_CONTEXT_TARGETS = VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_CONTEXT) + 0xE,
};
/*! \brief An abstract handle to a target.
* \ingroup group_target
*/
typedef struct _vx_target *vx_target;
/*! \brief The target attributes list
* \ingroup group_target
*/
enum vx_target_attribute_e {
/*! \brief Returns the index of the given target. Use a <tt>\ref vx_uint32</tt> parameter.*/
VX_TARGET_ATTRIBUTE_INDEX = VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_TARGET) + 0x0,
/*! \brief Returns the name of the given target in the format "vendor.vendor_string".
* Use a <tt>\ref vx_char</tt>[<tt>\ref VX_MAX_TARGET_NAME</tt>] array
*/
VX_TARGET_ATTRIBUTE_NAME = VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_TARGET) + 0x1,
/*! \brief Returns the number of kernels that the target is capable of processing.
* This is then used to allocate a table which is then filled when <tt>\ref vxQueryTarget</tt>
* is called with <tt>\ref VX_TARGET_ATTRIBUTE_KERNELTABLE</tt>.
* Use a <tt>\ref vx_uint32</tt> parameter.
*/
VX_TARGET_ATTRIBUTE_NUMKERNELS = VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_TARGET) + 0x2,
/*! \brief Returns the table of all the kernels that a given target can execute.
* Use a <tt>vx_kernel_info_t</tt> array.
* \pre You must call <tt>\ref vxQueryTarget</tt> with <tt>\ref VX_TARGET_ATTRIBUTE_NUMKERNELS</tt>
* to compute the necessary size of the array.
*/
VX_TARGET_ATTRIBUTE_KERNELTABLE = VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_TARGET) + 0x3,
};
#if defined(__cplusplus)
extern "C" {
#endif
/*! \brief Used to retrieve a target reference by the index of the target.
* \param [in] context The reference to the overall context.
* \param [in] index The index of the target to get a reference to.
* \return <tt>\ref vx_target</tt>
* \retval 0 Invalid index.
* \retval * A target reference.
* \note Use <tt>\ref vxQueryContext</tt> with <tt>\ref VX_CONTEXT_NUMTARGETS</tt> to retrieve the upper limit of targets.
* \ingroup group_target
*/
VX_API_ENTRY vx_target VX_API_CALL vxGetTargetByIndex(vx_context context, vx_uint32 index);
/*! \brief Used to get a reference to named target when the name is known beforehand.
* \param [in] context The reference to the overall context.
* \param [in] name The target string name.
* \return <tt>\ref vx_target</tt>
* \retval 0 Invalid index.
* \retval * A target reference.
* \ingroup group_target
*/
VX_API_ENTRY vx_target VX_API_CALL vxGetTargetByName(vx_context context, const vx_char *name);
/*! \brief Releases a reference to a target object.
* The object may not be garbage collected until its total reference count is zero.
* \param [in] target The pointer to the target to release.
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS No errors.
* \retval VX_ERROR_INVALID_REFERENCE If target is not a <tt>\ref vx_target</tt>.
* \note After returning from this function the reference will be zeroed.
* \ingroup group_target
*/
VX_API_ENTRY vx_status VX_API_CALL vxReleaseTarget(vx_target *target);
/*! \brief Used to query the target about it's properties.
* \param [in] target The reference to the target.
* \param [in] attribute The <tt>\ref vx_target_attribute_e</tt> value to query for.
* \param [out] ptr The location at which the resulting value will be stored.
* \param [in] size The size of the container to which ptr points.
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \pre <tt>\ref vxGetTargetByName</tt> or <tt>\ref vxGetTargetByIndex</tt>
* \ingroup group_target
*/
VX_API_ENTRY vx_status VX_API_CALL vxQueryTarget(vx_target target, vx_enum attribute, void *ptr, vx_size size);
/*! \brief Used to assign target affinity to a node.
* \note This assignment overrides implementation chosen behavior.
* \param [in] node The node reference to assign affinity to.
* \param [in] target The reference to the target to execute the Node on.
* \pre <tt>\ref vxGetTargetByName</tt> or <tt>\ref vxGetTargetByIndex</tt>
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \ingroup group_target
* \pre <tt>vxCreateGenericNode</tt> or some other node creation function.
* \retval VX_ERROR_INVALID_REFERENCE Either node or target was not a valid reference.
* \retval VX_ERROR_NOT_SUPPORTED The node can not be executed on that target.
*/
VX_API_ENTRY vx_status VX_API_CALL vxAssignNodeAffinity(vx_node node, vx_target target);
#if defined(__cplusplus)
}
#endif
#endif

View File

@ -0,0 +1,293 @@
/*
* Copyright (c) 2012-2017 The Khronos Group Inc.
*
* 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
*
* http://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 _VX_HELPER_H_
#define _VX_HELPER_H_
#include <VX/vx.h>
/*! \file
* \brief The OpenVX Helper Library Interface.
*
* \defgroup group_helper OpenVX Helper
* \brief The helper is an non-standardized set of convenience constructs for OpenVX.
* \details These functions use only the OpenVX API in order to implement their
* functionality. As such structures, objects, defines, typedefs and functions
* defined herein are not part of the OpenVX standard, and are
* included as EXAMPLE code only.
*/
/*! \brief A definition for TAU, or 2*PI.
* \ingroup group_helper
*/
#define VX_TAU 6.28318530717958647692
/*! \brief Maximum number of supported entries.
* \ingroup group_helper
*/
#ifndef VX_MAX_LOG_NUM_ENTRIES
#define VX_MAX_LOG_NUM_ENTRIES (1024)
#endif
#ifndef dimof
/*! \brief A helper macro to determine the number of elements in an array.
* \ingroup group_helper
*/
#define dimof(x) (sizeof(x)/sizeof(x[0]))
#endif
/*! \brief Contains everything needed to abstractly describe a parameter to a kernel. This is used to
* declare kernel parameters at compile time.
* \ingroup group_helper
*/
typedef struct _vx_param_description_t {
vx_enum direction; /*!< \brief From \ref vx_direction_e */
vx_enum data_type; /*!< \brief From \ref vx_type_e */
vx_enum state; /*!< \brief From \ref vx_parameter_state_e */
} vx_param_description_t;
/*! \brief Contains everything needed to abstractly describe a kernel.
* This is used to declare kernels at compile time.
* \ingroup group_helper
*/
typedef struct _vx_kernel_description_t {
/*! \brief The vx_kernel_e enum */
vx_enum enumeration;
/*! \brief The name that kernel will be used with \ref vxGetKernelByName. */
vx_char name[VX_MAX_KERNEL_NAME];
/*! \brief The pointer to the function to execute the kernel */
vx_kernel_f function;
/*! \brief The pointer to the array of parameter descriptors */
vx_param_description_t *parameters;
/*! \brief The number of paraemeters in the array. */
vx_uint32 numParams;
/*! \brief The parameters validator */
vx_kernel_validate_f validate;
/*! \brief The input validator (deprecated in openvx 1.1) */
void* input_validate;
/*! \brief The output validator (deprecated in openvx 1.1) */
void* output_validate;
/*! \brief The initialization function */
vx_kernel_initialize_f initialize;
/*! \brief The deinitialization function */
vx_kernel_deinitialize_f deinitialize;
} vx_kernel_description_t;
/*! \brief A log entry contains the graph reference, a status and a message.
* \ingroup group_helper
*/
typedef struct _vx_log_entry_t {
/*! \brief The status code */
vx_status status;
/*! \brief The reference to which the message and status pertains. */
vx_reference reference;
/*! \brief This indicates if the log entry is valid/active or not. */
vx_enum active;
/*! \brief The message given to the log from OpenVX. This may be an empty string. */
char message[VX_MAX_LOG_MESSAGE_LEN];
} vx_log_entry_t;
/*! \brief The log of a graph
* \ingroup group_helper
*/
typedef struct _vx_log_t {
vx_int32 first; /*!< Inclusive */
vx_int32 last; /*!< Exclusive */
vx_uint32 count; /*!< == VX_MAX_LOG_NUM_ENTRIES */
/*! \brief The set of all log entries. */
vx_log_entry_t entries[VX_MAX_LOG_NUM_ENTRIES];
} vx_log_t;
#define FGETS(str, fh) \
{ \
char* success = fgets(str, sizeof(str), fh); \
if (!success) \
{ \
printf("fgets failed\n"); \
} \
}
#ifdef __cplusplus
extern "C" {
#endif
uint32_t math_gcd(uint32_t a, uint32_t b);
/*! \brief Returns the previous entry of the log. When called consecutively it
* will return the entire log. The log will be cleared by reading it.
* \param [in] ref The reference to filter the log entries against.
* If the context is given, the next entry will be returned.
* \param [out] message A predefined location to store a copy of the log's
* message value.
* This must point to at least <tt>\ref VX_MAX_LOG_MESSAGE_LEN</tt> bytes of characters.
* \return Returns the status of the log entry from <tt>\ref vx_status_e</tt>.
* \ingroup group_helper
* \note The API returns errors oldest to newest order.
* When VX_SUCCESS is returned, the log reading is complete.
*/
vx_status vxGetLogEntry(vx_reference ref, char message[VX_MAX_LOG_MESSAGE_LEN]);
/*! \brief This enables the helper library logging feature to take over the error
* log callback and keep a database of previous log entries.
* \ingroup group_helper
*/
void vxRegisterHelperAsLogReader(vx_context context);
/*!
* \brief A method to construct a node via arbitrary parameters and an enum.
* \param [in] graph The handle to desired graph to add the node to.
* \param [in] kernelenum The \ref vx_kernel_e enum value used to create a node.
* \param [in] params The array of parameter information.
* \param [in] num The number of elements in params.
* \return vx_node
* \retval 0 Indicates a failure.
* \ingroup group_helper
*/
vx_node vxCreateNodeByStructure(vx_graph graph,
vx_enum kernelenum,
vx_reference params[],
vx_uint32 num);
/*! \brief A method to clear out the log for a particular reference, such as a graph.
* \param [in] ref The reference to remove from the log.
* \ingroup group_helper
*/
void vxClearLog(vx_reference ref);
/*! \brief This is used to connect one node parameter to another node parameter
* when the original handles to the data objects are already lost.
* The context determines if a buffer is necessary or can be optimized out.
* \param [in] a The first parameter
* \param [in] b The second parameter
* \note a or b must be an output parameter and other other an input.
* \return Returns a status code.
* \ingroup group_helper
*/
vx_status vxLinkParametersByReference(vx_parameter a, vx_parameter b);
/*! \brief This is used to connect one parameter to another parameter by
* explicity indexing when the handles to the data objects are lost.
* \param [in] node_a The source node to link from.
* \param [in] index_a The index of the \ref vx_parameter to link from.
* \param [in] node_b The sink node to link to.
* \param [in] index_b The index of the \ref vx_parameter to link to.
* \return Returns a status code.
* \ingroup group_helper
*/
vx_status vxLinkParametersByIndex(vx_node node_a, vx_uint32 index_a, vx_node node_b, vx_uint32 index_b);
/*! \brief This helper is used to easily set the affine matrix to a rotation and scale.
* \param [in] matrix The handle to the matrix.
* \param [in] angle The rotation angle in degrees.
* \param [in] scale The scaling value. Values less than one are enlarging.
* \param [in] center_x The center pixel in the x direction.
* \param [in] center_y The center pixel in the y direction.
* \return Returns a \ref vx_status_e enumeration.
* \ingroup group_helper
*/
vx_status vxSetAffineRotationMatrix(vx_matrix matrix,
vx_float32 angle,
vx_float32 scale,
vx_float32 center_x,
vx_float32 center_y);
/*! \brief [Helper] This function changes the points of a rectangle by some
* delta value per coordinate.
* \param [in] rect The rectangle to modify.
* \param [in] dsx The start x delta.
* \param [in] dsy The start y delta.
* \param [in] dex The end x delta.
* \param [in] dey The end y delta.
* \return vx_status
* \retval VX_SUCCESS Modified rectangle.
* \retval VX_ERROR_INVALID_REFERENCE Not a valid rectangle.
* \ingroup group_helper
*/
vx_status vxAlterRectangle(vx_rectangle_t *rect,
vx_int32 dsx,
vx_int32 dsy,
vx_int32 dex,
vx_int32 dey);
/*! \brief Adds a parameter to a graph by indicating the source node, and the
* index of the parameter on the node.
* \param [in] g The graph handle.
* \param [in] n The node handle.
* \param [in] index The index of the parameter on the node.
* \return Returns a \ref vx_status_e enumeration.
* \ingroup group_helper
*/
vx_status vxAddParameterToGraphByIndex(vx_graph g, vx_node n, vx_uint32 index);
#if defined(EXPERIMENTAL_USE_TARGET)
/*! \brief Finds all targets which report that they implement a particular kernel by name.
* \param [in] context The overall context.
* \param [in] kname The name of the kernel to find.
* \param [in,out] targets The array of pointers to character arrays. Each index will
* be modified. If the kernel does not exist on the target, the name will be zeroed.
* If the kernel does exist on the target, the name of the target will be filled in.
* \pre targets must be a preallocated array of vx_char pointers to
* <tt>\ref VX_MAX_TARGET_NAME</tt> characters with number of elements equal to
* the number of targets in the implementation.
* \ingroup group_helper
*/
vx_bool vxFindAllTargetsOfKernelsByName(vx_context context, vx_char kname[VX_MAX_KERNEL_NAME], vx_char *targets[]);
/*! \brief Allocates and returns a list of all available targets in a context.
* \param [in] context The overall context.
* \param [out] targets A pointer to variable to hold the array of target strings.
* \param [out] num_targets A pointer to a variable to hold the number of targets found.
* \ingroup group_helper
*/
vx_bool vxCreateListOfAllTargets(vx_context context, vx_char **targets[], vx_uint32 *num_targets);
/*! \brief Free the array of target name strings.
* \param [in,out] targets The pointer to the variable that holds the array of strings. This variable will be set
* to NULL after this call.
* \param [in] num_targets The number of targets in the system.
* \ingroup group_helper
*/
void vxDestroyListOfAllTargets(vx_char **targets[], vx_uint32 num_targets);
#endif
/*! \brief Find the overlapping rectange between two rectangles.
* \ingroup group_helper
*/
vx_bool vxFindOverlapRectangle(vx_rectangle_t *rect_a, vx_rectangle_t *rect_b, vx_rectangle_t *rect_res);
/*! \brief Read a rectangle-shaped section of an image into a 2D array.
* \ingroup group_helper
*/
void vxReadRectangle(const void *base,
const vx_imagepatch_addressing_t *addr,
const vx_border_t *borders,
vx_df_image type,
vx_uint32 center_x,
vx_uint32 center_y,
vx_uint32 radius_x,
vx_uint32 radius_y,
void *destination);
#ifdef __cplusplus
}
#endif
#endif /* _VX_HELPER_H_ */

View File

@ -0,0 +1,498 @@
/*
* Copyright (c) 2012-2017 The Khronos Group Inc.
*
* 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
*
* http://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 _OPENVX_KERNELS_H_
#define _OPENVX_KERNELS_H_
/*!
* \file
* \brief The list of supported kernels in the OpenVX standard.
*/
#ifdef __cplusplus
extern "C" {
#endif
/*!
* \brief The standard list of available libraries
* \ingroup group_kernel
*/
enum vx_library_e {
/*! \brief The base set of kernels as defined by Khronos. */
VX_LIBRARY_KHR_BASE = 0x0,
};
/*!
* \brief The standard list of available vision kernels.
*
* Each kernel listed here can be used with the <tt>\ref vxGetKernelByEnum</tt> call.
* When programming the parameters, use
* \arg <tt>\ref VX_INPUT</tt> for [in]
* \arg <tt>\ref VX_OUTPUT</tt> for [out]
* \arg <tt>\ref VX_BIDIRECTIONAL</tt> for [in,out]
*
* When programming the parameters, use
* \arg <tt>\ref VX_TYPE_IMAGE</tt> for a <tt>\ref vx_image</tt> in the size field of <tt>\ref vxGetParameterByIndex</tt> or <tt>\ref vxSetParameterByIndex</tt> * \arg <tt>\ref VX_TYPE_ARRAY</tt> for a <tt>\ref vx_array</tt> in the size field of <tt>\ref vxGetParameterByIndex</tt> or <tt>\ref vxSetParameterByIndex</tt> * \arg or other appropriate types in \ref vx_type_e.
* \ingroup group_kernel
*/
enum vx_kernel_e {
/*!
* \brief The Color Space conversion kernel.
* \details The conversions are based on the <tt>\ref vx_df_image_e</tt> code in the images.
* \see group_vision_function_colorconvert
*/
VX_KERNEL_COLOR_CONVERT = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x1,
/*!
* \brief The Generic Channel Extraction Kernel.
* \details This kernel can remove individual color channels from an interleaved
* or semi-planar, planar, sub-sampled planar image. A client could extract
* a red channel from an interleaved RGB image or do a Luma extract from a
* YUV format.
* \see group_vision_function_channelextract
*/
VX_KERNEL_CHANNEL_EXTRACT = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x2,
/*!
* \brief The Generic Channel Combine Kernel.
* \details This kernel combine multiple individual planes into a single
* multiplanar image of the type specified in the output image.
* \see group_vision_function_channelcombine
*/
VX_KERNEL_CHANNEL_COMBINE = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x3,
/*! \brief The Sobel 3x3 Filter Kernel.
* \see group_vision_function_sobel3x3
*/
VX_KERNEL_SOBEL_3x3 = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x4,
/*!
* \brief The Magnitude Kernel.
* \details This kernel produces a magnitude plane from two input gradients.
* \see group_vision_function_magnitude
*/
VX_KERNEL_MAGNITUDE = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x5,
/*!
* \brief The Phase Kernel.
* \details This kernel produces a phase plane from two input gradients.
* \see group_vision_function_phase
*/
VX_KERNEL_PHASE = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x6,
/*!
* \brief The Scale Image Kernel.
* \details This kernel provides resizing of an input image to an output image.
* The scaling factor is determined but the relative sizes of the input and
* output.
* \see group_vision_function_scale_image
*/
VX_KERNEL_SCALE_IMAGE = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x7,
/*! \brief The Table Lookup kernel
* \see group_vision_function_lut
*/
VX_KERNEL_TABLE_LOOKUP = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x8,
/*! \brief The Histogram Kernel.
* \see group_vision_function_histogram
*/
VX_KERNEL_HISTOGRAM = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x9,
/*! \brief The Histogram Equalization Kernel.
* \see group_vision_function_equalize_hist
*/
VX_KERNEL_EQUALIZE_HISTOGRAM = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0xA,
/*! \brief The Absolute Difference Kernel.
* \see group_vision_function_absdiff
*/
VX_KERNEL_ABSDIFF = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0xB,
/*! \brief The Mean and Standard Deviation Kernel.
* \see group_vision_function_meanstddev
*/
VX_KERNEL_MEAN_STDDEV = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0xC,
/*! \brief The Threshold Kernel.
* \see group_vision_function_threshold
*/
VX_KERNEL_THRESHOLD = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0xD,
/*! \brief The Integral Image Kernel.
* \see group_vision_function_integral_image
*/
VX_KERNEL_INTEGRAL_IMAGE = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0xE,
/*! \brief The dilate kernel.
* \see group_vision_function_dilate_image
*/
VX_KERNEL_DILATE_3x3 = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0xF,
/*! \brief The erode kernel.
* \see group_vision_function_erode_image
*/
VX_KERNEL_ERODE_3x3 = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x10,
/*! \brief The median image filter.
* \see group_vision_function_median_image
*/
VX_KERNEL_MEDIAN_3x3 = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x11,
/*! \brief The box filter kernel.
* \see group_vision_function_box_image
*/
VX_KERNEL_BOX_3x3 = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x12,
/*! \brief The gaussian filter kernel.
* \see group_vision_function_gaussian_image
*/
VX_KERNEL_GAUSSIAN_3x3 = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x13,
/*! \brief The custom convolution kernel.
* \see group_vision_function_custom_convolution
*/
VX_KERNEL_CUSTOM_CONVOLUTION = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x14,
/*! \brief The gaussian image pyramid kernel.
* \see group_vision_function_gaussian_pyramid
*/
VX_KERNEL_GAUSSIAN_PYRAMID = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x15,
/*! \brief The min and max location kernel.
* \see group_vision_function_minmaxloc
*/
VX_KERNEL_MINMAXLOC = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x19,
/*! \brief The bit-depth conversion kernel.
* \see group_vision_function_convertdepth
*/
VX_KERNEL_CONVERTDEPTH = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x1A,
/*! \brief The Canny Edge Detector.
* \see group_vision_function_canny
*/
VX_KERNEL_CANNY_EDGE_DETECTOR = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x1B,
/*! \brief The Bitwise And Kernel.
* \see group_vision_function_and
*/
VX_KERNEL_AND = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x1C,
/*! \brief The Bitwise Inclusive Or Kernel.
* \see group_vision_function_or
*/
VX_KERNEL_OR = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x1D,
/*! \brief The Bitwise Exclusive Or Kernel.
* \see group_vision_function_xor
*/
VX_KERNEL_XOR = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x1E,
/*! \brief The Bitwise Not Kernel.
* \see group_vision_function_not
*/
VX_KERNEL_NOT = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x1F,
/*! \brief The Pixelwise Multiplication Kernel.
* \see group_vision_function_mult
*/
VX_KERNEL_MULTIPLY = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x20,
/*! \brief The Addition Kernel.
* \see group_vision_function_add
*/
VX_KERNEL_ADD = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x21,
/*! \brief The Subtraction Kernel.
* \see group_vision_function_sub
*/
VX_KERNEL_SUBTRACT = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x22,
/*! \brief The Warp Affine Kernel.
* \see group_vision_function_warp_affine
*/
VX_KERNEL_WARP_AFFINE = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x23,
/*! \brief The Warp Perspective Kernel.
* \see group_vision_function_warp_perspective
*/
VX_KERNEL_WARP_PERSPECTIVE = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x24,
/*! \brief The Harris Corners Kernel.
* \see group_vision_function_harris
*/
VX_KERNEL_HARRIS_CORNERS = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x25,
/*! \brief The FAST Corners Kernel.
* \see group_vision_function_fast
*/
VX_KERNEL_FAST_CORNERS = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x26,
/*! \brief The Optical Flow Pyramid (LK) Kernel.
* \see group_vision_function_opticalflowpyrlk
*/
VX_KERNEL_OPTICAL_FLOW_PYR_LK = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x27,
/*! \brief The Remap Kernel.
* \see group_vision_function_remap
*/
VX_KERNEL_REMAP = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x28,
/*! \brief The Half Scale Gaussian Kernel.
* \see group_vision_function_scale_image
*/
VX_KERNEL_HALFSCALE_GAUSSIAN = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x29,
VX_KERNEL_MAX_1_0, /*!< \internal Used for VX1.0 bounds checking in the conformance test. */
/* kernel added in OpenVX 1.1 */
/*! \brief The Laplacian Image Pyramid Kernel.
* \see group_vision_function_laplacian_pyramid
*/
VX_KERNEL_LAPLACIAN_PYRAMID = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x2A,
/*! \brief The Laplacian Pyramid Reconstruct Kernel.
* \see group_vision_function_laplacian_pyramid
*/
VX_KERNEL_LAPLACIAN_RECONSTRUCT = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x2B,
/*! \brief The Non Linear Filter Kernel.
* \see group_vision_function_nonlinear_filter
*/
VX_KERNEL_NON_LINEAR_FILTER = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x2C,
VX_KERNEL_MAX_1_1, /*!< \internal Used for VX1.1 bounds checking in the conformance test. */
/* kernel added in OpenVX 1.2 */
/*! \brief The Match Template Kernel.
* \see group_vision_match_template
*/
VX_KERNEL_MATCH_TEMPLATE = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x2D,
/*! \brief The LBP Kernel.
* \see group_lbp
*/
VX_KERNEL_LBP = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x2E,
/*! \brief The hough lines probability Kernel.
* \see group_vision_hough_lines_p
*/
VX_KERNEL_HOUGH_LINES_P = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x2F,
/*! \brief The tensor multiply Kernel.
* \see group_vision_function_tensor_multiply
*/
VX_KERNEL_TENSOR_MULTIPLY = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x30,
/*! \brief The tensor add Kernel.
* \see group_vision_function_tensor_add
*/
VX_KERNEL_TENSOR_ADD = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x31,
/*! \brief The tensor subtract Kernel.
* \see group_vision_function_tensor_subtract
*/
VX_KERNEL_TENSOR_SUBTRACT = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x32,
/*! \brief The tensor table look up Kernel.
* \see group_vision_function_tensor_tablelookup
*/
VX_KERNEL_TENSOR_TABLE_LOOKUP = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x33,
/*! \brief The tensor transpose Kernel.
* \see group_vision_function_tensor_transpose
*/
VX_KERNEL_TENSOR_TRANSPOSE = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x34,
/*! \brief The tensor convert depth Kernel.
* \see group_vision_function_tensor_convert_depth
*/
VX_KERNEL_TENSOR_CONVERT_DEPTH = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x35,
/*! \brief The tensor matrix multiply Kernel.
* \see group_vision_function_tensor_matrix_multiply
*/
VX_KERNEL_TENSOR_MATRIX_MULTIPLY = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x36,
/*! \brief The data object copy kernel.
* \see group_vision_function_copy
*/
VX_KERNEL_COPY = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x37,
/*! \brief The non-max suppression kernel.
* \see group_vision_function_nms
*/
VX_KERNEL_NON_MAX_SUPPRESSION = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x38,
/*! \brief The scalar operation kernel.
* \see group_control_flow
*/
VX_KERNEL_SCALAR_OPERATION = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x39,
/*! \brief The HOG features kernel.
* \see group_vision_function_hog
*/
VX_KERNEL_HOG_FEATURES = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x3A,
/*! \brief The HOG Cells kernel.
* \see group_vision_function_hog
*/
VX_KERNEL_HOG_CELLS = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x3B,
/*! \brief The bilateral filter kernel.
* \see group_vision_function_bilateral_filter
*/
VX_KERNEL_BILATERAL_FILTER = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x3C,
/*! \brief The select kernel.
* \see group_control_flow
*/
VX_KERNEL_SELECT = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x3D,
/* insert new kernels here */
/*! \brief The max kernel.
* \see group_vision_function_max
*/
VX_KERNEL_MAX = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x3E,
/*! \brief The min kernel.
* \see group_vision_function_min
*/
VX_KERNEL_MIN = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x3F,
/*! \brief The weigthed average kernel.
* \see group_vision_function_weighted_average
*/
VX_KERNEL_WEIGHTED_AVERAGE = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_BASE) + 0x40,
/* insert new kernels here */
VX_KERNEL_NN_CONVOLUTION_RELU_POOLING_LAYER = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x0,
VX_KERNEL_NN_CONVOLUTION_RELU_LAYER = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x1,
VX_KERNEL_NN_FULLY_CONNECTED_RELU_LAYER = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x2,
//VX_KERNEL_NN_SOFTMAX_LAYER = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x3,
//VX_KERNEL_NN_NORMALIZATION_LAYER = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x4,
VX_KERNEL_NN_LRN_LAYER = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x3,
//VX_KERNEL_NN_NORMALIZE_IMAGE_LAYER = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x4,
//VX_KERNEL_NN_POOLING_LAYER = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x7,
//VX_KERNEL_NN_ACTIVATION_LAYER = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x9,
VX_KERNEL_NN_LEAKY = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x4,
VX_KERNEL_NN_BATCH_NORM = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x5,
VX_KERNEL_NN_RPN = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x6,
//VX_KERNEL_NN_ROIPOOL = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0xD,
VX_KERNEL_NN_CONCAT2_LAYER = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x7,
//VX_KERNEL_NN_CONVOLUTION_LAYER = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0xF,
VX_KERNEL_NN_CONCATINDEFINITE_LAYER = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x8,
VX_KERNEL_NN_REORG_LAYER = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x9,
//VX_KERNEL_NN_DECONVOLUTION_LAYER = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x12,
VX_KERNEL_NN_TENSOR_DIV = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0xA,
VX_KERNEL_NN_L2NORMALIZE_LAYER = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0xB,
VX_KERNEL_NN_TENSOR_COPY = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0xC,
VX_KERNEL_NN_CONVOLUTION_RELU_POOLING_LAYER2 = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0xD,
VX_KERNEL_NN_POOLING_LAYER2 = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0xE,
VX_KERNEL_NN_TENSOR_REDUCE_SUM = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0xF,
VX_KERNEL_NN_TENSOR_PAD = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x10,
VX_KERNEL_NN_LSTM_UNIT = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x11,
VX_KERNEL_NN_LSTM_LAYER = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x12,
VX_KERNEL_NN_REORG2_LAYER = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x13,
VX_KERNEL_NN_TENSOR_ROUNDING = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x14,
VX_KERNEL_NN_HASH_LUT_LAYER = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x15,
VX_KERNEL_NN_LSH_PROJECTION_LAYER = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x16,
VX_KERNEL_NN_TENSOR_RESHPE = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x17,
VX_KERNEL_NN_LUT2_LAYER = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x18,
VX_KERNEL_NN_TENSOR_SCALE = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x19,
VX_KERNEL_NN_RNN_LAYER = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x1A,
VX_KERNEL_NN_SOFTMAX2_LAYER = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x1B,
VX_KERNEL_NN_SVDF_LAYER = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x1C,
VX_KERNEL_NN_NORMALIZATION_LAYER2 = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x1D,
VX_KERNEL_NN_TENSOR_REVERSE = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x1E,
VX_KERNEL_NN_TENSOR_TRANSPOSE = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x1F,
VX_KERNEL_NN_TENSOR_MEAN = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x20,
VX_KERNEL_NN_TENSOR_SQUEEZE = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x21,
VX_KERNEL_NN_TENSOR_STRIDE_SLICE = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x22,
VX_KERNEL_NN_TENSOR_PAD2 = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x23,
VX_KERNEL_NN_YUV2RGB_SCALE = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x24,
VX_KERNEL_NN_PRELU = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x25,
VX_KERNEL_NN_GRU_UNIT_LAYER = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x26,
VX_KERNEL_NN_GRU_LAYER = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x27,
VX_KERNEL_NN_CONV_LSTM_UNIT_LAYER = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x28,
VX_KERNEL_NN_CONV_LSTM_LAYER = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x29,
VX_KERNEL_NN_FULLY_CONNECTED_LAYER = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x2A,
VX_KERNEL_NN_L2NORMALIZE_LAYER2 = VX_KERNEL_BASE(VX_ID_VIVANTE, VX_LIBRARY_KHR_BASE) + 0x2B,
VX_KERNEL_MAX_1_2, /*!< \internal Used for VX1.2 bounds checking in the conformance test. */
};
#ifdef __cplusplus
}
#endif
#endif /* _OPEN_VISION_LIBRARY_KERNELS_H_ */

View File

@ -0,0 +1,35 @@
/****************************************************************************
*
* Copyright 2017 - 2020 Vivante Corporation, Santa Clara, California.
* All Rights Reserved.
*
* 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, sub license, 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 (including the
* next paragraph) 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 NON-INFRINGEMENT.
* IN NO EVENT SHALL VIVANTE AND/OR ITS SUPPLIERS 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 _VX_KHR_CNN_H_
#define _VX_KHR_CNN_H_
#define OPENVX_KHR_CNN "vx_khr_cnn"
#include <VX/vx_khr_nn.h>
#endif

View File

@ -0,0 +1,75 @@
/****************************************************************************
*
* Copyright 2017 - 2020 Vivante Corporation, Santa Clara, California.
* All Rights Reserved.
*
* 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, sub license, 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 (including the
* next paragraph) 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 NON-INFRINGEMENT.
* IN NO EVENT SHALL VIVANTE AND/OR ITS SUPPLIERS 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 __VX_KHR_COMPATIBLE_H__
#define __VX_KHR_COMPATIBLE_H__
/*
VX_DECONVOLUTION_WEIGHT_LAYOUT_COMPATIBLE_KHRONOS is used to distingush deconvolution weight layout
[value]
0: weight_layout is whnc
1: weight_layout is whcn
*/
#define VX_DECONVOLUTION_WEIGHT_LAYOUT_COMPATIBLE_KHRONOS 1
/*
VX_CONVERT_POLICY_WRAP_ENABLE is used to differentiate two overflow_policys(VX_CONVERT_POLICY_WRAP and VX_CONVERT_POLICY_SAT)
[value]
0: both overflow_policys considered as VX_CONVERT_POLICY_SAT
1: overflow_policy is determined by arguments.
*/
#define VX_CONVERT_POLICY_WRAP_ENABLE 1
#define VX_13_NN_COMPATIBLITY 1
/*
VX_L2NORM_AXIS_PARAMETER_SUPPORT is used to declare that L2NORMALIZE can support axis parameter
[value]
0: not support
1: support
*/
#define VX_L2NORM_AXIS_PARAMETER_SUPPORT 1
/*
VX_SOFTMAX_AXIS_PARAMETER_SUPPORT is used to declare that SOFTAMX can support axis parameter
[value]
0: not support
1: support
*/
#define VX_SOFTMAX_AXIS_PARAMETER_SUPPORT 1
/*
VX_NORMALIZATION_AXIS_PARAMETER_SUPPORT is used to declare that NORMALIZATION can support axis parameter
[value]
0: not support
1: support
*/
#define VX_NORMALIZATION_AXIS_PARAMETER_SUPPORT 1
/*
VX_ACTIVATION_EXT_SUPPORT is used to declare that ACTIVATION can support swish and hswish
[value]
0: not support
1: support
*/
#define VX_ACTIVATION_EXT_SUPPORT 1
#endif /* __VX_KHR_COMPATIBLE_H__ */

View File

@ -0,0 +1,42 @@
/*
* Copyright (c) 2012-2017 The Khronos Group Inc.
*
* 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
*
* http://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 _VX_KHR_DOT_H_
#define _VX_KHR_DOT_H_
#define OPENVX_KHR_DOT "vx_khr_dot"
#include <VX/vx.h>
#ifdef __cplusplus
extern "C" {
#endif
/*! \brief Exports a single graph to a dotfile.
* \param [in] graph The graph to export.
* \param [in] dotfile The name of the file to write to.
* \param [in] showData If true, data objects will be listed in the graph too.
* \see http://www.graphviz.com
*/
vx_status vxExportGraphToDot(vx_graph g, vx_char dotfile[], vx_bool showData);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,80 @@
/*
* Copyright (c) 2017-2017 The Khronos Group Inc.
*
* 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
*
* http://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.
*/
/*! \file
* \defgroup group_icd OpenVX ICD Loader API
* \brief The OpenVX Installable Client Driver (ICD) Loader API.
* \details The vx_khr_icd extension provides a mechanism for vendors to implement Installable Client Driver (ICD) for OpenVX. The OpenVX ICD Loader API provides a mechanism for applications to access these vendor implementations.
*/
#ifndef _VX_KHR_ICD_H_
#define _VX_KHR_ICD_H_
#include <VX/vx.h>
#include <VX/vxu.h>
/*! \brief Platform handle of an implementation.
* \ingroup group_icd
*/
typedef struct _vx_platform * vx_platform;
#ifdef __cplusplus
extern "C" {
#endif
/*! \brief Queries list of available platforms.
* \param [in] capacity Maximum number of items that platform[] can hold.
* \param [out] platform[] List of platform handles.
* \param [out] pNumItems Number of platform handles returned.
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS No errors.
* \retval VX_FAILURE If no platforms are found.
* \ingroup group_icd
*/
vx_status VX_API_CALL vxIcdGetPlatforms(vx_size capacity, vx_platform platform[], vx_size * pNumItems);
/*! \brief Queries the platform for some specific information.
* \param [in] platform The platform handle.
* \param [in] attribute The attribute to query. Use one of the following:
* <tt>\ref VX_CONTEXT_VENDOR_ID</tt>,
* <tt>\ref VX_CONTEXT_VERSION</tt>,
* <tt>\ref VX_CONTEXT_EXTENSIONS_SIZE</tt>,
* <tt>\ref VX_CONTEXT_EXTENSIONS</tt>.
* \param [out] ptr The location at which to store the resulting value.
* \param [in] size The size in bytes of the container to which \a ptr points.
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS No errors.
* \retval VX_ERROR_INVALID_REFERENCE If the platform is not a <tt>\ref vx_platform</tt>.
* \retval VX_ERROR_INVALID_PARAMETERS If any of the other parameters are incorrect.
* \retval VX_ERROR_NOT_SUPPORTED If the attribute is not supported on this implementation.
* \ingroup group_icd
*/
vx_status VX_API_CALL vxQueryPlatform(vx_platform platform, vx_enum attribute, void *ptr, vx_size size);
/*! \brief Creates a <tt>\ref vx_context</tt> from a <tt>\ref vx_platform</tt>.
* \details This creates a top-level object context for OpenVX from a platform handle.
* \returns The reference to the implementation context <tt>\ref vx_context</tt>. Any possible errors
* preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>.
* \ingroup group_icd
*/
vx_context VX_API_CALL vxCreateContextFromPlatform(vx_platform platform);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,88 @@
/*
* Copyright (c) 2012-2018 The Khronos Group Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and/or associated documentation files (the
* "Materials"), to deal in the Materials without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Materials, and to
* permit persons to whom the Materials are 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 Materials.
*
* MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS
* KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS
* SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT
* https://www.khronos.org/registry/
*
* THE MATERIALS ARE 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
* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
#ifndef _OPENVX_IMPORT_KERNEL_H_
#define _OPENVX_IMPORT_KERNEL_H_
#include <VX/vx.h>
/*!
* \file
* \brief The OpenVX import kernel extension API.
*/
#define OPENVX_KHR_IMPORT_KERNEL "vx_khr_import_kernel"
/*! \brief The import kernel extension library set
* \ingroup group_import_kernel
*/
#define VX_LIBRARY_KHR_IMPORT_KERNEL_EXTENSION (0x5)
/*
define type for vxImportKernelFromURL() function
*/
#define VX_VIVANTE_IMPORT_KERNEL_FROM_FILE "vx_vivante_file"
#define VX_VIVANTE_IMPORT_KERNEL_FROM_FOLDER "vx_vivante_folder"
#define VX_VIVANTE_IMPORT_KERNEL_FROM_LABEL "vx_vivante_label"
#define VX_VIVANTE_IMPORT_KERNEL_FROM_POINTER "vx_vivante_pointer"
#ifdef __cplusplus
extern "C" {
#endif
/*! \brief Import a kernel from binary specified by URL.
*
* The name of kernel parameters can be queried using the vxQueryReference API
* with vx_parameter as ref and VX_REFERENCE_NAME as attribute.
*
* \param context [in] The OpenVX context
* \param type [in] Vendor-specific identifier that indicates to the implementation
* how to interpret the url. For example, if an implementation can interpret the url
* as a file, a folder a symbolic label, or a pointer, then a vendor may choose
* to use "vx_<vendor>_file", "vx_<vendor>_folder", "vx_<vendor>_label", and
* "vx_<vendor>_pointer", respectively for this field. Container types starting
* with "vx_khr_" are reserved. Refer to vendor documentation for list of
* container types supported
* \param url [in] URL to binary container.
*
* \retval On success, a valid vx_kernel object. Calling vxGetStatus with the return value
* as a parameter will return VX_SUCCESS if the function was successful.
*
* \ingroup group_import_kernel
*/
VX_API_ENTRY vx_kernel VX_API_CALL vxImportKernelFromURL(
vx_context context,
const vx_char * type,
const vx_char * url
);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,38 @@
/*
* Copyright (c) 2012-2017 The Khronos Group Inc.
*
* 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
*
* http://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 _VX_KHR_INTERP_H_
#define _VX_KHR_INTERP_H_
/*! \brief The Interpolation Type Query Extension.
* \file
*/
#define OPENVX_KHR_INTERP "vx_khr_interpolation"
#include <VX/vx.h>
/*! \brief Additional interpolation types */
enum vx_interpolation_type_ext_e {
/*! \brief Bicubic interpolation method */
VX_INTERPOLATION_BICUBIC = VX_ENUM_BASE(VX_ID_KHRONOS, VX_ENUM_INTERPOLATION) + 0x3,
/*! \brief Mipmapping interpolation method */
VX_INTERPOLATION_MIPMAP = VX_ENUM_BASE(VX_ID_KHRONOS, VX_ENUM_INTERPOLATION) + 0x4,
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,658 @@
/*
* Copyright (c) 2012-2017 The Khronos Group Inc.
*
* 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
*
* http://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 _VX_KHR_NN_INTERNAL_H_
#define _VX_KHR_NN_INTERNAL_H_
/*!
* \file
* \brief The Khronos Extension for Deep Convolutional Networks Functions.
*
* \defgroup group_cnn Extension: Deep Convolutional Networks API
* \brief Convolutional Network Nodes.
*/
#define OPENVX_KHR_NN_INTERNAL "vx_khr_nn_internal"
#include <VX/vx.h>
#ifdef __cplusplus
extern "C" {
#endif
/*TODO: check it for OpenVX 1.2*/
//#if defined(OPENVX_CNN_1_0)
//#undef OPENVX_CNN_1_1
//#endif
/*! \brief [Graph] Creates a Convolutional Network Convolution and Activation(Relu) and pooling Layer Node.
* \details This function implement Convolutional Network Convolution and Activation(Relu) and pooling layer.
* \param [in] graph The handle to the graph.
* \param [in] inputs The input tensor data. 3 lower dimensions represent a single input, all following dimensions represent number of batches, possibly nested.
* The dimension order is [width, height, #IFM, #batches]. \n
* \param [in] weights_biases [static] Point to WeightBiasesParameter data, vx_weights_biases_parameter is an opaque reference.\n
* \param [in] pad_x [static] Number of elements added at each side in the x dimension of the input.
* \param [in] pad_y [static] Number of elements added at each side in the y dimension of the input. In fully connected layers this input is ignored.
* \param [in] accumulator_bits [static] Is the total number of bits used during intermediate accumulation.
* \param [in] overflow_policy [static] A <tt> VX_TYPE_ENUM</tt> of the <tt> vx_convert_policy_e</tt> enumeration.
* \param [in] rounding_policy [static] A <tt> VX_TYPE_ENUM</tt> of the <tt> vx_round_policy_e</tt> enumeration.
* \param [in] down_scale_size_rounding [static] Rounding method for calculating output dimensions. See <tt>\ref vx_convolutional_network_rounding_type_e</tt>
* \param [in] enable_relu [static] If true, enable vxActivationLayer's relu function
* \param [in] pool_type [static] if neither max pooling nor average pooling, disable pooling function. (see <tt>\ref vx_convolutional_network_pooling_type_e</tt>).
* \param [in] pool_size_x [static] Size of the pooling region in the x dimension
* \param [in] pool_size_y [static] Size of the pooling region in the y dimension.
* \param [out] outputs The output tensor data. Output will have the same number and structure of dimensions as input.
* \return <tt> vx_node</tt>.
* \retval 0 Node could not be created.
* \retval * Node handle.
* \ingroup group_cnn
*/
VX_API_ENTRY vx_node VX_API_CALL vxConvolutionReluPoolingLayer(
vx_graph graph,
vx_tensor inputs,
vx_weights_biases_parameter weights_biases,
vx_uint32 pad_x,
vx_uint32 pad_y,
vx_uint8 accumulator_bits,
vx_enum overflow_policy,
vx_enum rounding_policy,
vx_enum down_scale_size_rounding,
vx_bool enable_relu,
vx_enum pool_type,
vx_uint32 pool_size_x,
vx_uint32 pool_size_y,
vx_tensor outputs
);
/*! \brief [Graph] Creates a Convolutional Network Convolution and Activation(Relu) Layer Node.
* \details This function implement Convolutional Network Convolution and Activation(Relu) layer.
* \param [in] graph The handle to the graph.
* \param [in] inputs The input tensor data. 3 lower dimensions represent a single input, all following dimensions represent number of batches, possibly nested.
* The dimension order is [width, height, #IFM, #batches]. \n
* \param [in] weights_biases [static] Point to WeightBiasesParameter data, vx_weights_biases_parameter is an opaque reference.
* \param [in] pad_x [static] Number of elements added at each side in the x dimension of the input.
* \param [in] pad_y [static] Number of elements added at each side in the y dimension of the input. In fully connected layers this input is ignored.
* \param [in] accumulator_bits [static] Is the total number of bits used during intermediate accumulation.
* \param [in] overflow_policy [static] A <tt> VX_TYPE_ENUM</tt> of the <tt> vx_convert_policy_e</tt> enumeration.
* \param [in] rounding_policy [static] A <tt> VX_TYPE_ENUM</tt> of the <tt> vx_round_policy_e</tt> enumeration.
* \param [in] down_scale_size_rounding [static] Rounding method for calculating output dimensions. See <tt>\ref vx_convolutional_network_rounding_type_e</tt>
* \param [in] enable_relu [static] If true, enable vxActivationLayer's relu function.
* \param [out] outputs The output tensor data. Output will have the same number and structure of dimensions as input.
* \return <tt> vx_node</tt>.
* \retval 0 Node could not be created.
* \retval * Node handle.
* \ingroup group_cnn
*/
VX_API_ENTRY vx_node VX_API_CALL vxConvolutionReluLayer(
vx_graph graph,
vx_tensor inputs,
vx_weights_biases_parameter weights_biases,
vx_uint32 pad_x,
vx_uint32 pad_y,
vx_uint8 accumulator_bits,
vx_enum overflow_policy,
vx_enum rounding_policy,
vx_enum down_scale_size_rounding,
vx_bool enable_relu,
vx_tensor outputs
);
/*! \brief [Graph] Creates a Fully connected and Activation(Relu) Convolutional Network Layer Node.
* \details This function implement Fully connected and Activation(Relu) Convolutional Network layers.
* \param [in] graph The handle to the graph.
* \param [in] inputs The input tensor data. There two possible input layouts:
* 1. [#IFM, #batches]. See <tt>\ref vxCreateTensor</tt> and <tt>\ref vxCreateVirtualTensor</tt>.
* 2. [width, height, #IFM, #batches]. See <tt>\ref vxCreateTensor</tt> and <tt>\ref vxCreateVirtualTensor</tt>\n
* In both cases number of batches are optional and may be multidimensional.
* The second option is a special case to deal with convolution layer followed by fully connected.
* The dimension order is [#IFM, #batches]. See <tt>\ref vxCreateTensor</tt> and <tt>\ref vxCreateVirtualTensor</tt>. Note that batch may be multidimensional.
* \param [in] weights_biases [static] Point to WeightBiasesParameter data, vx_weights_biases_parameter is an opaque reference.\n
* \param [in] pad [static] Number of elements added at each side in the input.
* \param [in] accumulator_bits [static] Is the total number of bits used during intermediate accumulation.
* \param [in] overflow_policy [static] A <tt> VX_TYPE_ENUM</tt> of the <tt> vx_convert_policy_e</tt> enumeration.
* \param [in] rounding_policy [static] A <tt> VX_TYPE_ENUM</tt> of the <tt> vx_round_policy_e</tt> enumeration.
* \param [in] down_scale_size_rounding [static] Rounding method for calculating output dimensions. See <tt>\ref vx_convolutional_network_rounding_type_e</tt>
* \param [in] enable_relu [static] If true, enable vxActivationLayer's relu function.
* \param [out] outputs The output tensor data. Output dimension layout is [#OFM,#batches]. See <tt>\ref vxCreateTensor</tt> and <tt>\ref vxCreateVirtualTensor</tt>, where #batches may be multidimensional.
* \return <tt> vx_node</tt>.
* \retval 0 Node could not be created.
* \retval * Node handle.
* \ingroup group_cnn
*/
VX_API_ENTRY vx_node VX_API_CALL vxFullyConnectedReluLayer(
vx_graph graph,
vx_tensor inputs,
vx_weights_biases_parameter weights_biases,
vx_uint32 pad,
vx_uint8 accumulator_bits,
vx_enum overflow_policy,
vx_enum rounding_policy,
vx_enum down_scale_size_rounding,
vx_bool enable_relu,
vx_tensor outputs
);
/*! \brief Input parameter for convolutionReluPooling2
* \ingroup group_cnn
*/
typedef struct _vx_nn_convolution_relu_pooling_params_t
{
vx_size dilation_x; /*!< \brief "inflate" the kernel by inserting zeros between the kernel elements in the x direction.
The value is the number of zeros to insert. */
vx_size dilation_y; /*!< \brief "inflate" the kernel by inserting zeros between the kernel elements in the y direction.
The value is the number of zeros to insert. */
vx_uint32 pad_x_left; /*!< \brief Number of elements added at each side in the left of x dimension of the input. */
vx_uint32 pad_x_right; /*!< \brief Number of elements added at each side in the right of x dimension of the input. */
vx_uint32 pad_y_top; /*!< \brief Number of elements added at each side in the top of y dimension of the input. */
vx_uint32 pad_y_bottom; /*!< \brief Number of elements added at each side in the bottom of y dimension of the input. */
vx_uint8 accumulator_bits; /*!< \brief Is the total number of bits used during intermediate accumulation. */
vx_enum overflow_policy; /*!< \brief A VX_TYPE_ENUM of the vx_convert_policy_e enumeration. */
vx_enum rounding_policy; /*!< \brief A VX_TYPE_ENUM of the vx_round_policy_e enumeration. */
vx_enum down_scale_size_rounding; /*!< \brief Rounding method for calculating output dimensions. See vx_convolutional_network_rounding_type_e */
vx_bool enable_relu; /*!< \brief Enable Relu layer function or not. */
vx_enum pool_type; /*!< \brief neither max pooling nor average pooling, disable pooling function (see vx_convolutional_network_pooling_type_e). */
vx_uint32 pool_size_x; /*!< \brief Size of the pooling region in the x dimension */
vx_uint32 pool_size_y; /*!< \brief Size of the pooling region in the y dimension. */
vx_enum pad_mode; /*!< \brief A VX_TYPE_ENUM of the <tt> \ref vx_pad_mode_e </tt> enumeration. */
vx_scalar pad_const; /*!< \brief The order const value if setting pad mode to const, the const value is base value, not quantized value. */
} vx_nn_convolution_relu_pooling_params_t, * vx_nn_convolution_relu_pooling_params;
/*! \brief Extended input parameter for a convolutionReluPooling2 operation.
* \ingroup group_cnn
*\version 0.3
*/
typedef struct _vx_nn_convolution_relu_pooling_params_ext_t
{
vx_nn_convolution_relu_pooling_params_t base; /*!< \brief convolution relu pooling params <tt>\ref vx_nn_convolution_relu_pooling_params_t</tt> */
vx_uint32 stride_x; /*!< \brief skip x jump for down scale. */
vx_uint32 stride_y; /*!< \brief skip y jump for down scale. */
} vx_nn_convolution_relu_pooling_params_ext_t, * vx_nn_convolution_relu_pooling_params_ext;
/*! \brief The 2nd version of extended input parameter for a convolutionReluPooling2 operation.
*\ingroup group_cnn
*\version 0.4
*/
typedef struct _vx_nn_convolution_relu_pooling_params_ext2_t
{
vx_nn_convolution_relu_pooling_params_ext_t ext; /*!< \brief convolution relu pooling params <tt>\ref vx_nn_convolution_relu_pooling_params__ext_t</tt> */
vx_int32 depth_multiplier; /*!< \brief specifying the depthwise multiplier for depthwise convolution. */
vx_enum src_rank_mode; /*!< \brief source rank mode A VX_TYPE_ENUM of the <tt> \ref vx_tensor_rank_type_e </tt> enumeration. */
vx_enum convert_dst_format; /*!< \brief The convert target format. */
} vx_nn_convolution_relu_pooling_params_ext2_t, * vx_nn_convolution_relu_pooling_params_ext2;
#define MERGED_NODE_COUNT_MAX 4
typedef struct _vx_nn_convolution_relu_pooling_params_ext3_t
{
vx_nn_convolution_relu_pooling_params_ext2_t ext2; /*!< \brief convolution relu pooling params <tt>\ref vx_nn_convolution_relu_pooling_params__ext_t</tt> */
vx_uint32 mergedNodeCount;
vx_float32* interScale; /*!< \brief specifying the depthwise multiplier for depthwise convolution. */
vx_int32* interZeroPoint;
vx_enum* interDataType;
} vx_nn_convolution_relu_pooling_params_ext3_t, * vx_nn_convolution_relu_pooling_params_ext3;
/*! \brief [Graph] Creates a Convolutional Network Convolution and Activation(Relu) and Pooling Layer Node, this fucntion match kronos NN Extension 1.2 verion.
* \details This function implement Convolutional Network Convolution and Activation(Relu) and Pooling layer.
* For fixed-point data types, a fixed point calculation is performed with round and saturate according to the number of accumulator bits. The number of the accumulator bits are implementation defined,
* and should be at least 16.\n
* round: rounding according the <tt>vx_round_policy_e</tt> enumeration. \n
* saturate: A saturation according the <tt>vx_convert_policy_e</tt> enumeration.
* The following equation is implemented: \n
* \f$ outputs[j,k,i] = saturate(round(\sum_{l} (\sum_{m,n} inputs[j-m,k-n,l] \times weights[m,n,l,i])+biasses[j,k,i])) \f$\n
* Where \f$m,n\f$ are indexes on the convolution matrices. \f$ l\f$ is an index on all the convolutions per input.\f$ i\f$ is an index per output.
* \f$ j,k \f$ are the inputs/outputs spatial indexes.
* Convolution is done on the width and height dimensions of the <tt>\ref vx_tensor</tt>. Therefore, we use here the term x for index along the width dimension and y for index along the height dimension.\n
* before the Convolution is done, a padding with zeros of the width and height input dimensions is performed.
* Then down scale is done by picking the results according to a skip jump. The skip in the x and y is determined by the output size dimensions.
* The relation between input to output is as follows: \n
* \f$ width_{output} = round(\frac{(width_{input} + paddingleft_x + paddingright_x - kernel_x - (kernel_x -1) * dilation_x)}{skip_x} + 1) \f$\n
* and \n
* \f$ height_{output} = round(\frac{(height + paddingtop_y + paddingbottom_y - kernel_y - (kernel_y -1) * dilation_y)}{skip_y} + 1) \f$\n
* where \f$width\f$ is the size of the input width dimension. \f$height\f$ is the size of the input height dimension.
* \f$width_{output}\f$ is the size of the output width dimension. \f$height_{output}\f$ is the size of the output height dimension.
* \f$kernel_x\f$ and \f$kernel_y\f$ are the convolution sizes in width and height dimensions.
* skip is calculated by the relation between input and output.
* rounding is done according to <tt>\ref vx_convolutional_network_rounding_type_e</tt>.
* \param [in] graph The handle to the graph.
* \param [in] inputs The input tensor data. 3 lower dimensions represent a single input, all following dimensions represent number of batches, possibly nested.
* The dimension order is [width, height, #IFM, #batches]. \n
* \param [in] weights_biases [static] Point to WeightBiasesParameter data, vx_weights_biases_parameter is an opaque reference.
* \param [in] convolution_relu_pooling_params [static] Pointer to parameters of type <tt>\ref vx_nn_convolution_relu_pooling_params_t</tt>
* \param [in] size_of_convolution_relu_pooling_params [static] Size in bytes of convolution_relu_pooling_params.
* \param [out] outputs The output tensor data. Output will have the same number and structure of dimensions as input.
* \return <tt> vx_node</tt>.
* \returns A node reference <tt>\ref vx_node</tt>. Any possible errors preventing a
* successful creation should be checked using <tt>\ref vxGetStatus</tt>.
* \ingroup group_cnn
*/
VX_API_ENTRY vx_node VX_API_CALL vxConvolutionReluPoolingLayer2(
vx_graph graph,
vx_tensor inputs,
vx_weights_biases_parameter weights_biases,
const vx_nn_convolution_relu_pooling_params_t * convolution_relu_pooling_params,
vx_size size_of_convolution_relu_pooling_params,
vx_tensor outputs);
/*! \brief The optimization direvative for weights_biases_parameter create.
* \ingroup group_cnn
*/
typedef struct _vx_weights_biases_parameter_optimizations_t {
vx_int8 zrl; /*!< \brief The zero run length. Set negtive value to disable*/
vx_enum outputFormat; /*!< \brief The output format. */
vx_int32 inputZeroPoint; /*!< \brief zero point of input. A 32 bit integer, in range [0, 255], Set zero value to disable */
} vx_weights_biases_parameter_optimizations_t;
typedef struct _vx_weights_biases_parameter_optimizations_ext_t {
vx_int8 zrl; /*!< \brief The zero run length. Set negtive value to disable*/
vx_enum outputFormat; /*!< \brief The output format. */
vx_int32 inputZeroPoint; /*!< \brief zero point of input. A 32 bit integer, in range [0, 255], Set zero value to disable */
vx_uint32 num_of_input_dims; /*< \brief The input dimesion number*/
vx_uint32 num_of_output_dims; /*!< \brief The output dimesion number*/
} vx_weights_biases_parameter_optimizations_ext_t;
typedef struct _vx_weights_biases_parameter_optimizations_ext2_t {
vx_weights_biases_parameter_optimizations_ext_t ext;
vx_float32 inputScale;
vx_float32 outputScale;
vx_enum inputFormat;
vx_int32 output_ZP_dw; /*depthwise conv output ZP*/
vx_float32 output_scale_dw; /*depthwise conv output scale*/
vx_int8 output_fpp_dw; /*depthwise conv output fix-point*/
} vx_weights_biases_parameter_optimizations_ext2_t;
/*!
* \brief Creates a reference to a vx_weights_biases_parameter opaque object.
*
* \param [in] layer_type The network type of objects to hold. Types allowed are:
* \arg VX_CONVOLUTIONAL_NETWORK_CONVOLUTION_LAYER for convolution layer.
* \arg VX_CONVOLUTIONAL_NETWORK_FULLYCONNECTED_LAYER for fullyconnected layer.
* \param [in] num_of_dims The dimention number of input & output image tensor.
* \param [in] inputs_dims The input tensor's dimension size.
* \param [in] pad_x The number of elements subtracted at each side in the x dimension of the input.
* \param [in] pad_y The number of elements subtracted at each side in the y dimension of the input.
* \param [in] pooling_size_x The size of the pooling region in the x dimension, 0 means no pooling operation.
* \param [in] pooling_size_y The size of the pooling region in the y dimension, 0 means no pooling operation.
* \param [in] down_scale_size_rounding A <tt> VX_TYPE_ENUM</tt> of the <tt> vx_round_policy_e</tt> enumeration.
* \param [in] convolution_outputs_dims The output's dimension size after covolution operation.
* \param [in] pool_outputs_dims The output's dimension size after pooling operation.
* \param [in] optimizations A optional param for <tt>\ref vx_weights_biases_parameter_optimizations_t</tt>.
* \param [in] weights The weights tensor which need be compressed.
* \param [in] biases The biases tensor which need be compressed.
*
* \returns An opaque vx_weights_biases_parameter reference with compressed kernel data. Any possible errors preventing a
* successful creation should be checked using <tt>\ref vxGetStatus</tt>.
*
* \ingroup group_cnn
*/
VX_API_ENTRY vx_weights_biases_parameter VX_API_CALL
vxCreateWeightsBiasesParameterFromTensors(
vx_enum layer_type,
vx_uint32 num_of_dims,
vx_uint32 * inputs_dims,
vx_uint32 pad_x,
vx_uint32 pad_y,
vx_uint32 pooling_size_x,
vx_uint32 pooling_size_y,
vx_enum down_scale_size_rounding,
vx_uint32 * convolution_outputs_dims,
vx_uint32 * pool_outputs_dims,
vx_weights_biases_parameter_optimizations_t *optimizations,
vx_tensor weights,
vx_tensor biases);
/*!
* \brief Creates a reference to an opaque vx_weights_biases_parameter object.
*
* \param [in] layer_type The network type of objects to hold. Types allowed are:
* \arg VX_CONVOLUTIONAL_NETWORK_CONVOLUTION_LAYER for convolution layer.
* \arg VX_CONVOLUTIONAL_NETWORK_FULLYCONNECTED_LAYER for fullyconnected layer.
* \param [in] num_of_dims The dimention number of input & output image tensor.
* \param [in] inputs_dims The input tensor's dimension size.
* \param [in] convolution_outputs_dims The output's dimension size after covolution operation.
* \param [in] pool_outputs_dims The output's dimension size after pooling operation.
* \param [in] output_format The output tensor element type.
* \param [in] convolution_relu_pooling_params The convolution_relu_pooling_params Pointer to parameters of type <tt>\ref vx_nn_convolution_relu_pooling_params_t</tt>
* \param [in] size_of_convolution_relu_pooling_params The size in bytes of convolution_relu_pooling_params.
* \param [in] optimizations A optional param for <tt>\ref vx_weights_biases_parameter_optimizations_t</tt>.
* \param [in] weights The weights tensor which need be compressed.
* \param [in] biases The biases tensor which need be compressed.
*
* \returns An opaque vx_weights_biases_parameter reference with compressed kernel data. Any possible errors preventing a
* successful creation should be checked using <tt>\ref vxGetStatus</tt>.
*
* \ingroup group_cnn
*/
VX_API_ENTRY vx_weights_biases_parameter VX_API_CALL vxCreateWeightsBiasesParameterFromTensors2(
vx_enum layer_type,
vx_uint32 num_of_dims,
vx_uint32 * inputs_dims,
vx_uint32 * convolution_outputs_dims,
vx_uint32 * pool_outputs_dims,
vx_enum output_format,
const vx_nn_convolution_relu_pooling_params convolution_relu_pooling_params,
vx_size size_of_convolution_relu_pooling_params,
vx_weights_biases_parameter_optimizations_t *optimizations,
vx_tensor weights,
vx_tensor biases);
/*!
* \brief Creates a reference to an opaque vx_weights_biases_parameter object.
*
* \param [in] layer_type The network type of objects to hold. Types allowed are:
* \arg VX_CONVOLUTIONAL_NETWORK_CONVOLUTION_LAYER for convolution layer.
* \arg VX_CONVOLUTIONAL_NETWORK_FULLYCONNECTED_LAYER for fullyconnected layer.
* \param [in] inputs_dims The input tensor's dimension size.
* \param [in] convolution_outputs_dims The output's dimension size after covolution operation.
* \param [in] pool_outputs_dims The output's dimension size after pooling operation.
* \param [in] convolution_relu_pooling_params The convolution_relu_pooling_params Pointer to parameters of type <tt>\ref vx_nn_convolution_relu_pooling_params_t</tt>
* \param [in] size_of_convolution_relu_pooling_params The size in bytes of convolution_relu_pooling_params.
* \param [in] optimizations A optional param for <tt>\ref vx_weights_biases_parameter_optimizations_t</tt>.
* \param [in] size_of_optimizations The size in bytes of optimizations.
* \param [in] weights The weights tensor which need be compressed.
* \param [in] biases The biases tensor which need be compressed.
*
* \returns An opaque vx_weights_biases_parameter reference with compressed kernel data. Any possible errors preventing a
* successful creation should be checked using <tt>\ref vxGetStatus</tt>.
*
* \ingroup group_cnn
*/
VX_API_ENTRY vx_weights_biases_parameter VX_API_CALL vxCreateWeightsBiasesParameterFromTensors3(
vx_enum layer_type,
vx_uint32 * inputs_dims,
vx_uint32 * convolution_outputs_dims,
vx_uint32 * pool_outputs_dims,
const vx_nn_convolution_relu_pooling_params convolution_relu_pooling_params,
vx_size size_of_convolution_relu_pooling_params,
vx_weights_biases_parameter_optimizations_t *optimizations,
vx_size size_of_optimizations,
vx_tensor weights,
vx_tensor biases);
/*! \brief Releases the OpenVX object vx_weights_biases_parameter.
* \param [in] weights_bias The pointer to the reference to the vx_weights_biases_parameter.
* \post After returning from this function the reference is zeroed.
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS No errors.
* \retval VX_ERROR_INVALID_REFERENCE If weights_bias is not a <tt> vx_weights_biases_parameter</tt>.
* \pre <tt>\ref vxCreateWeightsBiasesParameterFromTensors / vxCreateWeightsBiasesParameterFromTensors2/ vxCreateWeightsBiasesParameter / vxCreateWeightsBiasesParameterFromStream</tt>
* \ingroup group_cnn
*/
VX_API_ENTRY vx_status VX_API_CALL vxReleaseWeightsBiasesParameter(vx_weights_biases_parameter *weights_bias);
/*!
* \brief Creates a reference to an vx_weights_biases_parameter object.
* \param [in] context The OpenVX context object.
* \param [in] layer_type The network type of objects to hold. Types allowed are:
* \arg VX_CONVOLUTIONAL_NETWORK_CONVOLUTION_LAYER for convolution layer.
* \arg VX_CONVOLUTIONAL_NETWORK_FULLYCONNECTED_LAYER for fullyconnected layer.
* \param [in] num_of_dims The dimention number of input & output image tensor.
* \param [in] inputs_dims The input tensor's dimension size.
* \param [in] pad_x The number of elements subtracted at each side in the x dimension of the input.
* \param [in] pad_y The number of elements subtracted at each side in the y dimension of the input.
* \param [in] pooling_size_x The size of the pooling region in the x dimension, 0 means no pooling operation.
* \param [in] pooling_size_y The size of the pooling region in the y dimension, 0 means no pooling operation.
* \param [in] down_scale_size_rounding A <tt> VX_TYPE_ENUM</tt> of the <tt> vx_round_policy_e</tt> enumeration.
* \param [in] convolution_outputs_dims The output's dimension size after covolution operation.
* \param [in] pool_outputs_dims The output's dimension size after pooling operation.
* \param [in] weights_num_of_dims The dimention number of weights tensor.
* \param [in] weights_dims The dimention size of weights tensor.
* \param [in] weights_data_format The format of weights tensor.
* \param [in] weights_fixed_point_pos The fixed point position when the weights element type is int16/int8, if 0 calculations are performed in integer math.
* \param [in] biases_num_of_dims The dimention number of biases tensor.
* \param [in] biases_dims The dimention size of biases tensor.
* \param [in] biases_data_format The format of biases tensor.
* \param [in] biases_fixed_point_pos The fixed point position when the biases element type is int16/int8, if 0 calculations are performed in integer math.
* \param [in] raw_data_size The data size of compressed data.
*
* \returns A weightsbiases reference without compressed kernel data <tt>vx_weights_biases_parameter</tt>. Any possible errors preventing a
* successful creation should be checked using <tt>\ref vxGetStatus</tt>.
*
* \ingroup group_cnn
*/
VX_API_ENTRY vx_weights_biases_parameter VX_API_CALL
vxCreateWeightsBiasesParameter(
vx_context context,
vx_enum layer_type,
vx_uint32 num_of_dims,
vx_uint32 * inputs_dims,
vx_uint32 pad_x,
vx_uint32 pad_y,
vx_uint32 pooling_size_x,
vx_uint32 pooling_size_y,
vx_enum down_scale_size_rounding,
vx_uint32 * convolution_outputs_dims,
vx_uint32 * pool_outputs_dims,
vx_uint32 weights_num_of_dims,
vx_uint32 * weights_dims,
vx_enum weights_data_format,
vx_int8 weights_fixed_point_pos,
vx_uint32 biases_num_of_dims,
vx_uint32 * biases_dims,
vx_enum biases_data_format,
vx_int8 biases_fixed_point_pos,
vx_uint32 raw_data_size
);
/*! \brief Input parameters for a gru operation.
* \ingroup group_cnn
* \version 0.5
*/
typedef struct _vx_nn_gru_params_t
{
vx_tensor reset2input_weights; /*!< \brief [static] Weight matrix for the reset gate with input. A 2-D tensor of type T, of shape [input_size, cell_size]. where "cell_size" corresponds to the number of cell units.*/
vx_tensor update2input_weights; /*!< \brief [static] Weight matrix for the update gate with input. A 2-D tensor of type T, of shape [input_size, cell_size]. */
vx_tensor reset2recurrent_weights; /*!< \brief [static] Weight matrix for the reset gate with recurrent(h_prev). A 2-D tensor of type T, of shape [cell_size, cell_size]. */
vx_tensor update2recurrent_weights; /*!< \brief [static] Weight matrix for the update gate with recurrent(h_prev). A 2-D tensor of type T, of shape [cell_size, cell_size]. */
vx_tensor connection2input_weights; /*!< \brief [static] Weight matrix for the cell connection gate with input. A 2-D tensor of type T, of shape [input_size, cell_size]. */
vx_tensor connection2recurrent_weights; /*!< \brief [static] Weight matrix for the cell connection gate with recurrent(h_prev). A 2-D tensor of type T, of shape [cell_size, cell_size]. */
vx_tensor gate_input_bias; /*!< \brief [static] Bias vector for the reset and update gate for input. A 1-D tensor of type T, of shape [cell_size].*/
vx_tensor gate_recurrent_bias; /*!< \brief [static] Bias vector for the reset and update gate for recurrent. A 1-D tensor of type T, of shape [cell_size].*/
vx_tensor connection_bias; /*!< \brief [static] Bias vector for the cell connection gate. A 1-D tensor of type T, of shape [cell_size].*/
} vx_nn_gru_params_t;
/*! \brief [Graph] Creates a Long short-term memory unit (gru) Unit Networks Layer Node. not implement yet.
* \details
* The implementation is based on: http://arxiv.org/abs/1406.1078
* Computes the GRU cell forward propagation for 1 time step.
* This kernel op implements the following mathematical equations:
* Biases are initialized with:
* * `b_ru` - constant_initializer(1.0)
* * `b_c` - constant_initializer(0.0)
*
* x_h_prev = [x, h_prev]
* [r_bar u_bar] = x_h_prev * w_ru + b_ru
* r = sigmoid(r_bar)
* u = sigmoid(u_bar)
* h_prevr = h_prev x r
* x_h_prevr = [x h_prevr]
* c_bar = x_h_prevr * w_c + b_c
* c = tanh(c_bar)
* h = (1-u) x c + u x h_prev
*
* \param [in] graph The handle to the graph.
* \param [in] input A 2-D tensor of type T, of shape [input_size, batch_size], where
* "batch_size" corresponds to the batching dimension, and "input_size"
* is the size of the input.
* \param [in] h_prev A 2-D tensor of type T, of shape [cell_size, batch_size].
* \param [in] gru_params gru paraments <tt>\ref vx_nn_gru_params_t </tt>.
* \param [in] size_of_gru_params [static] The size of the gru_params.
* \param [out] output A 2-D tensor of type T, of shape [cell_size, batch_size].
* This is effectively the same as the current "output_state" value.
* \return <tt> vx_node</tt>.
* \returns A node reference <tt>\ref vx_node</tt>. Any possible errors preventing a
* successful creation should be checked using <tt>\ref vxGetStatus</tt>.
* \ingroup group_cnn
* \version 0.5
*/
VX_API_ENTRY vx_node VX_API_CALL vxGRUUnitLayer(
vx_graph graph,
vx_tensor input,
vx_tensor h_prev,
const vx_nn_gru_params_t * gru_params,
vx_size size_of_gru_params,
vx_tensor output);
/*! \brief [Graph] Creates a Long short-term memory layer (gru) Networks Layer Node. not implement yet.
* \details
*
* \param [in] graph The handle to the graph.
* \param [in] input A 3-D tensor of type T, of shape [input_size, batch_size, time_step], where
* "input_size" corresponds to the size of the input, and "batch_size"
* is the batching dimension, time_step means time length actually used by the input.
* \param [in] h_prev optional, A 2-D tensor of type T, of shape [cell_size, batch_size], where
* "input_size" corresponds to the size of the input, and "batch_size"
* is the batching dimension.
* \param [in] vx_nn_gru_params gru paraments <tt>\ref vx_nn_gru_params_t </tt>.
* \param [in] size_of_gru_layer_params [static] The size of the vx_nn_gru_params.
* \param [out] output A 2-D tensor of type T, of shape [cell_size, batch_size].
* This is effectively the same as the current "output_state" value.
* \return <tt> vx_node</tt>.
* \returns A node reference <tt>\ref vx_node</tt>. Any possible errors preventing a
* successful creation should be checked using <tt>\ref vxGetStatus</tt>.
* \ingroup group_cnn
* \version 0.5
*/
VX_API_ENTRY vx_node VX_API_CALL vxGRULayer(
vx_graph graph,
vx_tensor input,
vx_tensor h_prev,
const vx_nn_gru_params_t * gru_layer_params,
vx_size size_of_gru_layer_params,
vx_tensor output
);
/*! \brief Input parameters for a convolution lstm operation.
* \ingroup group_cnn
* \version 0.5
*/
typedef struct _vx_nn_convlstm_params_t
{
vx_tensor input2input_weight; /*!< \brief Optional A 2-D tensor of type T, of shape [num_units, input_size]. where "num_units" corresponds to the number of cell units.*/
vx_tensor input2forget_weight; /*!< \brief A 2-D tensor of type T, of shape [num_units, input_size].*/
vx_tensor input2cell_weight; /*!< \brief A 2-D tensor of type T, of shape [num_units, input_size].*/
vx_tensor input2output_weight; /*!< \brief A 2-D tensor of type T, of shape [num_units, input_size].*/
vx_tensor recurrent2input_weight; /*!< \brief Optional A 2-D tensor of type T, of shape [num_units, output_size]. where "output_size" corresponds to either the number of cell units (i.e., "num_units"), or the second dimension of the "projection_weights", if defined.*/
vx_tensor recurrent2forget_weight; /*!< \brief A 2-D tensor of type T, of shape [num_units, output_size].*/
vx_tensor recurrent2cell_weight; /*!< \brief A 2-D tensor of type T, of shape [num_units, output_size].*/
vx_tensor recurrent2output_weight; /*!< \brief A 2-D tensor of type T, of shape [num_units, output_size].*/
vx_tensor input_gate_bias; /*!< \brief Optional A 1-D tensor of type T, of shape [num_units].*/
vx_tensor forget_gate_bias; /*!< \brief A 1-D tensor of type T, of shape [num_units].*/
vx_tensor cell_bias; /*!< \brief A 1-D tensor of type T, of shape [num_units].*/
vx_tensor output_gate_bias; /*!< \brief A 1-D tensor of type T, of shape [num_units].*/
vx_tensor activation; /*!< \brief Optional. An ActivationFunctionType indicating the activation function. If "NONE" is specified then it results in a linear activation.If "NONE" is specified then it results in a linear activation.*/
vx_float32 forget_bias; /*!< \brief Float32[static] A bias for the forget gate. If set to 0.0f(by default) then bias is ignored.*/
vx_bool skip_connection; /*< \brief If set to `vx_true_e`, concatenate the input to the output of the conv LSTM. Default: `vx_false_e`.*/
} vx_nn_convlstm_params_t;
/*! \brief input parameters for a convolution lstm layer operation.
* \ingroup group_cnn
*/
typedef struct _vx_nn_convlstm_layer_params_t
{
vx_nn_convlstm_params_t convlstm_param; /*!< \brief convolution lstm input param <tt>\ref vx_nn_convlstm_params_t</tt>.*/
vx_enum convlstm_layer_type; /*!< \brief convolution lstm layer type.*/
} vx_nn_convlstm_layer_params_t;
/*! \brief [Graph] Creates a Convolution Long short-term memory unit (ConvLSTM) Unit Networks Layer Node. not implement yet.
* \details
*
* https://arxiv.org/pdf/1506.04214v1.pdf
*
* \param [in] graph The handle to the graph.
* \param [in] input A 2-D tensor of type T, of shape [input_size, batch_size], where
* "batch_size" corresponds to the batching dimension, and "input_size"
* is the size of the input.
* \param [in] output_state_in A 2-D tensor of type T, of shape [output_size, batch_size].
* \param [in] cell_state_in A 2-D tensor of type T, of shape [num_units, batch_size].
* \param [in] convlstm_params LSTM paraments <tt>\ref vx_nn_convlstm_params_t </tt>.
* \param [in] size_of_convlstm_params [static] The size of the convlstm_params.
* \param [out] scratch A 3-D tensor of type T, of shape [num_cell, 4, batch_size].
* \param [out] output_state_out A 2-D tensor of type T, of shape [output_size, batch_size].
* \param [out] cell_state_out A 2-D tensor of type T, of shape [num_units, batch_size].
* \param [out] output A 2-D tensor of type T, of shape [output_size, batch_size].
* This is effectively the same as the current "output_state" value.
* \return <tt> vx_node</tt>.
* \returns A node reference <tt>\ref vx_node</tt>. Any possible errors preventing a
* successful creation should be checked using <tt>\ref vxGetStatus</tt>.
* \ingroup group_cnn
* \version 0.5
*/
VX_API_ENTRY vx_node VX_API_CALL vxConvLSTMUnitLayer(
vx_graph graph,
vx_tensor input,
vx_tensor output_state_in,
vx_tensor cell_state_in,
const vx_nn_convlstm_params_t * convlstm_params,
vx_size size_of_convlstm_params,
vx_tensor output_state_out,
vx_tensor cell_state_out,
vx_tensor output);
/*! \brief [Graph] Creates a Long short-term memory layer (LSTM) Networks Layer Node. not implement yet.
* \details
*
* \param [in] graph The handle to the graph.
* \param [in] input A 3-D tensor of type T, of shape [input_size, batch_size, time_step], where
* "input_size" corresponds to the size of the input, and "batch_size"
* is the batching dimension, time_step means time length actually used by the input.
* \param [in] static_input optional, A 2-D tensor of type T, of shape [input_size, batch_size], where
* "input_size" corresponds to the size of the input, and "batch_size"
* is the batching dimension.
* \param [in] cont optional, A 2-D tensor of type T, of shape [input_size, batch_size], where
* "input_size" corresponds to the size of the input, and "batch_size"
* is the batching dimension.
* \param [in] convlstm_layer_params LSTM paraments <tt>\ref vx_nn_convlstm_layer_params_t </tt>.
* \param [in] size_of_convlstm_layer_params [static] The size of the convlstm_layer_params.
* \param [out] output A 2-D tensor of type T, of shape [output_size, batch_size].
* This is effectively the same as the current "output_state" value.
* \return <tt> vx_node</tt>.
* \returns A node reference <tt>\ref vx_node</tt>. Any possible errors preventing a
* successful creation should be checked using <tt>\ref vxGetStatus</tt>.
* \ingroup group_cnn
* \version 0.5
*/
VX_API_ENTRY vx_node VX_API_CALL vxConvLSTMLayer(
vx_graph graph,
vx_tensor input,
vx_tensor static_input,
vx_tensor cont,
const vx_nn_convlstm_layer_params_t * convlstm_layer_params,
vx_size size_of_convlstm_layer_params,
vx_tensor output
);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,61 @@
/*
* Copyright (c) 2012-2017 The Khronos Group Inc.
*
* 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
*
* http://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 _VX_KHR_NODE_MEMORY_H_
#define _VX_KHR_NODE_MEMORY_H_
/*! \brief The Node Memory Extension.
* \file
*/
#define OPENVX_KHR_NODE_MEMORY "vx_khr_node_memory"
#include <VX/vx.h>
/*! \brief The kernel object attributes for global and local memory.
* \ingroup group_kernel
*/
enum vx_kernel_attribute_memory_e {
/*! \brief The global data pointer size to be shared across all instances of
* the kernel (nodes are instances of kernels).
* Use a \ref vx_size parameter.
* \note If not set it will default to zero.
*/
VX_KERNEL_GLOBAL_DATA_SIZE = VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_KERNEL) + 0x5,
/*! \brief The global data pointer to the shared across all the instances of
* the kernel (nodes are instances of the kernels).
* Use a \ref void * parameter.
*/
VX_KERNEL_GLOBAL_DATA_PTR = VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_KERNEL) + 0x6,
};
/*! \brief The node object attributes for global and local memory.
* \ingroup group_node
*/
enum vx_node_attribute_memory_e {
/*! \brief Used to indicate the size of the shared kernel global memory area.
* Use a \ref vx_size parameter.
*/
VX_NODE_GLOBAL_DATA_SIZE = VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_NODE) + 0x9,
/*! \brief Used to indicate the pointer to the shared kernel global memory area.
* Use a void * parameter.
*/
VX_NODE_GLOBAL_DATA_PTR = VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_NODE) + 0xA,
};
#endif

View File

@ -0,0 +1,268 @@
/*
* Copyright (c) 2012-2017 The Khronos Group Inc.
*
* 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
*
* http://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 _VX_KHR_OPENCL_H_
#define _VX_KHR_OPENCL_H_
#include <VX/vx.h>
#include <VX/vx_compatibility.h>
/*! \file
* \brief The OpenVX to OpenCL Inter-op Extension Header.
*
* \defgroup group_cl_api API
* \brief The API used by Clients to add OpenCL Kernels as <tt>vx_kernel</tt>.
* \details
*
* \defgroup group_cl_def Extension Defines
* \brief The Extension defines and constants.
*
* \defgroup group_cl_image Images
* \brief OpenVX Images
* \details Depending on whether the OpenCL implementation supports images, <tt>vx_image</tt>
* may map to an <tt>image2d_t</tt> or a OpenCL buffer.
*
* \defgroup group_cl_array Arrays
* \brief OpenVX Arrays
*
* \defgroup group_cl_convolution Convolutions
* \brief OpenVX Convolutions
*
* \defgroup group_cl_distribution Distributions
* \brief OpenVX Distributions
*
* \defgroup group_cl_matrix Matricies
* \brief OpenVX Matrix
*
* \defgroup group_cl_types OpenVX to OpenCL Atomic Types
* \brief Atomic Types
* \details OpenVX types map to OpenCL types through this table:
* | VX | OpenCL|
* |:---------|:------|
* |<tt>vx_uint8</tt> |<tt>uchar</tt> |
* |<tt>vx_int8</tt> |<tt>char</tt> |
* |<tt>vx_uint16</tt> |<tt>ushort</tt> |
* |<tt>vx_int16</tt> |<tt>short</tt> |
* |<tt>vx_uint32</tt> |<tt>uint</tt> |
* |<tt>vx_int32</tt> |<tt>int</tt> |
* |<tt>vx_uint64</tt> |<tt>ulong</tt> |
* |<tt>vx_int64</tt> |<tt>long</tt> |
* |<tt>vx_float32</tt>|<tt>float</tt> |
* |<tt>vx_float64</tt>|<tt>double</tt> |
* |<tt>vx_size</tt> |<tt>size_t</tt> |
*
* \note <tt>size_t</tt> can not be used as a parameter to a <tt>__kernel</tt>.
*/
#ifndef VX_SCALE_UNITY
#define VX_SCALE_UNITY (1024)
#endif
/*!\brief The maximum number of planes an image may have which is compatible across both
* API.
* \ingroup group_cl_def
*/
#define VX_CL_MAX_PLANES (4)
#if defined(VX_CL_DOCUMENTATION) || !defined(VX_CL_KERNEL)
#if defined(__APPLE__) || defined(DARWIN)
#include <OpenCL/OpenCL.h>
#else
#include <CL/cl.h>
#endif
#if (!defined(__APPLE__)) && defined(CL_USE_LUMINANCE)
#define CL_USE_IMAGES
#endif
/*! \brief The string name of this extension to match for in the extensions list
* \ingroup group_cl_def
*/
#define OPENVX_KHR_OPENCL "vx_khr_opencl"
/*! \brief Adds an OpenCL Kernel as source code into the OpenVX implementation.
* \param [in] context The OpenVX Context.
* \param [in] name The name of the kernel in OpenVX nomenclature.
* \param [in] enumeration The OpenVX kernel enumeration used to identify this kernel.
* \param [in] source The array of source line pointers.
* \param [in] line_lengths The array of lines lengths for each line of source.
* \param [in] num_lines the number of lines in both the sources array and line_lengths array.
* \param [in] symbol_name The name of the kernel to call in the program.
* \param [in] numParams The number of parameters to the OpenVX kernel.
* \param [in] input The input validator.
* \param [in] output The output validator.
* \see <tt>vxAddParameterToKernel</tt> to configure the specific parameter attributes.
* \ingroup group_cl_api
*/
VX_API_ENTRY vx_kernel VX_API_CALL vxAddOpenCLAsSourceKernel(vx_context context,
vx_char name[VX_MAX_KERNEL_NAME],
vx_enum enumeration,
char *source[],
size_t line_lengths[],
size_t num_lines,
char symbol_name[],
vx_uint32 numParams,
vx_kernel_input_validate_f input,
vx_kernel_output_validate_f output);
/*! \brief Adds an OpenCL Kernel as binary program into the OpenVX implementation.
* \param [in] context The OpenVX Context.
* \param [in] name The name of the kernel in OpenVX nomenclature.
* \param [in] enumeration The OpenVX kernel enumeration used to identify this kernel.
* \param [in] program The OpenCL Program which contains the kernel (either pre-compiled or compiled by user).
* \param [in] symbol_name The name of the kernel to call in the program.
* \param [in] numParams The number of parameters to the OpenVX kernel.
* \param [in] input The input validator.
* \param [in] output The output validator.
* \see <tt>vxAddParameterToKernel</tt> to configure the specific parameter attributes.
* \ingroup group_cl_api
*/
VX_API_ENTRY vx_kernel VX_API_CALL vxAddOpenCLAsBinaryKernel(vx_context context,
vx_char name[VX_MAX_KERNEL_NAME],
vx_enum enumeration,
cl_program program,
char symbol_name[],
vx_uint32 numParams,
vx_kernel_input_validate_f input,
vx_kernel_output_validate_f output);
#endif // External API
#if defined(VX_CL_DOCUMENTATION) || defined(VX_CL_KERNEL)
#if defined(__IMAGE_SUPPORT__) && defined(CL_USE_LUMINANCE)
#define CL_USE_IMAGES
#endif
/*! \brief Allows access to an image pixel as a typecast pointer deference.
* \param type The OpenCL single element type
* \param ptr The <tt>__global</tt> pointer to the base of the image.
* \param x The x coordinate.
* \param y The y coordinate.
* \param sx The x stride.
* \param sy The y stride.
* \ingroup group_cl_image
*/
#define vxImagePixel(type, ptr, x, y, sx, sy) \
(*(type *)(&((uchar *)ptr)[((y) * sy) + ((x) * sx)]))
/*!
* \brief Allows access to an array item as a typecast pointer deference.
* \param type The OpenCL single element type or structure type.
* \param ptr The <tt>__global</tt> pointer to the base of the array.
* \param index The index of the element to access.
* \param stride The stride in bytes between two adjacent elements.
* \ingroup group_cl_array
*/
#define vxArrayItem(type, ptr, index, stride) \
(*(type *)(&((uchar *)ptr)[index*stride]))
/*! \brief Allows access to a matrix element \f$ M_{ij} \f$ where i is the column and j is the row.
* \param type The OpenCL single element type of the matrix.
* \param ptr The <tt>__global</tt> pointer to the base of the array.
* \param columns The number of columns in the matrix.
* \param i The column index
* \param j The row index
* \ingroup group_cl_matrix
*/
#define vxMatrixElement(type, ptr, columns, i, j) (((type *)ptr)[columns*j + i])
/*! \brief Allows access to a convolution element \f$ C_{ij} \f$ where i is the column and j is the row.
* \note Convolution elements are always of type <tt>short</tt>.
* \param ptr The <tt>__global</tt> pointer to the base of the array.
* \param columns The number of columns in the matrix.
* \param i The column index
* \param j The row index
* \ingroup group_cl_convolution
*/
#define vxConvolveElement(ptr, columns, i, j) (((short *)ptr)[columns*j + i])
/*! \brief Allows access to a distribution frequency counter.
* \param ptr The <tt>__global</tt> pointer to the base of the distribution.
* \param value The value to retrive the frequency count for.
* \param offset The offset within the input domain.
* \param range The total range within the domain starting from offset.
* \param window_size The window size of the bin.
* \ingroup group_cl_distribution
*/
#define vxGetFrequency(ptr, value, offset, range, window_size) \
((offset <= value) && (value <= (range+offset)) ? ptr[(value-offset)/window_size] : 0)
/*! \brief Increments a distribution frequency counter for a value.
* \param ptr The <tt>__global</tt> pointer to the base of the distribution.
* \param value The value to increment the frequency count for.
* \param offset The offset within the input domain.
* \param range The total range within the domain starting from offset.
* \param window_size The window size of the bin.
* \ingroup group_cl_distribution
*/
#define vxIncFrequency(ptr, value, offset, range, window_size) \
((offset <= value) && (value <= (range+offset)) ? ++ptr[(value-offset)/window_size] : 0)
/*! \brief Decrements a distribution frequency counter for a value.
* \param ptr The <tt>__global</tt> pointer to the base of the distribution.
* \param value The value to decrement the frequency count for.
* \param offset The offset within the input domain.
* \param range The total range within the domain starting from offset.
* \param window_size The window size of the bin.
* \ingroup group_cl_distribution
*/
#define vxDecFrequency(ptr, value, offset, range, window_size) \
((offset <= value) && (value <= (range+offset)) ? --ptr[(value-offset)/window_size] : 0)
#if defined(VX_VERSION_1_1) && (VX_VERSION >= VX_VERSION_1_1)
/*! \brief Allows access to a distribution frequency counter.
* \param ptr The <tt>__global</tt> pointer to the base of the distribution.
* \param value The value to retrive the frequency count for.
* \param offset The offset within the input domain.
* \param range The total range within the domain starting from offset.
* \param num_bins The number of bins in the domain range.
* \ingroup group_cl_distribution
*/
#define vxGetFrequency2(ptr, value, offset, range, num_bins) \
((offset <= value) && (value <= (range+offset)) ? ptr[(value-offset)*num_bins/range] : 0)
/*! \brief Increments a distribution frequency counter for a value.
* \param ptr The <tt>__global</tt> pointer to the base of the distribution.
* \param value The value to increment the frequency count for.
* \param offset The offset within the input domain.
* \param range The total range within the domain starting from offset.
* \param num_bins The number of bins in the domain range.
* \ingroup group_cl_distribution
*/
#define vxIncFrequency2(ptr, value, offset, range, num_bins) \
((offset <= value) && (value <= (range+offset)) ? ++ptr[(value-offset)*num_bins/range] : 0)
/*! \brief Decrements a distribution frequency counter for a value.
* \param ptr The <tt>__global</tt> pointer to the base of the distribution.
* \param value The value to decrement the frequency count for.
* \param offset The offset within the input domain.
* \param range The total range within the domain starting from offset.
* \param num_bins The number of bins in the domain range.
* \ingroup group_cl_distribution
*/
#define vxDecFrequency2(ptr, value, offset, range, num_bins) \
((offset <= value) && (value <= (range+offset)) ? --ptr[(value-offset)*num_bins/range] : 0)
#endif /*VX_VERSION_1_1*/
#endif
#endif

View File

@ -0,0 +1,376 @@
/*
* Copyright (c) 2012-2017 The Khronos Group Inc.
*
* 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
*
* http://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 _VX_KHR_TILING_H_
#define _VX_KHR_TILING_H_
/*!
* \file
* \brief The Khronos Extension for User Tiling Functions.
*
* \defgroup group_tiling Extension: User Tiling API
* \brief The Khronos Extension for User Tiling Functions.
*/
#define OPENVX_KHR_TILING "vx_khr_tiling"
#if defined(OPENVX_TILING_1_0)
#undef OPENVX_TILING_1_1
#endif
#include <VX/vx.h>
/* For vx_kernel_input_validate_f and vx_kernel_output_validate_f: */
#include <VX/vx_compatibility.h>
/*! \def VX_RESTRICT
* \brief A platform wrapper for the restrict keyword.
* \ingroup group_tiling
*/
#if defined(_WIN32)
#define VX_RESTRICT
#else
#if defined(__cplusplus) || defined(ANDROID)
#define VX_RESTRICT __restrict
#elif defined(__linux__)
#define VX_RESTRICT
#elif defined __QNXNTO__
#define VX_RESTRICT
#else
#define VX_RESTRICT restrict
#endif
#endif
/*! \brief The User Tiling Function tile block size declaration.
* \details The author of a User Tiling Kernel will use this structure to define
* the dimensionality of the tile block.
* \ingroup group_tiling
*/
typedef struct _vx_tile_block_size_t {
vx_int32 width; /*!< \brief Tile block width in pixels. */
vx_int32 height; /*!< \brief Tile block height in pixels. */
} vx_tile_block_size_t;
/*! \brief The User Tiling Function Neighborhood declaration.
* \details The author of a User Tiling Kernel will use this structure to define
* the neighborhood surrounding the tile block.
* \ingroup group_tiling
*/
typedef struct _vx_neighborhood_size_t {
vx_int32 left; /*!< \brief Left of the tile block. */
vx_int32 right; /*!< \brief Right of the tile block. */
vx_int32 top; /*!< \brief Top of the tile block. */
vx_int32 bottom; /*!< \brief Bottom of the tile block. */
} vx_neighborhood_size_t;
/*! \brief A structure which describes the tile's parent image.
* \ingroup group_tiling
*/
typedef struct _vx_image_description_t {
vx_uint32 width; /*!< \brief Width of the image */
vx_uint32 height; /*!< \brief Height of the image */
vx_df_image format; /*!< \brief The <tt>\ref vx_df_image_e</tt> of the image */
vx_uint32 planes; /*!< \brief The number of planes in the image */
vx_enum range; /*!< \brief The <tt>\ref vx_channel_range_e</tt> enumeration. */
vx_enum space; /*!< \brief The <tt>\ref vx_color_space_e</tt> enumeration. */
} vx_image_description_t;
/*! \brief The maximum number of planes in a tiled image.
* \ingroup group_tiling
*/
#define VX_MAX_TILING_PLANES (4)
/*! \brief The tile structure declaration.
* \ingroup group_tiling
*/
typedef struct _vx_tile_t {
/*! \brief The array of pointers to the tile's image plane. */
vx_uint8 * VX_RESTRICT base[VX_MAX_TILING_PLANES];
/*! \brief The top left X pixel index within the width dimension of the image. */
vx_uint32 tile_x;
/*! \brief The top left Y pixel index within the height dimension of the image. */
vx_uint32 tile_y;
/*! \brief The array of addressing structure to describe each plane. */
vx_imagepatch_addressing_t addr[VX_MAX_TILING_PLANES];
/*! \brief The output block size structure. */
vx_tile_block_size_t tile_block;
/*! \brief The neighborhood definition. */
vx_neighborhood_size_t neighborhood;
/*! \brief The description and attributes of the image. */
vx_image_description_t image;
} vx_tile_t;
#ifndef VX_TILE_ATTRIBUTES_DEFINITIONS
/*!
* \brief The full height of the tile's parent image in pixels.
* \param [in] ptile The pointer to the \ref vx_tile_t structure.
* \ingroup group_tiling
*/
#define vxImageHeight(ptile) ((ptile))->image.height)
/*!
* \brief The full width of the tile's parent image in pixels.
* \param [in] ptile The pointer to the \ref vx_tile_t structure.
* \ingroup group_tiling
*/
#define vxImageWidth(ptile) ((ptile))->image.width)
/*!
* \brief The offset between the left edge of the image and the left edge of the tile, in pixels.
* \param [in] ptile The pointer to the \ref vx_tile_t structure.
* \ingroup group_tiling
*/
#define vxTileX(ptile) ((ptile)->tile_x)
/*!
* \brief The offset between the top edge of the image and the top edge of the tile, in pixels.
* \param [in] ptile The pointer to the \ref vx_tile_t structure.
* \ingroup group_tiling
*/
#define vxTileY(ptile) ((ptile)->tile_y)
/*!
* \brief The width of the tile in pixels.
* \param [in] ptile The pointer to the \ref vx_tile_t structure.
* \param [in] index The plane index.
* \ingroup group_tiling
*/
#define vxTileWidth(ptile, index) ((ptile)->addr[index].dim_x)
/*!
* \brief The height of the tile in pixels.
* \param [in] ptile The pointer to the \ref vx_tile_t structure.
* \param [in] index The plane index.
* \ingroup group_tiling
*/
#define vxTileHeight(ptile, index) ((ptile)->addr[index].dim_y)
/*!
* \brief The tile block height.
* \param [in] ptile The pointer to the \ref vx_tile_t structure.
* \ingroup group_tiling
*/
#define vxTileBlockHeight(ptile) ((ptile)->tile_block.height)
/*!
* \brief The tile block width.
* \param [in] ptile The pointer to the \ref vx_tile_t structure.
* \ingroup group_tiling
*/
#define vxTileBlockWidth(ptile) ((ptile)->tile_block.width)
/*!
* \brief The simple wrapper to access each image's neighborhood -X value.
* \param [in] ptile The pointer to the \ref vx_tile_t structure.
* \ingroup group_tiling
*/
#define vxNeighborhoodLeft(ptile) ((ptile)->neighborhood.left)
/*!
* \brief The simple wrapper to access each image's neighborhood +X value.
* \param [in] ptile The pointer to the \ref vx_tile_t structure.
* \ingroup group_tiling
*/
#define vxNeighborhoodRight(ptile) ((ptile)->neighborhood.right)
/*!
* \brief The simple wrapper to access each image's neighborhood -Y value.
* \param [in] ptile The pointer to the \ref vx_tile_t structure.
* \ingroup group_tiling
*/
#define vxNeighborhoodTop(ptile) ((ptile)->neighborhood.top)
/*!
* \brief The simple wrapper to access each image's neighborhood +Y value.
* \param [in] ptile The pointer to the \ref vx_tile_t structure.
* \ingroup group_tiling
*/
#define vxNeighborhoodBottom(ptile) ((ptile)->neighborhood.bottom)
#if 0
/*!
* \brief The simple wrapper to access each image's stride X value.
* \param [in] ptile The pointer to the \ref vx_tile_t structure.
* \ingroup group_tiling
*/
#define vxStrideSizeX(ptile, index) ((ptile)->addr[index].stride_x)
/*!
* \brief The simple wrapper to access each image's stride Y value.
* \param [in] ptile The pointer to the \ref vx_tile_t structure.
* \ingroup group_tiling
*/
#define vxStrideSizeY(ptile, index) ((ptile)->addr[index].stride_y)
/*!
* \brief The simple wrapper to access each image's step X value.
* \param [in] ptile The pointer to the \ref vx_tile_t structure.
* \ingroup group_tiling
*/
#define vxStepSizeX(ptile, index) ((ptile)->addr[index].step_x)
/*!
* \brief The simple wrapper to access each image's step Y value.
* \param [in] ptile The pointer to the \ref vx_tile_t structure.
* \ingroup group_tiling
*/
#define vxStepSizeY(ptile, index) ((ptile)->addr[index].step_y)
#endif
#endif
/*! \brief The User Kernel Tiling Attributes.
* \ingroup group_tiling
*/
enum vx_kernel_attribute_tiling_e {
/*! \brief This allows a tiling mode kernel to set its input neighborhood. */
VX_KERNEL_INPUT_NEIGHBORHOOD = VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_KERNEL) + 0x7,
/*! \brief This allows a tiling mode kernel to set its output tile block size. */
VX_KERNEL_OUTPUT_TILE_BLOCK_SIZE = VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_KERNEL) + 0x8,
/*! \brief This allows the author to set the border mode on the tiling kernel. */
VX_KERNEL_BORDER = VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_KERNEL) + 0x9,
/*! \brief This determines the per tile memory allocation. */
VX_KERNEL_TILE_MEMORY_SIZE = VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_KERNEL) + 0xA,
#if defined(OPENVX_TILING_1_1)
/*! \brief This allows a tiling mode kernel to set its input tile block size. */
VX_KERNEL_INPUT_TILE_BLOCK_SIZE = VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_KERNEL) + 0xB,
/*! \brief This allows a tiling mode kernel to set its output neighborhood. */
VX_KERNEL_OUTPUT_NEIGHBORHOOD = VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_KERNEL) + 0xC,
#endif
};
/*! \brief The User Node Tiling Attributes.
* \note These are largely unusable by the tiling function, as it doesn't give you the node reference!
* \ingroup group_tiling
*/
enum vx_node_attribute_tiling_e {
/*! \brief This allows a tiling mode node to get its input neighborhood. */
VX_NODE_INPUT_NEIGHBORHOOD = VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_NODE) + 0xB,
/*! \brief This allows a tiling mode node to get its output tile block size. */
VX_NODE_OUTPUT_TILE_BLOCK_SIZE = VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_NODE) + 0xC,
/*! \brief This is the size of the tile local memory area. */
VX_NODE_TILE_MEMORY_SIZE = VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_NODE) + 0xD,
#if defined(OPENVX_TILING_1_1)
/*! \brief This allows a tiling mode node to get its input tile block size. */
VX_NODE_INPUT_TILE_BLOCK_SIZE = VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_NODE) + 0xE,
/*! \brief This allows a tiling mode node to get its output neighborhood. */
VX_NODE_OUTPUT_NEIGHBORHOOD = VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_NODE) + 0xF,
#endif
};
/*! \brief The tiling border mode extensions
* \ingroup group_tiling
*/
enum vx_border_tiling_e {
/*! \brief This value indicates that the author of the tiling kernel wrote
* code to handle border conditions into the kernel itself. If this mode
* is set, it can not be overriden by a call to the \ref vxSetNodeAttribute
* with \ref VX_NODE_BORDER.
*/
VX_BORDER_MODE_SELF = VX_ENUM_BASE(VX_ID_KHRONOS, VX_ENUM_BORDER) + 0x3,
};
/*! \typedef vx_tiling_kernel_f
* \brief Tiling Kernel function typedef for User Tiling Kernels.
* \note Tiles may come in any dimension and are not guaranteed to be delivered in
* any particular order.
* \param [in] parameters The array abstract pointers to parameters.
* \param [in] tile_memory The local tile memory pointer if requested, otherwise NULL.
* \param [in] tile_memory_size The size of the local tile memory, if not requested, 0.
* \ingroup group_tiling
*/
#ifdef __cplusplus
typedef void (*vx_tiling_kernel_f)(void * VX_RESTRICT parameters[],
void * VX_RESTRICT tile_memory,
vx_size tile_memory_size);
#else
typedef void (*vx_tiling_kernel_f)(void * VX_RESTRICT parameters[VX_RESTRICT],
void * VX_RESTRICT tile_memory,
vx_size tile_memory_size);
#endif
#ifndef VX_IMAGE_PIXEL_DEFINITION
/*! \def vxImageOffset
* \brief Computes the offset within an image.
* \param [in] ptile The pointer to the \ref vx_tile_t structure.
* \param [in] i The plane index.
* \param [in] x The Width Coordinates.
* \param [in] y The Height Coordinates.
* \param [in] ox The X offset.
* \param [in] oy The Y offset.
* \ingroup group_tiling
*/
#define vxImageOffset(ptile, i, x, y, ox, oy) \
((ptile)->addr[i].stride_y * (vx_int32)(((vx_int32)((oy)+(y)) * (vx_int32)(ptile)->addr[i].scale_y)/(vx_int32)VX_SCALE_UNITY)) + \
((ptile)->addr[i].stride_x * (vx_int32)(((vx_int32)((ox)+(x)) * (vx_int32)(ptile)->addr[i].scale_x)/(vx_int32)VX_SCALE_UNITY))
/*! \def vxImagePixel
* \brief Accesses an image pixel as a type-cast indexed pointer dereference.
* \param [in] type The type of the image pixel. Example values are <tt>\ref vx_uint8</tt>, <tt>\ref vx_uint16</tt>, <tt>\ref vx_uint32</tt>, etc.
* \param [in] ptile The pointer to the \ref vx_tile_t structure.
* \param [in] i The plane index.
* \param [in] x The Center Pixel in Width Coordinates.
* \param [in] y The Center Pixel in Height Coordinates.
* \param [in] ox The X offset.
* \param [in] oy The Y offset.
* \ingroup group_tiling
*/
#define vxImagePixel(type, ptile, i, x, y, ox, oy) \
*((type *)(&((vx_uint8 *)(ptile)->base[i])[vxImageOffset(ptile, i, x, y, ox, oy)]))
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*! \brief Allows a user to add a tile-able kernel to the OpenVX system.
* \param [in] context The handle to the implementation context.
* \param [in] name The string to be used to match the kernel.
* \param [in] enumeration The enumerated value of the kernel to be used by clients.
* \param [in] flexible_func_ptr The process-local flexible function pointer to be invoked.
* \param [in] fast_func_ptr The process-local fast function pointer to be invoked.
* \param [in] num_params The number of parameters for this kernel.
* \param [in] input The pointer to a function which will validate the
* input parameters to this kernel.
* \param [in] output The pointer to a function which will validate the
* output parameters to this kernel.
* \note Tiling Kernels do not have access to any of the normal node attributes listed
* in \ref vx_node_attribute_e.
* \post Call <tt>\ref vxAddParameterToKernel</tt> for as many parameters as the function has,
* then call <tt>\ref vxFinalizeKernel</tt>.
* \retval 0 Indicates that an error occurred when adding the kernel.
* Note that the fast or flexible formula, but not both, can be NULL.
* \ingroup group_tiling
*/
VX_API_ENTRY vx_kernel VX_API_CALL vxAddTilingKernel(vx_context context,
vx_char name[VX_MAX_KERNEL_NAME],
vx_enum enumeration,
vx_tiling_kernel_f flexible_func_ptr,
vx_tiling_kernel_f fast_func_ptr,
vx_uint32 num_params,
vx_kernel_input_validate_f input,
vx_kernel_output_validate_f output);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,96 @@
/*
* Copyright (c) 2012-2017 The Khronos Group Inc.
*
* 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
*
* http://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 _VX_KHR_VARIANT_H_
#define _VX_KHR_VARIANT_H_
/*!
* \file
* \brief The Khronos Extension for Kernel Variants.
*
* \defgroup group_variants Extension: Kernel Variants
* \brief The Khronos Extension for Kernel Variants.
* \details Kernel Variants allow the Client-Defined Functions to create several
* kernels on the same target with the same name, but with slight variations
* between them. Frequently these variants are expected to employ different
* algorithms or methodologies.
*
* All target specific kernels and target variants must conform to the same OpenVX
* specification of the OpenVX Kernel in order to use the string name and enumeration.
* For example, a vendor may supply multiple targets,
* and implement the same functionality on each. Futhermore the same
* vendor may offer a variant on some specific target which offers some differentiation but
* still conforms to the definition of the OpenVX Kernel.
* In this example there are 3 implementations of the same computer vision function, "Sobel3x3".
* \arg On "CPU" a "Sobel3x3" which is "faster". A variant which may produce slightly less accurate but still conformant results.
* \arg On "CPU" a "Sobel3x3" which is more "accurate". A variant which may run slower but produces bit exact results.
* \arg On "GPU" a "Sobel3x3" \e default variant which may run on a remote core and produce bit exact results.
*
* In each of the cases a client of OpenVX could request the kernels in nearly
* the same the same manner. There are two main approaches, which depend on the
* method a client calls to get the kernel reference. The first uses enumerations.
* This method allows to client to attempt to find other targets and variants, but if
* these are not present, the default node would still have been constructed.
* The second method depends on using fully qualified strings to get the kernel reference.
* This second method is more compact but is does not permit fail-safing to default versions.
*
* As part of this extension, the function <tt>vxGetKernelByName</tt> will now accept more
* qualifications to the string naming scheme. Kernels names can be additionally
* qualified in 2 separate ways, by target and by variant. A "fully" qualified name is in the format of
* <i>target</i><b>:</b><i>kernel</i><b>:</b><i>variant</i>.
* Both \e target and \e variant may be omitted (for an unqualified name).
* In this case, the implementation will assume the "default" value of these
* names (which could literally be "default"). Names may also be fully
* qualified with target included.
* Examples:
* \arg "khronos.c_model:org.khonos.openvx.sobel3x3:default" - fully qualified
* \arg "org.khronos.openvx.sobel3x3:default" (missing target) - partially qualified
* \arg "khronos.c_model:org.khronos.openvx.sobel3x3" (missing variant) - partially qualifed.
* \arg "org.khronos.openvx.sobel3x3" - unqualified.
*
*/
/*! \brief The string name of the extension.
* \ingroup group_variants
*/
#define OPENVX_KHR_VARIANTS "vx_khr_variants"
/*! \brief Defines the maximum number of characters in a variant string.
* \ingroup group_variants
*/
#define VX_MAX_VARIANT_NAME (64)
#include <VX/vx.h>
#ifdef __cplusplus
extern "C" {
#endif
/*! \brief Used to choose a variant of a kernel for execution on a particular node.
* \param [in] node The reference to the node.
* \param [in] variantName The name of the variant to choose.
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \ingroup group_variants
*/
VX_API_ENTRY vx_status VX_API_CALL vxChooseKernelVariant(vx_node node, vx_char variantName[VX_MAX_VARIANT_NAME]);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,156 @@
/*
* Copyright (c) 2012-2017 The Khronos Group Inc.
*
* 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
*
* http://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 _VX_KHR_XML_H_
#define _VX_KHR_XML_H_
/*! \file
* \brief The OpenVX XML Schema Extension Header.
*
* \defgroup group_xml Extension: XML API
* \brief The Khronos Extension for OpenVX XML Import and Export Support.
*/
#define OPENVX_KHR_XML "vx_khr_xml"
#include <VX/vx.h>
/*! \brief The Object Type Enumeration for Imports.
* \ingroup group_xml
*/
enum vx_ext_import_type_e {
VX_TYPE_IMPORT = 0x814,/*!< \brief A <tt>\ref vx_import</tt> */
};
/*! \brief The import type enumeration.
* \ingroup group_xml
* \see VX_IMPORT_ATTRIBUTE_TYPE
*/
enum vx_ext_import_types_e {
VX_IMPORT_TYPE_XML = 0,/*!< \brief The XML import type */
};
/*! \brief The import attributes list
* \ingroup group_xml
* \see vxQueryImport
*/
enum vx_import_attribute_e {
/*! \brief Returns the number of references in the import object. Use a <tt>\ref vx_uint32</tt> parameter.*/
VX_IMPORT_ATTRIBUTE_COUNT = VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_IMPORT) + 0x0,
/*! \brief Returns the type of import. Use a <tt>\ref vx_ext_import_types_e </tt> parameter */
VX_IMPORT_ATTRIBUTE_TYPE = VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_IMPORT) + 0x1,
};
/*! \brief An abstract handle to an import object.
* \ingroup group_xml
* \extends vx_reference
*/
typedef struct _vx_import *vx_import;
#ifdef __cplusplus
extern "C" {
#endif
/*! \brief Exports all objects in the context to an XML file which uses the OpenVX
* XML Schema.
* \param [in] context The context to export.
* \param [in] xmlfile The file name to write the XML into.
* \note The reference numbers contained in the xml file can appear in any order but
* should be inclusive from index number 0 to [number of references - 1]. For example,
* if there are 20 references in the xml file, none of the reference indices should be >= 20.
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \see https://www.khronos.org/registry/vx/schema/openvx-1-1.xsd
* \ingroup group_xml
*/
VX_API_ENTRY vx_status VX_API_CALL vxExportToXML(vx_context context, vx_char xmlfile[]);
/*! \brief Imports all framework and data objects from an XML file into the given context.
* \param [in] context The context to import into.
* \param [in] xmlfile The XML file to read.
* \note The reference indices in the import object corresponds with the reference numbers in the
* XML file. It is assumed that the program has some means to know which references to use from
* imported list (either by name: <tt>\ref vxGetImportReferenceByName</tt>, or by index from looking at the XML
* file (debug use case): <tt>\ref vxGetImportReferenceByIndex</tt>). Alternativly, the program can use
* <tt>\ref vxGetImportReferenceByIndex</tt> in a loop and query each one to understand what was imported. After
* all references of interest have been retrieved, this import obects should be released using
* <tt>\ref vxReleaseImport</tt>.
* \return \ref vx_import object containing references to the imported objects in the context
* \see https://www.khronos.org/registry/vx/schema/openvx-1-1.xsd
* \ingroup group_xml
*/
VX_API_ENTRY vx_import VX_API_CALL vxImportFromXML(vx_context context, vx_char xmlfile[]);
/*! \brief Used to retrieve a reference by name from the import when the name is known beforehand. If
* multiple references have the same name, then *any* one of them may be returned.
* \param [in] import The reference to the import object.
* \param [in] name The reference string name.
* \return <tt>\ref vx_reference</tt>
* \retval 0 Invalid import object or name does not match a reference in the import object.
* \retval * The reference matching the requested name.
* \note Use <tt>\ref vxReleaseReference</tt> to release the reference before releasing the context.
* \pre <tt>\ref vxImportFromXML</tt>
* \ingroup group_xml
*/
VX_API_ENTRY vx_reference VX_API_CALL vxGetImportReferenceByName(vx_import import, const vx_char *name);
/*! \brief Used to retrieve a reference by the index from the import.
* \param [in] import The reference to the import object.
* \param [in] index The index of the reference in the import object to return.
* \return <tt>\ref vx_reference</tt>
* \retval 0 Invalid import object or index.
* \retval * The reference at the requested index number.
* \note Use <tt>\ref vxQueryImport</tt> with <tt>\ref VX_IMPORT_ATTRIBUTE_COUNT</tt> to retrieve
* the upper limit of references in the import.
* \note Use <tt>\ref vxReleaseReference</tt> to release the reference before releasing the context.
* \pre <tt>\ref vxImportFromXML</tt>
* \ingroup group_xml
*/
VX_API_ENTRY vx_reference VX_API_CALL vxGetImportReferenceByIndex(vx_import import, vx_uint32 index);
/*! \brief Used to query the import about its properties.
* \param [in] import The reference to the import object.
* \param [in] attribute The <tt>\ref vx_import_attribute_e</tt> value to query for.
* \param [out] ptr The location at which the resulting value will be stored.
* \param [in] size The size of the container to which ptr points.
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \pre <tt>\ref vxImportFromXML</tt>
* \ingroup group_xml
*/
VX_API_ENTRY vx_status VX_API_CALL vxQueryImport(vx_import import, vx_enum attribute, void *ptr, vx_size size);
/*! \brief Releases a reference to an import object.
* Also internally releases its references to its imported objects. These
* imported objects may not be garbage collected until their total reference
* counts are zero.
* \param [in] import The pointer to the import object to release.
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS No errors.
* \retval VX_ERROR_INVALID_REFERENCE If import is not a <tt>\ref vx_import</tt>.
* \note After returning from this function the reference will be zeroed.
* \pre <tt>\ref vxImportFromXML</tt>
* \ingroup group_xml
*/
VX_API_ENTRY vx_status VX_API_CALL vxReleaseImport(vx_import *import);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,385 @@
/*
* Copyright (c) 2012-2017 The Khronos Group Inc.
*
* 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
*
* http://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 _OPENVX_EXT_DEBUG_H_
#define _OPENVX_EXT_DEBUG_H_
#include <VX/vx.h>
/*!
* \file
* \brief The OpenVX Debugging Extension.
* \defgroup group_debug_ext Debugging Extension
* \defgroup group_vision_function_copy_image Kernel: Copy Image
* \defgroup group_vision_function_copy_array Kernel: Copy Array
* \defgroup group_vision_function_fwrite_image Kernel: File Write Image
* \defgroup group_vision_function_fwrite_array Kernel: File Write Array
* \defgroup group_vision_function_plus1 Kernel: Plus One Image
* \defgroup group_vision_function_fill_image Kernel: Fill Image
* \defgroup group_vision_function_check_image Kernel: Check Image
* \defgroup group_vision_function_check_array Kernel: Check Array
* \defgroup group_vision_function_compare_images Kernel: Compare Images
*/
/*! \brief The maximum filepath name length.
* \ingroup group_debug_ext
*/
#define VX_MAX_FILE_NAME (256)
/*! \brief The library value for the extension
* \ingroup group_debug_ext
*/
#define VX_LIBRARY_KHR_DEBUG (0xFF)
/*! \brief The list of extensions to OpenVX from the Sample Implementation.
* \ingroup group_debug_ext
*/
enum vx_kernel_debug_ext_e {
/*!
* \brief The Copy kernel. Output = Input.
* \param [in] vx_image The input image.
* \param [out] vx_image The output image.
* \see group_vision_function_copy_image
*/
VX_KERNEL_DEBUG_COPY_IMAGE = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_DEBUG) + 0x0,
/*!
* \brief The Copy Kernel, Output = Input.
* \param [in] vx_array The input array.
* \param [out] vx_array The output array.
* \see group_vision_function_copy_array
*/
VX_KERNEL_DEBUG_COPY_ARRAY = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_DEBUG) + 0x1,
/*!
* \brief The File Writing Kernel for Images.
* \param [in] vx_image The input image.
* \param [in] vx_array The name of the file.
* \see group_vision_function_fwrite_image
*/
VX_KERNEL_DEBUG_FWRITE_IMAGE = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_DEBUG) + 0x2,
/*!
* \brief The File Writing Kernel for Arrays
* \param [in] vx_array The input array.
* \param [in] vx_array The name of the file.
* \see group_vision_function_fwrite_array
*/
VX_KERNEL_DEBUG_FWRITE_ARRAY = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_DEBUG) + 0x3,
/*!
* \brief The File Reading Kernel for images.
* \param [in] vx_array The name of the file to read.
* \param [out] vx_image The output image.
* \see group_vision_function_fread_image
*/
VX_KERNEL_DEBUG_FREAD_IMAGE = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_DEBUG) + 0x4,
/*!
* \brief The File Reading Kernel for Arrays.
* \param [in] vx_array The name of the file to read.
* \param [out] vx_image The output image.
* \see group_vision_function_fread_array
*/
VX_KERNEL_DEBUG_FREAD_ARRAY = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_DEBUG) + 0x5,
/*!
* \brief Fills the image with a given value.
* \param [in] vx_uint32
* \param [out] vx_image
* \ingroup group_vision_function_fill_image
*/
VX_KERNEL_FILL_IMAGE = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_DEBUG) + 0x6,
/*!
* \brief Checks an image against a known value and returns a number of
* errors.
* \param [in] vx_image
* \param [in] vx_uint32
* \param [out] vx_scalar
* \ingroup group_vision_function_check_image
*/
VX_KERNEL_CHECK_IMAGE = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_DEBUG) + 0x7,
/*!
* \brief Checks an array against a known value and returns a number of
* errors.
* \param [in] vx_array
* \param [in] vx_uint8
* \param [out] vx_scalar
* \ingroup group_vision_function_check_array
*/
VX_KERNEL_CHECK_ARRAY = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_DEBUG) + 0x8,
/*!
* \brief Compares two images and returns the number of differences.
* \param [in] vx_image
* \param [in] vx_image
* \param [out] vx_scalar
* \ingroup group_vision_function_compare_image
*/
VX_KERNEL_COMPARE_IMAGE = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_DEBUG) + 0x9,
/*!
* \brief Copies an image from a memory area.
* \param [in] void *
* \param [out] vx_image
* \see group_vision_function_copy_ptr
*/
VX_KERNEL_COPY_IMAGE_FROM_PTR = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_DEBUG) + 0xA,
};
/******************************************************************************/
// GRAPH MODE FUNCTIONS
/******************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
/*!
* \brief [Graph] Creates a Copy Image Node.
* \param [in] graph The handle to the graph.
* \param [in] input The input image.
* \param [out] output The output image.
* \see VX_KERNEL_COPY_IMAGE
* \note Graph Mode Function.
* \ingroup group_vision_function_copy_image
*/
vx_node vxCopyImageNode(vx_graph graph, vx_image input, vx_image output);
/*!
* \brief [Graph] Creates a Copy Array Node.
* \param [in] graph The handle to the graph.
* \param [in] input The input array.
* \param [out] output The output array.
* \see VX_KERNEL_COPY_ARRAY
* \note Graph Mode Function.
* \ingroup group_vision_function_copy_array
*/
vx_node vxCopyArrayNode(vx_graph graph, vx_array input, vx_array output);
/*! \brief [Graph] Writes the source image to the file.
* \param [in] graph The handle to the graph.
* \param [in] image The input array.
* \param [in] name The name of the file.
* \note Graph Mode Function.
* \ingroup group_vision_function_fwrite_image
*/
vx_node vxFWriteImageNode(vx_graph graph, vx_image image, vx_char name[VX_MAX_FILE_NAME]);
/*! \brief [Graph] Writes the source array to the file.
* \param [in] graph The handle to the graph.
* \param [in] array The input array.
* \param [in] name The name of the file.
* \note Graph Mode Function.
* \ingroup group_vision_function_fwrite_array
*/
vx_node vxFWriteArrayNode(vx_graph graph, vx_array array, vx_char name[VX_MAX_FILE_NAME]);
/*! \brief [Graph] Writes the source image to the file.
* \param [in] graph The handle to the graph.
* \param [in] name The name of the file.
* \param [out] image The output image.
* \note Graph Mode Function.
* \ingroup group_vision_function_fread_image
*/
vx_node vxFReadImageNode(vx_graph graph, vx_char name[VX_MAX_FILE_NAME], vx_image image);
/*! \brief [Graph] Writes the source array to the file.
* \param [in] graph The handle to the graph.
* \param [in] name The name of the file.
* \param [out] array The output array.
* \note Graph Mode Function.
* \ingroup group_vision_function_fread_array
*/
vx_node vxFReadArrayNode(vx_graph graph, vx_char name[VX_MAX_FILE_NAME], vx_array array);
/*! \brief [Graph] Adds 1 to each uint8 pixel. This will clamp at 255.
* \param [in] graph The handle to the graph.
* \param [in,out] image The image to increment.
* \note Graph Mode Function
* \ingroup group_vision_function_plus1
*/
vx_node vxPlusOneNode(vx_graph graph, vx_image image);
/*!
* \brief [Graph] Fills an image with a known value.
* \param [in] graph The handle to the graph.
* \param [in] value The known value to fill the image with.
* \param [out] output The image to fill.
* \note Graph Mode Function
* \ingroup group_vision_function_fill_image
*/
vx_node vxFillImageNode(vx_graph graph, vx_uint32 value, vx_image output);
/*!
* \brief [Graph] Checks an image against a known value.
* \param [in] graph The handle to the graph.
* \param [in] input The image to check.
* \param [in] value The known value to check the image against.
* \param [out] errs The handle to the number of errors found.
* \note Graph Mode Function
* \ingroup group_vision_function_check_image
*/
vx_node vxCheckImageNode(vx_graph graph, vx_image input, vx_uint32 value, vx_scalar errs);
/*!
* \brief [Graph] Checks a array for a known value.
* \param [in] graph The handle to the graph.
* \param [in] input The array to check.
* \param [in] value The known value to check against.
* \param [out] errs An output of the number of errors.
* \note Graph Mode Function
* \ingroup group_vision_function_check_array
*/
vx_node vxCheckArrayNode(vx_graph graph, vx_array input, vx_uint8 value, vx_scalar errs);
/*!
* \brief [Graph] Compares two images and returns the number of pixel sub-channels
* which are different.
* \param [in] graph The handle to the graph.
* \param [in] a The first image.
* \param [in] b The second image.
* \param [out] diffs The handle to scalar to hold the number of differences.
* \note Graph Mode Function
* \ingroup group_vision_function_compare_image
*/
vx_node vxCompareImagesNode(vx_graph graph, vx_image a, vx_image b, vx_scalar diffs);
/*! \brief [Graph] Copies a HOST memory area into an image.
* \param [in] graph The handle to the graph.
* \param [in] ptr The input pointer to the memory area to copy.
* \param [out] output The output image.
* \note Graph Mode Function
* \ingroup group_vision_function_copy_ptr
*/
vx_node vxCopyImageFromPtrNode(vx_graph graph, void *ptr, vx_image output);
/******************************************************************************/
// IMMEDIATE MODE FUNCTION
/******************************************************************************/
/*! \brief [Immediate] Copies the source image to the destination image.
* \param [in] src The input image.
* \param [in] dst The output image.
* \note Immediate Mode Function.
* \ingroup group_vision_function_copy_image
*/
vx_status vxuCopyImage(vx_context context, vx_image src, vx_image dst);
/*! \brief [Immediate] Copies the source array to the destination array.
* \param [in] src The input array.
* \param [in] dst The output array.
* \note Immediate Mode Function.
* \ingroup group_vision_function_copy_array
*/
vx_status vxuCopyArray(vx_context context, vx_array src, vx_array dst);
/*! \brief [Immediate] Writes the source image to the file.
* \param [in] image The input array.
* \param [in] name The name of the file.
* \note Immediate Mode Function.
* \ingroup group_vision_function_fwrite_image
*/
vx_status vxuFWriteImage(vx_context context, vx_image image, vx_char name[VX_MAX_FILE_NAME]);
/*! \brief [Immediate] Writes the source array to the file.
* \param [in] array The input array.
* \param [in] name The name of the file.
* \note Immediate Mode Function.
* \ingroup group_vision_function_fwrite_array
*/
vx_status vxuFWriteArray(vx_context context, vx_array array, vx_char name[VX_MAX_FILE_NAME]);
/*! \brief [Immediate] Reads the source image from the file.
* \param [in] name The name of the file.
* \param [out] image The output image.
* \note Immediate Mode Function.
* \ingroup group_vision_function_fread_image
*/
vx_status vxuFReadImage(vx_context context, vx_char name[VX_MAX_FILE_NAME], vx_image image);
/*! \brief [Immediate] Reads the source array from the file.
* \param [in] name The name of the file.
* \param [out] array The output array.
* \note Immediate Mode Function.
* \ingroup group_vision_function_fread_array
*/
vx_status vxuFReadArray(vx_context context, vx_char name[VX_MAX_FILE_NAME], vx_array array);
/*! \brief [Immediate] Adds 1 to each uint8 pixel. This will clamp at 255.
* \param [in,out] image The image to increment.
* \note Immediate Mode Function
* \ingroup group_vision_function_plus1
*/
vx_node vxuPlusOneNode(vx_context context, vx_image image);
/*!
* \brief [Immediate] Fills an image with a known value.
* \param [in] value The known value to fill the image with.
* \param [out] output The image to fill.
* \note Immediate Mode Function
* \ingroup group_vision_function_fill_image
*/
vx_status vxuFillImage(vx_context context, vx_uint32 value, vx_image output);
/*!
* \brief [Immediate] Checks an image against a known value.
* \param [in] output The image to check.
* \param [in] value The known value to check the image against.
* \param [out] numErrors The handle to the number of errors found.
* \note Immediate Mode Function
* \ingroup group_vision_function_check_image
*/
vx_status vxuCheckImage(vx_context context, vx_image input, vx_uint32 value, vx_uint32 *numErrors);
/*!
* \brief [Immediate] Checks a array for a known value.
* \param [in] input The array to check.
* \param [in] value The known value to check against.
* \param [out] numErrors An output of the number of errors.
* \note Immediate Mode Function
* \ingroup group_vision_function_check_array
*/
vx_status vxuCheckArray(vx_context context, vx_array input, vx_uint8 value, vx_uint32 *numErrors);
/*!
* \brief [Immediate] Compares two images and returns the number of pixel sub-channels
* which are different.
* \param [in] a The first image.
* \param [in] b The second image.
* \param [out] numDiffs The handle to scalar to hold the number of differences.
* \note Immediate Mode Function
* \ingroup group_vision_function_compare_image
*/
vx_status vxuCompareImages(vx_context context, vx_image a, vx_image b, vx_uint32 *numDiffs);
/*! \brief [Immediate] Copies a HOST memory area into an image.
* \param [in] ptr The input pointer to the memory area to copy.
* \param [out] output The output image.
* \note Immediate Mode Function
* \ingroup group_vision_function_copy_ptr
*/
vx_status vxuCopyImageFromPtr(vx_context context, void *ptr, vx_image output);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,252 @@
/*
* Copyright (c) 2012-2017 The Khronos Group Inc.
*
* 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
*
* http://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 _VX_EXT_EXTRAS_H_
#define _VX_EXT_EXTRAS_H_
/*! \file
* \brief Extras Extension.
*
* \defgroup group_extras_ext Khronos Extras Extension.
* \brief A Set of Kernels which extend OpenVX.
*
* \defgroup group_vision_function_laplacian_image Kernel: Laplacian Filter
* \brief Computes a Laplacian filter over a window of the input image.
* \details This filter uses the follow convolution matrix:
\f[
\mathbf{K}_{gaussian} = \begin{vmatrix}
1 & 1 & 1\\
1 &-8 & 1\\
1 & 1 & 1
\end{vmatrix} * \frac{1}{1}
\f]
*
* \defgroup group_vision_function_scharr3x3 Kernel: Sobel 3x3
* \brief The Scharr Image Filter Kernel
* \details This kernel produces two output planes (one can be omitted)
* in the x and y plane. The Scharr operators \f$G_x, G_y\f$ are defined as:
\f[
\mathbf{G}_x=\begin{vmatrix}
-3 & 0 & +3\\
-10& 0 & +10\\
-3 & 0 & +3
\end{vmatrix}
,
\mathbf{G}_y=\begin{vmatrix}
-3 & -10 & -3 \\
0 & 0 & 0 \\
+3 & +10 & +3
\end{vmatrix}
\f]
*
*/
/*! \brief The Khronos Extras Library
* \ingroup group_extras_ext
*/
#define VX_LIBRARY_KHR_EXTRAS (0xFE)
/*! \brief The Khronos Extras Kernels.
* \ingroup group_extras_ext
*/
enum vx_kernel_extras_ext_e {
/*! \brief The Non-Maximum Supression Kernel for Canny.
* \note Use "org.khronos.extra.nonmaximasuppression" to \ref vxGetKernelByName.
* \param [in] vx_image The magnitude image in VX_DF_IMAGE_U8.
* \param [in] vx_image The phase image in VX_DF_IMAGE_U8.
* \param [out] vx_image The edge image in VX_DF_IMAGE_U8.
* \ingroup group_vision_function_nonmaxsuppression
*/
VX_KERNEL_EXTRAS_NONMAXSUPPRESSION_CANNY = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_EXTRAS) + 0x0,
/*! \brief The laplacian filter kernel.
* \note Use "org.khronos.extras.laplacian3x3" to \ref vxGetKernelByName.
* \param [in] vx_image The VX_DF_IMAGE_U8 input image.
* \param [out] vx_image The VX_DF_IMAGE_U8 output image.
* \see group_vision_function_laplacian_image
*/
VX_KERNEL_EXTRAS_LAPLACIAN_3x3 = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_EXTRAS) + 0x1,
/*! \brief The scharr filter kernel.
* \note Use "org.khronos.extras.scharr3x3" to \ref vxGetKernelByName.
* \param [in] vx_image The VX_DF_IMAGE_U8 input image.
* \param [out] vx_image The VX_DF_IMAGE_S16 output gradient x image.
* \param [out] vx_image The VX_DF_IMAGE_S16 output gradient y image.
* \see group_vision_function_scharr3x3
*/
VX_KERNEL_EXTRAS_SCHARR_3x3 = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_EXTRAS) + 0x2,
/*! \brief The Harris Score Kernel.
* \note use "org.khronos.extras.harris_score".
* \param [in] vx_image A VX_DF_IMAGE_S16 X Gradient
* \param [in] vx_image A VX_DF_IMAGE_S16 Y Gradient
* \param [in] vx_scalar A block size.
* \param [out] vx_image A VX_DF_IMAGE_S32 corner score per pixel.
* \ingroup group_vision_function_harris_score
*/
VX_KERNEL_EXTRAS_HARRIS_SCORE = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_EXTRAS) + 0x3,
/*! \brief The Sobel MxN kernel.
* \note Use "org.khronos.extras.sobelMxN" to \ref vxGetKernelByName.
* \param [in] vx_image The VX_DF_IMAGE_U8 input image.
* \param [in] vx_scalar Window Size (3,5,7)
* \param [out] vx_image The VX_DF_IMAGE_S16 output gradient x image.
* \param [out] vx_image The VX_DF_IMAGE_S16 output gradient y image.
* \see group_vision_function_sobelmxn
*/
VX_KERNEL_EXTRAS_SOBEL_MxN = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_EXTRAS) + 0x4,
/*! \brief The image to list converter.
* \param [in] vx_image The VX_DF_IMAGE_U8 or VX_DF_IMAGE_S32 image.
* \param [out] vx_array The array of output
* \param [out] vx_scalar The total number of non zero points in image (optional)
* \ingroup group_vision_function_image_lister
*/
VX_KERNEL_EXTRAS_IMAGE_LISTER = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_EXTRAS) + 0x5,
/*! \brief The Euclidean Non-Maximum Suppression Kernel for Harris Corners.
* \param [in] vx_image The VX_DF_IMAGE_F32 image.
* \param [in] vx_scalar The minimum threshold
* \param [in] vx_scalar The euclidean distance from the considered pixel.
* \param [out] vx_image The VX_DF_IMAGE_F32 image.
* \ingroup group_vision_function_euclidean_nonmax
*/
VX_KERNEL_EXTRAS_EUCLIDEAN_NONMAXSUPPRESSION_HARRIS = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_EXTRAS) + 0x6,
/*! \brief Elementwise binary norm kernel.
* \param [in] vx_image Left image (VX_DF_IMAGE_S16).
* \param [in] vx_image Right image (VX_DF_IMAGE_S16).
* \param [in] vx_scalar Norm type (vx_norm_type_e).
* \param [in] vx_image Output image (VX_DF_IMAGE_U16).
*/
VX_KERNEL_EXTRAS_ELEMENTWISE_NORM = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_EXTRAS) + 0x7,
/*! \brief Edge tracing kernel.
* \param [in] vx_image Norm image (VX_DF_IMAGE_U16).
* \param [in] vx_image Phase image (VX_DF_IMAGE_U8).
* \param [in] vx_threshold Threshold (VX_THRESHOLD_TYPE_RANGE).
* \param [out] vx_image Output binary image (VX_DF_IMAGE_U8).
*/
VX_KERNEL_EXTRAS_EDGE_TRACE = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_EXTRAS) + 0x8
};
/*! \brief Extra VX_DF_IMAGE codes supported by this extension. */
enum _vx_extra_df_image {
/*! \brief A single plane of 32 bit float data.
* The range of the data is not specified.
*/
VX_DF_IMAGE_F32 = VX_DF_IMAGE('F','0','3','2'),
};
#ifdef __cplusplus
extern "C" {
#endif
/*! \brief [Graph] Creates a Non Max Suppress Node.
* \param [in] graph The handle to the graph.
* \param [in] input The input image in VX_DF_IMAGE_U8 format.
* \param [out] output The output image in VX_DF_IMAGE_U8 format.
* \ingroup group_vision_function_laplacian_image
*/
vx_node vxNonMaxSuppressionCannyNode(vx_graph graph, vx_image mag, vx_image phase, vx_image edge);
/*! \brief [Immediate] Creates a Non Max Suppress Node.
* \param [in] graph The handle to the graph.
* \param [in] input The input image in VX_DF_IMAGE_U8 format.
* \param [out] output The output image in VX_DF_IMAGE_U8 format.
* \ingroup group_vision_function_laplacian_image
*/
vx_status vxuNonMaxSuppressionCanny(vx_context context, vx_image mag, vx_image phase, vx_image edge);
/*! \brief [Graph] Creates a Laplacian Filter Node.
* \param [in] graph The handle to the graph.
* \param [in] input The input image in VX_DF_IMAGE_U8 format.
* \param [out] output The output image in VX_DF_IMAGE_U8 format.
* \ingroup group_vision_function_laplacian_image
*/
vx_node vxLaplacian3x3Node(vx_graph graph, vx_image input, vx_image output);
/*! \brief [Immediate] Computes a laplacian filter on the image by a 3x3 window.
* \param [in] input The input image in VX_DF_IMAGE_U8 format.
* \param [out] output The output image in VX_DF_IMAGE_U8 format.
* \ingroup group_vision_function_laplacian_image
*/
vx_status vxuLaplacian3x3(vx_context context, vx_image input, vx_image output);
/*! \brief [Graph] Creates a Scharr Filter Node.
* \param [in] graph The handle to the graph.
* \param [in] input The input image in VX_DF_IMAGE_U8 format.
* \param [out] output The output image in VX_DF_IMAGE_U8 format.
* \ingroup group_vision_function_laplacian_image
*/
vx_node vxScharr3x3Node(vx_graph graph, vx_image input, vx_image output1, vx_image output2);
/*! \brief [Immediate] Computes a Scharr filter on the image by a 3x3 window.
* \param [in] input The input image in VX_DF_IMAGE_U8 format.
* \param [out] output The output image in VX_DF_IMAGE_U8 format.
* \ingroup group_vision_function_laplacian_image
*/
vx_status vxuScharr3x3(vx_context context, vx_image input, vx_image output1, vx_image output2);
vx_node vxSobelMxNNode(vx_graph graph, vx_image input, vx_scalar win, vx_image gx, vx_image gy);
vx_status vxuSobelMxN(vx_context context, vx_image input, vx_scalar win, vx_image gx, vx_image gy);
vx_node vxHarrisScoreNode(vx_graph graph,
vx_image gx,
vx_image gy,
vx_scalar sensitivity,
vx_scalar grad_size,
vx_scalar block_size,
vx_scalar shift,
vx_image score);
vx_status vxuHarrisScore(vx_context context, vx_image gx,
vx_image gy,
vx_scalar sensitivity,
vx_scalar grad_size,
vx_scalar block_size,
vx_scalar shift,
vx_image score);
vx_node vxEuclideanNonMaxHarrisNode(vx_graph graph,
vx_image input,
vx_scalar strength_thresh,
vx_scalar min_distance,
vx_image output);
vx_status vxuEuclideanNonMaxHarris(vx_context context, vx_image input,
vx_scalar strength_thresh,
vx_scalar min_distance,
vx_image output);
vx_node vxImageListerNode(vx_graph graph, vx_image input, vx_array arr, vx_scalar num_points);
vx_status vxuImageLister(vx_context context, vx_image input,
vx_array arr, vx_scalar num_points);
vx_node vxElementwiseNormNode(vx_graph graph, vx_image input_x, vx_image input_y, vx_scalar norm_type, vx_image output);
vx_node vxEdgeTraceNode(vx_graph graph, vx_image norm, vx_threshold threshold, vx_image output);
#ifdef __cplusplus
}
#endif
#endif /* _VX_EXT_EXTRAS_H_ */

View File

@ -0,0 +1,109 @@
/*
* Copyright (c) 2012-2017 The Khronos Group Inc.
*
* 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
*
* http://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.
*/
#pragma once
#ifndef _OPENVX_EXT_XYZ_H_
#define _OPENVX_EXT_XYZ_H_
/*!
* \file
* \brief An example of how to wrap a User Extension Kernel.
*
* \defgroup group_xyz_ext The Example User Kernel Extension
*
*/
#include <VX/vx.h>
/*!
* \file vx_ext_xyz.h
* \brief The example header for how to write a user mode extension to OpenVX.
*/
/*! \brief The XYZ Data area in bytes
* \ingroup group_xyz_ext
*/
#define XYZ_DATA_AREA (1024)
/*! \brief The required number of items in the temp array
* \ingroup group_xyz_ext
*/
#define XYZ_TEMP_NUMITEMS (374)
/*! \brief The minimum value of the scalar for the XYZ Kernel.
* \ingroup group_xyz_ext
*/
#define XYZ_VALUE_MIN (-10)
/*! \brief The maximum value of the scalar for the XYZ Kernel.
* \ingroup group_xyz_ext
*/
#define XYZ_VALUE_MAX (10)
//! [KERNEL ENUM]
#define VX_KERNEL_NAME_KHR_XYZ "org.khronos.example.xyz"
/*! \brief The XYZ Example Library Set
* \ingroup group_xyz_ext
*/
#define VX_LIBRARY_XYZ (0x3) // assigned from Khronos, vendors control their own
/*! \brief The list of XYZ Kernels.
* \ingroup group_xyz_ext
*/
enum vx_kernel_xyz_ext_e {
/*! \brief The Example User Defined Kernel */
VX_KERNEL_KHR_XYZ = VX_KERNEL_BASE(VX_ID_DEFAULT, VX_LIBRARY_XYZ) + 0x0,
// up to 0xFFF kernel enums can be created.
};
//! [KERNEL ENUM]
#ifdef __cplusplus
extern "C" {
#endif
//! [node]
/*! \brief [Graph] This is an example ISV or OEM provided node which executes
* in the Graph to call the XYZ kernel.
* \param [in] graph The handle to the graph in which to instantiate the node.
* \param [in] input The input image.
* \param [in] value The input scalar value
* \param [out] output The output image.
* \param [in,out] temp A temp array for some data which is needed for
* every iteration.
* \ingroup group_example_kernel
*/
vx_node vxXYZNode(vx_graph graph, vx_image input, vx_uint32 value, vx_image output, vx_array temp);
//! [node]
//! [vxu]
/*! \brief [Immediate] This is an example of an immediate mode version of the XYZ node.
* \param [in] context The overall context of the implementation.
* \param [in] input The input image.
* \param [in] value The input scalar value
* \param [out] output The output image.
* \param [in,out] temp A temp array for some data which is needed for
* every iteration.
* \ingroup group_example_kernel
*/
vx_status vxuXYZ(vx_context context, vx_image input, vx_uint32 value, vx_image output, vx_array temp);
//! [vxu]
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,947 @@
/*
* Copyright (c) 2012-2017 The Khronos Group Inc.
*
* 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
*
* http://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 _OPENVX_NODES_H_
#define _OPENVX_NODES_H_
/*!
* \file vx_nodes.h
* \brief The "Simple" API interface for OpenVX. These APIs are just
* wrappers around the more verbose functions defined in <tt>\ref vx_api.h</tt>.
*/
#ifdef __cplusplus
extern "C" {
#endif
/*! \brief [Graph] Creates a color conversion node.
* \param [in] graph The reference to the graph.
* \param [in] input The input image from which to convert.
* \param [out] output The output image to which to convert, which must have the same dimensions as the input image.
* \see <tt>VX_KERNEL_COLOR_CONVERT</tt>
* \ingroup group_vision_function_colorconvert
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxColorConvertNode(vx_graph graph, vx_image input, vx_image output);
/*! \brief [Graph] Creates a channel extract node.
* \param [in] graph The reference to the graph.
* \param [in] input The input image. Must be one of the defined \ref vx_df_image_e multi-channel formats.
* \param [in] channel The <tt>\ref vx_channel_e</tt> channel to extract.
* \param [out] output The output image. Must be <tt>\ref VX_DF_IMAGE_U8</tt>, and must have the same dimensions as the input image.
* <tt>\see VX_KERNEL_CHANNEL_EXTRACT</tt>
* \ingroup group_vision_function_channelextract
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxChannelExtractNode(vx_graph graph,
vx_image input,
vx_enum channel,
vx_image output);
/*! \brief [Graph] Creates a channel combine node.
* \param [in] graph The graph reference.
* \param [in] plane0 The plane that forms channel 0. Must be <tt>\ref VX_DF_IMAGE_U8</tt>.
* \param [in] plane1 The plane that forms channel 1. Must be <tt>\ref VX_DF_IMAGE_U8</tt>.
* \param [in] plane2 [optional] The plane that forms channel 2. Must be <tt>\ref VX_DF_IMAGE_U8</tt>.
* \param [in] plane3 [optional] The plane that forms channel 3. Must be <tt>\ref VX_DF_IMAGE_U8</tt>.
* \param [out] output The output image. The format of the image must be defined, even if the image is virtual. Must have the same dimensions as the input images
* \see <tt>VX_KERNEL_CHANNEL_COMBINE</tt>
* \ingroup group_vision_function_channelcombine
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxChannelCombineNode(vx_graph graph,
vx_image plane0,
vx_image plane1,
vx_image plane2,
vx_image plane3,
vx_image output);
/*! \brief [Graph] Creates a Phase node.
* \param [in] graph The reference to the graph.
* \param [in] grad_x The input x image. This must be in <tt>\ref VX_DF_IMAGE_S16</tt> format.
* \param [in] grad_y The input y image. This must be in <tt>\ref VX_DF_IMAGE_S16</tt> format.
* \param [out] orientation The phase image. This is in <tt>\ref VX_DF_IMAGE_U8</tt> format, and must have the same dimensions as the input images.
* \see <tt>VX_KERNEL_PHASE</tt>
* \ingroup group_vision_function_phase
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxPhaseNode(vx_graph graph, vx_image grad_x, vx_image grad_y, vx_image orientation);
/*! \brief [Graph] Creates a Sobel3x3 node.
* \param [in] graph The reference to the graph.
* \param [in] input The input image in <tt>\ref VX_DF_IMAGE_U8</tt> format.
* \param [out] output_x [optional] The output gradient in the x direction in <tt>\ref VX_DF_IMAGE_S16</tt>. Must have the same dimensions as the input image.
* \param [out] output_y [optional] The output gradient in the y direction in <tt>\ref VX_DF_IMAGE_S16</tt>. Must have the same dimensions as the input image.
* \see <tt>VX_KERNEL_SOBEL_3x3</tt>
* \ingroup group_vision_function_sobel3x3
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxSobel3x3Node(vx_graph graph, vx_image input, vx_image output_x, vx_image output_y);
/*! \brief [Graph] Create a Magnitude node.
* \param [in] graph The reference to the graph.
* \param [in] grad_x The input x image. This must be in <tt>\ref VX_DF_IMAGE_S16</tt> format.
* \param [in] grad_y The input y image. This must be in <tt>\ref VX_DF_IMAGE_S16</tt> format.
* \param [out] mag The magnitude image. This is in <tt>\ref VX_DF_IMAGE_S16</tt> format. Must have the same dimensions as the input image.
* \see <tt>VX_KERNEL_MAGNITUDE</tt>
* \ingroup group_vision_function_magnitude
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxMagnitudeNode(vx_graph graph, vx_image grad_x, vx_image grad_y, vx_image mag);
/*! \brief [Graph] Creates a Scale Image Node.
* \param [in] graph The reference to the graph.
* \param [in] src The source image of type <tt>\ref VX_DF_IMAGE_U8</tt>.
* \param [out] dst The destination image of type <tt>\ref VX_DF_IMAGE_U8</tt>.
* \param [in] type The interpolation type to use. \see vx_interpolation_type_e.
* \ingroup group_vision_function_scale_image
* \note The destination image must have a defined size and format. The border modes
* <tt>\ref VX_NODE_BORDER</tt> value <tt>\ref VX_BORDER_UNDEFINED</tt>,
* <tt>\ref VX_BORDER_REPLICATE</tt> and <tt>\ref VX_BORDER_CONSTANT</tt> are supported.
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxScaleImageNode(vx_graph graph, vx_image src, vx_image dst, vx_enum type);
/*! \brief [Graph] Creates a Table Lookup node. If a value from the input image is not present in the lookup table, the result is undefined.
* \param [in] graph The reference to the graph.
* \param [in] input The input image in <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt>.
* \param [in] lut The LUT which is of type <tt>\ref VX_TYPE_UINT8</tt> if input image is <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_TYPE_INT16</tt> if input image is <tt>\ref VX_DF_IMAGE_S16</tt>.
* \param [out] output The output image of the same type and size as the input image.
* \ingroup group_vision_function_lut
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>.
*/
VX_API_ENTRY vx_node VX_API_CALL vxTableLookupNode(vx_graph graph, vx_image input, vx_lut lut, vx_image output);
/*! \brief [Graph] Creates a Histogram node.
* \param [in] graph The reference to the graph.
* \param [in] input The input image in <tt>\ref VX_DF_IMAGE_U8</tt>.
* \param [out] distribution The output distribution.
* \ingroup group_vision_function_histogram
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxHistogramNode(vx_graph graph, vx_image input, vx_distribution distribution);
/*! \brief [Graph] Creates a Histogram Equalization node.
* \param [in] graph The reference to the graph.
* \param [in] input The grayscale input image in <tt>\ref VX_DF_IMAGE_U8</tt>.
* \param [out] output The grayscale output image of type <tt>\ref VX_DF_IMAGE_U8</tt> with equalized brightness and contrast and same size as the input image.
* \ingroup group_vision_function_equalize_hist
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxEqualizeHistNode(vx_graph graph, vx_image input, vx_image output);
/*! \brief [Graph] Creates an AbsDiff node.
* \param [in] graph The reference to the graph.
* \param [in] in1 An input image in <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt> format.
* \param [in] in2 An input image in <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt> format.
* \param [out] out The output image in <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt> format, which must have the same dimensions as the input image.
* \ingroup group_vision_function_absdiff
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxAbsDiffNode(vx_graph graph, vx_image in1, vx_image in2, vx_image out);
/*! \brief [Graph] Creates a mean value and optionally, a standard deviation node.
* \param [in] graph The reference to the graph.
* \param [in] input The input image. <tt>\ref VX_DF_IMAGE_U8</tt> is supported.
* \param [out] mean The <tt>\ref VX_TYPE_FLOAT32</tt> average pixel value.
* \param [out] stddev [optional] The <tt>\ref VX_TYPE_FLOAT32</tt> standard deviation of the pixel values.
* \ingroup group_vision_function_meanstddev
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxMeanStdDevNode(vx_graph graph, vx_image input, vx_scalar mean, vx_scalar stddev);
/*! \brief [Graph] Creates a Threshold node and returns a reference to it.
* \param [in] graph The reference to the graph in which the node is created.
* \param [in] input The input image. Only images with format <tt>\ref VX_DF_IMAGE_U8</tt>
* and <tt>\ref VX_DF_IMAGE_S16</tt> are supported.
* \param [in] thresh The thresholding object that defines the parameters of
* the operation. The <tt>\ref VX_THRESHOLD_INPUT_FORMAT</tt> must be the same as the input image format and
* the <tt>\ref VX_THRESHOLD_OUTPUT_FORMAT</tt> must be the same as the output image format.
* \param [out] output The output image, that will contain as pixel value
* true and false values defined by \p thresh. Only images with format
* <tt>\ref VX_DF_IMAGE_U8</tt> are supported. The dimensions are the same as the input image.
* \ingroup group_vision_function_threshold
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation
* should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxThresholdNode(vx_graph graph, vx_image input, vx_threshold thresh, vx_image output);
/*! \brief [Graph] Creates a Non-Maxima Suppression node.
* \param [in] graph The reference to the graph.
* \param [in] input The input image in <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt> format.
* \param [in] mask [optional] Constrict suppression to a ROI. The mask image is of type <tt>\ref VX_DF_IMAGE_U8</tt> and must be the same dimensions as the input image.
* \param [in] win_size The size of window over which to perform the localized non-maxima suppression. Must be odd, and less than or equal to the smallest dimension of the input image.
* \param [out] output The output image, of the same type and size as the input, that has been non-maxima suppressed.
* \ingroup group_vision_function_nms
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxNonMaxSuppressionNode(vx_graph graph, vx_image input, vx_image mask, vx_int32 win_size, vx_image output);
/*! \brief [Graph] Creates an Integral Image Node.
* \param [in] graph The reference to the graph.
* \param [in] input The input image in <tt>\ref VX_DF_IMAGE_U8</tt> format.
* \param [out] output The output image in <tt>\ref VX_DF_IMAGE_U32</tt> format, which must have the same dimensions as the input image.
* \ingroup group_vision_function_integral_image
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxIntegralImageNode(vx_graph graph, vx_image input, vx_image output);
/*! \brief [Graph] Creates an Erosion Image Node.
* \param [in] graph The reference to the graph.
* \param [in] input The input image in <tt>\ref VX_DF_IMAGE_U8</tt> format.
* \param [out] output The output image in <tt>\ref VX_DF_IMAGE_U8</tt> format, which must have the same dimensions as the input image.
* \ingroup group_vision_function_erode_image
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxErode3x3Node(vx_graph graph, vx_image input, vx_image output);
/*! \brief [Graph] Creates a Dilation Image Node.
* \param [in] graph The reference to the graph.
* \param [in] input The input image in <tt>\ref VX_DF_IMAGE_U8</tt> format.
* \param [out] output The output image in <tt>\ref VX_DF_IMAGE_U8</tt> format, which must have the same dimensions as the input image.
* \ingroup group_vision_function_dilate_image
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxDilate3x3Node(vx_graph graph, vx_image input, vx_image output);
/*! \brief [Graph] Creates a Median Image Node.
* \param [in] graph The reference to the graph.
* \param [in] input The input image in <tt>\ref VX_DF_IMAGE_U8</tt> format.
* \param [out] output The output image in <tt>\ref VX_DF_IMAGE_U8</tt> format, which must have the same dimensions as the input image.
* \ingroup group_vision_function_median_image
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxMedian3x3Node(vx_graph graph, vx_image input, vx_image output);
/*! \brief [Graph] Creates a Box Filter Node.
* \param [in] graph The reference to the graph.
* \param [in] input The input image in <tt>\ref VX_DF_IMAGE_U8</tt> format.
* \param [out] output The output image in <tt>\ref VX_DF_IMAGE_U8</tt> format, which must have the same dimensions as the input image.
* \ingroup group_vision_function_box_image
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxBox3x3Node(vx_graph graph, vx_image input, vx_image output);
/*! \brief [Graph] Creates a Gaussian Filter Node.
* \param [in] graph The reference to the graph.
* \param [in] input The input image in <tt>\ref VX_DF_IMAGE_U8</tt> format.
* \param [out] output The output image in <tt>\ref VX_DF_IMAGE_U8</tt> format, which must have the same dimensions as the input image.
* \ingroup group_vision_function_gaussian_image
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxGaussian3x3Node(vx_graph graph, vx_image input, vx_image output);
/*! \brief [Graph] Creates a Non-linear Filter Node.
* \param [in] graph The reference to the graph.
* \param [in] function The non-linear filter function. See <tt>\ref vx_non_linear_filter_e</tt>.
* \param [in] input The input image in <tt>\ref VX_DF_IMAGE_U8</tt> format.
* \param [in] mask The mask to be applied to the Non-linear function. <tt>\ref VX_MATRIX_ORIGIN</tt> attribute is used
* to place the mask appropriately when computing the resulting image. See <tt>\ref vxCreateMatrixFromPattern</tt>.
* \param [out] output The output image in <tt>\ref VX_DF_IMAGE_U8</tt> format, which must have the same dimensions as the input image.
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
* \ingroup group_vision_function_nonlinear_filter
*/
VX_API_ENTRY vx_node VX_API_CALL vxNonLinearFilterNode(vx_graph graph, vx_enum function, vx_image input, vx_matrix mask, vx_image output);
/*! \brief [Graph] Creates a custom convolution node.
* \param [in] graph The reference to the graph.
* \param [in] input The input image in <tt>\ref VX_DF_IMAGE_U8</tt> format.
* \param [in] conv The <tt>\ref vx_int16</tt> convolution matrix.
* \param [out] output The output image in <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt> format, which must have the same dimensions as the input image.
* \ingroup group_vision_function_custom_convolution
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxConvolveNode(vx_graph graph, vx_image input, vx_convolution conv, vx_image output);
/*! \brief [Graph] Creates a node for a Gaussian Image Pyramid.
* \param [in] graph The reference to the graph.
* \param [in] input The input image in <tt>\ref VX_DF_IMAGE_U8</tt> format.
* \param [out] gaussian The Gaussian pyramid with <tt>\ref VX_DF_IMAGE_U8</tt> to construct.
* \ingroup group_vision_function_gaussian_pyramid
* \see group_pyramid
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxGaussianPyramidNode(vx_graph graph, vx_image input, vx_pyramid gaussian);
/*! \brief [Graph] Creates a node for a Laplacian Image Pyramid.
* \param [in] graph The reference to the graph.
* \param [in] input The input image in <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt> format.
* \param [out] laplacian The Laplacian pyramid with <tt>\ref VX_DF_IMAGE_S16</tt> to construct.
* \param [out] output The lowest resolution image in <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt> format necessary to reconstruct the input image from the pyramid. The output image format should be same as input image format.
* \ingroup group_vision_function_laplacian_pyramid
* \see group_pyramid
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxLaplacianPyramidNode(vx_graph graph, vx_image input,
vx_pyramid laplacian, vx_image output);
/*! \brief [Graph] Reconstructs an image from a Laplacian Image pyramid.
* \param [in] graph The reference to the graph.
* \param [in] laplacian The Laplacian pyramid with <tt>\ref VX_DF_IMAGE_S16</tt> format.
* \param [in] input The lowest resolution image in <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt> format for the Laplacian pyramid.
* \param [out] output The output image in <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt> format with the highest possible resolution reconstructed from the Laplacian pyramid. The output image format should be same as input image format.
* \ingroup group_vision_function_laplacian_reconstruct
* \see group_pyramid
* \return <tt>\ref vx_node</tt>.
* \retval 0 Node could not be created.
* \retval * Node handle.
*/
VX_API_ENTRY vx_node VX_API_CALL vxLaplacianReconstructNode(vx_graph graph, vx_pyramid laplacian, vx_image input,
vx_image output);
/*! \brief [Graph] Creates a image weighted average node.
* \param [in] graph The reference to the graph.
* \param [in] img1 The first input <tt>\ref VX_DF_IMAGE_U8</tt> image.
* \param [in] alpha The input <tt>\ref VX_TYPE_FLOAT32</tt> scalar value with a value in the range of \f$ 0.0 \le \alpha \le 1.0 \f$.
* \param [in] img2 The second <tt>\ref VX_DF_IMAGE_U8</tt> image, which must have the same dimensions as the img1.
* \param [out] output The output <tt>\ref VX_DF_IMAGE_U8</tt> image, which must have the same dimensions as the img1.
* \ingroup group_vision_function_weighted_average
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxWeightedAverageNode(vx_graph graph, vx_image img1, vx_scalar alpha, vx_image img2, vx_image output);
/*! \brief [Graph] Creates a min,max,loc node.
* \param [in] graph The reference to create the graph.
* \param [in] input The input image in <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt> format.
* \param [out] minVal The minimum value in the image, which corresponds to the type of the input.
* \param [out] maxVal The maximum value in the image, which corresponds to the type of the input.
* \param [out] minLoc [optional] The minimum <tt>\ref VX_TYPE_COORDINATES2D</tt> locations. If the input image has several minimums, the kernel will return up to the capacity of the array.
* \param [out] maxLoc [optional] The maximum <tt>\ref VX_TYPE_COORDINATES2D</tt> locations. If the input image has several maximums, the kernel will return up to the capacity of the array.
* \param [out] minCount [optional] The total number of detected minimums in image. Use a <tt>\ref VX_TYPE_SIZE</tt> scalar.
* \param [out] maxCount [optional] The total number of detected maximums in image. Use a <tt>\ref VX_TYPE_SIZE</tt> scalar.
* \ingroup group_vision_function_minmaxloc
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxMinMaxLocNode(vx_graph graph,
vx_image input,
vx_scalar minVal, vx_scalar maxVal,
vx_array minLoc, vx_array maxLoc,
vx_scalar minCount, vx_scalar maxCount);
/*! \brief [Graph] Creates a pixel-wise minimum kernel.
* \param [in] graph The reference to the graph where to create the node.
* \param [in] in1 The first input image. Must be of type <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt>.
* \param [in] in2 The second input image. Must be of type <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt>.
* \param [out] out The output image which will hold the result of min and will have the same type and dimensions of the imput images.
* \ingroup group_vision_function_min
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxMinNode(vx_graph graph, vx_image in1, vx_image in2, vx_image out);
/*! \brief [Graph] Creates a pixel-wise maximum kernel.
* \param [in] graph The reference to the graph where to create the node.
* \param [in] in1 The first input image. Must be of type <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt>.
* \param [in] in2 The second input image. Must be of type <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt>.
* \param [out] out The output image which will hold the result of max and will have the same type and dimensions of the imput images.
* \ingroup group_vision_function_max
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxMaxNode(vx_graph graph, vx_image in1, vx_image in2, vx_image out);
/*! \brief [Graph] Creates a bitwise AND node.
* \param [in] graph The reference to the graph.
* \param [in] in1 A <tt>\ref VX_DF_IMAGE_U8</tt> input image.
* \param [in] in2 A <tt>\ref VX_DF_IMAGE_U8</tt> input image.
* \param [out] out The <tt>\ref VX_DF_IMAGE_U8</tt> output image, which must have the same dimensions as the input images.
* \ingroup group_vision_function_and
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxAndNode(vx_graph graph, vx_image in1, vx_image in2, vx_image out);
/*! \brief [Graph] Creates a bitwise INCLUSIVE OR node.
* \param [in] graph The reference to the graph.
* \param [in] in1 A <tt>\ref VX_DF_IMAGE_U8</tt> input image.
* \param [in] in2 A <tt>\ref VX_DF_IMAGE_U8</tt> input image.
* \param [out] out The <tt>\ref VX_DF_IMAGE_U8</tt> output image, which must have the same dimensions as the input images.
* \ingroup group_vision_function_or
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxOrNode(vx_graph graph, vx_image in1, vx_image in2, vx_image out);
/*! \brief [Graph] Creates a bitwise EXCLUSIVE OR node.
* \param [in] graph The reference to the graph.
* \param [in] in1 A <tt>\ref VX_DF_IMAGE_U8</tt> input image.
* \param [in] in2 A <tt>\ref VX_DF_IMAGE_U8</tt> input image.
* \param [out] out The <tt>\ref VX_DF_IMAGE_U8</tt> output image, which must have the same dimensions as the input images.
* \ingroup group_vision_function_xor
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxXorNode(vx_graph graph, vx_image in1, vx_image in2, vx_image out);
/*! \brief [Graph] Creates a bitwise NOT node.
* \param [in] graph The reference to the graph.
* \param [in] input A <tt>\ref VX_DF_IMAGE_U8</tt> input image.
* \param [out] output The <tt>\ref VX_DF_IMAGE_U8</tt> output image, which must have the same dimensions as the input image.
* \ingroup group_vision_function_not
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxNotNode(vx_graph graph, vx_image input, vx_image output);
/*! \brief [Graph] Creates a scalar operation node.
* \param [in] graph The reference to the graph.
* \param [in] scalar_operation A <tt>\ref VX_TYPE_ENUM</tt> of the <tt>\ref vx_scalar_operation_e</tt> enumeration.
* \param [in] a First scalar operand.
* \param [in] b Second scalar operand.
* \param [out] output Result of the scalar operation.
* \ingroup group_control_flow
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxScalarOperationNode(vx_graph graph, vx_enum scalar_operation, vx_scalar a, vx_scalar b, vx_scalar output);
/*! \brief [Graph] Selects one of two data objects depending on the the value of a condition (boolean scalar), and copies its data into another data object.
* \details This node supports predicated execution flow within a graph. All the data objects passed to this kernel shall
* have the same object type and meta data. It is important to note that an implementation may optimize away the select and copy when virtual data
* objects are used.\n
* If there is a kernel node that contribute only into virtual data objects during the graph execution due to certain data path being eliminated by not
* taken argument of select node, then the OpenVX implementation guarantees that there will not be any side effects to graph execution and node state.\n
* If the path to a select node contains non-virtual objects, user nodes, or nodes with completion callbacks, then that path may not be "optimized out"
* because the callback must be executed and the non-virtual objects must be modified.
* \param [in] graph The reference to the graph.
* \param [in] condition <tt>\ref VX_TYPE_BOOL</tt> predicate variable.
* \param [in] true_value Data object for true.
* \param [in] false_value Data object for false.
* \param [out] output Output data object.
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
* \ingroup group_control_flow
*/
VX_API_ENTRY vx_node VX_API_CALL vxSelectNode(vx_graph graph, vx_scalar condition, vx_reference true_value, vx_reference false_value, vx_reference output);
/*! \brief [Graph] Creates an pixelwise-multiplication node.
* \param [in] graph The reference to the graph.
* \param [in] in1 An input image, <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt>.
* \param [in] in2 An input image, <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt>.
* \param [in] scale A non-negative <tt>\ref VX_TYPE_FLOAT32</tt> multiplied to each product before overflow handling.
* \param [in] overflow_policy A <tt>\ref VX_TYPE_ENUM</tt> of the <tt>\ref vx_convert_policy_e</tt> enumeration.
* \param [in] rounding_policy A <tt>\ref VX_TYPE_ENUM</tt> of the <tt>\ref vx_round_policy_e</tt> enumeration.
* \param [out] out The output image, a <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt> image. Must have the same type and dimensions of the imput images.
* \ingroup group_vision_function_mult
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxMultiplyNode(vx_graph graph,
vx_image in1, vx_image in2,
vx_scalar scale,
vx_enum overflow_policy,
vx_enum rounding_policy,
vx_image out);
/*! \brief [Graph] Creates an arithmetic addition node.
* \param [in] graph The reference to the graph.
* \param [in] in1 An input image, <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt>.
* \param [in] in2 An input image, <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt>.
* \param [in] policy A <tt>\ref VX_TYPE_ENUM</tt> of the \ref vx_convert_policy_e enumeration.
* \param [out] out The output image, a <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt> image, which must have the same dimensions as the input images.
* \ingroup group_vision_function_add
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxAddNode(vx_graph graph,
vx_image in1, vx_image in2,
vx_enum policy,
vx_image out);
/*! \brief [Graph] Creates an arithmetic subtraction node.
* \param [in] graph The reference to the graph.
* \param [in] in1 An input image, <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt>, the minuend.
* \param [in] in2 An input image, <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt>, the subtrahend.
* \param [in] policy A <tt>\ref VX_TYPE_ENUM</tt> of the \ref vx_convert_policy_e enumeration.
* \param [out] out The output image, a <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt> image, which must have the same dimensions as the input images.
* \ingroup group_vision_function_sub
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxSubtractNode(vx_graph graph,
vx_image in1, vx_image in2,
vx_enum policy,
vx_image out);
/*! \brief [Graph] Creates a bit-depth conversion node.
* \param [in] graph The reference to the graph.
* \param [in] input The input image.
* \param [out] output The output image with the same dimensions of the input image.
* \param [in] policy A <tt>\ref VX_TYPE_ENUM</tt> of the <tt>\ref vx_convert_policy_e</tt> enumeration.
* \param [in] shift A scalar containing a <tt>\ref VX_TYPE_INT32</tt> of the shift value.
* \ingroup group_vision_function_convertdepth
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxConvertDepthNode(vx_graph graph, vx_image input, vx_image output, vx_enum policy, vx_scalar shift);
/*! \brief [Graph] Creates a Canny Edge Detection Node.
* \param [in] graph The reference to the graph.
* \param [in] input The input <tt>\ref VX_DF_IMAGE_U8</tt> image.
* \param [in] hyst The double threshold for hysteresis. The <tt>\ref VX_THRESHOLD_INPUT_FORMAT</tt> shall be either
* <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt>. The <tt>\ref VX_THRESHOLD_OUTPUT_FORMAT</tt> is ignored.
* \param [in] gradient_size The size of the Sobel filter window, must support at least 3, 5, and 7.
* \param [in] norm_type A flag indicating the norm used to compute the gradient, <tt>\ref VX_NORM_L1</tt> or <tt>\ref VX_NORM_L2</tt>.
* \param [out] output The output image in <tt>\ref VX_DF_IMAGE_U8</tt> format with values either 0 or 255.
* \ingroup group_vision_function_canny
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxCannyEdgeDetectorNode(vx_graph graph, vx_image input, vx_threshold hyst,
vx_int32 gradient_size, vx_enum norm_type,
vx_image output);
/*! \brief [Graph] Creates an Affine Warp Node.
* \param [in] graph The reference to the graph.
* \param [in] input The input <tt>\ref VX_DF_IMAGE_U8</tt> image.
* \param [in] matrix The affine matrix. Must be 2x3 of type \ref VX_TYPE_FLOAT32.
* \param [in] type The interpolation type from <tt>\ref vx_interpolation_type_e</tt>.
* <tt>\ref VX_INTERPOLATION_AREA</tt> is not supported.
* \param [out] output The output <tt>\ref VX_DF_IMAGE_U8</tt> image and the same dimensions as the input image.
* \ingroup group_vision_function_warp_affine
* \note The border modes <tt>\ref VX_NODE_BORDER</tt> value <tt>\ref VX_BORDER_UNDEFINED</tt> and
* <tt>\ref VX_BORDER_CONSTANT</tt> are supported.
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxWarpAffineNode(vx_graph graph, vx_image input, vx_matrix matrix, vx_enum type, vx_image output);
/*! \brief [Graph] Creates a Perspective Warp Node.
* \param [in] graph The reference to the graph.
* \param [in] input The input <tt>\ref VX_DF_IMAGE_U8</tt> image.
* \param [in] matrix The perspective matrix. Must be 3x3 of type <tt>\ref VX_TYPE_FLOAT32</tt>.
* \param [in] type The interpolation type from <tt>\ref vx_interpolation_type_e</tt>.
* <tt>\ref VX_INTERPOLATION_AREA</tt> is not supported.
* \param [out] output The output <tt>\ref VX_DF_IMAGE_U8</tt> image with the same dimensions as the input image.
* \ingroup group_vision_function_warp_perspective
* \note The border modes <tt>\ref VX_NODE_BORDER</tt> value <tt>\ref VX_BORDER_UNDEFINED</tt> and
* <tt>\ref VX_BORDER_CONSTANT</tt> are supported.
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxWarpPerspectiveNode(vx_graph graph, vx_image input, vx_matrix matrix, vx_enum type, vx_image output);
/*! \brief [Graph] Creates a Harris Corners Node.
* \param [in] graph The reference to the graph.
* \param [in] input The input <tt>\ref VX_DF_IMAGE_U8</tt> image.
* \param [in] strength_thresh The <tt>\ref VX_TYPE_FLOAT32</tt> minimum threshold with which to eliminate Harris Corner scores (computed using the normalized Sobel kernel).
* \param [in] min_distance The <tt>\ref VX_TYPE_FLOAT32</tt> radial Euclidean distance for non-maximum suppression.
* \param [in] sensitivity The <tt>\ref VX_TYPE_FLOAT32</tt> scalar sensitivity threshold \f$ k \f$ from the Harris-Stephens equation.
* \param [in] gradient_size The gradient window size to use on the input. The
* implementation must support at least 3, 5, and 7.
* \param [in] block_size The block window size used to compute the Harris Corner score.
* The implementation must support at least 3, 5, and 7.
* \param [out] corners The array of <tt>\ref VX_TYPE_KEYPOINT</tt> objects. The order of the keypoints in this array is implementation dependent.
* \param [out] num_corners [optional] The total number of detected corners in image. Use a \ref VX_TYPE_SIZE scalar.
* \ingroup group_vision_function_harris
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxHarrisCornersNode(vx_graph graph,
vx_image input,
vx_scalar strength_thresh,
vx_scalar min_distance,
vx_scalar sensitivity,
vx_int32 gradient_size,
vx_int32 block_size,
vx_array corners,
vx_scalar num_corners);
/*! \brief [Graph] Creates a FAST Corners Node.
* \param [in] graph The reference to the graph.
* \param [in] input The input <tt>\ref VX_DF_IMAGE_U8</tt> image.
* \param [in] strength_thresh Threshold on difference between intensity of the central pixel and pixels on Bresenham's circle
* of radius 3 (<tt>\ref VX_TYPE_FLOAT32</tt> scalar), with a value in the range of 0.0 \f$\le\f$ strength_thresh < 256.0.
* Any fractional value will be truncated to an integer.
* \param [in] nonmax_suppression If true, non-maximum suppression is applied to
* detected corners before being placed in the <tt>\ref vx_array</tt> of <tt>\ref VX_TYPE_KEYPOINT</tt> objects.
* \param [out] corners Output corner <tt>\ref vx_array</tt> of <tt>\ref VX_TYPE_KEYPOINT</tt>. The order of the
* keypoints in this array is implementation dependent.
* \param [out] num_corners [optional] The total number of detected corners in image. Use a \ref VX_TYPE_SIZE scalar.
* \ingroup group_vision_function_fast
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxFastCornersNode(vx_graph graph, vx_image input, vx_scalar strength_thresh, vx_bool nonmax_suppression, vx_array corners, vx_scalar num_corners);
/*! \brief [Graph] Creates a Lucas Kanade Tracking Node.
* \param [in] graph The reference to the graph.
* \param [in] old_images Input of first (old) image pyramid in <tt>\ref VX_DF_IMAGE_U8</tt>.
* \param [in] new_images Input of destination (new) image pyramid <tt>\ref VX_DF_IMAGE_U8</tt>.
* \param [in] old_points An array of key points in a <tt>\ref vx_array</tt> of <tt>\ref VX_TYPE_KEYPOINT</tt>; those key points are defined at
* the \a old_images high resolution pyramid.
* \param [in] new_points_estimates An array of estimation on what is the output key points in a <tt>\ref vx_array</tt> of
* <tt>\ref VX_TYPE_KEYPOINT</tt>; those keypoints are defined at the \a new_images high resolution pyramid.
* \param [out] new_points An output array of key points in a <tt>\ref vx_array</tt> of <tt>\ref VX_TYPE_KEYPOINT</tt>; those key points are
* defined at the \a new_images high resolution pyramid.
* \param [in] termination The termination can be <tt>\ref VX_TERM_CRITERIA_ITERATIONS</tt> or <tt>\ref VX_TERM_CRITERIA_EPSILON</tt> or
* <tt>\ref VX_TERM_CRITERIA_BOTH</tt>.
* \param [in] epsilon The <tt>\ref vx_float32</tt> error for terminating the algorithm.
* \param [in] num_iterations The number of iterations. Use a <tt>\ref VX_TYPE_UINT32</tt> scalar.
* \param [in] use_initial_estimate Use a <tt>\ref VX_TYPE_BOOL</tt> scalar.
* \param [in] window_dimension The size of the window on which to perform the algorithm. See
* <tt>\ref VX_CONTEXT_OPTICAL_FLOW_MAX_WINDOW_DIMENSION</tt>
* \ingroup group_vision_function_opticalflowpyrlk
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxOpticalFlowPyrLKNode(vx_graph graph,
vx_pyramid old_images,
vx_pyramid new_images,
vx_array old_points,
vx_array new_points_estimates,
vx_array new_points,
vx_enum termination,
vx_scalar epsilon,
vx_scalar num_iterations,
vx_scalar use_initial_estimate,
vx_size window_dimension);
/*! \brief [Graph] Creates a Remap Node.
* \param [in] graph The reference to the graph that will contain the node.
* \param [in] input The input <tt>\ref VX_DF_IMAGE_U8</tt> image.
* \param [in] table The remap table object.
* \param [in] policy An interpolation type from <tt>\ref vx_interpolation_type_e</tt>.
* <tt>\ref VX_INTERPOLATION_AREA</tt> is not supported.
* \param [out] output The output <tt>\ref VX_DF_IMAGE_U8</tt> image with the same dimensions as the input image.
* \note The border modes <tt>\ref VX_NODE_BORDER</tt> value <tt>\ref VX_BORDER_UNDEFINED</tt> and
* <tt>\ref VX_BORDER_CONSTANT</tt> are supported.
* \return A <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
* \ingroup group_vision_function_remap
*/
VX_API_ENTRY vx_node VX_API_CALL vxRemapNode(vx_graph graph,
vx_image input,
vx_remap table,
vx_enum policy,
vx_image output);
/*! \brief [Graph] Performs a Gaussian Blur on an image then half-scales it. The interpolation mode used is nearest-neighbor.
* \details The output image size is determined by:
* \f[
* W_{output} = \frac{W_{input} + 1}{2} \\
* ,
* H_{output} = \frac{H_{input} + 1}{2}
* \f]
* \param [in] graph The reference to the graph.
* \param [in] input The input <tt>\ref VX_DF_IMAGE_U8</tt> image.
* \param [out] output The output <tt>\ref VX_DF_IMAGE_U8</tt> image.
* \param [in] kernel_size The input size of the Gaussian filter. Supported values are 1, 3 and 5.
* \ingroup group_vision_function_scale_image
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxHalfScaleGaussianNode(vx_graph graph, vx_image input, vx_image output, vx_int32 kernel_size);
VX_API_ENTRY vx_node VX_API_CALL vxCensus3x3Node(vx_graph graph, vx_image src, vx_image dst);
/*! \brief [Graph] The Node Compares an image template against overlapped image regions.
* \details The detailed equation to the matching can be found in <tt>\ref vx_comp_metric_e</tt>.
* The output of the template matching node is a comparison map as described in <tt>\ref vx_comp_metric_e</tt>.
* The Node have a limitation on the template image size (width*height). It should not be larger then 65535.
* If the valid region of the template image is smaller than the entire template image, the result in the destination image is implementation-dependent.
* \param [in] graph The reference to the graph.
* \param [in] src The input image of type <tt>\ref VX_DF_IMAGE_U8</tt>.
* \param [in] templateImage Searched template of type <tt>\ref VX_DF_IMAGE_U8</tt>.
* \param [in] matchingMethod attribute specifying the comparison method <tt>\ref vx_comp_metric_e</tt>. This function support only <tt>\ref VX_COMPARE_CCORR_NORM</tt> and <tt>\ref VX_COMPARE_L2</tt>.
* \param [out] output Map of comparison results. The output is an image of type VX_DF_IMAGE_S16
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
* \ingroup group_vision_function_match_template
*/
VX_API_ENTRY vx_node VX_API_CALL vxMatchTemplateNode(vx_graph graph, vx_image src, vx_image templateImage, vx_enum matchingMethod, vx_image output);
/*! \brief [Graph] Creates a node that extracts LBP image from an input image
* \param [in] graph The reference to the graph.
* \param [in] in An input image in <tt>vx_image</tt>. Or \f$ SrcImg\f$ in the equations. the image is of type <tt>\ref VX_DF_IMAGE_U8</tt>
* \param [in] format A variation of LBP like original LBP and mLBP. see <tt> \ref vx_lbp_format_e </tt>
* \param [in] kernel_size Kernel size. Only size of 3 and 5 are supported
* \param [out] out An output image in <tt>vx_image</tt>.Or \f$ DstImg\f$ in the equations. the image is of type <tt>\ref VX_DF_IMAGE_U8</tt> with the same dimensions as the input image.
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
* \ingroup group_vision_function_lbp
*/
VX_API_ENTRY vx_node VX_API_CALL vxLBPNode(vx_graph graph, vx_image in, vx_enum format, vx_int8 kernel_size, vx_image out);
/*! \brief [Graph] Performs cell calculations for the average gradient magnitude and gradient orientation histograms.
* \details Firstly, the gradient magnitude and gradient orientation are computed for each pixel in the input image.
* Two 1-D centred, point discrete derivative masks are applied to the input image in the horizontal and vertical directions.
* \f[ M_h = [-1, 0, 1] \f] and \f[ M_v = [-1, 0, 1]^T \f]
* \f$G_v\f$ is the result of applying mask \f$M_v\f$ to the input image, and \f$G_h\f$ is the result of applying mask \f$M_h\f$ to the input image.
* The border mode used for the gradient calculation is implementation dependent. Its behavior should be similar to <tt>\ref VX_BORDER_UNDEFINED</tt>.
* The gradient magnitudes and gradient orientations for each pixel are then calculated in the following manner.
* \f[ G(x,y) = \sqrt{G_v(x,y)^2 + G_h(x,y)^2} \f]
* \f[ \theta(x,y) = arctan(G_v(x,y), G_h(x,y)) \f]
* where \f$arctan(v, h)\f$
* is \f$ tan^{-1}(v/h)\f$ when \f$h!=0\f$,
*
* \f$ -pi/2 \f$ if \f$v<0\f$ and \f$h==0\f$,
*
* \f$ pi/2 \f$ if \f$v>0\f$ and \f$h==0\f$
*
* and \f$ 0 \f$ if \f$v==0\f$ and \f$h==0\f$
*
* Secondly, the gradient magnitudes and orientations are used to compute the bins output tensor and optional magnitudes output tensor.
* These tensors are computed on a cell level where the cells are rectangular in shape.
* The magnitudes tensor contains the average gradient magnitude for each cell.
* \f[magnitudes(c) = \frac{1}{(cell\_width * cell\_height)}\sum\limits_{w=0}^{cell\_width} \sum\limits_{h=0}^{cell\_height} G_c(w,h)\f]
* where \f$G_c\f$ is the gradient magnitudes related to cell \f$c\f$.
* The bins tensor contains histograms of gradient orientations for each cell.
* The gradient orientations at each pixel range from 0 to 360 degrees. These are quantised into a set of histogram bins based on the num_bins parameter.
* Each pixel votes for a specific cell histogram bin based on its gradient orientation. The vote itself is the pixel's gradient magnitude.
* \f[bins(c, n) = \sum\limits_{w=0}^{cell\_width} \sum\limits_{h=0}^{cell\_height} G_c(w,h) * 1[B_c(w, h, num\_bins) == n]\f]
* where \f$B_c\f$ produces the histogram bin number based on the gradient orientation of the pixel at location (\f$w\f$, \f$h\f$) in cell \f$c\f$ based on
* the \f$num\_bins\f$ and \f[1[B_c(w, h, num\_bins) == n]\f] is a delta-function with value 1 when \f$B_c(w, h, num\_bins) == n\f$ or 0 otherwise.
* \param [in] graph The reference to the graph.
* \param [in] input The input image of type <tt>\ref VX_DF_IMAGE_U8</tt>.
* \param [in] cell_width The histogram cell width of type <tt>\ref VX_TYPE_INT32</tt>.
* \param [in] cell_height The histogram cell height of type <tt>\ref VX_TYPE_INT32</tt>.
* \param [in] num_bins The histogram size of type <tt>\ref VX_TYPE_INT32</tt>.
* \param [out] magnitudes (Optional) The output average gradient magnitudes per cell of <tt>\ref vx_tensor</tt> of type <tt>\ref VX_TYPE_INT16</tt> of size \f$ [floor(image_{width}/cell_{width}) ,floor(image_{height}/cell_{height}) ] \f$.
* \param [out] bins The output gradient orientation histograms per cell of <tt>\ref vx_tensor</tt> of type <tt>\ref VX_TYPE_INT16</tt> of size \f$ [floor(image_{width}/cell_{width}) ,floor(image_{height}/cell_{height}), num_{bins}] \f$.
* \return <tt>\ref vx_node</tt>.
* \retval 0 Node could not be created.
* \retval * Node handle.
* \ingroup group_vision_function_hog
*/
VX_API_ENTRY vx_node VX_API_CALL vxHOGCellsNode(vx_graph graph, vx_image input, vx_int32 cell_width, vx_int32 cell_height, vx_int32 num_bins, vx_tensor magnitudes, vx_tensor bins);
/*! \brief [Graph] The node produces HOG features for the W1xW2 window in a sliding window fashion over the whole input image. Each position produces a HOG feature vector.
* \details Firstly if a magnitudes tensor is provided the cell histograms in the bins tensor are normalised by the average cell gradient magnitudes.
\f[bins(c,n) = \frac{bins(c,n)}{magnitudes(c)}\f]
* To account for changes in illumination and contrast the cell histograms must be locally normalized which requires grouping the cell histograms together into larger spatially connected blocks.
* Blocks are rectangular grids represented by three parameters: the number of cells per block, the number of pixels per cell, and the number of bins per cell histogram.
* These blocks typically overlap, meaning that each cell histogram contributes more than once to the final descriptor.
* To normalize a block its cell histograms \f$h\f$ are grouped together to form a vector \f$v = [h_1, h_2, h_3, ... , h_n]\f$.
* This vector is normalised using L2-Hys which means performing L2-norm on this vector; clipping the result (by limiting the maximum values of v to be threshold) and renormalizing again. If the threshold is equal to zero then L2-Hys normalization is not performed.
* \f[L2norm(v) = \frac{v}{\sqrt{\|v\|_2^2 + \epsilon^2}}\f]
* where \f$ \|v\|_k \f$ be its k-norm for k=1, 2, and \f$ \epsilon \f$ be a small constant.
* For a specific window its HOG descriptor is then the concatenated vector of the components of the normalized cell histograms from all of the block regions contained in the window.
* The W1xW2 window starting position is at coordinates 0x0.
* If the input image has dimensions that are not an integer multiple of W1xW2 blocks with the specified stride, then the last positions that contain only a partial W1xW2 window
* will be calculated with the remaining part of the W1xW2 window padded with zeroes.
* The Window W1xW2 must also have a size so that it contains an integer number of cells, otherwise the node is not well-defined.
* The final output tensor will contain HOG descriptors equal to the number of windows in the input image.
* The output features tensor has 3 dimensions, given by:\n
* \f[[ (floor((image_{width}-window_{width})/window_{stride}) + 1),\f]
* \f[ (floor((image_{height}-window_{height})/window_{stride}) + 1),\f]
* \f[ floor((window_{width} - block_{width})/block_{stride} + 1) * floor((window_{height} - block_{height})/block_{stride} + 1) *\f]
* \f[ (((block_{width} * block_{height}) / (cell_{width} * cell_{height})) * num_{bins})] \f]
* See <tt>\ref vxCreateTensor</tt> and <tt>\ref vxCreateVirtualTensor</tt>.
* We recommend the output tensors always be *virtual* objects, with this node connected directly to the classifier.
* The output tensor will be very large, and using non-virtual tensors will result in a poorly optimized implementation.
* Merging of this node with a classifier node such as that described in the classifier extension will result in better performance.
* Notice that this node creation function has more parameters than the corresponding kernel. Numbering of kernel parameters (required if you create this node using the generic interface) is explicitly specified here.
* \param [in] graph The reference to the graph.
* \param [in] input The input image of type <tt>\ref VX_DF_IMAGE_U8</tt>. (Kernel parameter #0)
* \param [in] magnitudes (Optional) The gradient magnitudes per cell of <tt>\ref vx_tensor</tt> of type <tt>\ref VX_TYPE_INT16</tt>. It is the output of <tt>\ref vxHOGCellsNode</tt>. (Kernel parameter #1)
* \param [in] bins The gradient orientation histograms per cell of <tt>\ref vx_tensor</tt> of type <tt>\ref VX_TYPE_INT16</tt>. It is the output of <tt>\ref vxHOGCellsNode</tt>. (Kernel parameter #2)
* \param [in] params The parameters of type <tt>\ref vx_hog_t</tt>. (Kernel parameter #3)
* \param [in] hog_param_size Size of <tt>\ref vx_hog_t</tt> in bytes. Note that this parameter is not counted as one of the kernel parameters.
* \param [out] features The output HOG features of <tt>\ref vx_tensor</tt> of type <tt>\ref VX_TYPE_INT16</tt>. (Kernel parameter #4)
* \return <tt>\ref vx_node</tt>.
* \retval 0 Node could not be created.
* \retval * Node handle.
* \ingroup group_vision_function_hog
*/
VX_API_ENTRY vx_node VX_API_CALL vxHOGFeaturesNode(vx_graph graph, vx_image input, vx_tensor magnitudes, vx_tensor bins, const vx_hog_t *params, vx_size hog_param_size, vx_tensor features);
/*! \brief [Graph] Finds the Probabilistic Hough Lines detected in the input binary image, each line is stored in the output array as a set of points (x1, y1, x2, y2) .
* \details Some implementations of the algorithm may have a random or non-deterministic element. If the target application is in a safety-critical environment this
* should be borne in mind and steps taken in the implementation, the application or both to achieve the level of determinism required by the system design.
* \param [in] graph graph handle
* \param [in] input 8 bit, single channel binary source image
* \param [in] params parameters of the struct <tt>\ref vx_hough_lines_p_t</tt>
* \param [out] lines_array lines_array contains array of lines, see <tt>\ref vx_line2d_t</tt> The order of lines in implementation dependent
* \param [out] num_lines [optional] The total number of detected lines in image. Use a VX_TYPE_SIZE scalar
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
* \ingroup group_vision_function_hough_lines_p
*/
VX_API_ENTRY vx_node VX_API_CALL vxHoughLinesPNode(vx_graph graph, vx_image input, const vx_hough_lines_p_t *params, vx_array lines_array, vx_scalar num_lines);
/*! \brief [Graph] The function applies bilateral filtering to the input tensor.
* \param [in] graph The reference to the graph.
* \param [in] src The input data a <tt>\ref vx_tensor</tt>. maximum 3 dimension and minimum 2. The tensor is of type <tt>\ref VX_TYPE_UINT8</tt> or <tt>\ref VX_TYPE_INT16</tt>.
* dimensions are [radiometric ,width,height] or [width,height].See <tt>\ref vxCreateTensor</tt> and <tt>\ref vxCreateVirtualTensor</tt>.
* \param [in] diameter of each pixel neighbourhood that is used during filtering. Values of diameter must be odd. Bigger then 3 and smaller then 10.
* \param [in] sigmaValues Filter sigma in the radiometric space. Supported values are bigger then 0 and smaller or equal 20.
* \param [in] sigmaSpace Filter sigma in the spatial space. Supported values are bigger then 0 and smaller or equal 20.
* \param [out] dst The output data a <tt>\ref vx_tensor</tt>,Of type <tt>\ref VX_TYPE_UINT8</tt> or <tt>\ref VX_TYPE_INT16</tt>. And must be the same type and size of the input.
* \note The border modes
* <tt>\ref VX_NODE_BORDER</tt> value
* <tt>\ref VX_BORDER_REPLICATE</tt> and <tt>\ref VX_BORDER_CONSTANT</tt> are supported.
* \return <tt>vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>vxGetStatus</tt>
* \ingroup group_vision_function_bilateral_filter
*/
VX_API_ENTRY vx_node VX_API_CALL vxBilateralFilterNode(vx_graph graph, vx_tensor src, vx_int32 diameter, vx_float32 sigmaSpace, vx_float32 sigmaValues, vx_tensor dst);
/*! \brief [Graph] Performs element wise multiplications on element values in the input tensor data with a scale.
* \param [in] graph The handle to the graph.
* \param [in] input1 Input tensor data. Implementations must support input tensor data type <tt>\ref VX_TYPE_INT16</tt> with fixed_point_position 8,
* and tensor data types <tt>\ref VX_TYPE_UINT8</tt> and <tt>\ref VX_TYPE_INT8</tt>, with fixed_point_position 0.
* \param [in] input2 Input tensor data. The dimensions and sizes of input2 match those of input1, unless the vx_tensor of one or more dimensions in input2 is 1.
* In this case, those dimensions are treated as if this tensor was expanded to match the size of the corresponding dimension of input1,
* and data was duplicated on all terms in that dimension. After this expansion, the dimensions will be equal.
* The data type must match the data type of Input1.
* \param [in] scale A non-negative <tt>\ref VX_TYPE_FLOAT32</tt> multiplied to each product before overflow handling.
* \param [in] overflow_policy A <tt>\ref vx_convert_policy_e</tt> enumeration.
* \param [in] rounding_policy A <tt>\ref vx_round_policy_e</tt> enumeration.
* \param [out] output The output tensor data with the same dimensions as the input tensor data.
* \ingroup group_vision_function_tensor_multiply
* \return <tt>\ref vx_node</tt>.
* \returns A node reference <tt>\ref vx_node</tt>. Any possible errors preventing a
* successful creation should be checked using <tt>\ref vxGetStatus</tt>.
*/
VX_API_ENTRY vx_node VX_API_CALL vxTensorMultiplyNode(vx_graph graph, vx_tensor input1, vx_tensor input2, vx_scalar scale, vx_enum overflow_policy,
vx_enum rounding_policy, vx_tensor output);
/*! \brief [Graph] Performs arithmetic addition on element values in the input tensor data.
* \param [in] graph The handle to the graph.
* \param [in] input1 Input tensor data. Implementations must support input tensor data type <tt>\ref VX_TYPE_INT16</tt> with fixed_point_position 8,
* and tensor data types <tt>\ref VX_TYPE_UINT8</tt> and <tt>\ref VX_TYPE_INT8</tt>, with fixed_point_position 0.
* \param [in] input2 Input tensor data. The dimensions and sizes of input2 match those of input1, unless the vx_tensor of one or more dimensions in input2 is 1.
* In this case, those dimensions are treated as if this tensor was expanded to match the size of the corresponding dimension of input1,
* and data was duplicated on all terms in that dimension. After this expansion, the dimensions will be equal.
* The data type must match the data type of Input1.
* \param [in] policy A <tt>\ref vx_convert_policy_e</tt> enumeration.
* \param [out] output The output tensor data with the same dimensions as the input tensor data.
* \ingroup group_vision_function_tensor_add
* \return <tt>\ref vx_node</tt>.
* \returns A node reference <tt>\ref vx_node</tt>. Any possible errors preventing a
* successful creation should be checked using <tt>\ref vxGetStatus</tt>.
*/
VX_API_ENTRY vx_node VX_API_CALL vxTensorAddNode(vx_graph graph, vx_tensor input1, vx_tensor input2, vx_enum policy, vx_tensor output);
/*! \brief [Graph] Performs arithmetic subtraction on element values in the input tensor data.
* \param [in] graph The handle to the graph.
* \param [in] input1 Input tensor data. Implementations must support input tensor data type <tt>\ref VX_TYPE_INT16</tt> with fixed_point_position 8,
* and tensor data types <tt>\ref VX_TYPE_UINT8</tt> and <tt>\ref VX_TYPE_INT8</tt>, with fixed_point_position 0.
* \param [in] input2 Input tensor data. The dimensions and sizes of input2 match those of input1, unless the vx_tensor of one or more dimensions in input2 is 1.
* In this case, those dimensions are treated as if this tensor was expanded to match the size of the corresponding dimension of input1,
* and data was duplicated on all terms in that dimension. After this expansion, the dimensions will be equal.
* The data type must match the data type of Input1.
* \param [in] policy A <tt>\ref vx_convert_policy_e</tt> enumeration.
* \param [out] output The output tensor data with the same dimensions as the input tensor data.
* \ingroup group_vision_function_tensor_subtract
* \return <tt>\ref vx_node</tt>.
* \returns A node reference <tt>\ref vx_node</tt>. Any possible errors preventing a
* successful creation should be checked using <tt>\ref vxGetStatus</tt>.
*/
VX_API_ENTRY vx_node VX_API_CALL vxTensorSubtractNode(vx_graph graph, vx_tensor input1, vx_tensor input2, vx_enum policy, vx_tensor output);
/*! \brief [Graph] Performs LUT on element values in the input tensor data.
* \param [in] graph The handle to the graph.
* \param [in] input1 Input tensor data. Implementations must support input tensor data type <tt>\ref VX_TYPE_INT16</tt> with fixed_point_position 8,
* and tensor data types <tt>\ref VX_TYPE_UINT8</tt>, with fixed_point_position 0.
* \param [in] lut The look-up table to use, of type <tt>\ref vx_lut</tt>.
* The elements of input1 are treated as unsigned integers to determine an index into the look-up table.
* The data type of the items in the look-up table must match that of the output tensor.
* \param [out] output The output tensor data with the same dimensions as the input tensor data.
* \ingroup group_vision_function_tensor_tablelookup
* \return <tt>\ref vx_node</tt>.
* \returns A node reference <tt>\ref vx_node</tt>. Any possible errors preventing a
* successful creation should be checked using <tt>\ref vxGetStatus</tt>.
*/
VX_API_ENTRY vx_node VX_API_CALL vxTensorTableLookupNode(vx_graph graph, vx_tensor input1, vx_lut lut, vx_tensor output);
/*! \brief [Graph] Performs transpose on the input tensor.
* The node transpose the tensor according to a specified 2 indexes in the tensor (0-based indexing)
* \param [in] graph The handle to the graph.
* \param [in] input Input tensor data, Implementations must support input tensor data type <tt>\ref VX_TYPE_INT16</tt> with fixed_point_position 8,
* and tensor data types <tt>\ref VX_TYPE_UINT8</tt> and <tt>\ref VX_TYPE_INT8</tt>, with fixed_point_position 0.
* \param [out] output output tensor data,
* \param [in] dimension1 Dimension index that is transposed with dim 2.
* \param [in] dimension2 Dimension index that is transposed with dim 1.
* \ingroup group_vision_function_tensor_transpose
* \return <tt>\ref vx_node</tt>.
* \returns A node reference <tt>\ref vx_node</tt>. Any possible errors preventing a
* successful creation should be checked using <tt>\ref vxGetStatus</tt>.
*/
VX_API_ENTRY vx_node VX_API_CALL vxTensorTransposeNode(vx_graph graph, vx_tensor input, vx_tensor output, vx_size dimension1, vx_size dimension2);
/*! \brief [Graph] Creates a bit-depth conversion node.
* \param [in] graph The reference to the graph.
* \param [in] input The input tensor. Implementations must support input tensor data type <tt>\ref VX_TYPE_INT16</tt> with fixed_point_position 8,
* and tensor data types <tt>\ref VX_TYPE_UINT8</tt> and <tt>\ref VX_TYPE_INT8</tt>, with fixed_point_position 0.
* \param [in] policy A <tt>\ref VX_TYPE_ENUM</tt> of the <tt>\ref vx_convert_policy_e</tt> enumeration.
* \param [in] norm A scalar containing a <tt>\ref VX_TYPE_FLOAT32</tt> of the normalization value.
* \param [in] offset A scalar containing a <tt>\ref VX_TYPE_FLOAT32</tt> of the offset value subtracted before normalization.
* \param [out] output The output tensor. Implementations must support input tensor data type <tt>\ref VX_TYPE_INT16</tt>. with fixed_point_position 8.
* And <tt>\ref VX_TYPE_UINT8</tt> with fixed_point_position 0.
* \ingroup group_vision_function_tensor_convert_depth
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
*/
VX_API_ENTRY vx_node VX_API_CALL vxTensorConvertDepthNode(vx_graph graph, vx_tensor input, vx_enum policy, vx_scalar norm, vx_scalar offset, vx_tensor output);
/*! \brief [Graph] Creates a generalized matrix multiplication node.
* \param [in] graph The reference to the graph.
* \param [in] input1 The first input 2D tensor of type <tt>\ref VX_TYPE_INT16</tt> with fixed_point_pos 8, or tensor data types <tt>\ref VX_TYPE_UINT8</tt> or <tt>\ref VX_TYPE_INT8</tt>, with fixed_point_pos 0.
* \param [in] input2 The second 2D tensor. Must be in the same data type as input1.
* \param [in] input3 The third 2D tensor. Must be in the same data type as input1. [optional].
* \param [in] matrix_multiply_params Matrix multiply parameters, see <tt>\ref vx_tensor_matrix_multiply_params_t </tt>.
* \param [out] output The output 2D tensor. Must be in the same data type as input1. Output dimension must agree the formula in the description.
* \ingroup group_vision_function_tensor_matrix_multiply
* \return <tt>\ref vx_node</tt>.
* \returns A node reference <tt>\ref vx_node</tt>. Any possible errors preventing a
* successful creation should be checked using <tt>\ref vxGetStatus</tt>.
*/
VX_API_ENTRY vx_node VX_API_CALL vxTensorMatrixMultiplyNode(vx_graph graph, vx_tensor input1, vx_tensor input2, vx_tensor input3,
const vx_tensor_matrix_multiply_params_t *matrix_multiply_params, vx_tensor output);
/*! \brief Copy data from one object to another.
* \note An implementation may optimize away the copy when virtual data objects are used.
* \param [in] graph The reference to the graph.
* \param [in] input The input data object.
* \param [out] output The output data object with meta-data identical to the input data object.
* \return <tt>\ref vx_node</tt>.
* \retval vx_node A node reference. Any possible errors preventing a successful creation
* should be checked using <tt>\ref vxGetStatus</tt>
* \ingroup group_vision_function_copy
*/
VX_API_ENTRY vx_node VX_API_CALL vxCopyNode(vx_graph graph, vx_reference input, vx_reference output);
#ifdef __cplusplus
}
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,67 @@
/*
* Copyright (c) 2012-2017 The Khronos Group Inc.
*
* 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
*
* http://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 _OPENVX_VENDORS_H_
#define _OPENVX_VENDORS_H_
/*!
* \file
* \brief The Vendor ID list for OpenVX.
*/
/*! \brief The Vendor ID of the Implementation. As new vendors submit their
* implementations, this enumeration will grow.
* \ingroup group_basic_features
*/
enum vx_vendor_id_e {
VX_ID_KHRONOS = 0x000, /*!< \brief The Khronos Group */
VX_ID_TI = 0x001, /*!< \brief Texas Instruments, Inc. */
VX_ID_QUALCOMM = 0x002, /*!< \brief Qualcomm, Inc. */
VX_ID_NVIDIA = 0x003, /*!< \brief NVIDIA Corporation */
VX_ID_ARM = 0x004, /*!< \brief ARM Ltd. */
VX_ID_BDTI = 0x005, /*!< \brief Berkley Design Technology, Inc. */
VX_ID_RENESAS = 0x006, /*!< \brief Renasas Electronics */
VX_ID_VIVANTE = 0x007, /*!< \brief Vivante Corporation */
VX_ID_XILINX = 0x008, /*!< \brief Xilinx Inc. */
VX_ID_AXIS = 0x009, /*!< \brief Axis Communications */
VX_ID_MOVIDIUS = 0x00A, /*!< \brief Movidius Ltd. */
VX_ID_SAMSUNG = 0x00B, /*!< \brief Samsung Electronics */
VX_ID_FREESCALE = 0x00C, /*!< \brief Freescale Semiconductor */
VX_ID_AMD = 0x00D, /*!< \brief Advanced Micro Devices */
VX_ID_BROADCOM = 0x00E, /*!< \brief Broadcom Corporation */
VX_ID_INTEL = 0x00F, /*!< \brief Intel Corporation */
VX_ID_MARVELL = 0x010, /*!< \brief Marvell Technology Group Ltd. */
VX_ID_MEDIATEK = 0x011, /*!< \brief MediaTek, Inc. */
VX_ID_ST = 0x012, /*!< \brief STMicroelectronics */
VX_ID_CEVA = 0x013, /*!< \brief CEVA DSP */
VX_ID_ITSEEZ = 0x014, /*!< \brief Itseez, Inc. */
VX_ID_IMAGINATION=0x015, /*!< \brief Imagination Technologies */
VX_ID_NXP = 0x016, /*!< \brief NXP Semiconductors */
VX_ID_VIDEANTIS = 0x017, /*!< \brief Videantis */
VX_ID_SYNOPSYS = 0x018, /*!< \brief Synopsys */
VX_ID_CADENCE = 0x019, /*!< \brief Cadence */
VX_ID_HUAWEI = 0x01A, /*!< \brief Huawei */
VX_ID_SOCIONEXT = 0x01B, /*!< \brief Socionext */
/* Add new vendor code above this line */
VX_ID_USER = 0xFFE, /*!< \brief For use by vxAllocateUserKernelId and vxAllocateUserKernelLibraryId */
VX_ID_MAX = 0xFFF,
/*! \brief For use by all Kernel authors until they can obtain an assigned ID. */
VX_ID_DEFAULT = VX_ID_MAX,
};
#endif

View File

@ -0,0 +1,62 @@
/****************************************************************************
*
* Copyright 2017 - 2020 Vivante Corporation, Santa Clara, California.
* All Rights Reserved.
*
* 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, sub license, 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 (including the
* next paragraph) 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 NON-INFRINGEMENT.
* IN NO EVENT SHALL VIVANTE AND/OR ITS SUPPLIERS 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 _VX_VIV_SYS_H_
#define _VX_VIV_SYS_H_
#include <VX/vx.h>
#ifdef __cplusplus
extern "C" {
#endif
/*! \brief set clock fscale value to change core and shader frequency.
* \param [in] coreIndex Global core index to set the specific core clock frequency.
* If the value is 0xFFFFFFFF, all the cores will be set.
* \param [in] vipFscaleValue Set core frequency scale size. Value can be 64, 32, 16, 8, 4, 2, 1.
* 64 means 64/64 full frequency, 1 means 1/64 frequency.
* \param [in] shaderFscaleValue Set shader frequency scale size. Value can be 64, 32, 16, 8, 4, 2, 1.
* 64 means 64/64 full frequency, 1 means 1/64 frequency.
*
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS No errors;
* \retval VX_ERROR_INVAID_PARAMETERS Invalid frequency scale values.
* \retval VX_FAILURE Failed to change core and shader frequency.
*/
VX_API_ENTRY vx_status VX_API_CALL vxSysSetVipFrequency(
vx_uint32 coreIndex,
vx_uint32 vipFscaleValue,
vx_uint32 shaderFscaleValue
);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,924 @@
/*
* Copyright (c) 2012-2017 The Khronos Group Inc.
*
* 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
*
* http://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 _OPENVX_UTILITY_H_
#define _OPENVX_UTILITY_H_
/*!
* \file
* \brief The OpenVX Utility Library.
*/
#ifdef __cplusplus
extern "C" {
#endif
/*! \brief [Immediate] Invokes an immediate Color Conversion.
* \param [in] context The reference to the overall context.
* \param [in] input The input image.
* \param [out] output The output image.
* \ingroup group_vision_function_colorconvert
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuColorConvert(vx_context context, vx_image input, vx_image output);
/*! \brief [Immediate] Invokes an immediate Channel Extract.
* \param [in] context The reference to the overall context.
* \param [in] input The input image. Must be one of the defined <tt>\ref vx_df_image_e</tt> multi-channel formats.
* \param [in] channel The <tt>\ref vx_channel_e</tt> enumeration to extract.
* \param [out] output The output image. Must be <tt>\ref VX_DF_IMAGE_U8</tt>.
* \ingroup group_vision_function_channelextract
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuChannelExtract(vx_context context, vx_image input, vx_enum channel, vx_image output);
/*! \brief [Immediate] Invokes an immediate Channel Combine.
* \param [in] context The reference to the overall context.
* \param [in] plane0 The plane that forms channel 0. Must be <tt>\ref VX_DF_IMAGE_U8</tt>.
* \param [in] plane1 The plane that forms channel 1. Must be <tt>\ref VX_DF_IMAGE_U8</tt>.
* \param [in] plane2 [optional] The plane that forms channel 2. Must be <tt>\ref VX_DF_IMAGE_U8</tt>.
* \param [in] plane3 [optional] The plane that forms channel 3. Must be <tt>\ref VX_DF_IMAGE_U8</tt>.
* \param [out] output The output image.
* \ingroup group_vision_function_channelcombine
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuChannelCombine(vx_context context, vx_image plane0, vx_image plane1, vx_image plane2, vx_image plane3, vx_image output);
/*! \brief [Immediate] Invokes an immediate Sobel 3x3.
* \param [in] context The reference to the overall context.
* \param [in] input The input image in <tt>\ref VX_DF_IMAGE_U8</tt> format.
* \param [out] output_x [optional] The output gradient in the x direction in <tt>\ref VX_DF_IMAGE_S16</tt>.
* \param [out] output_y [optional] The output gradient in the y direction in <tt>\ref VX_DF_IMAGE_S16</tt>.
* \ingroup group_vision_function_sobel3x3
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuSobel3x3(vx_context context, vx_image input, vx_image output_x, vx_image output_y);
/*! \brief [Immediate] Invokes an immediate Magnitude.
* \param [in] context The reference to the overall context.
* \param [in] grad_x The input x image. This must be in <tt>\ref VX_DF_IMAGE_S16</tt> format.
* \param [in] grad_y The input y image. This must be in <tt>\ref VX_DF_IMAGE_S16</tt> format.
* \param [out] mag The magnitude image. This will be in <tt>\ref VX_DF_IMAGE_S16</tt> format.
* \ingroup group_vision_function_magnitude
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuMagnitude(vx_context context, vx_image grad_x, vx_image grad_y, vx_image mag);
/*! \brief [Immediate] Invokes an immediate Phase.
* \param [in] context The reference to the overall context.
* \param [in] grad_x The input x image. This must be in <tt>\ref VX_DF_IMAGE_S16</tt> format.
* \param [in] grad_y The input y image. This must be in <tt>\ref VX_DF_IMAGE_S16</tt> format.
* \param [out] orientation The phase image. This will be in <tt>\ref VX_DF_IMAGE_U8</tt> format.
* \ingroup group_vision_function_phase
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuPhase(vx_context context, vx_image grad_x, vx_image grad_y, vx_image orientation);
/*! \brief [Immediate] Scales an input image to an output image.
* \param [in] context The reference to the overall context.
* \param [in] src The source image of type <tt>\ref VX_DF_IMAGE_U8</tt>.
* \param [out] dst The destintation image of type <tt>\ref VX_DF_IMAGE_U8</tt>.
* \param [in] type The interpolation type. \see vx_interpolation_type_e.
* \ingroup group_vision_function_scale_image
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuScaleImage(vx_context context, vx_image src, vx_image dst, vx_enum type);
/*! \brief [Immediate] Processes the image through the LUT.
* \param [in] context The reference to the overall context.
* \param [in] input The input image in <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt>.
* \param [in] lut The LUT which is of type <tt>\ref VX_TYPE_UINT8</tt> if input image is <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_TYPE_INT16</tt> if input image is <tt>\ref VX_DF_IMAGE_S16</tt>.
* \param [out] output The output image of the same type as the input image.
* \ingroup group_vision_function_lut
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuTableLookup(vx_context context, vx_image input, vx_lut lut, vx_image output);
/*! \brief [Immediate] Generates a distribution from an image.
* \param [in] context The reference to the overall context.
* \param [in] input The input image in <tt>\ref VX_DF_IMAGE_U8</tt>
* \param [out] distribution The output distribution.
* \ingroup group_vision_function_histogram
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuHistogram(vx_context context, vx_image input, vx_distribution distribution);
/*! \brief [Immediate] Equalizes the Histogram of a grayscale image.
* \param [in] context The reference to the overall context.
* \param [in] input The grayscale input image in <tt>\ref VX_DF_IMAGE_U8</tt>
* \param [out] output The grayscale output image of type <tt>\ref VX_DF_IMAGE_U8</tt> with equalized brightness and contrast.
* \ingroup group_vision_function_equalize_hist
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuEqualizeHist(vx_context context, vx_image input, vx_image output);
/*! \brief [Immediate] Computes the absolute difference between two images.
* \param [in] context The reference to the overall context.
* \param [in] in1 An input image in <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt> format.
* \param [in] in2 An input image in <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt> format.
* \param [out] out The output image in <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt> format.
* \ingroup group_vision_function_absdiff
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuAbsDiff(vx_context context, vx_image in1, vx_image in2, vx_image out);
/*! \brief [Immediate] Computes the mean value and optionally the standard deviation.
* \param [in] context The reference to the overall context.
* \param [in] input The input image. <tt>\ref VX_DF_IMAGE_U8</tt> is supported.
* \param [out] mean The average pixel value.
* \param [out] stddev [optional] The standard deviation of the pixel values.
* \ingroup group_vision_function_meanstddev
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuMeanStdDev(vx_context context, vx_image input, vx_float32 *mean, vx_float32 *stddev);
/*! \brief [Immediate] Threshold's an input image and produces a <tt>\ref VX_DF_IMAGE_U8</tt> boolean image.
* \param [in] context The reference to the overall context.
* \param [in] input The input image. Only images with format <tt>\ref VX_DF_IMAGE_U8</tt>
* and <tt>\ref VX_DF_IMAGE_S16</tt> are supported.
* \param [in] thresh The thresholding object that defines the parameters of
* the operation. The <tt>\ref VX_THRESHOLD_INPUT_FORMAT</tt> must be the same as the input image format and
* the <tt>\ref VX_THRESHOLD_OUTPUT_FORMAT</tt> must be the same as the output image format.
* \param [out] output The output image, that will contain as pixel value
* true and false values defined by \p thresh. Only images with format
* <tt>\ref VX_DF_IMAGE_U8</tt> are supported.
* \ingroup group_vision_function_threshold
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuThreshold(vx_context context, vx_image input, vx_threshold thresh, vx_image output);
/*! \brief [Immediate] Performs Non-Maxima Suppression on an image, producing an image of the same type.
* \param [in] context The reference to the overall context.
* \param [in] input The input image in <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt> format.
* \param [in] mask [optional] Constrict suppression to a ROI. The mask image is of type <tt>\ref VX_DF_IMAGE_U8</tt> and must be the same dimensions as the input image.
* \param [in] win_size The size of window over which to perform the localized non-maxima suppression. Must be odd, and less than or equal to the smallest dimension of the input image.
* \param [out] output The output image, of the same type as the input, that has been non-maxima suppressed.
* \ingroup group_vision_function_nms
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuNonMaxSuppression(vx_context context, vx_image input, vx_image mask, vx_int32 win_size, vx_image output);
/*! \brief [Immediate] Computes the integral image of the input.
* \param [in] context The reference to the overall context.
* \param [in] input The input image in <tt>\ref VX_DF_IMAGE_U8</tt> format.
* \param [out] output The output image in <tt>\ref VX_DF_IMAGE_U32</tt> format.
* \ingroup group_vision_function_integral_image
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuIntegralImage(vx_context context, vx_image input, vx_image output);
/*! \brief [Immediate] Erodes an image by a 3x3 window.
* \param [in] context The reference to the overall context.
* \param [in] input The input image in <tt>\ref VX_DF_IMAGE_U8</tt> format.
* \param [out] output The output image in <tt>\ref VX_DF_IMAGE_U8</tt> format.
* \ingroup group_vision_function_erode_image
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuErode3x3(vx_context context, vx_image input, vx_image output);
/*! \brief [Immediate] Dilates an image by a 3x3 window.
* \param [in] context The reference to the overall context.
* \param [in] input The input image in <tt>\ref VX_DF_IMAGE_U8</tt> format.
* \param [out] output The output image in <tt>\ref VX_DF_IMAGE_U8</tt> format.
* \ingroup group_vision_function_dilate_image
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuDilate3x3(vx_context context, vx_image input, vx_image output);
/*! \brief [Immediate] Computes a median filter on the image by a 3x3 window.
* \param [in] context The reference to the overall context.
* \param [in] input The input image in <tt>\ref VX_DF_IMAGE_U8</tt> format.
* \param [out] output The output image in <tt>\ref VX_DF_IMAGE_U8</tt> format.
* \ingroup group_vision_function_median_image
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuMedian3x3(vx_context context, vx_image input, vx_image output);
/*! \brief [Immediate] Computes a box filter on the image by a 3x3 window.
* \param [in] context The reference to the overall context.
* \param [in] input The input image in <tt>\ref VX_DF_IMAGE_U8</tt> format.
* \param [out] output The output image in <tt>\ref VX_DF_IMAGE_U8</tt> format.
* \ingroup group_vision_function_box_image
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuBox3x3(vx_context context, vx_image input, vx_image output);
/*! \brief [Immediate] Computes a gaussian filter on the image by a 3x3 window.
* \param [in] context The reference to the overall context.
* \param [in] input The input image in <tt>\ref VX_DF_IMAGE_U8</tt> format.
* \param [out] output The output image in <tt>\ref VX_DF_IMAGE_U8</tt> format.
* \ingroup group_vision_function_gaussian_image
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuGaussian3x3(vx_context context, vx_image input, vx_image output);
/*! \brief [Immediate] Performs Non-linear Filtering.
* \param [in] context The reference to the overall context.
* \param [in] function The non-linear filter function. See <tt>\ref vx_non_linear_filter_e</tt>.
* \param [in] input The input image in <tt>\ref VX_DF_IMAGE_U8</tt> format.
* \param [in] mask The mask to be applied to the Non-linear function. <tt>\ref VX_MATRIX_ORIGIN</tt> attribute is used
* to place the mask appropriately when computing the resulting image. See <tt>\ref vxCreateMatrixFromPattern</tt> and <tt>\ref vxCreateMatrixFromPatternAndOrigin</tt>.
* \param [out] output The output image in <tt>\ref VX_DF_IMAGE_U8</tt> format.
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
* \ingroup group_vision_function_nonlinear_filter
*/
VX_API_ENTRY vx_status VX_API_CALL vxuNonLinearFilter(vx_context context, vx_enum function, vx_image input, vx_matrix mask, vx_image output);
/*! \brief [Immediate] Computes a convolution on the input image with the supplied
* matrix.
* \param [in] context The reference to the overall context.
* \param [in] input The input image in <tt>\ref VX_DF_IMAGE_U8</tt> format.
* \param [in] conv The <tt>\ref vx_int16</tt> convolution matrix.
* \param [out] output The output image in <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt> format.
* \ingroup group_vision_function_custom_convolution
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuConvolve(vx_context context, vx_image input, vx_convolution conv, vx_image output);
/*! \brief [Immediate] Computes a Gaussian pyramid from an input image.
* \param [in] context The reference to the overall context.
* \param [in] input The input image in <tt>\ref VX_DF_IMAGE_U8</tt>
* \param [out] gaussian The Gaussian pyramid with <tt>\ref VX_DF_IMAGE_U8</tt> to construct.
* \ingroup group_vision_function_gaussian_pyramid
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuGaussianPyramid(vx_context context, vx_image input, vx_pyramid gaussian);
/*! \brief [Immediate] Computes a Laplacian pyramid from an input image.
* \param [in] context The reference to the overall context.
* \param [in] input The input image in <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt> format.
* \param [out] laplacian The Laplacian pyramid with <tt>\ref VX_DF_IMAGE_S16</tt> to construct.
* \param [out] output The lowest resolution image in <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt> format necessary to reconstruct the input image from the pyramid. The output image format should be same as input image format.
* \ingroup group_vision_function_laplacian_pyramid
* \see group_pyramid
* \return A <tt>\ref vx_status</tt> enumeration.
* \retval VX_SUCCESS Success.
* \retval * An error occured. See <tt>\ref vx_status_e</tt>
*/
VX_API_ENTRY vx_status VX_API_CALL vxuLaplacianPyramid(vx_context context, vx_image input, vx_pyramid laplacian, vx_image output);
/*! \brief [Immediate] Reconstructs an image from a Laplacian Image pyramid.
* \param [in] context The reference to the overall context.
* \param [in] laplacian The Laplacian pyramid with <tt>\ref VX_DF_IMAGE_S16</tt> format.
* \param [in] input The lowest resolution image in <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt> format for the Laplacian pyramid.
* \param [out] output The output image in <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt> format with the highest possible resolution reconstructed from the Laplacian pyramid. The output image format should be same as input image format.
* \ingroup group_vision_function_laplacian_reconstruct
* \see group_pyramid
* \return A <tt>\ref vx_status</tt> enumeration.
* \retval VX_SUCCESS Success.
* \retval * An error occured. See <tt>\ref vx_status_e</tt>
*/
VX_API_ENTRY vx_status VX_API_CALL vxuLaplacianReconstruct(vx_context context, vx_pyramid laplacian, vx_image input,
vx_image output);
/*! \brief [Immediate] Computes a weighted average image.
* \param [in] context The reference to the overall context.
* \param [in] img1 The first <tt>\ref VX_DF_IMAGE_U8</tt> image.
* \param [in] alpha A <tt>\ref VX_TYPE_FLOAT32</tt> type, the input value with the range \f$ 0.0 \le \alpha \le 1.0 \f$.
* \param [in] img2 The second <tt>\ref VX_DF_IMAGE_U8</tt> image.
* \param [out] output The output <tt>\ref VX_DF_IMAGE_U8</tt> image.
* \ingroup group_vision_function_weighted_average
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuWeightedAverage(vx_context context, vx_image img1, vx_scalar alpha, vx_image img2, vx_image output);
/*! \brief [Immediate] Computes the minimum and maximum values of the image.
* \param [in] context The reference to the overall context.
* \param [in] input The input image in <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt> format.
* \param [out] minVal The minimum value in the image, which corresponds to the type of the input.
* \param [out] maxVal The maximum value in the image, which corresponds to the type of the input.
* \param [out] minLoc [optional] The minimum <tt>\ref VX_TYPE_COORDINATES2D</tt> locations. If the input image has several minimums, the kernel will return up to the capacity of the array.
* \param [out] maxLoc [optional] The maximum <tt>\ref VX_TYPE_COORDINATES2D</tt> locations. If the input image has several maximums, the kernel will return up to the capacity of the array.
* \param [out] minCount [optional] The total number of detected minimums in image. Use a <tt>\ref VX_TYPE_SIZE</tt> scalar.
* \param [out] maxCount [optional] The total number of detected maximums in image. Use a <tt>\ref VX_TYPE_SIZE</tt> scalar.
* \ingroup group_vision_function_minmaxloc
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuMinMaxLoc(vx_context context, vx_image input,
vx_scalar minVal, vx_scalar maxVal,
vx_array minLoc, vx_array maxLoc,
vx_scalar minCount, vx_scalar maxCount);
/*! \brief [Immediate] Computes pixel-wise minimum values between two images.
* \param [in] context The reference to the overall context.
* \param [in] in1 The first input image. Must be of type <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt>.
* \param [in] in2 The second input image. Must be of type <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt>.
* \param [out] out The output image which will hold the result of min.
* \ingroup group_vision_function_min
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuMin(vx_context context, vx_image in1, vx_image in2, vx_image out);
/*! \brief [Immediate] Computes pixel-wise maximum values between two images.
* \param [in] context The reference to the overall context.
* \param [in] in1 The first input image. Must be of type <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt>.
* \param [in] in2 The second input image. Must be of type <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt>.
* \param [out] out The output image which will hold the result of max.
* \ingroup group_vision_function_max
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuMax(vx_context context, vx_image in1, vx_image in2, vx_image out);
/*! \brief [Immediate] Converts the input images bit-depth into the output image.
* \param [in] context The reference to the overall context.
* \param [in] input The input image.
* \param [out] output The output image.
* \param [in] policy A <tt>\ref VX_TYPE_ENUM</tt> of the <tt>\ref vx_convert_policy_e</tt> enumeration.
* \param [in] shift A scalar containing a <tt>\ref VX_TYPE_INT32</tt> of the shift value.
* \ingroup group_vision_function_convertdepth
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>..
*/
VX_API_ENTRY vx_status VX_API_CALL vxuConvertDepth(vx_context context, vx_image input, vx_image output, vx_enum policy, vx_int32 shift);
/*! \brief [Immediate] Computes Canny Edges on the input image into the output image.
* \param [in] context The reference to the overall context.
* \param [in] input The input <tt>\ref VX_DF_IMAGE_U8</tt> image.
* \param [in] hyst The double threshold for hysteresis. The <tt>\ref VX_THRESHOLD_INPUT_FORMAT</tt> shall be either
* <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt>. The <tt>\ref VX_THRESHOLD_OUTPUT_FORMAT</tt> is ignored.
* \param [in] gradient_size The size of the Sobel filter window, must support at least 3, 5 and 7.
* \param [in] norm_type A flag indicating the norm used to compute the gradient, <tt>\ref VX_NORM_L1</tt> or <tt>\ref VX_NORM_L2</tt>.
* \param [out] output The output image in <tt>\ref VX_DF_IMAGE_U8</tt> format with values either 0 or 255.
* \ingroup group_vision_function_canny
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuCannyEdgeDetector(vx_context context, vx_image input, vx_threshold hyst,
vx_int32 gradient_size, vx_enum norm_type,
vx_image output);
/*! \brief [Immediate] Performs a Gaussian Blur on an image then half-scales it. The interpolation mode used is nearest-neighbor.
* \param [in] context The reference to the overall context.
* \param [in] input The input <tt>\ref VX_DF_IMAGE_U8</tt> image.
* \param [out] output The output <tt>\ref VX_DF_IMAGE_U8</tt> image.
* \param [in] kernel_size The input size of the Gaussian filter. Supported values are 1, 3 and 5.
* \ingroup group_vision_function_scale_image
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuHalfScaleGaussian(vx_context context, vx_image input, vx_image output, vx_int32 kernel_size);
/*! \brief [Immediate] Computes the bitwise and between two images.
* \param [in] context The reference to the overall context.
* \param [in] in1 A <tt>\ref VX_DF_IMAGE_U8</tt> input image
* \param [in] in2 A <tt>\ref VX_DF_IMAGE_U8</tt> input image
* \param [out] out The <tt>\ref VX_DF_IMAGE_U8</tt> output image.
* \ingroup group_vision_function_and
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuAnd(vx_context context, vx_image in1, vx_image in2, vx_image out);
/*! \brief [Immediate] Computes the bitwise inclusive-or between two images.
* \param [in] context The reference to the overall context.
* \param [in] in1 A <tt>\ref VX_DF_IMAGE_U8</tt> input image
* \param [in] in2 A <tt>\ref VX_DF_IMAGE_U8</tt> input image
* \param [out] out The <tt>\ref VX_DF_IMAGE_U8</tt> output image.
* \ingroup group_vision_function_or
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuOr(vx_context context, vx_image in1, vx_image in2, vx_image out);
/*! \brief [Immediate] Computes the bitwise exclusive-or between two images.
* \param [in] context The reference to the overall context.
* \param [in] in1 A <tt>\ref VX_DF_IMAGE_U8</tt> input image
* \param [in] in2 A <tt>\ref VX_DF_IMAGE_U8</tt> input image
* \param [out] out The <tt>\ref VX_DF_IMAGE_U8</tt> output image.
* \ingroup group_vision_function_xor
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuXor(vx_context context, vx_image in1, vx_image in2, vx_image out);
/*! \brief [Immediate] Computes the bitwise not of an image.
* \param [in] context The reference to the overall context.
* \param [in] input The <tt>\ref VX_DF_IMAGE_U8</tt> input image
* \param [out] output The <tt>\ref VX_DF_IMAGE_U8</tt> output image.
* \ingroup group_vision_function_not
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuNot(vx_context context, vx_image input, vx_image output);
/*! \brief [Immediate] Performs elementwise multiplications on pixel values in the input images and a scale.
* \param [in] context The reference to the overall context.
* \param [in] in1 A <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt> input image.
* \param [in] in2 A <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt> input image.
* \param [in] scale A non-negative <tt>\ref VX_TYPE_FLOAT32</tt> multiplied to each product before overflow handling.
* \param [in] overflow_policy A <tt>\ref vx_convert_policy_e</tt> enumeration.
* \param [in] rounding_policy A <tt>\ref vx_round_policy_e</tt> enumeration.
* \param [out] out The output image in <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt> format.
* \ingroup group_vision_function_mult
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuMultiply(vx_context context, vx_image in1, vx_image in2, vx_float32 scale, vx_enum overflow_policy, vx_enum rounding_policy, vx_image out);
/*! \brief [Immediate] Performs arithmetic addition on pixel values in the input images.
* \param [in] context The reference to the overall context.
* \param [in] in1 A <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt> input image.
* \param [in] in2 A <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt> input image.
* \param [in] policy A \ref vx_convert_policy_e enumeration.
* \param [out] out The output image in <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt> format.
* \ingroup group_vision_function_add
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuAdd(vx_context context, vx_image in1, vx_image in2, vx_enum policy, vx_image out);
/*! \brief [Immediate] Performs arithmetic subtraction on pixel values in the input images.
* \param [in] context The reference to the overall context.
* \param [in] in1 A <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt> input image, the minuend.
* \param [in] in2 A <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt> input image, the subtrahend.
* \param [in] policy A \ref vx_convert_policy_e enumeration.
* \param [out] out The output image in <tt>\ref VX_DF_IMAGE_U8</tt> or <tt>\ref VX_DF_IMAGE_S16</tt> format.
* \ingroup group_vision_function_sub
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuSubtract(vx_context context, vx_image in1, vx_image in2, vx_enum policy, vx_image out);
/*! \brief [Immediate] Performs an Affine warp on an image.
* \param [in] context The reference to the overall context.
* \param [in] input The input <tt>\ref VX_DF_IMAGE_U8</tt> image.
* \param [in] matrix The affine matrix. Must be 2x3 of type \ref VX_TYPE_FLOAT32.
* \param [in] type The interpolation type from \ref vx_interpolation_type_e.
* \ref VX_INTERPOLATION_AREA is not supported.
* \param [out] output The output <tt>\ref VX_DF_IMAGE_U8</tt> image.
* \ingroup group_vision_function_warp_affine
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuWarpAffine(vx_context context, vx_image input, vx_matrix matrix, vx_enum type, vx_image output);
/*! \brief [Immediate] Performs an Perspective warp on an image.
* \param [in] context The reference to the overall context.
* \param [in] input The input <tt>\ref VX_DF_IMAGE_U8</tt> image.
* \param [in] matrix The perspective matrix. Must be 3x3 of type \ref VX_TYPE_FLOAT32.
* \param [in] type The interpolation type from \ref vx_interpolation_type_e.
* \ref VX_INTERPOLATION_AREA is not supported.
* \param [out] output The output <tt>\ref VX_DF_IMAGE_U8</tt> image.
* \ingroup group_vision_function_warp_perspective
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuWarpPerspective(vx_context context, vx_image input, vx_matrix matrix, vx_enum type, vx_image output);
/*! \brief [Immediate] Computes the Harris Corners over an image and produces the array of scored points.
* \param [in] context The reference to the overall context.
* \param [in] input The input <tt>\ref VX_DF_IMAGE_U8</tt> image.
* \param [in] strength_thresh The <tt>\ref VX_TYPE_FLOAT32</tt> minimum threshold which to eliminate Harris Corner scores (computed using the normalized Sobel kernel).
* \param [in] min_distance The <tt>\ref VX_TYPE_FLOAT32</tt> radial Euclidean distance for non-maximum suppression.
* \param [in] sensitivity The <tt>\ref VX_TYPE_FLOAT32</tt> scalar sensitivity threshold \f$ k \f$ from the Harris-Stephens equation.
* \param [in] gradient_size The gradient window size to use on the input. The
* implementation must support at least 3, 5, and 7.
* \param [in] block_size The block window size used to compute the harris corner score.
* The implementation must support at least 3, 5, and 7.
* \param [out] corners The array of <tt>\ref VX_TYPE_KEYPOINT</tt> structs. The order of the keypoints in this array is implementation dependent.
* \param [out] num_corners [optional] The total number of detected corners in image. Use a \ref VX_TYPE_SIZE scalar
* \ingroup group_vision_function_harris
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuHarrisCorners(vx_context context,
vx_image input,
vx_scalar strength_thresh,
vx_scalar min_distance,
vx_scalar sensitivity,
vx_int32 gradient_size,
vx_int32 block_size,
vx_array corners,
vx_scalar num_corners);
/*! \brief [Immediate] Computes corners on an image using FAST algorithm and produces the array of feature points.
* \param [in] context The reference to the overall context.
* \param [in] input The input <tt>\ref VX_DF_IMAGE_U8</tt> image.
* \param [in] strength_thresh Threshold on difference between intensity of the central pixel and pixels on Bresenham's circle
* of radius 3 (<tt>\ref VX_TYPE_FLOAT32</tt> scalar), with a value in the range of 0.0 \f$\le\f$ strength_thresh < 256.0.
* Any fractional value will be truncated to an integer.
* \param [in] nonmax_suppression If true, non-maximum suppression is applied to
* detected corners before being places in the <tt>\ref vx_array</tt> of <tt>\ref VX_TYPE_KEYPOINT</tt> structs.
* \param [out] corners Output corner <tt>\ref vx_array</tt> of <tt>\ref VX_TYPE_KEYPOINT</tt>. The order of the keypoints in this array is implementation dependent.
* \param [out] num_corners [optional] The total number of detected corners in image. Use a \ref VX_TYPE_SIZE scalar.
* \ingroup group_vision_function_fast
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuFastCorners(vx_context context, vx_image input, vx_scalar strength_thresh, vx_bool nonmax_suppression, vx_array corners, vx_scalar num_corners);
/*! \brief [Immediate] Computes an optical flow on two images.
* \param [in] context The reference to the overall context.
* \param [in] old_images Input of first (old) image pyramid in <tt>\ref VX_DF_IMAGE_U8</tt>.
* \param [in] new_images Input of destination (new) image pyramid in <tt>\ref VX_DF_IMAGE_U8</tt>
* \param [in] old_points an array of key points in a vx_array of <tt>\ref VX_TYPE_KEYPOINT</tt> those key points are defined at
* the old_images high resolution pyramid
* \param [in] new_points_estimates an array of estimation on what is the output key points in a <tt>\ref vx_array</tt> of
* <tt>\ref VX_TYPE_KEYPOINT</tt> those keypoints are defined at the new_images high resolution pyramid
* \param [out] new_points an output array of key points in a <tt>\ref vx_array</tt> of <tt>\ref VX_TYPE_KEYPOINT</tt> those key points are
* defined at the new_images high resolution pyramid
* \param [in] termination termination can be <tt>\ref VX_TERM_CRITERIA_ITERATIONS</tt> or <tt>\ref VX_TERM_CRITERIA_EPSILON</tt> or
* <tt>\ref VX_TERM_CRITERIA_BOTH</tt>
* \param [in] epsilon is the <tt>\ref vx_float32</tt> error for terminating the algorithm
* \param [in] num_iterations is the number of iterations. Use a <tt>\ref VX_TYPE_UINT32</tt> scalar.
* \param [in] use_initial_estimate Can be set to either <tt>\ref vx_false_e</tt> or <tt>\ref vx_true_e</tt>.
* \param [in] window_dimension The size of the window on which to perform the algorithm. See
* <tt>\ref VX_CONTEXT_OPTICAL_FLOW_MAX_WINDOW_DIMENSION</tt>
*
* \ingroup group_vision_function_opticalflowpyrlk
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuOpticalFlowPyrLK(vx_context context,
vx_pyramid old_images,
vx_pyramid new_images,
vx_array old_points,
vx_array new_points_estimates,
vx_array new_points,
vx_enum termination,
vx_scalar epsilon,
vx_scalar num_iterations,
vx_scalar use_initial_estimate,
vx_size window_dimension);
/*! \brief [Immediate] The function compares an image template against overlapped image regions.
* \details The detailed equation to the matching can be found in <tt>\ref vx_comp_metric_e</tt>.
* The output of the template matching node is a comparison map as described in <tt>\ref vx_comp_metric_e</tt>.
* The Node have a limitation on the template image size (width*height). It should not be larger then 65535.
* If the valid region of the template image is smaller than the entire template image, the result in the destination image is implementation-dependent.
* \param [in] context The reference to the overall context.
* \param [in] src The input image of type <tt>\ref VX_DF_IMAGE_U8</tt>.
* \param [in] templateImage Searched template of type <tt>\ref VX_DF_IMAGE_U8</tt>.
* \param [in] matchingMethod attribute specifying the comparison method <tt>\ref vx_comp_metric_e</tt>. This function support only <tt>\ref VX_COMPARE_CCORR_NORM</tt> and <tt>\ref VX_COMPARE_L2</tt>.
* \param [out] output Map of comparison results. The output is an image of type <tt>\ref VX_DF_IMAGE_S16</tt>
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
* \ingroup group_vision_function_match_template
*/
VX_API_ENTRY vx_status VX_API_CALL vxuMatchTemplate(vx_context context, vx_image src, vx_image templateImage, vx_enum matchingMethod, vx_image output);
/*! \brief [Immediate] The function extracts LBP image from an input image
* \param [in] context The reference to the overall context.
* \param [in] in An input image in <tt>vx_image</tt>. Or \f$ SrcImg\f$ in the equations. the image is of type <tt>\ref VX_DF_IMAGE_U8</tt>
* \param [in] format A variation of LBP like original LBP and mLBP. see <tt> \ref vx_lbp_format_e </tt>
* \param [in] kernel_size Kernel size. Only size of 3 and 5 are supported
* \param [out] out An output image in <tt>vx_image</tt>.Or \f$ DstImg\f$ in the equations. the image is of type <tt>\ref VX_DF_IMAGE_U8</tt>
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
* \ingroup group_vision_function_lbp
*/
VX_API_ENTRY vx_status VX_API_CALL vxuLBP(vx_context context,
vx_image in, vx_enum format, vx_int8 kernel_size, vx_image out);
/*! \brief [Immediate] Performs cell calculations for the average gradient magnitude and gradient orientation histograms.
* \details Firstly, the gradient magnitude and gradient orientation are computed for each pixel in the input image.
* Two 1-D centred, point discrete derivative masks are applied to the input image in the horizontal and vertical directions.
* \f[ M_h = [-1, 0, 1] \f] and \f[ M_v = [-1, 0, 1]^T \f]
* \f$G_v\f$ is the result of applying mask \f$M_v\f$ to the input image, and \f$G_h\f$ is the result of applying mask \f$M_h\f$ to the input image.
* The border mode used for the gradient calculation is implementation dependent. Its behavior should be similar to <tt>\ref VX_BORDER_UNDEFINED</tt>.
* The gradient magnitudes and gradient orientations for each pixel are then calculated in the following manner.
* \f[ G(x,y) = \sqrt{G_v(x,y)^2 + G_h(x,y)^2} \f]
* \f[ \theta(x,y) = arctan(G_v(x,y), G_h(x,y)) \f]
* where \f$arctan(v, h)\f$
* is \f$ tan^{-1}(v/h)\f$ when \f$h!=0\f$,
*
* \f$ -pi/2 \f$ if \f$v<0\f$ and \f$h==0\f$,
*
* \f$ pi/2 \f$ if \f$v>0\f$ and \f$h==0\f$
*
* and \f$ 0 \f$ if \f$v==0\f$ and \f$h==0\f$
*
* Secondly, the gradient magnitudes and orientations are used to compute the bins output tensor and optional magnitudes output tensor.
* These tensors are computed on a cell level where the cells are rectangular in shape.
* The magnitudes tensor contains the average gradient magnitude for each cell.
* \f[magnitudes(c) = \frac{1}{(cell\_width * cell\_height)}\sum\limits_{w=0}^{cell\_width} \sum\limits_{h=0}^{cell\_height} G_c(w,h)\f]
* where \f$G_c\f$ is the gradient magnitudes related to cell \f$c\f$.
* The bins tensor contains histograms of gradient orientations for each cell.
* The gradient orientations at each pixel range from 0 to 360 degrees. These are quantised into a set of histogram bins based on the num_bins parameter.
* Each pixel votes for a specific cell histogram bin based on its gradient orientation. The vote itself is the pixel's gradient magnitude.
* \f[bins(c, n) = \sum\limits_{w=0}^{cell\_width} \sum\limits_{h=0}^{cell\_height} G_c(w,h) * 1[B_c(w, h, num\_bins) == n]\f]
* where \f$B_c\f$ produces the histogram bin number based on the gradient orientation of the pixel at location (\f$w\f$, \f$h\f$) in cell \f$c\f$ based on
* the \f$num\_bins\f$ and \f[1[B_c(w, h, num\_bins) == n]\f] is a delta-function with value 1 when \f$B_c(w, h, num\_bins) == n\f$ or 0 otherwise.
* \param [in] context The reference to the overall context.
* \param [in] input The input image of type <tt>\ref VX_DF_IMAGE_U8</tt>.
* \param [in] cell_width The histogram cell width of type <tt>\ref VX_TYPE_INT32</tt>.
* \param [in] cell_height The histogram cell height of type <tt>\ref VX_TYPE_INT32</tt>.
* \param [in] num_bins The histogram size of type <tt>\ref VX_TYPE_INT32</tt>.
* \param [out] magnitudes The output average gradient magnitudes per cell of <tt>\ref vx_tensor</tt> of type <tt>\ref VX_TYPE_INT16</tt> of size \f$ [floor(image_{width}/cell_{width}) ,floor(image_{height}/cell_{height}) ] \f$.
* \param [out] bins The output gradient orientation histograms per cell of <tt>\ref vx_tensor</tt> of type <tt>\ref VX_TYPE_INT16</tt> of size \f$ [floor(image_{width}/cell_{width}) ,floor(image_{height}/cell_{height}), num_{bins}] \f$.
*
* \ingroup group_vision_function_hog
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuHOGCells(vx_context context, vx_image input, vx_int32 cell_width, vx_int32 cell_height, vx_int32 num_bins, vx_tensor magnitudes, vx_tensor bins);
/*! \brief [Immediate] Computes Histogram of Oriented Gradients features for the W1xW2 window in a sliding window fashion over the whole input image.
* \details Firstly if a magnitudes tensor is provided the cell histograms in the bins tensor are normalised by the average cell gradient magnitudes.
\f[bins(c,n) = \frac{bins(c,n)}{magnitudes(c)}\f]
* To account for changes in illumination and contrast the cell histograms must be locally normalized which requires grouping the cell histograms together into larger spatially connected blocks.
* Blocks are rectangular grids represented by three parameters: the number of cells per block, the number of pixels per cell, and the number of bins per cell histogram.
* These blocks typically overlap, meaning that each cell histogram contributes more than once to the final descriptor.
* To normalize a block its cell histograms \f$h\f$ are grouped together to form a vector \f$v = [h_1, h_2, h_3, ... , h_n]\f$.
* This vector is normalised using L2-Hys which means performing L2-norm on this vector; clipping the result (by limiting the maximum values of v to be threshold) and renormalizing again. If the threshold is equal to zero then L2-Hys normalization is not performed.
* \f[L2norm(v) = \frac{v}{\sqrt{\|v\|_2^2 + \epsilon^2}}\f]
* where \f$ \|v\|_k \f$ be its k-norm for k=1, 2, and \f$ \epsilon \f$ be a small constant.
* For a specific window its HOG descriptor is then the concatenated vector of the components of the normalized cell histograms from all of the block regions contained in the window.
* The W1xW2 window starting position is at coordinates 0x0.
* If the input image has dimensions that are not an integer multiple of W1xW2 blocks with the specified stride, then the last positions that contain only a partial W1xW2 window
* will be calculated with the remaining part of the W1xW2 window padded with zeroes.
* The Window W1xW2 must also have a size so that it contains an integer number of cells, otherwise the node is not well-defined.
* The final output tensor will contain HOG descriptors equal to the number of windows in the input image.
* The output features tensor has 3 dimensions, given by:\n
* \f[[ (floor((image_{width}-window_{width})/window_{stride}) + 1),\f]
* \f[ (floor((image_{height}-window_{height})/window_{stride}) + 1),\f]
* \f[ floor((window_{width} - block_{width})/block_{stride} + 1) * floor((window_{height} - block_{height})/block_{stride} + 1) *\f]
* \f[ (((block_{width} * block_{height}) / (cell_{width} * cell_{height})) * num_{bins})] \f]
* See <tt>\ref vxCreateTensor</tt> and <tt>\ref vxCreateVirtualTensor</tt>.
* The output tensor from this function may be very large. For this reason, is it not recommended that this "immediate mode" version of the function be used.
* The preferred method to perform this function is as graph node with a virtual tensor as the output.
* \param [in] context The reference to the overall context.
* \param [in] input The input image of type <tt>\ref VX_DF_IMAGE_U8</tt>.
* \param [in] magnitudes The averge gradient magnitudes per cell of <tt>\ref vx_tensor</tt> of type <tt>\ref VX_TYPE_INT16</tt>. It is the output of <tt>\ref vxuHOGCells</tt>.
* \param [in] bins The gradient orientation histogram per cell of <tt>\ref vx_tensor</tt> of type <tt>\ref VX_TYPE_INT16</tt>. It is the output of <tt>\ref vxuHOGCells</tt>.
* \param [in] params The parameters of type <tt>\ref vx_hog_t</tt>.
* \param [in] hog_param_size Size of <tt>\ref vx_hog_t</tt> in bytes.
* \param [out] features The output HOG features of <tt>\ref vx_tensor</tt> of type <tt>\ref VX_TYPE_INT16</tt>.
*
* \ingroup group_vision_function_hog
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuHOGFeatures(vx_context context, vx_image input, vx_tensor magnitudes, vx_tensor bins, const vx_hog_t *params, vx_size hog_param_size, vx_tensor features);
/*! \brief [Immediate] Finds the Probabilistic Hough Lines detected in the input binary image, each line is stored in the output array as a set of points (x1, y1, x2, y2) .
* \details Some implementations of the algorithm may have a random or non-deterministic element. If the target application is in a safety-critical environment this
* should be borne in mind and steps taken in the implementation, the application or both to achieve the level of determinism required by the system design.
* \param [in] context The reference to the overall context.
* \param [in] input 8 bit, single channel binary source image
* \param [in] params parameters of the struct <tt>\ref vx_hough_lines_p_t</tt>
* \param [out] lines_array lines_array contains array of lines, see <tt>\ref vx_line2d_t</tt> The order of lines in implementation dependent
* \param [out] num_lines [optional] The total number of detected lines in image. Use a VX_TYPE_SIZE scalar
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
* \ingroup group_vision_function_hough_lines_p
*/
VX_API_ENTRY vx_status VX_API_CALL vxuHoughLinesP(vx_context context, vx_image input, const vx_hough_lines_p_t *params, vx_array lines_array, vx_scalar num_lines);
/*! \brief [Immediate] Remaps an output image from an input image.
* \param [in] context The reference to the overall context.
* \param [in] input The input <tt>\ref VX_DF_IMAGE_U8</tt> image.
* \param [in] table The remap table object.
* \param [in] policy The interpolation policy from \ref vx_interpolation_type_e.
* \ref VX_INTERPOLATION_AREA is not supported.
* \param [out] output The output <tt>\ref VX_DF_IMAGE_U8</tt> image.
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \ingroup group_vision_function_remap
*/
VX_API_ENTRY vx_status VX_API_CALL vxuRemap(vx_context context,
vx_image input,
vx_remap table,
vx_enum policy,
vx_image output);
/*! \brief [Immediate] The function applies bilateral filtering to the input tensor.
* \param [in] context The reference to the overall context.
* \param [in] src The input data a <tt>\ref vx_tensor</tt>. maximum 3 dimension and minimum 2. The tensor is of type <tt>\ref VX_TYPE_UINT8</tt> or <tt>\ref VX_TYPE_INT16</tt>.
* dimensions are [radiometric ,width,height] or [width,height]
* \param [in] diameter of each pixel neighbourhood that is used during filtering. Values of diameter must be odd. Bigger then 3 and smaller then 10.
* \param [in] sigmaValues Filter sigma in the radiometric space. Supported values are bigger then 0 and smaller or equal 20.
* \param [in] sigmaSpace Filter sigma in the spatial space. Supported values are bigger then 0 and smaller or equal 20.
* \param [out] dst The output data a <tt>\ref vx_tensor</tt>,Of type <tt>\ref VX_TYPE_UINT8</tt> or <tt>\ref VX_TYPE_INT16</tt>. And must be the same type and size of the input.
* \note The border modes
* <tt>\ref VX_NODE_BORDER</tt> value
* <tt>\ref VX_BORDER_REPLICATE</tt> and <tt>\ref VX_BORDER_CONSTANT</tt> are supported.
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
* \ingroup group_vision_function_bilateral_filter
*/
VX_API_ENTRY vx_status VX_API_CALL vxuBilateralFilter(vx_context context, vx_tensor src, vx_int32 diameter, vx_float32 sigmaSpace, vx_float32 sigmaValues, vx_tensor dst);
/*! \brief [Immediate] Performs element wise multiplications on element values in the input tensor data with a scale.
* \param [in] context The reference to the overall context.
* \param [in] input1 Input tensor data. Implementations must support input tensor data type <tt>\ref VX_TYPE_INT16</tt> with fixed_point_position 8,
* and tensor data types <tt>\ref VX_TYPE_UINT8</tt> and <tt>\ref VX_TYPE_INT8</tt>, with fixed_point_position 0.
* \param [in] input2 Input tensor data. The dimensions and sizes of input2 match those of input1, unless the vx_tensor of one or more dimensions in input2 is 1.
* In this case, those dimensions are treated as if this tensor was expanded to match the size of the corresponding dimension of input1,
* and data was duplicated on all terms in that dimension. After this expansion, the dimensions will be equal.
* The data type must match the data type of Input1.
* \param [in] scale A non-negative <tt>\ref VX_TYPE_FLOAT32</tt> multiplied to each product before overflow handling.
* \param [in] overflow_policy A <tt>\ref vx_convert_policy_e</tt> enumeration.
* \param [in] rounding_policy A <tt>\ref vx_round_policy_e</tt> enumeration.
* \param [out] output The output tensor data with the same dimensions as the input tensor data.
* \ingroup group_vision_function_tensor_multiply
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuTensorMultiply(vx_context context, vx_tensor input1, vx_tensor input2, vx_scalar scale, vx_enum overflow_policy,
vx_enum rounding_policy, vx_tensor output);
/*! \brief [Immediate] Performs arithmetic addition on element values in the input tensor data.
* \param [in] context The reference to the overall context.
* \param [in] input1 Input tensor data. Implementations must support input tensor data type <tt>\ref VX_TYPE_INT16</tt> with fixed_point_position 8,
* and tensor data types <tt>\ref VX_TYPE_UINT8</tt> and <tt>\ref VX_TYPE_INT8</tt>, with fixed_point_position 0.
* \param [in] input2 Input tensor data. The dimensions and sizes of input2 match those of input1, unless the vx_tensor of one or more dimensions in input2 is 1.
* In this case, those dimensions are treated as if this tensor was expanded to match the size of the corresponding dimension of input1,
* and data was duplicated on all terms in that dimension. After this expansion, the dimensions will be equal.
* The data type must match the data type of Input1.
* \param [in] policy A <tt>\ref vx_convert_policy_e</tt> enumeration.
* \param [out] output The output tensor data with the same dimensions as the input tensor data.
* \ingroup group_vision_function_tensor_add
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuTensorAdd(vx_context context, vx_tensor input1, vx_tensor input2, vx_enum policy, vx_tensor output);
/*! \brief [Immediate] Performs arithmetic subtraction on element values in the input tensor data.
* \param [in] context The reference to the overall context.
* \param [in] input1 Input tensor data. Implementations must support input tensor data type <tt>\ref VX_TYPE_INT16</tt> with fixed_point_position 8,
* and tensor data types <tt>\ref VX_TYPE_UINT8</tt> and <tt>\ref VX_TYPE_INT8</tt>, with fixed_point_position 0.
* \param [in] input2 Input tensor data. The dimensions and sizes of input2 match those of input1, unless the vx_tensor of one or more dimensions in input2 is 1.
* In this case, those dimensions are treated as if this tensor was expanded to match the size of the corresponding dimension of input1,
* and data was duplicated on all terms in that dimension. After this expansion, the dimensions will be equal.
* The data type must match the data type of Input1.
* \param [in] policy A <tt>\ref vx_convert_policy_e</tt> enumeration.
* \param [out] output The output tensor data with the same dimensions as the input tensor data.
* \ingroup group_vision_function_tensor_subtract
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuTensorSubtract(vx_context context, vx_tensor input1, vx_tensor input2, vx_enum policy, vx_tensor output);
/*! \brief [Immediate] Performs LUT on element values in the input tensor data.
* \param [in] context The reference to the overall context.
* \param [in] input1 Input tensor data. Implementations must support input tensor data type <tt>\ref VX_TYPE_INT16</tt> with fixed_point_position 8,
* and tensor data types <tt>\ref VX_TYPE_UINT8</tt>, with fixed_point_position 0.
* \param [in] lut The look-up table to use, of type <tt>\ref vx_lut</tt>.
* The elements of input1 are treated as unsigned integers to determine an index into the look-up table.
* The data type of the items in the look-up table must match that of the output tensor.
* \param [out] output The output tensor data with the same dimensions as the input tensor data.
* \ingroup group_vision_function_tensor_tablelookup
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuTensorTableLookup(vx_context context, vx_tensor input1, vx_lut lut, vx_tensor output);
/*! \brief [Immediate] Performs transpose on the input tensor.
* The tensor is transposed according to a specified 2 indexes in the tensor (0-based indexing)
* \param [in] context The reference to the overall context.
* \param [in] input Input tensor data, Implementations must support input tensor data type <tt>\ref VX_TYPE_INT16</tt> with fixed_point_position 8,
* and tensor data types <tt>\ref VX_TYPE_UINT8</tt> and <tt>\ref VX_TYPE_INT8</tt>, with fixed_point_position 0.
* \param [out] output output tensor data,
* \param [in] dimension1 Dimension index that is transposed with dim 2.
* \param [in] dimension2 Dimension index that is transposed with dim 1.
* \ingroup group_vision_function_tensor_transpose
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuTensorTranspose(vx_context context, vx_tensor input, vx_tensor output, vx_size dimension1, vx_size dimension2);
/*! \brief [Immediate] Performs a bit-depth conversion.
* \param [in] context The reference to the overall context.
* \param [in] input The input tensor. Implementations must support input tensor data type <tt>\ref VX_TYPE_INT16</tt> with fixed_point_position 8,
* and tensor data types <tt>\ref VX_TYPE_UINT8</tt> and <tt>\ref VX_TYPE_INT8</tt>, with fixed_point_position 0.
* \param [in] policy A <tt>\ref VX_TYPE_ENUM</tt> of the <tt>\ref vx_convert_policy_e</tt> enumeration.
* \param [in] norm A scalar containing a <tt>\ref VX_TYPE_FLOAT32</tt> of the normalization value.
* \param [in] offset A scalar containing a <tt>\ref VX_TYPE_FLOAT32</tt> of the offset value subtracted before normalization.
* \param [out] output The output tensor. Implementations must support input tensor data type <tt>VX_TYPE_INT16</tt>. with fixed_point_position 8.
* And <tt>VX_TYPE_UINT8</tt> with fixed_point_position 0.
* \ingroup group_vision_function_tensor_convert_depth
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuTensorConvertDepth(vx_context context, vx_tensor input, vx_enum policy, vx_scalar norm, vx_scalar offset, vx_tensor output);
/*! \brief [Immediate] Performs a generalized matrix multiplication.
* \param [in] context The reference to the overall context.
* \param [in] input1 The first input 2D tensor of type <tt>\ref VX_TYPE_INT16</tt> with fixed_point_pos 8, or tensor data types <tt>\ref VX_TYPE_UINT8</tt> or <tt>\ref VX_TYPE_INT8</tt>, with fixed_point_pos 0.
* \param [in] input2 The second 2D tensor. Must be in the same data type as input1.
* \param [in] input3 The third 2D tensor. Must be in the same data type as input1. [optional].
* \param [in] matrix_multiply_params Matrix multiply parameters, see <tt>\ref vx_tensor_matrix_multiply_params_t </tt>.
* \param [out] output The output 2D tensor. Must be in the same data type as input1. Output dimension must agree the formula in the description.
* \ingroup group_vision_function_tensor_matrix_multiply
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
*/
VX_API_ENTRY vx_status VX_API_CALL vxuTensorMatrixMultiply(vx_context context, vx_tensor input1, vx_tensor input2, vx_tensor input3,
const vx_tensor_matrix_multiply_params_t *matrix_multiply_params, vx_tensor output);
/*! \brief [Immediate] Copy data from one object to another.
* \param [in] context The reference to the overall context.
* \param [in] input The input data object.
* \param [out] output The output data object.
* \return A <tt>\ref vx_status_e</tt> enumeration.
* \retval VX_SUCCESS Success
* \retval * An error occurred. See <tt>\ref vx_status_e</tt>.
* \ingroup group_vision_function_copy
*/
VX_API_ENTRY vx_status VX_API_CALL vxuCopy(vx_context context, vx_reference input, vx_reference output);
#ifdef __cplusplus
}
#endif
#endif

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1 @@
libOpenVX.so.1.3.0

View File

@ -0,0 +1 @@
libOpenVX.so.1.3.0

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

13
samples/lenet/BUILD Normal file
View File

@ -0,0 +1,13 @@
cc_test(
name = "lenet_asymu8_cc",
copts = [
"-Werror", "-std=c++14"
],
srcs = [
"lenet_asymu8.cc",
"lenet_asymu8_weights.h"
],
deps = [
"//:tim-vx_interface"
],
)

View File

@ -0,0 +1,316 @@
/****************************************************************************
*
* 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 <algorithm>
#include <iomanip>
#include <iostream>
#include <tuple>
#include <vector>
#include "lenet_asymu8_weights.h"
#include "tim/vx/context.h"
#include "tim/vx/graph.h"
#include "tim/vx/operation.h"
#include "tim/vx/ops/activations.h"
#include "tim/vx/ops/conv2d.h"
#include "tim/vx/ops/fullyconnected.h"
#include "tim/vx/ops/pool2d.h"
#include "tim/vx/ops/softmax.h"
#include "tim/vx/tensor.h"
std::vector<uint8_t> input_data = {
0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 2, 0, 0, 8, 0,
3, 0, 7, 0, 2, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 3, 1, 1, 0, 14, 0, 0, 3, 0,
2, 4, 0, 0, 0, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 4, 3, 0, 0, 0, 5, 0, 4, 0, 0,
0, 0, 10, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 6, 5, 0, 2, 0, 9, 0, 12, 2, 0, 5, 1, 0,
0, 2, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3, 0, 33, 0, 0, 155, 186, 55, 17, 22, 0, 0, 3, 9, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2, 0, 167, 253, 255, 235, 255, 240, 134, 36, 0, 6, 1, 4, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 6, 87,
240, 251, 254, 254, 237, 255, 252, 191, 27, 0, 0, 5, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 19, 226, 255, 235,
255, 255, 254, 242, 255, 255, 68, 12, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 4, 1, 58, 254, 255, 158, 0, 2,
47, 173, 253, 247, 255, 65, 4, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 162, 240, 248, 92, 8, 0, 13, 0,
88, 249, 244, 148, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 17, 64, 244, 255, 210, 0, 0, 1, 2, 0, 52, 223,
255, 223, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 144, 245, 255, 142, 0, 4, 9, 0, 6, 0, 37, 222, 226,
42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 73,
255, 243, 104, 0, 0, 0, 0, 11, 0, 0, 0, 235, 242, 101, 4,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 133, 245, 226,
12, 4, 15, 0, 0, 0, 0, 24, 0, 235, 246, 41, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 236, 245, 152, 0, 10,
0, 0, 0, 0, 6, 0, 28, 227, 239, 1, 6, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 227, 240, 53, 4, 0, 0, 24,
0, 1, 0, 8, 181, 249, 177, 0, 2, 0, 0, 0, 0, 4, 0,
6, 1, 5, 0, 0, 87, 246, 219, 14, 0, 0, 2, 0, 10, 7,
0, 134, 255, 249, 104, 4, 0, 0, 0, 0, 0, 8, 0, 3, 0,
0, 0, 4, 89, 255, 228, 0, 11, 0, 8, 14, 0, 0, 100, 250,
248, 236, 0, 0, 8, 0, 0, 0, 0, 5, 0, 2, 0, 0, 2,
6, 68, 250, 228, 6, 6, 0, 0, 1, 0, 140, 240, 253, 238, 51,
31, 0, 3, 0, 0, 0, 0, 0, 0, 5, 0, 0, 2, 0, 26,
215, 255, 119, 0, 21, 1, 40, 156, 233, 244, 239, 103, 0, 6, 6,
0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 225, 251,
240, 141, 118, 139, 222, 244, 255, 249, 112, 17, 0, 0, 8, 3, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 84, 245, 255, 247,
255, 249, 255, 255, 249, 132, 11, 0, 9, 3, 1, 1, 0, 0, 0,
0, 2, 0, 0, 1, 0, 0, 6, 1, 0, 166, 236, 255, 255, 248,
249, 248, 72, 0, 0, 16, 0, 16, 0, 4, 0, 0, 0, 0, 0,
0, 0, 6, 0, 0, 4, 0, 0, 20, 106, 126, 188, 190, 112, 28,
0, 21, 0, 1, 2, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
};
template <typename T>
static void printTopN(const T* prob, int outputCount, int topNum) {
std::vector<std::tuple<int, T>> data;
for (int i = 0; i < outputCount; i++) {
data.push_back(std::make_tuple(i, prob[i]));
}
std::sort(data.begin(), data.end(),
[](auto& a, auto& b) { return std::get<1>(a) > std::get<1>(b); });
std::cout << " --- Top" << topNum << " ---" << std::endl;
for (int i = 0; i < topNum; i++) {
std::cout << std::setw(3) << std::get<0>(data[i]) << ": " << std::fixed
<< std::setprecision(6) << std::get<1>(data[i]) << std::endl;
}
}
int main(int argc, char** argv) {
auto context = tim::vx::Context::Create();
auto graph = context->CreateGraph();
tim::vx::ShapeType input_shape({28, 28, 1, 1});
tim::vx::Quantization input_quant(tim::vx::QuantType::ASYMMETRIC, 0.00390625f,
0);
tim::vx::TensorSpec input_spec(tim::vx::DataType::UINT8, input_shape,
tim::vx::TensorAttribute::INPUT, input_quant);
auto input = graph->CreateTensor(input_spec);
tim::vx::ShapeType conv1_weight_shape({5, 5, 1, 20});
tim::vx::Quantization conv1_weighteight_quant(tim::vx::QuantType::ASYMMETRIC,
0.00336234f, 119);
tim::vx::TensorSpec conv1_weighteight_spec(
tim::vx::DataType::UINT8, conv1_weight_shape,
tim::vx::TensorAttribute::CONSTANT, conv1_weighteight_quant);
auto conv1_weight =
graph->CreateTensor(conv1_weighteight_spec, &lenet_weights[0]);
tim::vx::ShapeType conv1_bias_shape({20});
tim::vx::Quantization conv1_bias_quant(tim::vx::QuantType::ASYMMETRIC,
1.313e-05f, 0);
tim::vx::TensorSpec conv1_bias_spec(
tim::vx::DataType::INT32, conv1_bias_shape,
tim::vx::TensorAttribute::CONSTANT, conv1_bias_quant);
auto conv1_bias = graph->CreateTensor(conv1_bias_spec, &lenet_weights[500]);
tim::vx::Quantization conv1_output_quant(tim::vx::QuantType::ASYMMETRIC,
0.01928069f, 140);
tim::vx::TensorSpec conv1_output_spec(tim::vx::DataType::UINT8, {},
tim::vx::TensorAttribute::TRANSIENT,
conv1_output_quant);
auto conv1_output = graph->CreateTensor(conv1_output_spec);
tim::vx::Quantization pool1_output_quant(tim::vx::QuantType::ASYMMETRIC,
0.01928069f, 140);
tim::vx::TensorSpec pool1_output_spec(tim::vx::DataType::UINT8, {},
tim::vx::TensorAttribute::TRANSIENT,
pool1_output_quant);
auto pool1_output = graph->CreateTensor(pool1_output_spec);
tim::vx::ShapeType conv2_weight_shape({5, 5, 20, 50});
tim::vx::Quantization conv2_weight_quant(tim::vx::QuantType::ASYMMETRIC,
0.0011482f, 128);
tim::vx::TensorSpec conv2_weight_spec(
tim::vx::DataType::UINT8, conv2_weight_shape,
tim::vx::TensorAttribute::CONSTANT, conv2_weight_quant);
auto conv2_weight =
graph->CreateTensor(conv2_weight_spec, &lenet_weights[580]);
tim::vx::ShapeType conv2_bias_shape({50});
tim::vx::Quantization conv2_bias_quant(tim::vx::QuantType::ASYMMETRIC,
2.214e-05f, 0);
tim::vx::TensorSpec conv2_bias_spec(
tim::vx::DataType::INT32, conv2_bias_shape,
tim::vx::TensorAttribute::CONSTANT, conv2_bias_quant);
auto conv2_bias = graph->CreateTensor(conv2_bias_spec, &lenet_weights[25580]);
tim::vx::Quantization conv2_output_quant(tim::vx::QuantType::ASYMMETRIC,
0.04075872f, 141);
tim::vx::TensorSpec conv2_output_spec(tim::vx::DataType::UINT8, {},
tim::vx::TensorAttribute::TRANSIENT,
conv2_output_quant);
auto conv2_output = graph->CreateTensor(conv2_output_spec);
tim::vx::Quantization pool2_output_quant(tim::vx::QuantType::ASYMMETRIC,
0.04075872f, 141);
tim::vx::TensorSpec pool2_output_spec(tim::vx::DataType::UINT8, {},
tim::vx::TensorAttribute::TRANSIENT,
pool2_output_quant);
auto pool2_output = graph->CreateTensor(pool2_output_spec);
tim::vx::ShapeType fc3_weight_shape({800, 500});
tim::vx::Quantization fc3_weight_quant(tim::vx::QuantType::ASYMMETRIC,
0.00073548f, 130);
tim::vx::TensorSpec fc3_weight_spec(
tim::vx::DataType::UINT8, fc3_weight_shape,
tim::vx::TensorAttribute::CONSTANT, fc3_weight_quant);
auto fc3_weight = graph->CreateTensor(fc3_weight_spec, &lenet_weights[25780]);
tim::vx::ShapeType fc3_bias_shape({500});
tim::vx::Quantization fc3_bias_quant(tim::vx::QuantType::ASYMMETRIC,
2.998e-05f, 0);
tim::vx::TensorSpec fc3_bias_spec(tim::vx::DataType::INT32, fc3_bias_shape,
tim::vx::TensorAttribute::CONSTANT,
fc3_bias_quant);
auto fc3_bias = graph->CreateTensor(fc3_bias_spec, &lenet_weights[425780]);
tim::vx::Quantization fc3_output_quant(tim::vx::QuantType::ASYMMETRIC,
0.01992089f, 0);
tim::vx::TensorSpec fc3_output_spec(tim::vx::DataType::UINT8, {},
tim::vx::TensorAttribute::TRANSIENT,
fc3_output_quant);
auto fc3_output = graph->CreateTensor(fc3_output_spec);
tim::vx::Quantization relu_output_quant(tim::vx::QuantType::ASYMMETRIC,
0.01992089f, 0);
tim::vx::TensorSpec relu_output_spec(tim::vx::DataType::UINT8, {},
tim::vx::TensorAttribute::TRANSIENT,
relu_output_quant);
auto relu_output = graph->CreateTensor(relu_output_spec);
tim::vx::ShapeType fc4_weight_shape({500, 10});
tim::vx::Quantization fc4_weight_quant(tim::vx::QuantType::ASYMMETRIC,
0.00158043f, 135);
tim::vx::TensorSpec fc4_weight_spec(
tim::vx::DataType::UINT8, fc4_weight_shape,
tim::vx::TensorAttribute::CONSTANT, fc4_weight_quant);
auto fc4_weight =
graph->CreateTensor(fc4_weight_spec, &lenet_weights[427780]);
tim::vx::ShapeType fc4_bias_shape({10});
tim::vx::Quantization fc4_bias_quant(tim::vx::QuantType::ASYMMETRIC,
3.148e-05f, 0);
tim::vx::TensorSpec fc4_bias_spec(tim::vx::DataType::INT32, fc4_bias_shape,
tim::vx::TensorAttribute::CONSTANT,
fc4_bias_quant);
auto fc4_bias = graph->CreateTensor(fc4_bias_spec, &lenet_weights[432780]);
tim::vx::Quantization fc4_output_quant(tim::vx::QuantType::ASYMMETRIC,
0.06251489f, 80);
tim::vx::TensorSpec fc4_output_spec(tim::vx::DataType::UINT8, {},
tim::vx::TensorAttribute::TRANSIENT,
fc4_output_quant);
auto fc4_output = graph->CreateTensor(fc4_output_spec);
tim::vx::ShapeType output_shape({10, 1});
tim::vx::TensorSpec output_spec(tim::vx::DataType::FLOAT32, output_shape,
tim::vx::TensorAttribute::OUTPUT);
auto output = graph->CreateTensor(output_spec);
auto conv1 = graph->CreateOperation<tim::vx::ops::Conv2d>(
conv1_weight_shape[3], tim::vx::PadType::VALID,
std::array<uint32_t, 2>({5, 5}), std::array<uint32_t, 2>({1, 1}),
std::array<uint32_t, 2>({1, 1}));
(*conv1)
.BindInputs({input, conv1_weight, conv1_bias})
.BindOutputs({conv1_output});
auto pool1 = graph->CreateOperation<tim::vx::ops::Pool2d>(
tim::vx::PoolType::MAX, tim::vx::PadType::NONE,
std::array<uint32_t, 2>({2, 2}), std::array<uint32_t, 2>({2, 2}));
(*pool1).BindInputs({conv1_output}).BindOutputs({pool1_output});
auto conv2 = graph->CreateOperation<tim::vx::ops::Conv2d>(
conv2_weight_shape[3], tim::vx::PadType::VALID,
std::array<uint32_t, 2>({5, 5}), std::array<uint32_t, 2>({1, 1}),
std::array<uint32_t, 2>({1, 1}));
(*conv2)
.BindInputs({pool1_output, conv2_weight, conv2_bias})
.BindOutputs({conv2_output});
auto pool2 = graph->CreateOperation<tim::vx::ops::Pool2d>(
tim::vx::PoolType::MAX, tim::vx::PadType::NONE,
std::array<uint32_t, 2>({2, 2}), std::array<uint32_t, 2>({2, 2}));
(*pool2).BindInputs({conv2_output}).BindOutputs({pool2_output});
auto fc3 = graph->CreateOperation<tim::vx::ops::FullyConnected>(
2, fc3_weight_shape[1]);
(*fc3)
.BindInputs({pool2_output, fc3_weight, fc3_bias})
.BindOutputs({fc3_output});
auto relu = graph->CreateOperation<tim::vx::ops::Relu>();
(*relu).BindInput(fc3_output).BindOutput(relu_output);
auto fc4 = graph->CreateOperation<tim::vx::ops::FullyConnected>(
0, fc4_weight_shape[1]);
(*fc4)
.BindInputs({relu_output, fc4_weight, fc4_bias})
.BindOutputs({fc4_output});
auto softmax = graph->CreateOperation<tim::vx::ops::Softmax>(1.0f, 0);
(*softmax).BindInput(fc4_output).BindOutput(output);
if (!graph->Compile()) {
std::cout << "Compile graph fail." << std::endl;
return -1;
}
if (!input->CopyDataToTensor(input_data.data(), input_data.size())) {
std::cout << "Copy input data fail." << std::endl;
return -1;
}
if (!graph->Run()) {
std::cout << "Run graph fail." << std::endl;
return -1;
}
std::vector<float> output_data;
output_data.resize(1 * 10);
if (!output->CopyDataFromTensor(output_data.data())) {
std::cout << "Copy output data fail." << std::endl;
return -1;
}
printTopN(output_data.data(), output_data.size(), 5);
return 0;
}

File diff suppressed because it is too large Load Diff

53
src/tim/vx/context.cc Normal file
View File

@ -0,0 +1,53 @@
/****************************************************************************
*
* 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/context.h"
#include "context_private.h"
#include "graph_private.h"
#include "tim/vx/graph.h"
#include "vsi_nn_pub.h"
namespace tim {
namespace vx {
ContextImpl::ContextImpl() : context_(vsi_nn_CreateContext()) {}
ContextImpl::~ContextImpl() {
if (context_) {
vsi_nn_ReleaseContext(&context_);
}
}
vsi_nn_context_t ContextImpl::context() { return context_; }
std::shared_ptr<Context> Context::Create() {
return std::make_shared<ContextImpl>();
}
std::shared_ptr<Graph> ContextImpl::CreateGraph() {
return std::make_shared<GraphImpl>(this);
}
} // namespace vx
} // namespace tim

View File

@ -0,0 +1,46 @@
/****************************************************************************
*
* 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 TIM_VX_CONTEXT_PRIVATE_H_
#define TIM_VX_CONTEXT_PRIVATE_H_
#include "tim/vx/context.h"
#include "vsi_nn_pub.h"
namespace tim {
namespace vx {
class ContextImpl : public Context {
public:
ContextImpl();
~ContextImpl();
vsi_nn_context_t context();
std::shared_ptr<Graph> CreateGraph();
protected:
vsi_nn_context_t context_;
};
} // namespace vx
} // namespace tim
#endif /* TIM_VX_CONTEXT_PRIVATE_H_ */

90
src/tim/vx/graph.cc Normal file
View File

@ -0,0 +1,90 @@
/****************************************************************************
*
* 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/graph.h"
#include <algorithm>
#include "context_private.h"
#include "graph_private.h"
#include "tensor_private.h"
#include "tim/vx/context.h"
#include "vsi_nn_pub.h"
namespace tim {
namespace vx {
GraphImpl::GraphImpl(ContextImpl* context)
: context_(context),
graph_(vsi_nn_CreateGraph(context_->context(), 0, 0)),
tensor_placeholder_(nullptr),
compiled_(false) {}
GraphImpl::~GraphImpl() { vsi_nn_ReleaseGraph(&graph_); }
vsi_nn_graph_t* GraphImpl::graph() { return graph_; }
void GraphImpl::AddInput(vsi_nn_tensor_id_t id) {
if (inputs_.end() == std::find(inputs_.begin(), inputs_.end(), id)) {
inputs_.push_back(id);
}
}
void GraphImpl::AddOutput(vsi_nn_tensor_id_t id) {
if (outputs_.end() == std::find(outputs_.begin(), outputs_.end(), id)) {
outputs_.push_back(id);
}
}
std::shared_ptr<Tensor> GraphImpl::CreateTensor(const TensorSpec& spec,
const void* data) {
return std::make_shared<TensorImpl>(this, spec, data);
}
std::shared_ptr<Tensor> GraphImpl::CreateTensorPlaceHolder() {
if (!tensor_placeholder_) {
tensor_placeholder_ = std::make_shared<TensorPlaceholder>(this);
}
return tensor_placeholder_;
}
bool GraphImpl::Compile() {
compiled_ = true;
vsi_nn_SetGraphInputs(graph_, inputs_.data(), inputs_.size());
vsi_nn_SetGraphOutputs(graph_, outputs_.data(), outputs_.size());
return (VSI_SUCCESS == vsi_nn_SetupGraph(graph_, true) &&
VSI_SUCCESS == vsi_nn_VerifyGraph(graph_));
}
bool GraphImpl::Run() {
if (!compiled_ && !Compile()) {
return false;
}
return (VSI_SUCCESS == vsi_nn_RunGraph(graph_));
}
} // namespace vx
} // namespace tim

View File

@ -0,0 +1,65 @@
/****************************************************************************
*
* 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 TIM_VX_GRAPH_PRIVATE_H_
#define TIM_VX_GRAPH_PRIVATE_H_
#include <vector>
#include "context_private.h"
#include "tim/vx/graph.h"
#include "vsi_nn_pub.h"
namespace tim {
namespace vx {
class GraphImpl : public Graph {
public:
GraphImpl(ContextImpl* context);
~GraphImpl();
/// Return the low-level graph object
vsi_nn_graph_t* graph();
void AddInput(vsi_nn_tensor_id_t id);
void AddOutput(vsi_nn_tensor_id_t id);
/// Implement parents' virtual functions
std::shared_ptr<Tensor> CreateTensor(const TensorSpec& spec,
const void* data = nullptr);
std::shared_ptr<Tensor> CreateTensorPlaceHolder();
bool Compile();
bool Run();
protected:
ContextImpl* context_;
vsi_nn_graph_t* graph_;
std::shared_ptr<Tensor> tensor_placeholder_;
bool compiled_;
std::vector<vsi_nn_tensor_id_t> inputs_;
std::vector<vsi_nn_tensor_id_t> outputs_;
};
} // namespace vx
} // namespace tim
#endif /* TIM_VX_GRAPH_PRIVATE_H_ */

View File

@ -0,0 +1,26 @@
#
# Copyright (C) 2018 The Android Open Source Project
#
# 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
#
# http://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.
#
BasedOnStyle: Google
CommentPragmas: NOLINT:.*
DerivePointerAlignment: false
AllowShortFunctionsOnASingleLine: Inline
ColumnLimit: 80
TabWidth: 4
UseTab: Never
IndentWidth: 4
BinPackArguments: false
BinPackParameters: false

338
src/tim/vx/internal/.gitignore vendored Normal file
View File

@ -0,0 +1,338 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
*-[Dd]ebug/
*-[Dd]ebugPublic/
*-[Rr]elease/
*-[Rr]eleases/
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
.bazelrc
.config_wksp.bzl
# Build results
*.o
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
NNApi0.3/
NNApi0.4/
OpenVX1.2/
lib/
bazel-bin
bazel-genfiles
bazel-out
bazel-ovxlib
bazel-testlogs
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# VS code
.vscode
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
**/Properties/launchSettings.json
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# TypeScript v1 declaration files
typings/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# IDE
.settings/

223
src/tim/vx/internal/BUILD Normal file
View File

@ -0,0 +1,223 @@
# Description:
# VSI OVX wrapper logic
package(
default_visibility = ["//visibility:public"],
features = ["-parse_headers"],
)
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
filegroup(
name = "all_files",
srcs = glob(
["**/*"],
exclude = [
"**/METADATA",
"**/OWNERS",
"external/*"
],
),
)
filegroup(
name = "kernel_hdrs",
srcs = glob([
"include/kernel/cl/*.h",
"include/kernel/evis/*.h",
"include/kernel/cpu/*.h",
])
)
filegroup(
name = "kernel_srcs",
srcs = glob([
"src/kernel/cl/*.c",
"src/kernel/evis/*.c",
"src/kernel/cpu/*.c",
"src/kernel/vx/*.c",
])
)
filegroup(
name = "operation_srcs",
srcs = glob([
"src/ops/*.c",
])
)
filegroup(
name = "operation_hdrs",
srcs = glob([
"include/ops/*.h",
])
)
filegroup(
name = "custom_hdrs",
srcs = glob([
"include/custom/ops/*.h",
]) + [
#custom
"include/custom/custom_node_type.def",
"include/custom/custom_ops.def",
"include/custom/vsi_nn_custom_node_type.h",
]
)
filegroup(
name = "custom_srcs",
srcs = glob([
"src/custom/ops/*.c",
"src/custom/ops/kernel/*.c",
])
)
cc_library(
name = "ovxlibimpl",
copts = [
"-Werror", "-Wmisleading-indentation",
"-fvisibility=hidden", '-DOVXLIB_API=__attribute__((visibility(\\"default\\")))',
],
linkopts = ["-ldl", "-lm"],
alwayslink=True,
linkstatic = True,
includes = [
"include",
],
hdrs = [
"include/vsi_nn_pub.h",
"include/vsi_nn_ops.h",
"include/vsi_nn_log.h",
"include/vsi_nn_context.h",
"include/vsi_nn_node_attr_template.h",
"include/vsi_nn_tensor.h",
"include/vsi_nn_prv.h",
"include/vsi_nn_types.h",
"include/vsi_nn_node.h",
"include/vsi_nn_node_type.h",
"include/vsi_nn_client_op.h",
"include/vsi_nn_graph.h",
"include/vsi_nn_test.h",
"include/vsi_nn_tensor_util.h",
"include/vsi_nn_version.h",
"include/vsi_nn_compatibility.h",
"include/vsi_nn_assert.h",
"include/vsi_nn_feature.h",
"include/vsi_nn_rnn.h",
"include/vsi_nn_rnn_helper.h",
"include/vsi_nn_rnn_prv.h",
"include/vsi_nn_internal_node.h",
"include/vsi_nn_daemon.h",
"include/vsi_nn_pre_post_process.h",
"include/vsi_nn_graph_optimization.h",
"include/utils/vsi_nn_link_list.h",
"include/utils/vsi_nn_math.h",
"include/utils/vsi_nn_util.h",
"include/utils/vsi_nn_code_generator.h",
"include/utils/vsi_nn_binary_tree.h",
"include/utils/vsi_nn_map.h",
"include/utils/vsi_nn_hashmap.h",
"include/utils/vsi_nn_limits.h",
"include/utils/vsi_nn_dtype_util.h",
"include/utils/vsi_nn_dtype_util_prv.h",
"include/utils/vsi_nn_vdata.h",
"include/utils/vsi_nn_tensor_op.h",
"include/utils/vsi_nn_shape_util.h",
"include/utils/vsi_nn_constraint_check.h",
"include/quantization/vsi_nn_asymmetric_affine.h",
"include/quantization/vsi_nn_dynamic_fixed_point.h",
"include/quantization/vsi_nn_perchannel_symmetric_affine.h",
"include/client/vsi_nn_vxkernel.h",
"include/interface/ops.def",
"include/kernel/vsi_nn_kernel.h",
"include/kernel/vsi_nn_gpu.h",
"include/kernel/vsi_nn_gpu_config.h",
"include/kernel/vsi_nn_kernel_eltwise.h",
"include/kernel/vsi_nn_kernel_node.h",
"include/kernel/vsi_nn_kernel_gpu_shape_optimize.h",
"include/vsi_nn_error.h",
# libnnext
"include/libnnext/vx_lib_nnext.h",
"include/libnnext/vsi_nn_libnnext_resource.h",
#internal
"include/internal/internal_ops.def",
"include/vsi_nn_feature_config.h"
] + [":kernel_hdrs"]
+ [":operation_hdrs"]
+ [":custom_hdrs"]
+ [
"include/vsi_nn_platform.h",
],
srcs = [
"src/vsi_nn_graph.c",
"src/vsi_nn_ops.c",
"src/vsi_nn_context.c",
"src/vsi_nn_node.c",
"src/vsi_nn_tensor.c",
"src/vsi_nn_client_op.c",
"src/vsi_nn_node_attr_template.c",
"src/vsi_nn_version.c",
"src/vsi_nn_rnn.c",
"src/vsi_nn_rnn_helper.c",
"src/vsi_nn_log.c",
"src/vsi_nn_internal_node.c",
"src/vsi_nn_daemon.c",
"src/vsi_nn_graph_optimization.c",
"src/vsi_nn_pre_post_process.c",
"src/client/vsi_nn_vxkernel.c",
"src/utils/vsi_nn_link_list.c",
"src/utils/vsi_nn_util.c",
"src/utils/vsi_nn_math.c",
"src/utils/vsi_nn_code_generator.c",
"src/utils/vsi_nn_binary_tree.c",
"src/utils/vsi_nn_map.c",
"src/utils/vsi_nn_hashmap.c",
"src/utils/vsi_nn_limits.c",
"src/utils/vsi_nn_dtype_util.c",
"src/utils/vsi_nn_vdata.c",
"src/utils/vsi_nn_tensor_op.c",
"src/utils/vsi_nn_shape_util.c",
"src/utils/vsi_nn_dtype.c",
"src/utils/vsi_nn_constraint_check.c",
"src/quantization/vsi_nn_asymmetric_affine.c",
"src/quantization/vsi_nn_dynamic_fixed_point.c",
"src/quantization/vsi_nn_perchannel_symmetric_affine.c",
"src/kernel/vsi_nn_kernel.c",
"src/kernel/vsi_nn_kernel_util.c",
"src/kernel/vsi_nn_kernel_backend.c",
"src/kernel/vsi_nn_kernel_eltwise.c",
"src/kernel/vsi_nn_kernel_selector.c",
"src/kernel/vsi_nn_kernel_node.c",
"src/kernel/vsi_nn_kernel_param.c",
"src/kernel/vsi_nn_gpu.c",
"src/kernel/vsi_nn_kernel_gpu_shape_optimize.c",
"src/libnnext/ops/kernel/vsi_nn_kernel_crop.c",
"src/libnnext/ops/kernel/vsi_nn_kernel_fullconnect2.c",
"src/libnnext/ops/kernel/vsi_nn_kernel_shufflechannel.c",
"src/libnnext/ops/kernel/vsi_nn_kernel_resize.c",
"src/libnnext/ops/kernel/vsi_nn_kernel_scale.c",
"src/libnnext/ops/kernel/vsi_nn_kernel_space2depth.c",
"src/libnnext/ops/kernel/vsi_nn_kernel_imageprocess.c",
"src/libnnext/ops/kernel/vsi_nn_kernel_layernormalize.c",
"src/libnnext/ops/kernel/vsi_nn_kernel_reduce.c",
"src/libnnext/ops/kernel/vsi_nn_kernel_signalframe.c",
"src/libnnext/ops/kernel/vsi_nn_kernel_tensorstackconcat.c",
"src/libnnext/ops/kernel/vsi_nn_kernel_sync_host.c",
"src/libnnext/ops/kernel/vsi_nn_kernel_spatial_transformer.c",
"src/libnnext/ops/kernel/vsi_nn_kernel_extra_ending.c",
"src/libnnext/ops/kernel/vsi_nn_kernel_topk.c",
"src/libnnext/ops/kernel/vsi_nn_kernel_roi_align.c",
"src/libnnext/ops/kernel/vsi_nn_kernel_heatmap_max_keypoint.c",
"src/libnnext/ops/kernel/vsi_nn_kernel_axis_aligned_bbox_transform.c",
"src/libnnext/ops/kernel/vsi_nn_kernel_box_with_nms_limit.c",
"src/libnnext/ops/kernel/vsi_nn_kernel_generate_proposals.c",
"src/libnnext/vsi_nn_libnnext_resource.c",
] + [":kernel_srcs"]
+ [":operation_srcs"]
+ [":custom_srcs"],
deps = ["//prebuilt-sdk:VIV_SDK_LIB"]
)

View File

@ -0,0 +1,132 @@
/****************************************************************************
*
* 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 _VSI_NN_VXKERNEL_H
#define _VSI_NN_VXKERNEL_H
#include "vsi_nn_types.h"
#include "vsi_nn_platform.h"
#include "vsi_nn_graph.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum _vx_kernel_type_e
{
VX_KERNEL_TYPE_CPU,
VX_KERNEL_TYPE_VX,
VX_KERNEL_TYPE_BIN
} vx_kernel_type_e;
typedef struct vsi_nn_kernel_info
{
char **resource_name;
uint8_t resource_num;
vx_kernel_type_e type;
vx_kernel_description_t ** kernel;
uint8_t kernel_index;
uint8_t init_index;
} vsi_nn_kernel_info_t;
uint8_t * vsi_nn_LoadBinarySource
(
uint8_t * file,
int32_t * sz
);
vsi_status vsi_nn_RegisterClientKernel
(
vsi_nn_graph_t * graph,
vsi_nn_kernel_info_t * kernel_info
);
/*
* Deprecated(vsi_nn_RegisterClientKernelAndCreateNode): use vsi_nn_RegisterClientKernelAndNewNode() insteatd.
*/
OVXLIB_API vx_node vsi_nn_RegisterClientKernelAndCreateNode
(
vsi_nn_graph_t * graph,
vx_kernel_description_t * kernel
);
OVXLIB_API vx_node vsi_nn_RegisterClientKernelAndNewNode
(
vsi_nn_graph_t * graph,
vsi_nn_kernel_info_t * kernel_info
);
OVXLIB_API vsi_status vsi_nn_ClientNodePassParameters
(
vx_node node,
vx_reference * params,
uint32_t num
);
OVXLIB_API vsi_status VX_CALLBACK vsi_nn_KernelValidator
(
vx_node node,
const vx_reference parameters[],
uint32_t num,
vx_meta_format metas[]
);
OVXLIB_API vsi_status VX_CALLBACK vsi_nn_KernelInitializer
(
vx_node nodObj,
const vx_reference *paramObj,
uint32_t paraNum
);
OVXLIB_API vsi_status VX_CALLBACK vsi_nn_KernelDeinitializer
(
vx_node nodObj,
const vx_reference *paraObj,
uint32_t paraNum
);
OVXLIB_API const char * vsi_nn_VxResourceGetPath();
OVXLIB_API void vsi_nn_VxResourceSetPath
(
char* path
);
OVXLIB_API const uint8_t * vsi_nn_VxBinResourceGetResource
(
char* name,
vx_size *len
);
OVXLIB_API vx_kernel_type_e vsi_nn_GetVXKernelTypeForShader();
OVXLIB_API vx_bool vsi_nn_is_do_vx_op_pre_init
(
vx_kernel_type_e type
);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,4 @@
/*
custom op data struct def
*/
DEF_NODE_TYPE(custom_softmax)

View File

@ -0,0 +1,4 @@
/*
Add custom ops to the end.
*/
DEF_OP(CUSTOM_SOFTMAX)

View File

@ -0,0 +1,35 @@
/****************************************************************************
*
* 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 _VSI_NN_OP_CUSTOM_SOFTMAX_H
#define _VSI_NN_OP_CUSTOM_SOFTMAX_H
#include "vsi_nn_platform.h"
#include "vsi_nn_types.h"
typedef struct _vsi_nn_custom_softmax_param
{
int32_t axis;
} vsi_nn_custom_softmax_param;
#endif

View File

@ -0,0 +1,31 @@
/****************************************************************************
*
* 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 _VSI_NN_CUSTOM_NODE_TYPE_H_
#define _VSI_NN_CUSTOM_NODE_TYPE_H_
/*
custom op head files
*/
#include "custom/ops/vsi_nn_op_custom_softmax.h"
#endif

View File

@ -0,0 +1,146 @@
/*
Add new ops to the end.
*/
DEF_OP(ADD)
DEF_OP(MULTIPLY)
DEF_OP(CONV2D)
DEF_OP(CONV_RELU)
DEF_OP(CONV_RELU_POOL)
DEF_OP(FCL)
DEF_OP(FCL_RELU)
DEF_OP(SOFTMAX)
DEF_OP(POOL)
DEF_OP(LEAKY_RELU)
DEF_OP(LRN)
DEF_OP(CONCAT)
DEF_OP(SPLIT)
DEF_OP(NOOP)
DEF_OP(ROI_POOL)
DEF_OP(BATCH_NORM)
DEF_OP(PROPOSAL)
DEF_OP(DECONVOLUTION)
DEF_OP(RESHAPE)
DEF_OP(PERMUTE)
DEF_OP(PRELU)
DEF_OP(UPSAMPLE)
DEF_OP(RELU)
DEF_OP(RELUN)
DEF_OP(LSTM)
DEF_OP(REORG)
DEF_OP(VARIABLE)
DEF_OP(L2_NORMALIZE)
DEF_OP(FCL2)
DEF_OP(POOLWITHARGMAX)
DEF_OP(ARGMAX)
DEF_OP(MAXIMUM)
DEF_OP(L2NORMALIZESCALE)
DEF_OP(CROP)
DEF_OP(SUBTRACT)
DEF_OP(RELU6)
DEF_OP(SIGMOID)
DEF_OP(TANH)
DEF_OP(SQRT)
DEF_OP(RSQRT)
DEF_OP(SOFTRELU)
DEF_OP(DIVIDE)
DEF_OP(DROPOUT)
DEF_OP(SHUFFLECHANNEL)
DEF_OP(RESIZE)
DEF_OP(REVERSE)
DEF_OP(DEPTH2SPACE)
DEF_OP(SPACE2DEPTH)
DEF_OP(DATACONVERT)
DEF_OP(SCALE)
DEF_OP(SLICE)
DEF_OP(ELU)
DEF_OP(BATCH2SPACE)
DEF_OP(SPACE2BATCH)
DEF_OP(PAD)
DEF_OP(IMAGEPROCESS)
DEF_OP(MATRIXMUL)
DEF_OP(LSTMUNIT)
DEF_OP(LAYER_NORM)
DEF_OP(REDUCE)
DEF_OP(INSTANCE_NORM)
DEF_OP(TENSORSTACKCONCAT)
DEF_OP(STRIDED_SLICE)
DEF_OP(SIGNAL_FRAME)
DEF_OP(A_TIMES_B_PLUS_C)
DEF_OP(SVDF)
DEF_OP(ABS)
DEF_OP(CONV1D)
DEF_OP(NBG)
DEF_OP(CONCATSHIFT)
DEF_OP(LRN2)
DEF_OP(RELATIONAL_OPS)
DEF_OP(SYNC_HOST)
DEF_OP(POW)
DEF_OP(FLOORDIV)
DEF_OP(MINIMUM)
DEF_OP(SPATIAL_TRANSFORMER)
DEF_OP(LOGICAL_OPS)
DEF_OP(SELECT)
DEF_OP(LSTMUNIT_ACTIVATION)
DEF_OP(LSTMUNIT_OVXLIB)
DEF_OP(TENSOR_ADD_MEAN_STDDEV_NORM)
DEF_OP(RELU1)
DEF_OP(STACK)
DEF_OP(FLOOR)
DEF_OP(SQUARE)
DEF_OP(NEG)
DEF_OP(EXP)
DEF_OP(LSTM_OVXLIB)
DEF_OP(PRE_PROCESS_TENSOR)
DEF_OP(HASHTABLE_LOOKUP)
DEF_OP(EMBEDDING_LOOKUP)
DEF_OP(LSH_PROJECTION)
DEF_OP(RNN)
DEF_OP(CLIP)
DEF_OP(POST_PROCESS)
DEF_OP(PRE_PROCESS_GRAY)
DEF_OP(UNSTACK)
DEF_OP(PRE_PROCESS_RGB)
DEF_OP(PRE_PROCESS)
DEF_OP(ADDN)
DEF_OP(PRE_PROCESS_YUV420)
DEF_OP(EXTRA_ENDING)
DEF_OP(GATHER)
DEF_OP(TILE)
DEF_OP(GROUPED_CONV2D)
DEF_OP(TOPK)
DEF_OP(PRE_PROCESS_BGRA)
DEF_OP(LOGICAL_NOT)
DEF_OP(SIN)
DEF_OP(LOG)
DEF_OP(ARGMIN)
DEF_OP(ROI_ALIGN)
DEF_OP(HEATMAP_MAX_KEYPOINT)
DEF_OP(AXIS_ALIGNED_BBOX_TRANSFORM)
DEF_OP(BOX_WITH_NMS_LIMIT)
DEF_OP(GENERATE_PROPOSALS)
DEF_OP(DETECTION_POSTPROCESS)
DEF_OP(RANDOM_MULTINOMIAL)
DEF_OP(LOG_SOFTMAX)
DEF_OP(RELU_KERAS)
DEF_OP(GRU_OVXLIB)
DEF_OP(GRUCELL_OVXLIB)
DEF_OP(UNIDIRECTIONAL_SEQUENCE_RNN)
DEF_OP(QUANTIZED_16BIT_LSTM)
DEF_OP(BIDIRECTIONAL_SEQUENCE_RNN)
DEF_OP(BIDIRECTIONAL_SEQUENCE_LSTM)
DEF_OP(RNNCELL_OVXLIB)
DEF_OP(SWISH)
DEF_OP(DEPTHWISE_CONV1D)
DEF_OP(GATHER_ND)
DEF_OP(CAST)
DEF_OP(LINEAR)
DEF_OP(BATCHNORM_SINGLE)
DEF_OP(MOMENTS)
DEF_OP(SQUEEZE)
DEF_OP(HARD_SIGMOID)
DEF_OP(MISH)
DEF_OP(EXPAND_BROADCAST)
DEF_OP(PRE_PROCESS_YUV444)
DEF_OP(PRE_PROCESS_NV12)
DEF_OP(SCATTER_ND)
DEF_OP(DECONVOLUTION1D)

View File

@ -0,0 +1,16 @@
/*
Add internal ops to the end.
*/
DEF_OP(SOFTMAX_INTERNAL)
DEF_OP(RELU_KERAS_INTERNAL)
DEF_OP(REDUCESUM_INTERNAL)
DEF_OP(REDUCEMAX_INTERNAL)
DEF_OP(REDUCEMIN_INTERNAL)
DEF_OP(REDUCEPROD_INTERNAL)
DEF_OP(REDUCEALL_INTERNAL)
DEF_OP(REDUCEANY_INTERNAL)
DEF_OP(RESIZE_INTERNAL)
DEF_OP(RESIZE_NEAREST_INTERNAL)
DEF_OP(DEPTH2SPACE_INTERNAL)
DEF_OP(GRUCELL_ACTIVATION_INTERNAL)
DEF_OP(GRUCELL_ACTIVATION_INTERNAL_SMA)

View File

@ -0,0 +1,100 @@
/****************************************************************************
*
* 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 _VSI_NN_GPU_H
#define _VSI_NN_GPU_H
#include "vsi_nn_gpu_config.h"
#define gpu_min(x, y) (((x) <= (y)) ? (x) : (y))
#define gpu_max(x, y) (((x) >= (y)) ? (x) : (y))
#define gpu_postshift( x ) (gpu_min( x, GPU_MAX_POST_SHIFT_BITS))
#define gpu_multiplier( x ) (gpu_min( x, GPU_MAX_MULTIPLIER_NUM))
// Alignment with a power of two value.
#define gpu_align_np2(n, align) (((n) + (align) - 1) - (((n) + (align) - 1) % (align)))
#define gpu_align_np2_safe(n, align) \
( \
(gpu_align_np2((n) & ~0ULL, (align) & ~0ULL) ^ gpu_align_np2(n, align)) ? \
(n) : gpu_align_np2(n, align) \
)
#define gpu_align_p2(n, align) ((n) + ((align) - 1)) & ~((align) - 1)
#define GPU_MAX_DIMENSION_SIZE (3)
typedef enum
{
GPU_DP_TYPE_16,
GPU_DP_TYPE_32,
} gpu_dp_type_e;
typedef struct
{
// 512 byte data
uint32_t data[16];
gpu_dp_type_e type;
} gpu_dp_inst_t;
typedef struct
{
uint32_t dim;
size_t global_offset[GPU_MAX_DIMENSION_SIZE];
size_t global_scale[GPU_MAX_DIMENSION_SIZE];
size_t local_size[GPU_MAX_DIMENSION_SIZE];
size_t global_size[GPU_MAX_DIMENSION_SIZE];
} gpu_param_t;
void gpu_dp_inst_update_postshfit
(
gpu_dp_inst_t * dp_inst,
int32_t shift
);
void gpu_dp_inst_update_multiplier
(
gpu_dp_inst_t * dp_inst,
int32_t start,
int32_t end,
int32_t multiplier
);
void gpu_quantize_multiplier_16bit
(
double double_multipier,
uint16_t * quantize_multiplier,
int32_t * shift
);
void gpu_quantize_multiplier_32bit
(
double double_multipier,
uint32_t * quantize_multiplier,
int32_t * shift
);
#endif

View File

@ -0,0 +1,34 @@
/****************************************************************************
*
* 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 _VSI_NN_GPU_CONFIG_H
#define _VSI_NN_GPU_CONFIG_H
#define GPU_TENSOR_MAX_WIDTH (65536)
#define GPU_MAX_MULTIPLIER_NUM (65535)
#define GPU_MAX_POST_SHIFT_BITS (31)
#define GPU_TENSOR_DIM_2 (2)
#endif

View File

@ -0,0 +1,908 @@
/****************************************************************************
*
* 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 _VSI_NN_KERNEL_H
#define _VSI_NN_KERNEL_H
#include <stdint.h>
#include "vsi_nn_log.h"
#include "vsi_nn_ops.h"
#include "vsi_nn_graph.h"
#include "vsi_nn_tensor.h"
#include "vsi_nn_daemon.h"
#include "vsi_nn_prv.h"
#include "utils/vsi_nn_util.h"
#include "utils/vsi_nn_shape_util.h"
#include "utils/vsi_nn_hashmap.h"
#include "utils/vsi_nn_math.h"
#include "kernel/vsi_nn_gpu.h"
#include "libnnext/vx_lib_nnext.h"
__BEGIN_DECLS
/** Kernel types */
typedef enum
{
VSI_NN_KERNEL_TYPE_CPU = 0,
VSI_NN_KERNEL_TYPE_EVIS,
VSI_NN_KERNEL_TYPE_CL,
VSI_NN_KERNEL_TYPE_VX,
VSI_NN_KERNEL_TYPE_NUM,
VSI_NN_KERNEL_TYPE_NONE = VSI_NN_KERNEL_TYPE_NUM
} vsi_nn_kernel_type_e;
/** Kernel pirority */
enum
{
VSI_NN_KERNEL_PIRORITY_DISABLE = 0,
VSI_NN_KERNEL_PIRORITY_NORMAL_LIMIT = 0x1FFFFFFF,
VSI_NN_KERNEL_PIRORITY_FORCE_EXEC = 0x20000000,
};
/** Kernel internal data type */
typedef enum
{
I8 = 0,
I16,
I32,
I64,
U8,
U16,
U32,
U64,
F16,
F32,
F64,
BF16,
BOOL8
} vsi_nn_kernel_dtype_e;
typedef enum
{
VSI_NN_KERNEL_QUANT_NONE,
VSI_NN_KERNEL_QUANT_DFP,
VSI_NN_KERNEL_QUANT_ASYMM,
VSI_NN_KERNEL_QUANT_ASYMM_PERCHANNEL,
VSI_NN_KERNEL_QUANT_SYMM,
VSI_NN_KERNEL_QUANT_SYMM_PERCHANNEL,
VSI_NN_KERNEL_QUANT_TYPE_NUM
} vsi_nn_kernel_quant_type_e;
/** GPU source format */
typedef enum
{
VSI_NN_GPU_SOURCE_FMT_CODE = 0,
VSI_NN_GPU_SOURCE_FMT_EXECUTABLE = 1,
VSI_NN_GPU_SOURCE_FMT_NUM
} vsi_nn_gpu_source_fmt_e;
typedef char * vsi_nn_kernel_source_t;
typedef uint32_t vsi_nn_kernel_unique_id_t;
typedef struct
{
char * data;
} vsi_nn_kernel_build_option_t;
typedef struct
{
size_t num;
vsi_nn_kernel_source_t * data;
vsi_nn_kernel_build_option_t build_option;
} vsi_nn_kernel_source_info_t;
typedef struct
{
vsi_nn_kernel_type_e type;
vsi_nn_kernel_unique_id_t unique_id;
vx_kernel_description_t info;
struct
{
vsi_nn_kernel_source_info_t sources[VSI_NN_GPU_SOURCE_FMT_NUM];
vsi_nn_gpu_source_fmt_e active_source_fmt;
} gpu;
} vsi_nn_kernel_t;
typedef struct
{
int32_t fl;
} vsi_nn_kernel_quant_dfp_t;
typedef struct
{
float scale;
int32_t zero_point;
} vsi_nn_kernel_quant_asymm_t;
typedef struct
{
vsi_float_array_t * scale;
vsi_int_array_t * zero_point;
int32_t channel_dim;
} vsi_nn_kernel_quant_asymm_perchannel_t;
typedef struct
{
vsi_nn_kernel_dtype_e dtype;
vsi_int_array_t * shape;
vsi_nn_kernel_quant_type_e quant;
union
{
vsi_nn_kernel_quant_dfp_t dfp;
vsi_nn_kernel_quant_asymm_t asymm;
vsi_nn_kernel_quant_asymm_perchannel_t asymm_v;
};
} vsi_nn_kernel_tensor_attr_t;
typedef struct
{
vsi_nn_kernel_type_e kernel_type;
int32_t fps;
} vsi_nn_kernel_pirority_t;
typedef struct
{
vsi_nn_kernel_pirority_t pirority[VSI_NN_KERNEL_TYPE_NUM];
int32_t allow_kernel_num;
} vsi_nn_kernel_selector_t;
typedef void * vsi_nn_kernel_node_param_t;
typedef void * vsi_nn_kernel_tensor_t;
typedef void * vsi_nn_kernel_node_t;
typedef void * vsi_nn_kernel_graph_t;
typedef void * vsi_nn_kernel_scalar_t;
typedef vsi_nn_hashmap_t vsi_nn_kernel_param_t;
typedef vsi_nn_kernel_node_t (* vsi_nn_kernel_setup_func_t)
(
vsi_nn_graph_t *,
vsi_nn_tensor_t **,
size_t input_num,
vsi_nn_tensor_t **,
size_t output_num,
const vsi_nn_kernel_param_t *,
vsi_nn_kernel_t *
);
typedef vsi_status (* vsi_nn_kernel_selector_func_t)
(
vsi_nn_graph_t *,
vsi_nn_tensor_t **,
size_t input_num,
vsi_nn_tensor_t **,
size_t output_num,
const vsi_nn_kernel_param_t *,
vsi_nn_kernel_selector_t *
);
typedef struct
{
vsi_nn_kernel_unique_id_t unique_id;
vsi_nn_kernel_setup_func_t setup[VSI_NN_KERNEL_TYPE_NUM];
vsi_nn_kernel_selector_func_t select;
} vsi_nn_kernel_backend_t;
vsi_nn_kernel_param_t * vsi_nn_kernel_param_create();
void vsi_nn_kernel_param_release( vsi_nn_kernel_param_t ** params );
void vsi_nn_kernel_param_clear( vsi_nn_kernel_param_t * params );
vsi_bool vsi_nn_kernel_param_add_int32
( vsi_nn_kernel_param_t * params, const char * key, int32_t value);
int32_t vsi_nn_kernel_param_get_int32
( const vsi_nn_kernel_param_t * params, const char * key);
vsi_bool vsi_nn_kernel_param_add_int64
( vsi_nn_kernel_param_t * params, const char * key, int64_t value);
int64_t vsi_nn_kernel_param_get_int64
( const vsi_nn_kernel_param_t * params, const char * key);
vsi_bool vsi_nn_kernel_param_add_float32
( vsi_nn_kernel_param_t * params, const char * key, float value);
float vsi_nn_kernel_param_get_float32
( const vsi_nn_kernel_param_t * params, const char * key);
vsi_bool vsi_nn_kernel_param_add_str
( vsi_nn_kernel_param_t * params, const char * key, const char * str);
const char * vsi_nn_kernel_param_get_str
( const vsi_nn_kernel_param_t * params, const char * key);
vsi_bool vsi_nn_kernel_param_add_buffer
( vsi_nn_kernel_param_t * params, const char * key, void * buf, size_t size);
void * vsi_nn_kernel_param_get_buffer
( const vsi_nn_kernel_param_t * params, const char * key, size_t * size);
/** Kernel register */
#define REGISTER_KERNEL_BACKEND(kernel_name, kernel_type, func) \
_INITIALIZER(_register_kernel_##kernel_name##_##kernel_type) \
{ \
vsi_nn_kernel_backend_register( \
""#kernel_name, \
VSI_NN_KERNEL_TYPE_##kernel_type, func ); \
}
#define REGISTER_KERNEL_SELECTOR(kernel_name, func) \
_INITIALIZER(_register_kernel_##kernel_name##_selector) \
{ \
vsi_nn_kernel_selector_register( \
""#kernel_name, func ); \
}
#if 0
typedef struct
{
const char* name;
vsi_nn_op_t op;
vsi_nn_kernel_type_e kernel_type;
vsi_nn_kernel_setup_func_t func;
} vsi_nn_kernel_section_meta_t;
#define REGISTER_KERNEL_BACKEND(operation, kernel_type, func) \
static vsi_nn_kernel_section_meta_t _kernel_meta = \
{""#operation, VSI_NN_OP_##operation, VSI_NN_KERNEL_TYPE_##kernel_type, func}; \
static vsi_nn_kernel_section_meta_t* _kernel_meta_ptr \
__attribute__((section("kernel_meta_section"))) = &_kernel_meta;
#endif
#if 0
#define REGISTER_KERNEL_BACKEND(operation, kernel_type, func) \
vsi_status func##_(vsi_nn_graph_t* graph, \
vsi_nn_tensor_t** inputs, size_t input_num, \
vsi_nn_tensor_t** outputs, size_t output_num) {\
return func(graph, inputs, input_num, outputs, output_num); \
}
#define REGISTER_KERNEL_BACKEND_MANUALLY(operation, kernel_type, func) \
extern vsi_status func##_(vsi_nn_graph_t*, \
vsi_nn_tensor_t** inputs, size_t input_num, \
vsi_nn_tensor_t** outputs, size_t output_num); \
vsi_nn_kernel_backend_register( ""#operation, \
VSI_NN_KERNEL_TYPE_##kernel_type, func##_ );
#endif
#define REGISTER_BACKEND_CL(operation, func) \
REGISTER_KERNEL_BACKEND(operation, CL, func)
#define REGISTER_BACKEND_EVIS(operation, func) \
REGISTER_KERNEL_BACKEND(operation, EVIS, func)
#define REGISTER_BACKEND_CPU(operation, func) \
REGISTER_KERNEL_BACKEND(operation, CPU, func)
#define REGISTER_BACKEND_OPENVX(operation, func) \
REGISTER_KERNEL_BACKEND(operation, VX, func)
#define DEF_KERNEL_BASE_CALLBACK( NAME ) \
static vsi_status NAME##_impl( vsi_nn_kernel_node_t node, \
const vsi_nn_kernel_node_param_t * param, \
size_t param_size ); \
static vx_status VX_CALLBACK NAME( \
vx_node node, const vx_reference * param,\
vx_uint32 param_size) {\
return (vx_status)NAME##_impl( \
(vsi_nn_kernel_node_t)node, \
(const vsi_nn_kernel_node_param_t *)param, \
(uint32_t)param_size \
); \
} \
static vsi_status NAME##_impl
#define DEF_KERNEL_INITIALIZER( NAME ) DEF_KERNEL_BASE_CALLBACK( NAME )
#define DEF_KERNEL_EXECUTOR( NAME ) DEF_KERNEL_BASE_CALLBACK( NAME )
#define DEF_KERNEL_DEINITIALIZER( NAME ) DEF_KERNEL_BASE_CALLBACK( NAME )
void vsi_nn_kernel_backend_register
(
const char * kernel_name,
vsi_nn_kernel_type_e kernel_type,
vsi_nn_kernel_setup_func_t setup_func
);
const vsi_nn_kernel_backend_t * vsi_nn_kernel_backend_get
( const char * );
vsi_status vsi_nn_kernel_backend_init( void );
void vsi_nn_kernel_backend_deinit( void );
void vsi_nn_kernel_selector_register
(
const char * kernel_name,
vsi_nn_kernel_selector_func_t selecotr_func
);
vsi_status vsi_nn_kernel_pirority_set
(
vsi_nn_kernel_selector_t * selector,
const vsi_nn_kernel_pirority_t * pirority,
size_t pirority_size
);
vsi_nn_kernel_t * vsi_nn_kernel_create
(
vsi_nn_kernel_type_e type
);
void vsi_nn_kernel_reset
(
vsi_nn_kernel_t * kernel,
vsi_nn_kernel_type_e type
);
void vsi_nn_kernel_release
(
vsi_nn_kernel_t ** kernel
);
void vsi_nn_kernel_add_source
(
vsi_nn_kernel_t * kernel,
vsi_nn_gpu_source_fmt_e fmt,
size_t source_num,
...
);
void vsi_nn_kernel_add_build_option
(
vsi_nn_kernel_t * kernel,
const char * option
);
vsi_nn_kernel_tensor_t vsi_nn_kernel_tensor_create
(
vsi_nn_kernel_graph_t graph,
const vsi_nn_kernel_tensor_attr_t* attr,
vsi_bool is_virtual
);
void vsi_nn_kernel_tensor_release
(
vsi_nn_kernel_tensor_t * tensor
);
vsi_nn_kernel_tensor_t vsi_nn_kernel_tensor_reshape
(
vsi_nn_kernel_tensor_t tensor,
int32_t * shape,
uint32_t rank
);
vsi_status vsi_nn_kernel_node_pass_param
(
vsi_nn_kernel_node_t node,
vsi_nn_kernel_node_param_t * params,
size_t num
);
static inline void vsi_nn_kernel_node_release
(
vsi_nn_kernel_node_t * node
)
{
if( node && *node )
{
vxReleaseNode( (vx_node*)node );
}
}
static inline void vsi_nn_kernel_node_pack_io
(
vsi_nn_kernel_node_param_t * params,
size_t param_num,
vsi_nn_tensor_t ** inputs,
size_t input_num,
vsi_nn_tensor_t ** outputs,
size_t output_num
)
{
size_t i;
size_t cnt;
/* Set inputs */
cnt = 0;
for( i = 0; i < input_num && cnt < param_num; i ++, cnt ++ )
{
if( inputs[i] )
{
params[cnt] = (vsi_nn_kernel_node_param_t)(inputs[i]->t);
}
else
{
params[cnt] = NULL;
}
}
/* Set outputs */
for( i = 0; i < output_num && cnt < param_num; i ++, cnt ++ )
{
if( outputs[i] )
{
params[cnt] = (vsi_nn_kernel_node_param_t)(outputs[i]->t);
}
else
{
params[cnt] = NULL;
}
}
} /* vsi_nn_kernel_node_pack_io() */
/** Kernel selector */
vsi_nn_kernel_node_t vsi_nn_kernel_selector
(
vsi_nn_graph_t * graph,
const char * kernel_name,
vsi_nn_tensor_t ** inputs,
size_t input_num,
vsi_nn_tensor_t ** outputs,
size_t output_num,
const vsi_nn_kernel_param_t * params
);
/** Map data type to gpu internal dtype. */
static inline vsi_nn_kernel_dtype_e vsi_nn_kernel_map_dtype
(
vsi_nn_type_e dtype
)
{
switch( dtype )
{
case VSI_NN_TYPE_INT8:
return I8;
case VSI_NN_TYPE_BOOL8:
return BOOL8;
case VSI_NN_TYPE_INT16:
return I16;
case VSI_NN_TYPE_INT32:
return I32;
case VSI_NN_TYPE_INT64:
return I64;
case VSI_NN_TYPE_UINT8:
return U8;
case VSI_NN_TYPE_UINT16:
return U16;
case VSI_NN_TYPE_UINT32:
return U32;
case VSI_NN_TYPE_FLOAT16:
return F16;
case VSI_NN_TYPE_BFLOAT16:
return BF16;
case VSI_NN_TYPE_FLOAT32:
return F32;
default:
VSILOGE("error data type %d", dtype);
break;
}
return I8;
} /* vsi_nn_kernel_map_dtype() */
static inline vsi_nn_type_e vsi_nn_dtype_map_kernel
(
vsi_nn_kernel_dtype_e dtype
)
{
switch( dtype )
{
case I8:
return VSI_NN_TYPE_INT8;
case BOOL8:
return VSI_NN_TYPE_BOOL8;
case I16:
return VSI_NN_TYPE_INT16;
case I32:
return VSI_NN_TYPE_INT32;
case I64:
return VSI_NN_TYPE_INT64;
case U8:
return VSI_NN_TYPE_UINT8;
case U16:
return VSI_NN_TYPE_UINT16;
case U32:
return VSI_NN_TYPE_UINT32;
case F16:
return VSI_NN_TYPE_FLOAT16;
case BF16:
return VSI_NN_TYPE_BFLOAT16;
case F32:
return VSI_NN_TYPE_FLOAT32;
default:
VSILOGE("error data type %d", dtype);
break;
}
return VSI_NN_TYPE_INT8;
} /* vsi_nn_kernel_map_dtype() */
static inline size_t vsi_nn_kernel_dtype_get_bytes
(
vsi_nn_kernel_dtype_e dtype
)
{
switch( dtype )
{
case I8:
case U8:
case BOOL8:
return sizeof(int8_t);
case I16:
case U16:
case F16:
case BF16:
return sizeof(int16_t);
case I32:
case U32:
case F32:
return sizeof(int32_t);
case I64:
return sizeof(int64_t);
default:
VSILOGE("Error data type %d", dtype);
break;
}
return 0;
} /* vsi_nn_kernel_dtype_get_bytes() */
static inline vsi_nn_kernel_quant_type_e vsi_nn_kernel_map_quant_type
( vsi_nn_qnt_type_e quant_type )
{
switch( quant_type )
{
case VSI_NN_QNT_TYPE_DFP:
return VSI_NN_KERNEL_QUANT_DFP;
case VSI_NN_QNT_TYPE_AFFINE_ASYMMETRIC:
return VSI_NN_KERNEL_QUANT_ASYMM;
case VSI_NN_QNT_TYPE_AFFINE_PERCHANNEL_SYMMETRIC:
return VSI_NN_KERNEL_QUANT_SYMM_PERCHANNEL;
default:
break;
}
return VSI_NN_KERNEL_QUANT_NONE;
} /* vsi_nn_kernel_map_quant_type() */
vsi_nn_kernel_node_t vsi_nn_kernel_create_node
(
vsi_nn_graph_t * graph,
vsi_nn_kernel_t * kernel
);
vsi_status vsi_nn_kernel_node_set_border
(vsi_nn_kernel_node_t node,
vx_border_t* border);
vsi_nn_kernel_scalar_t vsi_nn_kernel_scalar_create
(
vsi_nn_graph_t * graph,
vsi_nn_kernel_dtype_e dtype,
const void * data
);
static inline void vsi_nn_kernel_scalar_release
( vsi_nn_kernel_scalar_t * scalar )
{
if( scalar && *scalar )
{
vxReleaseScalar( (vx_scalar*)scalar );
}
} /* vsi_nn_kernel_scalar_relase() */
vsi_status vsi_nn_kernel_scalar_read_int8
( vsi_nn_kernel_scalar_t scalar, int8_t * out_data );
vsi_status vsi_nn_kernel_scalar_read_int32
( vsi_nn_kernel_scalar_t scalar, int32_t * out_data );
vsi_status vsi_nn_kernel_scalar_read_int64
( vsi_nn_kernel_scalar_t scalar, int64_t * out_data );
vsi_status vsi_nn_kernel_scalar_read_uint8
( vsi_nn_kernel_scalar_t scalar, uint8_t * out_data );
vsi_status vsi_nn_kernel_scalar_read_uint32
( vsi_nn_kernel_scalar_t scalar, uint32_t * out_data );
vsi_status vsi_nn_kernel_scalar_read_float32
( vsi_nn_kernel_scalar_t scalar, float * out_data );
vsi_status vsi_nn_kernel_scalar_read_float64
( vsi_nn_kernel_scalar_t scalar, double * out_data );
vsi_status vsi_nn_kernel_scalar_write_int8
( vsi_nn_kernel_scalar_t scalar, int8_t out_data );
vsi_status vsi_nn_kernel_scalar_write_int32
( vsi_nn_kernel_scalar_t scalar, int32_t out_data );
vsi_status vsi_nn_kernel_scalar_write_int64
( vsi_nn_kernel_scalar_t scalar, int64_t out_data );
vsi_status vsi_nn_kernel_scalar_write_uint8
( vsi_nn_kernel_scalar_t scalar, uint8_t out_data );
vsi_status vsi_nn_kernel_scalar_write_uint32
( vsi_nn_kernel_scalar_t scalar, uint32_t out_data );
vsi_status vsi_nn_kernel_scalar_write_float32
( vsi_nn_kernel_scalar_t scalar, float out_data );
vsi_status vsi_nn_kernel_scalar_write_float64
( vsi_nn_kernel_scalar_t scalar, double out_data );
vsi_status vsi_nn_kernel_scalar_get_dtype
(
vsi_nn_kernel_scalar_t scalar,
vsi_nn_kernel_dtype_e * dtype
);
vsi_status vsi_nn_kernel_register
(
vsi_nn_graph_t * graph,
vsi_nn_kernel_t * kernel
);
vsi_bool vsi_nn_kernel_gpu_check_shape
( const int32_t * shape, size_t rank );
vsi_status vsi_nn_kernel_gpu_add_param
(
vsi_nn_kernel_node_t node,
const char * param_key,
void * data
);
vsi_status vsi_nn_kernel_gpu_config
(
vsi_nn_kernel_node_t node,
const gpu_param_t * gpu_param
);
vsi_nn_kernel_tensor_attr_t * vsi_nn_kernel_tensor_attr_create
( vsi_nn_kernel_tensor_t tensor );
void vsi_nn_kernel_tensor_attr_release
( vsi_nn_kernel_tensor_attr_t ** attr );
/*
* Create a buffer with a copy of tensor data.
* attr is optional
*/
void * vsi_nn_kernel_tensor_create_buffer
(
vsi_nn_kernel_tensor_t tensor,
const vsi_nn_kernel_tensor_attr_t * attr,
vsi_bool convert_to_float
);
/*
* Read tensor data to buffer.
* attr is optional
*/
vsi_status vsi_nn_kernel_tensor_read
(
vsi_nn_kernel_tensor_t tensor,
const vsi_nn_kernel_tensor_attr_t * attr,
void * out_buffer,
size_t out_buffer_size
);
/*
* Write float data to tensor.
* attr is optional
*/
vsi_status vsi_nn_kernel_tensor_write_from_float
(
vsi_nn_kernel_tensor_t tensor,
const vsi_nn_kernel_tensor_attr_t * attr,
const float * float_buffer,
size_t size
);
/*
* Write data to tensor.
* attr is optional
*/
vsi_status vsi_nn_kernel_tensor_write
(
vsi_nn_kernel_tensor_t tensor,
const vsi_nn_kernel_tensor_attr_t * attr,
const void * buffer,
size_t size
);
static inline size_t vsi_nn_kernel_tensor_attr_get_size
( const vsi_nn_kernel_tensor_attr_t * attr )
{
if( !attr )
{
return 0;
}
return vsi_nn_shape_get_size( attr->shape->data, attr->shape->size );
} /* vsi_nn_kernel_tensor_attr_get_size() */
static inline size_t vsi_nn_kernel_tensor_attr_get_bytes
( const vsi_nn_kernel_tensor_attr_t * attr )
{
size_t size;
size_t type_bytes;
if( !attr )
{
return 0;
}
size = vsi_nn_kernel_tensor_attr_get_size( attr );
type_bytes = vsi_nn_kernel_dtype_get_bytes( attr->dtype );
return size * type_bytes;
} /* vsi_nn_kernel_tensor_attr_get_bytes() */
static inline void vsi_nn_kernel_tensor_attr_get_stride
( const vsi_nn_kernel_tensor_attr_t * attr, size_t * out_stride)
{
if( !attr || !out_stride )
{
return;
}
vsi_nn_shape_get_stride( attr->shape->data, attr->shape->size, out_stride );
} /* vsi_nn_kernel_tensor_attr_get_size() */
static inline vsi_bool vsi_nn_kernel_tensor_attr_is_quantized
( const vsi_nn_kernel_tensor_attr_t * attr )
{
return ( attr && attr->quant > VSI_NN_KERNEL_QUANT_NONE
&& attr->quant < VSI_NN_KERNEL_QUANT_TYPE_NUM
&& attr->dtype != F16
&& attr->dtype != BF16
&& attr->dtype != F32
&& attr->dtype != F64 );
} /* vsi_nn_kernel_tensor_attr_is_quantized() */
//TODO: Make vsi_nn_kernel_dtype_e to public and move dtype functions to vsi_nn_dtype.h
vsi_bool vsi_nn_dtype_convert_float_to_dtype
(
const float * buffer, size_t size,
vsi_nn_kernel_dtype_e dtype,
void * out_buffer
);
vsi_bool vsi_nn_dtype_convert_float_to_quantize_asymm
(
const float * buffer, size_t size,
vsi_nn_kernel_dtype_e dtype,
float scale, int32_t zero_point,
void * out_buffer
);
vsi_bool vsi_nn_dtype_convert_float_to_quantize_dfp
(
const float * buffer, size_t size,
vsi_nn_kernel_dtype_e dtype,
int32_t fl,
void * out_buffer
);
vsi_bool vsi_nn_dtype_convert_float_to_quantize_symm
(
const float * buffer, size_t size,
vsi_nn_kernel_dtype_e dtype,
float scale, int32_t zero_point,
void * out_buffer
);
vsi_bool vsi_nn_dtype_convert_float_to_quantize_symm_perchannel
(
const float * buffer, size_t size,
vsi_nn_kernel_dtype_e dtype,
const int32_t * shape, size_t rank,
const float * scale, size_t scale_size,
const int32_t * zero_point, size_t zero_point_size,
int32_t channel_dim,
void * out_buffer
);
vsi_bool vsi_nn_dtype_convert_dtype_to_float
(
const void * buffer,
size_t size,
vsi_nn_kernel_dtype_e dtype,
float * out_buffer
);
vsi_bool vsi_nn_dtype_convert_quantize_asymm_to_float
(
const void * buffer, size_t size,
vsi_nn_kernel_dtype_e dtype,
float scale, int32_t zero_point,
float * out_buffer
);
vsi_bool vsi_nn_dtype_convert_quantize_dfp_to_float
(
const void * buffer, size_t size,
vsi_nn_kernel_dtype_e dtype,
int32_t fl,
float * out_buffer
);
vsi_bool vsi_nn_dtype_convert_quantize_symm_to_float
(
const void * buffer, size_t size,
vsi_nn_kernel_dtype_e dtype,
float scale, int32_t zero_point,
float * out_buffer
);
vsi_bool vsi_nn_dtype_convert_quantize_symm_perchannel_to_float
(
const void * buffer, size_t size,
vsi_nn_kernel_dtype_e dtype,
const int32_t * shape, size_t rank,
const float * scale, size_t scale_size,
const int32_t * zero_point, size_t zero_point_size,
int32_t channel_dim,
float * out_buffer
);
vsi_nn_tensor_t* vsi_nn_pad_tensor
(
vsi_nn_graph_t * graph,
vsi_nn_tensor_t * input,
int32_t * pad_front,
int32_t * pad_end,
size_t pad_size,
vsi_nn_pad_mode_e mode,
float pad_value
);
vsi_nn_tensor_t* vsi_nn_merge_input_zeropoint_to_bias
(
vsi_nn_graph_t * graph,
vsi_nn_tensor_t * input,
vsi_nn_tensor_t * weight,
vsi_nn_tensor_t * bias
);
static inline const char* vsi_nn_kernel_type_str
(
vsi_nn_kernel_type_e type
)
{
switch( type )
{
case VSI_NN_KERNEL_TYPE_CPU:
return "CPU";
case VSI_NN_KERNEL_TYPE_EVIS:
return "EVIS";
case VSI_NN_KERNEL_TYPE_CL:
return "CL";
case VSI_NN_KERNEL_TYPE_VX:
return "OPENVX";
default:
break;
}
return "None";
} /* vsi_nn_kernel_type_str() */
__END_DECLS
#endif

View File

@ -0,0 +1,49 @@
/****************************************************************************
*
* 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 _VSI_NN_KERNEL_ELTWISE_H
#define _VSI_NN_KERNEL_ELTWISE_H
#include <stdint.h>
#include "kernel/vsi_nn_kernel.h"
vsi_bool vsi_nn_kernel_optimize_eltwise_shape
(
const int32_t* shape_x, const size_t rank_x,
const int32_t* shape_y, const size_t rank_y,
const int32_t* shape_output, const size_t rank_output,
int32_t* out_shape_x, int32_t* out_shape_y,
int32_t* out_shape_output, uint32_t* out_rank_output
);
vsi_bool vsi_nn_kernel_optimize_broadcast_shape
(
const int32_t** shape_in, const size_t* rank_in,
const int32_t input_num,
const int32_t* shape_output, const size_t rank_output,
int32_t** out_shape_in,
int32_t* out_shape_output, uint32_t* out_rank_output
);
#endif

View File

@ -0,0 +1,62 @@
/****************************************************************************
*
* 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 _VSI_NN_KERNEL_GPU_SHAPE_OPTIMIZE_H
#define _VSI_NN_KERNEL_GPU_SHAPE_OPTIMIZE_H
#include <stdint.h>
#include "kernel/vsi_nn_kernel.h"
vsi_bool vsi_nn_kernel_optimize_reduce_shape
(
const int32_t* shape_x, const size_t rank_x,
const int32_t *axis, const size_t axis_size,
const int32_t* shape_output, const size_t rank_output,
int32_t* out_shape_x, uint32_t* out_rank_x,
int32_t* out_shape_output, uint32_t* out_rank_output,
int32_t* out_axis, uint32_t* out_axis_size
);
vsi_bool vsi_nn_kernel_optimize_element_shape
(
const int32_t* shape_x, const size_t rank_x,
int32_t* out_shape_x, int32_t* out_rank_x
);
vsi_bool vsi_nn_kernel_optimize_softmax_shape
(
const int32_t* shape_x, const size_t rank_x, const int32_t axis,
int32_t* out_shape_x, uint32_t* out_rank_x,int32_t* out_axis
);
vsi_bool vsi_nn_kernel_optimize_tile_shape
(
const int32_t* shape_x, const size_t rank_x,
const int32_t* multiples, const size_t rank,
const int32_t* shape_output, const size_t rank_output,
int32_t* out_shape_x, int32_t* out_shape_y,
int32_t* out_shape_output, uint32_t* out_rank_output
);
#endif

Some files were not shown because too many files have changed in this diff Show More