Skip to content
This repository has been archived by the owner on Aug 15, 2019. It is now read-only.

Remove circular deps #1117

Merged
merged 10 commits into from
Jun 22, 2018
Merged

Remove circular deps #1117

merged 10 commits into from
Jun 22, 2018

Conversation

dsmilkov
Copy link
Contributor

@dsmilkov dsmilkov commented Jun 22, 2018

Remove all circular dependencies and add a lint check.

Circular dependencies prohibit us to properly sync the library internally at Google. This PR has no changes in functionality. Just moving code around.

An overview of the changes:

  • tensor.ts becomes a lightweight module with almost no dependencies. It doesn't depend on any environment/engine/ops anymore. Instead the environment registers an op handler and a tensor tracker, and the Tensor class delegates chain ops and registration to those handlers (see tensor.ts)
  • Combined environment.ts and engine.ts in one file as they were already deeply coupled
  • Split types.ts into types.ts and tensor_types.ts (the latter depends on tensor)
  • Split util.ts into util.ts and tensor_util.ts (the latter depends on tensor)
  • Split array_ops.ts into array_ops.ts and tensor_ops.ts (the latter doesn't call into ENV.engine, the former calls ENV.engine.runKernel)
  • Other minor splits (e.g. relu_ops.ts separated from unary_ops.ts because of circular dep, etc...)

DEV


This change is Reviewable

@dsmilkov dsmilkov changed the title [WIP] Remove circular deps Remove circular deps Jun 22, 2018
@dsmilkov dsmilkov requested review from nsthorat and tafsiri June 22, 2018 14:02
@nsthorat
Copy link
Contributor

:lgtm_strong:


Reviewed 1 of 31 files at r1, 1 of 48 files at r3.
Review status: :shipit: complete! 1 of 1 LGTMs obtained


src/environment.ts, line 660 at r4 (raw file):

const TEST_EPSILON_FLOAT32_DISABLED = 1e-1;

function hasExtension(gl: WebGLRenderingContext, extensionName: string) {

this file is enormous now, it was already growing out of hand.

There are a bunch of functions in this file that are leaves that do feature testing (all of the WebGL functions from here down), can you move them to a new file, maybe environment_util.ts?


src/tensor.ts, line 1261 at r4 (raw file):

}

// Maximum number of values before we decide to show ellipsis.

this file is also huge, could you move these functions out to tensor_util.ts (to remove dependency on Tensor just pass vals, shape, and strides directly)


src/tensor_types.ts, line 50 at r4 (raw file):

}

export interface ModelPredictConfig {

how about a model_types.ts file for these two interfaces (predict and inference model)?


Comments from Reviewable

@dsmilkov
Copy link
Contributor Author

Reviewed 31 of 31 files at r1, 3 of 3 files at r2, 48 of 48 files at r3, 27 of 27 files at r4, 5 of 7 files at r5.
Review status: :shipit: complete! 1 of 1 LGTMs obtained


src/environment.ts, line 660 at r4 (raw file):

Previously, nsthorat (Nikhil Thorat) wrote…

this file is enormous now, it was already growing out of hand.

There are a bunch of functions in this file that are leaves that do feature testing (all of the WebGL functions from here down), can you move them to a new file, maybe environment_util.ts?

Done! I split environment.ts into 3 files:

  • environment.ts 406 LOC
  • engine.ts 474 LOC
  • environment_util.ts 284 LOC

src/tensor.ts, line 1261 at r4 (raw file):

Previously, nsthorat (Nikhil Thorat) wrote…

this file is also huge, could you move these functions out to tensor_util.ts (to remove dependency on Tensor just pass vals, shape, and strides directly)

Done. Moved to tensor_format.ts since tensor_util.ts depends on Tensor since it has a bunch of utils that work with Tensors


src/tensor_types.ts, line 50 at r4 (raw file):

Previously, nsthorat (Nikhil Thorat) wrote…

how about a model_types.ts file for these two interfaces (predict and inference model)?

Done.


Comments from Reviewable

@dsmilkov dsmilkov merged commit 6ee7c87 into master Jun 22, 2018
@dsmilkov dsmilkov deleted the circle branch June 22, 2018 20:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants