Skip to content

C API Locking prevents custom gradient definition #48767

Description

@rnett

I am trying to add custom gradient support to the Java bindings (tensorflow/java#292). This is currently being prevented by the fact that TF_AddGradientsWithPrefix requires a lock on the graph, but so do any operation creation methods (i.e. TF_NewOperation), so it is impossible to create ops in gradient functions.

Is there a way I can get around this? I am considering calling TF_NewOperationLocked directly but I assume the locks are there for a reason.

Activity

  1. added
    type:othersissues not falling in bug, perfromance, support, build and install or feature
    on Apr 27, 2021
  2. added
    comp:apisHighlevel API related issues
    and removed
    type:othersissues not falling in bug, perfromance, support, build and install or feature
    on Apr 28, 2021
  3. added
    comp:coreissues related to core part of tensorflow
    and removed
    comp:apisHighlevel API related issues
    on Apr 28, 2021
  4. kkimdev commented on May 6, 2021

    @kkimdev
    Contributor

    Thanks for reporting the issue!

  5. saxenasaurabh commented on May 6, 2021

    @saxenasaurabh
    Member

    Please feel free to send a PR!

  6. rnett commented on May 6, 2021

    @rnett
    ContributorAuthor

    I can, but what's the preferred solution? Providing and exposing a TF_AddGradientsWithPrefixLocked that doesn't lock, or exposing TF_NewOperationLocked and TF_FinishOperationLocked? (See #48815)

  7. saxenasaurabh commented on May 6, 2021

    @saxenasaurabh
    Member

    Exposing TF_NewOperationLocked and TF_FinishOperationLocked sgtm.

  8. removed their assignment
    on Jun 18, 2021
  9. google-ml-butler commented on Jul 15, 2021

    @google-ml-butler

    Are you satisfied with the resolution of your issue?
    Yes
    No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions