Skip to content

Commit e2eda59

Browse files
committed
Removed backprop operations
1 parent d20246d commit e2eda59

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+20
-6092
lines changed

ngraph/src/ngraph/op/avg_pool.cpp

Lines changed: 0 additions & 308 deletions
Original file line numberDiff line numberDiff line change
@@ -241,170 +241,11 @@ shared_ptr<Node> op::v0::AvgPool::clone_with_new_inputs(const OutputVector& new_
241241
m_ceil_mode);
242242
}
243243

244-
constexpr NodeTypeInfo op::v0::AvgPoolBackprop::type_info;
245244
shared_ptr<Node> op::v0::AvgPool::get_default_value() const
246245
{
247246
return Constant::create(get_element_type(), get_shape(), {0});
248247
}
249248

250-
op::v0::AvgPoolBackprop::AvgPoolBackprop(const Shape& forward_arg_shape,
251-
const Output<Node>& delta,
252-
const Shape& window_shape,
253-
const Strides& window_movement_strides,
254-
const Shape& padding_below,
255-
const Shape& padding_above,
256-
bool include_padding_in_avg_computation)
257-
: Op({delta})
258-
, m_forward_arg_shape(forward_arg_shape)
259-
, m_window_shape(window_shape)
260-
, m_window_movement_strides(window_movement_strides)
261-
, m_padding_below(padding_below)
262-
, m_padding_above(padding_above)
263-
, m_include_padding_in_avg_computation(include_padding_in_avg_computation)
264-
{
265-
constructor_validate_and_infer_types();
266-
}
267-
268-
bool op::v0::AvgPoolBackprop::visit_attributes(AttributeVisitor& visitor)
269-
{
270-
visitor.on_attribute("forward_arg_shape", m_forward_arg_shape);
271-
visitor.on_attribute("window_shape", m_window_shape);
272-
visitor.on_attribute("window_movement_strides", m_window_movement_strides);
273-
visitor.on_attribute("padding_below", m_padding_below);
274-
visitor.on_attribute("padding_above", m_padding_above);
275-
visitor.on_attribute("include_padding_in_avg_computation",
276-
m_include_padding_in_avg_computation);
277-
return true;
278-
}
279-
280-
void op::v0::AvgPoolBackprop::validate_and_infer_types()
281-
{
282-
// infer_batched_forward_pooling wants CoordinateDiffs for these, while the pooling ops for
283-
// now still take Shape (no negative padding).
284-
CoordinateDiff padding_below(m_padding_below.begin(), m_padding_below.end());
285-
CoordinateDiff padding_above(m_padding_above.begin(), m_padding_above.end());
286-
287-
PartialShape forward_result_shape =
288-
infer_batched_pooling_forward(this,
289-
m_forward_arg_shape,
290-
padding_below,
291-
padding_above,
292-
m_window_shape,
293-
m_window_movement_strides,
294-
m_include_padding_in_avg_computation);
295-
296-
const PartialShape& delta_shape = get_input_partial_shape(0);
297-
298-
NODE_VALIDATION_CHECK(
299-
this,
300-
forward_result_shape.compatible(delta_shape),
301-
"Inferred forward output shape does not match delta shape (inferred forward output ",
302-
"shape: ",
303-
forward_result_shape,
304-
", delta shape: ",
305-
delta_shape,
306-
").");
307-
308-
// TODO(amprocte): Once m_forward_arg_shape is allowed to be dynamic, we may technically be
309-
// able to infer some extra information from forward_result_shape that was not present in the
310-
// forward arg shape---namely batch size and channel count. Merge that info in.
311-
set_output_type(0, get_input_element_type(0), m_forward_arg_shape);
312-
}
313-
314-
const Shape& op::v0::AvgPoolBackprop::get_forward_arg_shape() const
315-
{
316-
return m_forward_arg_shape;
317-
}
318-
319-
void op::v0::AvgPoolBackprop::set_forward_arg_shape(const Shape& forward_arg_shape)
320-
{
321-
m_forward_arg_shape = forward_arg_shape;
322-
}
323-
324-
const Shape& op::v0::AvgPoolBackprop::get_window_shape() const
325-
{
326-
return m_window_shape;
327-
}
328-
329-
void op::v0::AvgPoolBackprop::set_window_shape(const Shape& window_shape)
330-
{
331-
m_window_shape = window_shape;
332-
}
333-
334-
const Strides& op::v0::AvgPoolBackprop::get_window_movement_strides() const
335-
{
336-
return m_window_movement_strides;
337-
}
338-
339-
void op::v0::AvgPoolBackprop::set_window_movement_strides(const Strides& window_movement_strides)
340-
{
341-
m_window_movement_strides = window_movement_strides;
342-
}
343-
344-
const Shape& op::v0::AvgPoolBackprop::get_padding_below() const
345-
{
346-
return m_padding_below;
347-
}
348-
349-
void op::v0::AvgPoolBackprop::set_padding_below(const Shape& padding_below)
350-
{
351-
m_padding_below = padding_below;
352-
}
353-
354-
const Shape& op::v0::AvgPoolBackprop::get_padding_above() const
355-
{
356-
return m_padding_above;
357-
}
358-
359-
void op::v0::AvgPoolBackprop::set_padding_above(const Shape& padding_above)
360-
{
361-
m_padding_above = padding_above;
362-
}
363-
364-
bool op::v0::AvgPoolBackprop::get_include_padding_in_avg_computation() const
365-
{
366-
return m_include_padding_in_avg_computation;
367-
}
368-
369-
void op::v0::AvgPoolBackprop::set_include_padding_in_avg_computation(
370-
bool include_padding_in_avg_computation)
371-
{
372-
m_include_padding_in_avg_computation = include_padding_in_avg_computation;
373-
}
374-
375-
shared_ptr<Node> op::v0::AvgPoolBackprop::clone_with_new_inputs(const OutputVector& new_args) const
376-
{
377-
check_new_args_count(this, new_args);
378-
return make_shared<v0::AvgPoolBackprop>(m_forward_arg_shape,
379-
new_args.at(0),
380-
m_window_shape,
381-
m_window_movement_strides,
382-
m_padding_below,
383-
m_padding_above,
384-
m_include_padding_in_avg_computation);
385-
}
386-
387-
void op::v0::AvgPool::generate_adjoints(autodiff::Adjoints& adjoints, const OutputVector& deltas)
388-
{
389-
if (m_ceil_mode)
390-
{
391-
throw ngraph_error("Autodiff not supported on AvgPool with ceil_mode set");
392-
}
393-
394-
auto delta = deltas.at(0);
395-
396-
auto operand = input_value(0);
397-
auto& operand_shape = get_input_shape(0);
398-
auto backprop = make_shared<op::v0::AvgPoolBackprop>(operand_shape,
399-
delta,
400-
m_window_shape,
401-
m_window_movement_strides,
402-
m_padding_below,
403-
m_padding_above,
404-
m_include_padding_in_avg_computation);
405-
adjoints.add_delta(operand, backprop);
406-
}
407-
408249
// *** AvgPool OP SET 1 ***
409250
constexpr NodeTypeInfo op::v1::AvgPool::type_info;
410251

