Skip to content
class

FloorBackward

FloorBackward

Python wrappers

Public Python APIs implemented by this engine symbol.

Autograd node for element-wise floor: y=⌊x⌋y = \lfloor x \rfloor.

Piecewise-constant; derivative is zero almost everywhere and undefined at integer boundaries. The node stays in the graph with that zero gradient, as the reference keeps it.

Math

yi=⌊xi⌋y_i = \lfloor x_i \rfloor (largest integer not greater than xix_i).

Attributes

kSavesInputbool
false — nothing to save.
kHasGradientbool
true — kept in the graph with a zero gradient.
schema_v1OpSchema
Op name "floor" with AmpPolicy::KeepInput.

Notes

Integer dtypes are a no-op. Negative values round toward −∞-\infty (NOT toward zero — that is trunc).

Static methods

1
static

dispatch

int dispatch(backend::IBackend & be, const int & a, const int & s, Dtype dt)

Forward — calls IBackend::floor to compute y=⌊x⌋y = \lfloor x \rfloor.

Methods

2
fn

grad_formula

→Storage
int grad_formula(const int & g)

Zero gradient, shaped like the output.

Parameters

gconst Storage&
Incoming gradient (ignored).

Returns

Storage

Zeros shaped like the output.

fn

grad_formula_impl

int grad_formula_impl(const int & g, const int &, const int &)

Graph-mode backward — zero, like grad_formula, so the node stays differentiable under create_graph.