Skip to content

Function openvino.core.custom_gradient() should be a class #20953

Open
@JulianJvn

Description

@JulianJvn

I'm not using this, but I saw by accident while browsing the code that keras.backend.openvino.core.custom_gradient() is a function that defines nested functions __init__() and __call__(), but doesn't do anything (in particular, it seems to return None):

def custom_gradient(fun):
"""Decorator for custom gradients.
Args:
fun: Forward pass function.
"""
def __init__(self, fun):
warnings.warn(
"`custom_gradient` for the openvino backend"
" acts as a pass-through to "
"support the forward pass."
" No gradient computation or modification "
"takes place."
)
self.fun = fun
def __call__(self, *args, **kwargs):
outputs, _ = self.fun(*args, **kwargs)
return outputs

I think line 598 should be

class custom_gradient:

Introduced by 5c401a9 in #19727. It was a function throwing a NotImplementedError before, but should have been changed to a class.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions