-
Notifications
You must be signed in to change notification settings - Fork 950
Remove circular deps #1117
Remove circular deps #1117
Conversation
Reviewed 1 of 31 files at r1, 1 of 48 files at r3. src/environment.ts, line 660 at r4 (raw file):
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):
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):
how about a model_types.ts file for these two interfaces (predict and inference model)? Comments from Reviewable |
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. src/environment.ts, line 660 at r4 (raw file): Previously, nsthorat (Nikhil Thorat) wrote…
Done! I split
src/tensor.ts, line 1261 at r4 (raw file): Previously, nsthorat (Nikhil Thorat) wrote…
Done. Moved to src/tensor_types.ts, line 50 at r4 (raw file): Previously, nsthorat (Nikhil Thorat) wrote…
Done. Comments from Reviewable |
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 (seetensor.ts
)environment.ts
andengine.ts
in one file as they were already deeply coupledtypes.ts
intotypes.ts
andtensor_types.ts
(the latter depends on tensor)util.ts
intoutil.ts
andtensor_util.ts
(the latter depends on tensor)array_ops.ts
intoarray_ops.ts
andtensor_ops.ts
(the latter doesn't call into ENV.engine, the former calls ENV.engine.runKernel)relu_ops.ts
separated fromunary_ops.ts
because of circular dep, etc...)DEV
This change is