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

implement eltwise_max direct to metal (#533) #1335

Merged
merged 4 commits into from
Dec 2, 2024
Merged

Conversation

vroubtsovTT
Copy link
Contributor

@vroubtsovTT vroubtsovTT commented Nov 20, 2024

  1. TTIR_MaximumOp has been made to extend TTIR_GenericElementwiseBinaryOp in TTIROps.td and the ensuing necessary modifications were done throughout the metal pipeline
  2. convertComputeBinaryOp() in TTIRToTTMetal.cpp has been made to build all "generic" binary ops like add/maximum via commonComputeBinaryOp<> parameterized with the type of a tile op; several local vars (inCB0, inCB1, etc) have become redundant in the new code structure and were moved inside the mlir::isaarith::DivFOp else-branch
  3. simple_max.mlir is a new test for this, intentionally distinct from simple_eltwise.mlir

@nsmithtt
Copy link
Contributor

CI appears to be failing w/

/tmp/ttmlir_maximum_%5_tensix__0_0-0_0.cpp: In function 'void chlkc_pack::kernel_main()':
/tmp/ttmlir_maximum_%5_tensix__0_0-0_0.cpp:24:3: error: 'max_tiles_init' was not declared in this scope
   24 |   max_tiles_init(v2, v4);
      |   ^~~~~~~~~~~~~~
/tmp/ttmlir_maximum_%5_tensix__0_0-0_0.cpp:42:7: error: 'max_tiles' was not declared in this scope
   42 |       max_tiles(v2, v4, v19, v19, v20);
      |       ^~~~~~~~~
                 Always | FATAL    | trisc2 build failed

I think we are missing a header after all :p "compute_kernel_api.h" see:

builder->create<emitc::IncludeOp>(loc, "llk_defs.h",

@nsmithtt
Copy link
Contributor

Aside from the missing header the change looks perfect :)

@vroubtsovTT
Copy link
Contributor Author

vroubtsovTT commented Nov 20, 2024

patched TTKernelToEmitC.cpp to add compute_kernel_api.h inclusion. For the test file, emitted C looks like

#include "llk_defs.h"
#include "compute_kernel_api/common.h"
#include "compute_kernel_api/tilize.h"
#include "compute_kernel_api/untilize.h"
#include "compute_kernel_api/eltwise_binary.h"
#include "compute_kernel_api.h"
#include "compute_kernel_api/tile_move_copy.h"
#include "compute_kernel_api/eltwise_unary/eltwise_unary.h"
#include "compute_kernel_api/eltwise_unary/exp.h"
#include "compute_kernel_api/eltwise_unary/sfpu_split_includes.h"
#include "compute_kernel_api/eltwise_unary/recip.h"
#define REDUCE_OP PoolType::SUM
#define REDUCE_DIM ReduceDim::REDUCE_COL
#include "compute_kernel_api/reduce.h"
namespace NAMESPACE {
void kernel_main() {
...
      max_tiles(v2, v4, v19, v19, v20);

Copy link
Contributor

@nsmithtt nsmithtt left a comment

Choose a reason for hiding this comment

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

This looks great!

@vroubtsovTT vroubtsovTT merged commit 12fc71c into main Dec 2, 2024
20 checks passed
@vroubtsovTT vroubtsovTT deleted the vroubtsov/issue-533 branch December 3, 2024 16:11
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