MCPcopy Create free account
hub / github.com/cactus-compute/cactus / view

Method view

cactus/graph/graph_builder.cpp:72–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72size_t CactusGraph::view(size_t input, const std::vector<size_t>& new_shape) {
73 const auto& input_buffer = get_output_buffer(input);
74
75 size_t input_elements = 1;
76 for (size_t dim : input_buffer.shape) {
77 input_elements *= dim;
78 }
79
80 size_t new_elements = 1;
81 for (size_t dim : new_shape) {
82 new_elements *= dim;
83 }
84
85 if (input_elements != new_elements) {
86 throw std::runtime_error("View operation requires total number of elements to remain the same");
87 }
88
89 OpParams params{.new_shape = new_shape};
90 return add_node(OpType::VIEW, {input}, new_shape, params);
91}
92
93size_t CactusGraph::flatten(size_t input, int start_dim, int end_dim) {
94 const auto& input_buffer = get_output_buffer(input);

Callers 1

cactus_graph_viewFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected