Pass to convert dynamic batch to single batch.
More...
#include <DynamicBatchToSingleBatchPass.h>
Pass to convert dynamic batch to single batch.
Definition at line 28 of file DynamicBatchToSingleBatchPass.h.
◆ name()
virtual const char * luci::DynamicBatchToSingleBatchPass::name |
( |
void |
| ) |
const |
|
inlinevirtual |
◆ run()
bool luci::DynamicBatchToSingleBatchPass::run |
( |
loco::Graph * |
graph | ) |
|
|
virtual |
Run the pass.
- Returns
- false if there was nothing changed
Implements logo::Pass.
Definition at line 25 of file DynamicBatchToSingleBatchPass.cpp.
26{
27 assert(g);
28
29 bool changed = false;
30
31 auto graph_inputs =
g->inputs();
32
33
34 const uint32_t BATCH_DIM = 0;
35
37 {
38 auto input_node = loco::must_cast<luci::CircleInput *>(node);
39
41 continue;
42
43
45 continue;
46
48 {
49
50
51 throw std::runtime_error("First dimension of input is unknown, but its rank is not 4.");
52 }
53
54
56
57
60 auto tensor_shape = std::make_unique<loco::TensorShape>();
61 {
63 for (uint32_t i = 0; i < tensor_shape->
rank(); i++)
64 {
66 }
67 tensor_shape->
dim(BATCH_DIM).
set(1);
68 }
69
70 graph_input->shape(std::move(tensor_shape));
71
72 changed = true;
73 }
74
75 return changed;
76}
const Dimension & dim(uint32_t axis) const
uint32_t rank(void) const
loco::Use * at(uint32_t n) const
std::vector< Node * > input_nodes(const Graph *)
void graph_input_shape(luci::CircleInput *input)
This will set GraphInput shape from CircleInput shape.
CircleInput * input_node(loco::Graph *g, const loco::GraphInputIndex &index)
Find a Pull node with a given input index.
References luci::FixedArityNode< N, Base >::at(), loco::TensorShape::dim(), luci::CircleInput::index(), luci::input_node(), loco::input_nodes(), loco::TensorShape::rank(), and loco::Dimension::set().
The documentation for this class was generated from the following files: