Compute Library
PrintLayer Class Referencefinal

Print Layer. More...

#include <Layers.h>

Collaboration diagram for PrintLayer:

Public Member Functions

 PrintLayer (std::ostream &stream, const IOFormatInfo &format_info=IOFormatInfo(), const std::function< ITensor *(ITensor *)> transform=nullptr)
 Construct a print layer. More...
NodeID create_layer (IStream &s) override
 Create layer and add to the given stream. More...
- Public Member Functions inherited from ILayer
virtual ~ILayer ()=default
 Default destructor. More...
ILayerset_name (std::string name)
 Sets the name of the layer. More...
const std::string & name () const
 Layer name accessor. More...

Detailed Description

Print Layer.

Definition at line 1029 of file Layers.h.

Constructor & Destructor Documentation

◆ PrintLayer()

PrintLayer ( std::ostream &  stream,
const IOFormatInfo format_info = IOFormatInfo(),
const std::function< ITensor *(ITensor *)>  transform = nullptr 

Construct a print layer.

Example usage to locally dequantize and print a tensor:

Tensor *output = new Tensor(); const auto transform = [output](ITensor *input) { output->allocator()->init(*input->info()); output->info()->set_data_type(DataType::F32); output->allocator()->allocate();

Window win; win.use_tensor_dimensions(input->info()->tensor_shape()); Iterator in(input, win); Iterator out(output, win); execute_window_loop(win, [&](const Coordinates &) { *(reinterpret_cast<float *>(out.ptr())) = dequantize_qasymm8(*in.ptr(), input->info()->quantization_info().uniform()); }, in, out);

return output; };

graph << InputLayer(input_descriptor.set_quantization_info(in_quant_info), get_input_accessor(common_params, nullptr, false)) << ... << \ CNN Layers << ... << PrintLayer(std::cout, IOFormatInfo(), transform) << ... << OutputLayer(get_output_accessor(common_params, 5));

[in]streamOutput stream.
[in]format_info(Optional) Format info.
[in]transform(Optional) Input transform function.

Definition at line 1067 of file Layers.h.

1068  : _stream(stream), _format_info(format_info), _transform(transform)
1069  {
1070  }

Member Function Documentation

◆ create_layer()

NodeID create_layer ( IStream s)

Create layer and add to the given stream.

[in]sStream to add layer to.
ID of the created node.

Implements ILayer.

Definition at line 1072 of file Layers.h.

References GraphBuilder::add_print_node(), IStream::graph(), IStream::hints(), arm_compute::test::validation::input, ILayer::name(), IStream::tail_node(), and StreamHints::target_hint.

1073  {
1074  NodeParams common_params = { name(), s.hints().target_hint };
1075  NodeIdxPair input = { s.tail_node(), 0 };
1076  return GraphBuilder::add_print_node(s.graph(), common_params, input, _stream, _format_info, _transform);
1077  }
static NodeID add_print_node(Graph &g, NodeParams params, NodeIdxPair input, std::ostream &stream, const IOFormatInfo &format_info=IOFormatInfo(), const std::function< ITensor *(ITensor *)> transform=nullptr)
Adds a print layer node to the graph.
const std::string & name() const
Layer name accessor.
Definition: ILayer.h:64

The documentation for this class was generated from the following file: