Skip to content

initial setup for refactoring size processing to separate eigen-specific steps. - #425

Merged
perrydv merged 7 commits into
develfrom
refactor-size-processing
Jun 12, 2017
Merged

initial setup for refactoring size processing to separate eigen-specific steps.#425
perrydv merged 7 commits into
develfrom
refactor-size-processing

Conversation

@perrydv

@perrydv perrydv commented Jun 6, 2017

Copy link
Copy Markdown
Contributor

This PR is ready to merge if it passes tests.

This PR include basic setup for refactoring size processing to disentangle eigen-specific steps from general size and type annotation steps. Eigen-specific steps include annotation of what can be handled by eigen and generating intermediates where needed for implementation using eigen. Separating these steps into distinct compiler passes should make the code cleaner and more amenable to extension such as for other back-ends.

Currently the experimental size processing works for everything in basicMathTests.

Changes include:

  • Two new compiler flags that toggle new behavior (default off): experimentalNewSizeProcessing and experimentalSelfLiftStage.

  • A new compiler stage, exprClasses_toEigenize, modeled on exprClasses_setSize, with handlers partially set up for simple cases, with placeholders for non-simple cases.

  • A new test file. This includes a function that will compare whether old and new generated C++ files are identical for a given RCfunction. It currently has one toy test for that function. It also includes a function that wraps a call to test_math and checks whether current and experimental processing of each case in basicMathTests is identical. That passes.

Comment thread packages/nimble/R/RCfunction_compile.R Outdated
}

if(nimbleOptions('useRefactoredSizeProcessing')) {
exprClasses_setToEigenize(compileInfo$nimExpr, compileInfo$newLocalSymTab, compileInfo$typeEnv)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this the one place where we will eventually toggle based on nimbleOptions('useTensorflow')?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

At the moment, yes. I think it will get slightly more complicated: If lifting temporaries out of expressions happens at later steps, we'll need to manage which pathway of catch-up processing needs to happen on those temporaries.

perrydv and others added 5 commits June 8, 2017 07:40
# Conflicts:
#	packages/nimble/R/genCpp_exprClass.R
#	packages/nimble/R/genCpp_sizeProcessing.R
#	run_tests.R
Comment thread packages/nimble/R/RCfunction_compile.R Outdated
browser()
}

if(nimbleOptions('useRefactoredSizeProcessing')) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's a good habit to name these short-lived flags experimentalMyFlagName or internalMyFlagName to make it clear to our users that they shouldn't use these flags.

if(reset) {
nextIndex <<- 1
return(invisible(NULL))
labelFunctionMetaCreator <- function() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add comment describing the purpose of this function.

}

sizeDiagonal <- function(code, symTab, typeEnv) {
## refactor: code$name change step stays here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: If you label your comments useRefactoredSizeProcessing, you will have an easier time systematically cleaning up those comments when you're done.

@@ -0,0 +1,197 @@
1### INSTRUCTIONS:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thankyou for adding instructions! 👍


## Known concern: ordering of asRow()/asCol() and intermediates

compareOldAndNewCompilationRC <- function(input) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would be nice to have unit tests, rather than these tests that "this unit behaves the same as it used to".

Comment thread run_tests.R Outdated

# Avoid running these blacklisted tests, since they take too long.
blacklist <- c('test-Math2.R', 'test-Mcmc2.R', 'test-Mcmc3.R', 'test-Filtering2.R', 'test-ADfunctions.R', 'test-ADmodels.R')
blacklist <- c('test-Math2.R', 'test-Mcmc2.R', 'test-Mcmc3.R', 'test-Filtering2.R', 'test-ADfunctions.R', 'test-ADmodels.R','test-refactorSizeProcessing.R')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is the test blacklisted? Does it currently fail? This knowledge deserves to live as a comment in the code:

blacklist <- c(blacklist, 'test-refactorSizeProcessing.R')  # These tests of an experimental refactoring currently fail.

@perrydv

perrydv commented Jun 9, 2017

Copy link
Copy Markdown
Contributor Author

Thanks for the code review @fritzo ! I've updated for all points except the larger step of adding different flavors of tests. If tests pass I think this is ready to merge.

@fritzo

fritzo commented Jun 9, 2017

Copy link
Copy Markdown
Contributor

👍

@perrydv
perrydv merged commit e419ba8 into devel Jun 12, 2017
@perrydv
perrydv deleted the refactor-size-processing branch June 12, 2017 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants