Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[microNPU] Add various options to the cascader #10509

Merged
merged 2 commits into from
May 13, 2022

Conversation

jacobbohlin
Copy link
Contributor

This PR adds multiple options to the cascader. One option is to toggle multi-dimensional striping and it is disabled by default. The reasoning is that exploring striping in more than 1 dimension has a very high computational cost.
The remainder of the options are aimed towards developers/debugging and are prefixed with dev_. The options are exposed to tvmc. It also introduces the ability to dump information about the cascader proposals to a .json file.

Co-authored-by: Matthew Barrett [email protected]

@jacobbohlin
Copy link
Contributor Author

@areusch areusch removed their request for review April 8, 2022 22:56
Copy link
Contributor

@ekalda ekalda left a comment

Choose a reason for hiding this comment

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

Thanks @jacobbohlin, looks good to me in general, mostly nits and questions :)

if len(self.output_shape) != len(other.output_shape):
return False

return other >= self
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it supposed to be similar to the comparison in __ge__?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I thought the easiest way to define strict less than in this case was as the inverse of greater or equal, i.e. __ge__.

output_cycles = self._get_output_cycles(
op_type, op_str, ifm_dtype, ofm_dtype, activation
)
output_cycles *= reduce(lambda a, b: a * b, block_shape, 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe np.prod(block_shape) for simplicity

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's probably simpler, I will change it.

break
if select_proposal_idx != -1:
# Manually select proposal based on index
proposal_choice = proposals[select_proposal_idx % len(proposals)]
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the % len(proposals) for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's just to ensure that we always select a proposal. I can add a comment to clarify.

/*! \brief Flag to disable pareto culling for proposals to allow non pareto-optimal proposals */
bool disable_pareto_proposals;
/*! \brief Whether to consider multi-dimensional striping */
bool multi_dimensional_striping;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: maybe enable_multi_dimensional_striping to match with other similar variables

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good!

src/contrib/ethosu/cascader/pareto.h Show resolved Hide resolved
Comment on lines 58 to 70
TVM_ATTR_FIELD(dev_force_block_config)
.describe(
"Force the block config to a given value; format = "
"\"[BLK_HEIGHT]x[BLK_WIDTH]x[BLK_DEPTH]\"")
.set_default("");
Copy link
Contributor

Choose a reason for hiding this comment

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

Should that dev option also also come with a dev_warning?

Comment on lines 49 to 100
expected_stripe_configs = {
cs.StripeConfig([1, 1], [400, 400], [1, 1], [1, 2], [400, 400], [0, 0]),
cs.StripeConfig([1, 1], [400, 400], [1, 1], [2, 1], [400, 400], [0, 0]),
cs.StripeConfig([200, 1], [400, 400], [200, 1], [1, 2], [2, 400], [0, 0]),
cs.StripeConfig([200, 1], [400, 400], [200, 1], [2, 1], [2, 400], [0, 0]),
cs.StripeConfig([400, 1], [400, 400], [400, 1], [2, 1], [1, 400], [0, 0]),
cs.StripeConfig([1, 200], [400, 400], [1, 200], [1, 2], [400, 2], [0, 0]),
cs.StripeConfig([1, 200], [400, 400], [1, 200], [2, 1], [400, 2], [0, 0]),
cs.StripeConfig([200, 200], [400, 400], [200, 200], [2, 1], [2, 2], [0, 0]),
cs.StripeConfig([200, 200], [400, 400], [200, 200], [1, 2], [2, 2], [0, 0]),
cs.StripeConfig([400, 200], [400, 400], [400, 200], [2, 1], [1, 2], [0, 0]),
cs.StripeConfig([1, 400], [400, 400], [1, 400], [1, 2], [400, 1], [0, 0]),
cs.StripeConfig([200, 400], [400, 400], [200, 400], [1, 2], [2, 1], [0, 0]),
cs.StripeConfig([400, 400], [400, 400], [400, 400], [1, 2], [1, 1], [0, 0]),
}

output_stripe_configs = _generate_output_stripe_configs(
part=part_1, stripe_factors=stripe_factors, multi_dimensional=True
)

assert len(output_stripe_configs) == len(expected_stripe_configs)
assert set(output_stripe_configs) == expected_stripe_configs
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be good to have some tests for the various culling disabling options. Is it possible to compare sets of plans, proposals or block configs similarly to how it is done here for the stripe configs? In that case we could have similar regressions tests for non optimal proposals, plans and block configs.

@jacobbohlin jacobbohlin force-pushed the cascader-add-options branch from 4dbc61d to 61a78c7 Compare April 26, 2022 10:53
@jacobbohlin jacobbohlin force-pushed the cascader-add-options branch 2 times, most recently from a3e03cd to eb788dc Compare May 11, 2022 11:31
@manupak
Copy link
Contributor

manupak commented May 11, 2022

Might need to retrigger the CI...

@jacobbohlin jacobbohlin force-pushed the cascader-add-options branch from eb788dc to f518c57 Compare May 12, 2022 10:34
* Added option to toggle multi-dimensional striping, it is disabled by
  default because it has a very high computational cost. Single
  dimension striping shares most of the benefit with greatly reduced
  cost.
* Added multiple developer/debugging options prefixed with 'dev_'
  Also added these options to tvmc.
* Added cascader logging, if enabled it will dump information about the
  cascader proposals to a 'cascader_log.json' file.

Co-authored-by: Matthew Barrett <[email protected]>
Change-Id: I2ec59ae0bd84b73b2cc4bc56d39e3831b0aeec27
@jacobbohlin jacobbohlin force-pushed the cascader-add-options branch from f518c57 to 0e304b8 Compare May 13, 2022 07:40
Also added enable_striping to plan_generator.h

Change-Id: I496b30ed6af6f0730087329cd81a69c5040a5e4d
@jacobbohlin jacobbohlin force-pushed the cascader-add-options branch from 0e304b8 to 4dddb0e Compare May 13, 2022 09:47
Copy link
Contributor

@manupak manupak left a comment

Choose a reason for hiding this comment

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

LGTM!

@manupak manupak merged commit 7c75b77 into apache:main May 13, 2022
@manupak
Copy link
Contributor

manupak commented May 13, 2022

Thanks all! This is merged now

@jacobbohlin
Copy link
Contributor Author

Thank you!

mehrdadh pushed a commit to mehrdadh/tvm that referenced this pull request May 16, 2022
* [microNPU] Added options to Cascader

* Added option to toggle multi-dimensional striping, it is disabled by
  default because it has a very high computational cost. Single
  dimension striping shares most of the benefit with greatly reduced
  cost.
* Added multiple developer/debugging options prefixed with 'dev_'
  Also added these options to tvmc.
* Added cascader logging, if enabled it will dump information about the
  cascader proposals to a 'cascader_log.json' file.

Co-authored-by: Matthew Barrett <[email protected]>
Change-Id: I2ec59ae0bd84b73b2cc4bc56d39e3831b0aeec27

* Updated memory_reduction testcases

Also added enable_striping to plan_generator.h

Change-Id: I496b30ed6af6f0730087329cd81a69c5040a5e4d

Co-authored-by: Matthew Barrett <[email protected]>
shtinsa pushed a commit to Deelvin/tvm that referenced this pull request May 17, 2022
* [microNPU] Added options to Cascader

* Added option to toggle multi-dimensional striping, it is disabled by
  default because it has a very high computational cost. Single
  dimension striping shares most of the benefit with greatly reduced
  cost.
* Added multiple developer/debugging options prefixed with 'dev_'
  Also added these options to tvmc.
* Added cascader logging, if enabled it will dump information about the
  cascader proposals to a 'cascader_log.json' file.

Co-authored-by: Matthew Barrett <[email protected]>
Change-Id: I2ec59ae0bd84b73b2cc4bc56d39e3831b0aeec27

* Updated memory_reduction testcases

Also added enable_striping to plan_generator.h

Change-Id: I496b30ed6af6f0730087329cd81a69c5040a5e4d

Co-authored-by: Matthew Barrett <[email protected]>
shingjan pushed a commit to shingjan/tvm that referenced this pull request May 17, 2022
* [microNPU] Added options to Cascader

* Added option to toggle multi-dimensional striping, it is disabled by
  default because it has a very high computational cost. Single
  dimension striping shares most of the benefit with greatly reduced
  cost.
* Added multiple developer/debugging options prefixed with 'dev_'
  Also added these options to tvmc.
* Added cascader logging, if enabled it will dump information about the
  cascader proposals to a 'cascader_log.json' file.

Co-authored-by: Matthew Barrett <[email protected]>
Change-Id: I2ec59ae0bd84b73b2cc4bc56d39e3831b0aeec27

* Updated memory_reduction testcases

Also added enable_striping to plan_generator.h

Change-Id: I496b30ed6af6f0730087329cd81a69c5040a5e4d

Co-authored-by: Matthew Barrett <[email protected]>
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.

3 participants