@@ -594,155 +435,6 @@ shared_ptr<Node> op::v1::AvgPool::clone_with_new_inputs(const OutputVector& new_
594435
m_auto_pad);
595436
}
596437

597-
constexpr NodeTypeInfo op::v1::AvgPoolBackprop::type_info;
598-
599-
op::v1::AvgPoolBackprop::AvgPoolBackprop(const Output<Node>& delta,
600-
const Output<Node>& forward_arg_shape,
601-
const Strides& strides,
602-
const Shape& pads_begin,
603-
const Shape& pads_end,
604-
const Shape& kernel,
605-
bool exclude_pad)
606-
: Op({delta, forward_arg_shape})
607-
, m_kernel(kernel)
608-
, m_strides(strides)
609-
, m_pads_begin(pads_begin)
610-
, m_pads_end(pads_end)
611-
, m_exclude_pad(exclude_pad)
612-
{
613-
constructor_validate_and_infer_types();
614-
}
615-
616-
bool op::v1::AvgPoolBackprop::visit_attributes(AttributeVisitor& visitor)
617-
{
618-
visitor.on_attribute("kernel", m_kernel);
619-
visitor.on_attribute("strides", m_strides);
620-
visitor.on_attribute("pads_begin", m_pads_begin);
621-
visitor.on_attribute("pads_end", m_pads_end);
622-
visitor.on_attribute("exclude_pad", m_exclude_pad);
623-
return true;
624-
}
625-
626-
const Shape op::v1::AvgPoolBackprop::get_forward_arg_shape() const
627-
{
628-
Shape shape;
629-
if (auto const_op = as_type<op::Constant>(input_value(1).get_node()))
630-
{
631-
shape = const_op->get_shape_val();
632-
}
633-
return shape;
634-
}
635-
636-
void op::v1::AvgPoolBackprop::validate_and_infer_types()
637-
{
638-
// infer_batched_forward_pooling wants CoordinateDiffs for these, while the pooling ops for
639-
// now still take Shape (no negative padding).
640-
CoordinateDiff pads_begin(m_pads_begin.begin(), m_pads_begin.end());
641-
CoordinateDiff pads_end(m_pads_end.begin(), m_pads_end.end());
642-
643-
PartialShape forward_arg_shape{PartialShape::dynamic()};
644-
645-
if (input_value(1).get_node_shared_ptr()->is_constant())
646-
{
647-
forward_arg_shape = get_forward_arg_shape();
648-
}
649-
650-
PartialShape forward_result_shape = infer_batched_pooling_forward(
651-
this, forward_arg_shape, pads_begin, pads_end, m_kernel, m_strides, m_exclude_pad);
652-
653-
const PartialShape& delta_shape = get_input_partial_shape(0);
654-
655-
NODE_VALIDATION_CHECK(
656-
this,
657-
forward_result_shape.compatible(delta_shape),
658-
"Inferred forward output shape does not match delta shape (inferred forward output ",
659-
"shape: ",
660-
forward_result_shape,
661-
", delta shape: ",
662-
delta_shape,
663-
").");
664-
665-
set_input_is_relevant_to_shape(1);
666-
set_output_type(0, get_input_element_type(0), forward_arg_shape);
667-
}
668-
669-
const Shape& op::v1::AvgPoolBackprop::get_kernel() const
670-
{
671-
return m_kernel;
672-
}
673-
674-
void op::v1::AvgPoolBackprop::set_kernel(const Shape& kernel)
675-
{
676-
m_kernel = kernel;
677-
}
678-
679-
const Strides& op::v1::AvgPoolBackprop::get_strides() const
680-
{
681-
return m_strides;
682-
}
683-
684-
void op::v1::AvgPoolBackprop::set_strides(const Strides& strides)
685-
{
686-
m_strides = strides;
687-
}
688-
689-
const Shape& op::v1::AvgPoolBackprop::get_pads_begin() const
690-
{
691-
return m_pads_begin;
692-
}
693-
694-
void op::v1::AvgPoolBackprop::set_pads_begin(const Shape& pads_begin)
695-
{
696-
m_pads_begin = pads_begin;
697-
}
698-
699-
const Shape& op::v1::AvgPoolBackprop::get_pads_end() const
700-
{
701-
return m_pads_end;
702-
}
703-
704-
void op::v1::AvgPoolBackprop::set_pads_end(const Shape& pads_end)
705-
{
706-
m_pads_end = pads_end;
707-
}
708-
709-
bool op::v1::AvgPoolBackprop::get_exclude_pad() const
710-
{
711-
return m_exclude_pad;
712-
}
713-
714-
void op::v1::AvgPoolBackprop::set_exclude_pad(bool exclude_pad)
715-
{
716-
m_exclude_pad = exclude_pad;
717-
}
718-
719-
shared_ptr<Node> op::v1::AvgPoolBackprop::clone_with_new_inputs(const OutputVector& new_args) const
720-
{
721-
check_new_args_count(this, new_args);
722-
return make_shared<v1::AvgPoolBackprop>(new_args.at(0),
723-
new_args.at(1),
724-
m_strides,
725-
m_pads_begin,
726-
m_pads_end,
727-
m_kernel,
728-
m_exclude_pad);
729-
}
730-
731-
void op::v1::AvgPool::generate_adjoints(autodiff::Adjoints& adjoints, const OutputVector& deltas)
732-
{
733-
if (m_rounding_type == op::RoundingType::CEIL)
734-
{
735-
throw ngraph_error("Autodiff not supported on AvgPool with ceil_mode set");
736-
}
737-
738-
auto delta = deltas.at(0);
739-
740-
auto operand = input_value(0);
741-
auto backprop = make_shared<op::v1::AvgPoolBackprop>(
742-
delta, input_value(1), m_strides, m_pads_begin, m_pads_end, m_kernel, m_exclude_pad);
743-
adjoints.add_delta(operand, backprop);
744-
}
745-
746438
shared_ptr<Node> op::v1::AvgPool::get_default_value() const
747439
{
748440
return op::Constant::create(get_element_type(), get_shape(), {0});

0 commit comments

Comments
 (0)