Custom kernel example.
#include <cstdlib>
#include <iostream>
{
{
std::cerr << "Failed to create context\n";
return EXIT_FAILURE;
}
{
std::cerr << "Failed to create graph\n";
return EXIT_FAILURE;
}
context,
"example.scalar_add",
{
},
(void)node;
(void)num;
scalar_a->readValue(&a);
scalar_b->readValue(&b);
c = a + b;
scalar_out->writeValue(&c);
});
{
std::cerr << "Custom kernel not registered!\n";
return EXIT_FAILURE;
}
auto add_node =
Node::createNode(graph, add_kernel, {scalar_a, scalar_b, scalar_out});
{
std::cerr << "Failed to create node\n";
return EXIT_FAILURE;
}
{
std::cerr << "Graph processing failed\n";
return EXIT_FAILURE;
}
scalar_out->readValue(&result);
std::cout << "Result: " << a << " + " << b << " = " << result << std::endl;
return EXIT_SUCCESS;
}
CoreVX single-include header for C++ development.
int main()
Definition blur_pipeline.cpp:15
uint32_t vx_uint32
A 32-bit unsigned value.
Definition vx_types.h:85
vx_enum vx_status
A formal status type with known fixed size.
Definition vx_types.h:550
@ VX_TYPE_INT32
A vx_int32.
Definition vx_types.h:440
@ VX_SUCCESS
No error.
Definition vx_types.h:543
static vx_context createContext()
Create a new context.
static vx_status getStatus(vx_reference ref)
Provides a generic API to return status values from Object constructors if they fail.
static vx_graph createGraph(vx_context context)
Create a graph.
static vx_kernel registerCustomKernel(vx_context context, std::string name, const std::vector< Kernel::Param > ¶ms, vx_kernel_f function, vx_kernel_validate_f validate=nullptr, vx_kernel_initialize_f initialize=nullptr, vx_kernel_deinitialize_f deinitialize=nullptr)
Register a custom kernel.
static vx_node createNode(vx_graph graph, vx_kernel kernel)
Create a new node.
static vx_scalar createScalar(vx_context context, vx_enum data_type, const void *ptr)
Create a scalar object.
struct Node * vx_node
An opaque reference to a kernel node.
Definition vx_types.h:253
@ VX_OUTPUT
The parameter is an output only.
Definition vx_types.h:720
@ VX_INPUT
The parameter is an input only.
Definition vx_types.h:718
@ VX_PARAMETER_STATE_REQUIRED
Default. The parameter must be supplied. If not set, during Verify, an error is returned.
Definition vx_types.h:1436
The internal representation of a vx_array.
Definition vx_array.h:34
signed int int32_t
Definition stdint.h:42
struct Reference * vx_reference
Definition vx_types.h:173
struct Scalar * vx_scalar
Definition vx_types.h:208