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

Mlp example #172

Draft
wants to merge 32 commits into
base: main
Choose a base branch
from
Draft

Mlp example #172

wants to merge 32 commits into from

Conversation

jianyicheng
Copy link
Collaborator

No description provided.

@jianyicheng jianyicheng marked this pull request as draft April 24, 2024 12:52
Base automatically changed from docker-update to main April 24, 2024 15:47
Jianyi Cheng and others added 4 commits April 28, 2024 17:38
* Created test case with errors

* cache quantized weight after the first inference

* Removed quantization check

---------

Co-authored-by: Cheng Zhang <[email protected]>
Copy link
Collaborator

@pgimenes pgimenes left a comment

Choose a reason for hiding this comment

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

Then changes to chop/models/manual seem fine (although maybe unnecessary with the new HFTracer update), but I almost all the changes in chop/passes/graph/analysis (i.e. the test_verilog pass) are reimplementations of functionality already existing in chop/passes/graph/transforms/verilog, but less general, with no tests under machop/test to evaluate, and using deprecated components. The same goes for all the changes in mase_components. I agree with verilog testing being an analysis pass, but I think it would be best to drop these changes and move the existing code to passes/graph/analysis instead. The refactoring of emit verilog needs work and could have been implemented without adding 1000 lines of code. I would suggest refactoring this feature since there is time and this feature is not time pressured.



# DUT test specifications
class VerificationCase:
Copy link
Collaborator

Choose a reason for hiding this comment

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

verification classes should inherit from mase_cocotb.testbench.Testbench

dut.data_in_0_valid.value = 0
dut.data_out_0_ready.value = 1
debug_state(dut, "Pre-clk")
await FallingEdge(dut.clk)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Driving handshakes manually by assigning signals and awaiting clock edges is too verbose and error prone. We should use mase_cocotb.interfaces.streaming.StreamDriver instead



@cocotb.test()
async def test_top(dut):
Copy link
Collaborator

Choose a reason for hiding this comment

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

This functionality is already implemented in chop.passes.graph.transforms.verilog.emit_tb


def get_test_parameters(mg):
def hardware_reshape(input_data, input_shape, tiling):
Copy link
Collaborator

Choose a reason for hiding this comment

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

A good implementation is already available in chop.mase_cocotb.utils.fixed_preprocess_tensor


class VerificationCase:
Copy link
Collaborator

Choose a reason for hiding this comment

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

As previously mentioned, verification classes should inherit from mase_cocotb.Testbench

return parameter_map


def runner(mg, project_dir, top_name):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Already implemented in mase_cocotb.runner

total_size = math.prod(
node.meta["mase"].parameters["common"]["args"][param_name]["shape"]
)

dim = len(node.meta["mase"].parameters["common"]["args"][param_name]["shape"])
Copy link
Collaborator

Choose a reason for hiding this comment

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

The main-adls-2324 branch has a more clean, updated implementation of this handling of the size/dim/depth for the emitted BRAM. I would merge that into mlp_example branch and then see if any further changes are required here

Copy link
Collaborator

Choose a reason for hiding this comment

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

Separating the dataflow emitter will be useful (to enable using a memory shell later on instead of local BRAM), but it seems like the way it's been implemented has a lot of repeated and redundant code without any inheritance, and the size of the file has gotten huge. I would refactor this so the SignalEmitter, InterfaceEmitter etc are all agnostic of whether it's dataflow or memory mapped

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is an old implementation of linear, which should not be merged back into main. The new implementation without parametrization restrictions is already available in main-adls-2324, which is ready to be merged

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't understand any of the changes here. We're reverting back to using deprecated tb components, without any new functionality, when the current implementation is already working and general. I would discard this entire file

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