-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Enables 8-bit kernel in operators and tests Differential Revision: D65688410
- Loading branch information
1 parent
242f181
commit ac23009
Showing
10 changed files
with
74 additions
and
9 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
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 |
---|---|---|
|
@@ -37,3 +37,4 @@ DEFINE_OP(4); | |
DEFINE_OP(5); | ||
DEFINE_OP(6); | ||
DEFINE_OP(7); | ||
DEFINE_OP(8); |
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
29 changes: 29 additions & 0 deletions
29
...imental/ops/linear_8bit_act_xbit_weight/op_linear_8bit_act_xbit_weight_executorch/w8s.cpp
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,29 @@ | ||
// Copyright (c) Meta Platforms, Inc. and affiliates. | ||
// All rights reserved. | ||
// | ||
// This source code is licensed under the license found in the | ||
// LICENSE file in the root directory of this source tree. | ||
|
||
// Unlike ATen, ExecuTorch op registration appears to only allow on | ||
// EXECUTORCH_LIBRARY per cpp file due to a name redefinition error, so a new | ||
// file is needed for each variant | ||
|
||
#include <torchao/experimental/ops/linear_8bit_act_xbit_weight/op_linear_8bit_act_xbit_weight-impl.h> | ||
|
||
namespace { | ||
Tensor _op_out( | ||
RuntimeContext& ctx, | ||
const Tensor& activations, | ||
const Tensor& packed_weights, | ||
const Tensor& group_size_tensor, | ||
const Tensor& n_tensor, | ||
const Tensor& k_tensor, | ||
Tensor& out) { | ||
(void)ctx; | ||
linear_out_cpu</*weight_nbit*/ 8, /*has_weight_zeros*/ false>( | ||
activations, packed_weights, group_size_tensor, n_tensor, k_tensor, out); | ||
return out; | ||
} | ||
} // namespace | ||
|
||
EXECUTORCH_LIBRARY(torchao, "_linear_8bit_act_8bit0zp_weight.out", _op_out); |
29 changes: 29 additions & 0 deletions
29
...mental/ops/linear_8bit_act_xbit_weight/op_linear_8bit_act_xbit_weight_executorch/w8sz.cpp
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,29 @@ | ||
// Copyright (c) Meta Platforms, Inc. and affiliates. | ||
// All rights reserved. | ||
// | ||
// This source code is licensed under the license found in the | ||
// LICENSE file in the root directory of this source tree. | ||
|
||
// Unlike ATen, ExecuTorch op registration appears to only allow on | ||
// EXECUTORCH_LIBRARY per cpp file due to a name redefinition error, so a new | ||
// file is needed for each variant | ||
|
||
#include <torchao/experimental/ops/linear_8bit_act_xbit_weight/op_linear_8bit_act_xbit_weight-impl.h> | ||
|
||
namespace { | ||
Tensor _op_out( | ||
RuntimeContext& ctx, | ||
const Tensor& activations, | ||
const Tensor& packed_weights, | ||
const Tensor& group_size_tensor, | ||
const Tensor& n_tensor, | ||
const Tensor& k_tensor, | ||
Tensor& out) { | ||
(void)ctx; | ||
linear_out_cpu</*weight_nbit*/ 8, /*has_weight_zeros*/ true>( | ||
activations, packed_weights, group_size_tensor, n_tensor, k_tensor, out); | ||
return out; | ||
} | ||
} // namespace | ||
|
||
EXECUTORCH_LIBRARY(torchao, "_linear_8bit_act_8bit_weight.out", _op_out); |
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
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