Skip to content

Commit 9c770e6

Browse files
kimishpatelfacebook-github-bot
authored andcommitted
Setup dirsync for torchao experimental
Summary: In order to build and test kernels internally for mac, android and ios we need to add build support in xplat. Which means we need to setup mirroring between fbcode and xplat. For now setting this up only for experimental folder, pending larger decision on whether to sync the two folder entirely. Reviewed By: mzlee Differential Revision: D61480451
1 parent 2c8e3f3 commit 9c770e6

File tree

6 files changed

+45
-6
lines changed

6 files changed

+45
-6
lines changed

torchao/experimental/kernels/cpu/aarch64/benchmarks/build_and_run_benchmarks.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/bin/bash
2+
# (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
3+
24
# Call script with sh build_and_run_benchmarks.sh {BENCHAMRK}
35

46
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
2+
13
#pragma once
24

35
#define TORCHAO_ALWAYS_INLINE __attribute__((always_inline))

torchao/experimental/kernels/cpu/aarch64/tests/build_and_run_tests.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/bin/bash
2+
# (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
3+
24
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
35
export TORCHAO_LIBRARIES=${SCRIPT_DIR}/../../../../../..
46
export CMAKE_OUT=/tmp/cmake-out/torch_ao/tests

torchao/experimental/kernels/cpu/aarch64/tests/test_bitpacking.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,7 @@ template <int nbit>
185185
void test_bitpacking_32_lowbit_values() {
186186
int unpacked_bytes = 32;
187187
int packed_bytes = unpacked_bytes * nbit / 8;
188-
auto input_shifted =
189-
torchao::get_random_lowbit_vector(unpacked_bytes, nbit);
188+
auto input_shifted = torchao::get_random_lowbit_vector(unpacked_bytes, nbit);
190189
std::vector<int8_t> input(unpacked_bytes, 0);
191190
int8_t low = -(1 << (nbit - 1));
192191
int8_t high = (1 << (nbit - 1));
@@ -218,8 +217,7 @@ template <int nbit>
218217
void test_bitpacking_64_lowbit_values() {
219218
int unpacked_bytes = 64;
220219
int packed_bytes = unpacked_bytes * nbit / 8;
221-
auto input_shifted =
222-
torchao::get_random_lowbit_vector(unpacked_bytes, nbit);
220+
auto input_shifted = torchao::get_random_lowbit_vector(unpacked_bytes, nbit);
223221
std::vector<int8_t> input(unpacked_bytes, 0);
224222
int8_t low = -(1 << (nbit - 1));
225223
int8_t high = (1 << (nbit - 1));
@@ -259,8 +257,7 @@ template <int nbit>
259257
void test_bitpacking_128_lowbit_values() {
260258
int unpacked_bytes = 128;
261259
int packed_bytes = unpacked_bytes * nbit / 8;
262-
auto input_shifted =
263-
torchao::get_random_lowbit_vector(unpacked_bytes, nbit);
260+
auto input_shifted = torchao::get_random_lowbit_vector(unpacked_bytes, nbit);
264261
std::vector<int8_t> input(unpacked_bytes, 0);
265262
int8_t low = -(1 << (nbit - 1));
266263
int8_t high = (1 << (nbit - 1));
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
# (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
3+
4+
# Call script with sh build_and_run_benchmarks.sh {BENCHAMRK}
5+
6+
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
7+
export TORCHAO_LIBRARIES=${SCRIPT_DIR}/../../../..
8+
export CMAKE_OUT=/tmp/cmake-out/torch_ao/benchmarks
9+
cmake -DTORCHAO_LIBRARIES=${TORCHAO_LIBRARIES} \
10+
-S ${TORCHAO_LIBRARIES}/torchao/experimental/kernels/cpu/aarch64/benchmarks \
11+
-B ${CMAKE_OUT}
12+
13+
cmake --build ${CMAKE_OUT}
14+
15+
# Run
16+
case "$1" in
17+
quantization) ${CMAKE_OUT}/benchmark_quantization; ;;
18+
bitpacking) ${CMAKE_OUT}/benchmark_bitpacking; ;;
19+
linear) ${CMAKE_OUT}/benchmark_linear; ;;
20+
*) echo "Unknown benchmark: $1. Please specify quantization, bitpacking, or linear."; exit 1; ;;
21+
esac
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
# (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
3+
4+
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
5+
export TORCHAO_LIBRARIES=${SCRIPT_DIR}/../../../..
6+
export CMAKE_OUT=/tmp/cmake-out/torch_ao/tests
7+
cmake -DTORCHAO_LIBRARIES=${TORCHAO_LIBRARIES} -S ${TORCHAO_LIBRARIES}/torchao/experimental/kernels/cpu/aarch64/tests -B ${CMAKE_OUT}
8+
9+
cmake --build ${CMAKE_OUT}
10+
11+
# Run
12+
${CMAKE_OUT}/test_quantization
13+
${CMAKE_OUT}/test_bitpacking
14+
${CMAKE_OUT}/test_linear
15+
${CMAKE_OUT}/test_valpacking

0 commit comments

Comments
 (0)