samples/graph_ops.c
rml_graph ConnectPostprocessingGraph(rml_graph graph,
                                     const char* input_name,
                                     const uint32_t* input_shape)
{
    // Postprocessing graph includes gamma-correction
    // ldr_color = (clip(ldr_color, 0, 1)) ^ (gamma)
    // gamma = 0.4
    rml_graph postprocess_graph = NULL;
    RML_CHECK(rmlCreateGraph(&postprocess_graph));

    // Create placeholder for color
    rml_op input_op = CreatePlaceholderOp(postprocess_graph, input_name, input_shape);

    // Clip color
    rml_op_desc clip_desc = {RML_OP_CLIP, "clip", .clip = {input_op, 0.f, 1.f}};

    rml_op clip_op = NULL;
    RML_CHECK(rmlCreateOperation(postprocess_graph, &clip_desc, &clip_op));

    // Create gamma
    float gamma_const = 0.4f;
    rml_op gamma_op = CreateScalarOp(postprocess_graph, "gamma", RML_DTYPE_FLOAT32, &gamma_const);

    // Create pow operation
    rml_op pow_op = CreateBinaryOp(postprocess_graph, "pow", RML_OP_POW, clip_op, gamma_op);

    // Get tail graph inputs
    rml_strings tail_inputs;
    RML_CHECK(rmlGetGraphInputNames(postprocess_graph, &tail_inputs));

    // Get head graph outputs
    rml_strings head_outputs;
    RML_CHECK(rmlGetGraphOutputNames(graph, &head_outputs));

    // Connect base graph with postprocessing graph
    rml_graph connected_graph = NULL;
    RML_CHECK(rmlConnectGraphs(graph,
                               postprocess_graph,
                               1,
                               &head_outputs.items[0],
                               &tail_inputs.items[0],
                               &connected_graph));
    return connected_graph;
}
/*
 * Create postprocessing graph and connect it with base graph
 *
 * @param graph - base graph to be connected with postprocessing graph
 * @param input_name - unique input name of postprocessing graph
 * @param input_shape - input shape of postprocessing graph
 * @return connected graph
 */
Create postprocessing graph and connect it with base graph

@param graph - base graph to be connected with postprocessing graph
@param input_name - unique input name of postprocessing graph
@param input_shape - input shape of postprocessing graph
@return connected graph
Create postprocessing graph and connect it with base graph @param graph - base graph to be connected with postprocessing graph @param input_name - unique input name of postprocessing graph @param input_shape - input shape of postprocessing graph @return connected graph
rml_graph ConnectPostprocessingGraph(rml_graph graph,
                                     const char* input_name,
                                     const uint32_t* input_shape)
{
    rml_graph postprocess_graph = NULL;
    RML_CHECK(rmlCreateGraph(&postprocess_graph));
    rml_op input_op = CreatePlaceholderOp(postprocess_graph, input_name, input_shape);
    rml_op_desc clip_desc = {RML_OP_CLIP, "clip", .clip = {input_op, 0.f, 1.f}};
    rml_op clip_op = NULL;
    RML_CHECK(rmlCreateOperation(postprocess_graph, &clip_desc, &clip_op));
    float gamma_const = 0.4f;
    rml_op gamma_op = CreateScalarOp(postprocess_graph, "gamma", RML_DTYPE_FLOAT32, &gamma_const);
    rml_op pow_op = CreateBinaryOp(postprocess_graph, "pow", RML_OP_POW, clip_op, gamma_op);
    rml_strings tail_inputs;
    RML_CHECK(rmlGetGraphInputNames(postprocess_graph, &tail_inputs));
    rml_strings head_outputs;
    RML_CHECK(rmlGetGraphOutputNames(graph, &head_outputs));
    rml_graph connected_graph = NULL;
    RML_CHECK(rmlConnectGraphs(graph,
                               postprocess_graph,
                               1,
                               &head_outputs.items[0],
                               &tail_inputs.items[0],
                               &connected_graph));
    return connected_graph;
}
rml_graph ConnectPostprocessingGraph ( rml_graph graph , const char * input_name , const uint32_t * input_shape ) { rml_graph postprocess_graph = NULL ; RML_CHECK ( rmlCreateGraph ( & postprocess_graph ) ) ; rml_op input_op = CreatePlaceholderOp ( postprocess_graph , input_name , input_shape ) ; rml_op_desc clip_desc = { RML_OP_CLIP , " " , . clip = { input_op , 0.f , 1.f } } ; rml_op clip_op = NULL ; RML_CHECK ( rmlCreateOperation ( postprocess_graph , & clip_desc , & clip_op ) ) ; float gamma_const = 0.4f ; rml_op gamma_op = CreateScalarOp ( postprocess_graph , " " , RML_DTYPE_FLOAT32 , & gamma_const ) ; rml_op pow_op = CreateBinaryOp ( postprocess_graph , " " , RML_OP_POW , clip_op , gamma_op ) ; rml_strings tail_inputs ; RML_CHECK ( rmlGetGraphInputNames ( postprocess_graph , & tail_inputs ) ) ; rml_strings head_outputs ; RML_CHECK ( rmlGetGraphOutputNames ( graph , & head_outputs ) ) ; rml_graph connected_graph = NULL ; RML_CHECK ( rmlConnectGraphs ( graph , postprocess_graph , 1 , & head_outputs . items [ 0 ] , & tail_inputs . items [ 0 ] , & connected_graph ) ) ; return connected_graph ; }
Create postprocessing graph and connect it with base graph
Create postprocessing graph and connect it with base graph
// Postprocessing graph includes gamma-correction
 // ldr_color = (clip(ldr_color, 0, 1)) ^ (gamma)
 // gamma = 0.4
 // Create placeholder for color
 // Clip color
 // Create gamma
 // Create pow operation
 // Get tail graph inputs
 // Get head graph outputs
 // Connect base graph with postprocessing graph
