Skip to content

Conversation

@annxingyuan
Copy link
Contributor

@annxingyuan annxingyuan commented Mar 26, 2020

This is a prerequisite for #2955

Something to note is that we can't require the transpose impl functions from backend_webgl or backend_cpu because that would entail a circular dependency, so for now, when we remove a kernel from the backend, we have to import the op itself if we still want to use it within the backend.

Whenever kernels move out of the backend they can directly use the impl functions from other kernels.

Changes

  • Modularize transpose op / gradient.
  • Modularize transpose kernels for WebGL / CPU backends.

To see the logs from the Cloud Build CI, please join either our discussion or announcement mailing list.


This change is Reviewable

@annxingyuan annxingyuan changed the title WIP modularize transpose [core] Modularize transpose op and kernel. Mar 26, 2020
@annxingyuan annxingyuan self-assigned this Mar 26, 2020
Copy link
Contributor

@nsthorat nsthorat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 20 of 20 files at r1.
Reviewable status: :shipit: complete! 1 of 1 approvals obtained (waiting on @dsmilkov, @lina128, @nsthorat, and @tafsiri)

@nsthorat
Copy link
Contributor

Wait for @tafsiri of course.

Copy link
Contributor

@tafsiri tafsiri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work. LGTM. It would be good to see if we can resolve the type issues that seemed to have cropped up (assuming it was a typing issue).

Reviewed 16 of 20 files at r1.
Reviewable status: :shipit: complete! 2 of 1 approvals obtained (waiting on @annxingyuan, @dsmilkov, @lina128, and @tafsiri)


tfjs-core/src/ops/confusion_matrix.ts, line 87 at r1 (raw file):

  const oneHotPredictions =
      oneHot($predictions.asType('int32'), numClasses) as Tensor2D;
  const oneHotLabelsT: Tensor2D = oneHotLabels.transpose();

I'm curious why you needed to make this change (there are similar changes elsewhere). It it related to type definitions on the new chained augmentor?


tfjs-core/src/public/chained_ops/transpose.ts, line 28 at r1 (raw file):

}

Tensor.prototype.transpose = function<T extends Tensor>(perm?: number[]): T {

if you add this: T as the first param here then you do not need to cast the result. https://www.typescriptlang.org/docs/handbook/functions.html#this-parameters

Copy link
Contributor Author

@annxingyuan annxingyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 3 of 1 approvals obtained (waiting on @dsmilkov and @tafsiri)


tfjs-core/src/ops/confusion_matrix.ts, line 87 at r1 (raw file):

Previously, tafsiri (Yannick Assogba) wrote…

I'm curious why you needed to make this change (there are similar changes elsewhere). It it related to type definitions on the new chained augmentor?

Yes I think so.


tfjs-core/src/public/chained_ops/transpose.ts, line 28 at r1 (raw file):

Previously, tafsiri (Yannick Assogba) wrote…

if you add this: T as the first param here then you do not need to cast the result. https://www.typescriptlang.org/docs/handbook/functions.html#this-parameters

Done

@annxingyuan annxingyuan merged commit b3ac3de into master Mar 27, 2020
@annxingyuan annxingyuan deleted the modular_transpose branch March 27, 2020 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants