-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
373 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
// | ||
// This module define MatMulFp32Q4 operator, it is basically | ||
// matmul float32 with right hand side being a 2-D matrix | ||
// pre-packed and block-compacted into int4 | ||
// | ||
#pragma once | ||
#include "core/common/safeint.h" | ||
#include "core/providers/cuda/cuda_kernel.h" | ||
#include "core/providers/cuda/shared_inc/fpgeneric.h" | ||
|
||
namespace onnxruntime { | ||
namespace contrib { | ||
namespace cuda { | ||
using namespace onnxruntime::cuda; | ||
|
||
template <typename T> | ||
class MatMulNBits final : public CudaKernel { | ||
public: | ||
MatMulNBits(const OpKernelInfo& info) : CudaKernel(info) { | ||
ORT_ENFORCE(Status::OK() == info.GetAttr<int64_t>("K", &K_)); | ||
ORT_ENFORCE(Status::OK() == info.GetAttr<int64_t>("N", &N_)); | ||
ORT_ENFORCE(Status::OK() == info.GetAttr<int64_t>("block_size", &block_size_)); | ||
ORT_ENFORCE(Status::OK() == info.GetAttr<int64_t>("bits", &nbits_)); | ||
} | ||
|
||
Status ComputeInternal(OpKernelContext* context) const override; | ||
|
||
private: | ||
int64_t K_; | ||
int64_t N_; | ||
int64_t block_size_; | ||
int64_t nbits_; | ||
bool column_wise_quant_blk_{true}; | ||
}; | ||
|
||
} // namespace cuda | ||
} // namespace contrib | ||
} // namespace onnxruntime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.