Skip to content

Commit

Permalink
Move FakeFP16 back to internal to remove dependency on MKL (#36297)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: pytorch/pytorch#36297

Pull Request resolved: pytorch#343

We moved FakeFP16 back to close source and kept `RoundToFloat16` function in "fbgemm/FbgemmConvert.h".

This is because FakeFP16 introduced dependency on MKL in the FBGEMM core. Also it doesn't seem to be needed for open source, as it is not used anywhere.

Reviewed By: jspark1105

Differential Revision: D20937962

fbshipit-source-id: 9487a9fd2282b6df2f754c22bea36f2255a5c791
  • Loading branch information
jianyuh authored and facebook-github-bot committed Apr 10, 2020
1 parent f1d3330 commit 20b6cf1
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 773 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ else()
endif()

# Define file lists
get_filelist("get_fbgemm_generic_srcs(with_fp16=True)" FBGEMM_GENERIC_SRCS)
get_filelist("get_fbgemm_generic_srcs()" FBGEMM_GENERIC_SRCS)
get_filelist("get_fbgemm_avx2_srcs(msvc=${MSVC_BOOL})" FBGEMM_AVX2_SRCS)
get_filelist("get_fbgemm_avx512_srcs(msvc=${MSVC_BOOL})" FBGEMM_AVX512_SRCS)
get_filelist("get_fbgemm_public_headers(with_fp16=True)" FBGEMM_PUBLIC_HEADERS)
get_filelist("get_fbgemm_public_headers()" FBGEMM_PUBLIC_HEADERS)

add_library(fbgemm_generic OBJECT ${FBGEMM_GENERIC_SRCS})
add_library(fbgemm_avx2 OBJECT ${FBGEMM_AVX2_SRCS})
Expand Down
6 changes: 3 additions & 3 deletions bench/BenchUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/
#include "./BenchUtils.h"

#include <cstring>
#include <algorithm>
#include <cstring>
#include <random>
#include <type_traits>

Expand Down Expand Up @@ -43,8 +43,8 @@ randFill<uint8_t>(aligned_vector<uint8_t>& vec, uint8_t low, uint8_t high);
template void
randFill<int8_t>(aligned_vector<int8_t>& vec, int8_t low, int8_t high);
template void randFill<int>(aligned_vector<int>& vec, int low, int high);
//template void
//randFill<int64_t>(aligned_vector<int64_t>& vec, int64_t low, int64_t high);
// template void
// randFill<int64_t>(aligned_vector<int64_t>& vec, int64_t low, int64_t high);
template <>
void randFill(aligned_vector<int64_t>& vec, int64_t low, int64_t high) {
std::uniform_int_distribution<int64_t> dis(low, high);
Expand Down
315 changes: 0 additions & 315 deletions bench/FakeFP16Benchmark.cc

This file was deleted.

8 changes: 4 additions & 4 deletions defs.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
def get_fbgemm_generic_srcs(with_fp16 = False):
def get_fbgemm_generic_srcs():
return [
"src/EmbeddingSpMDM.cc",
"src/EmbeddingSpMDMNBit.cc",
Expand Down Expand Up @@ -32,9 +32,9 @@ def get_fbgemm_generic_srcs(with_fp16 = False):
"src/RowWiseSparseAdagradFused.cc",
"src/SparseAdagrad.cc",
"src/Utils.cc",
] + (["src/FbgemmFakeFP16.cc"] if with_fp16 else [])
]

def get_fbgemm_public_headers(with_fp16 = False):
def get_fbgemm_public_headers():
return [
"include/fbgemm/Fbgemm.h",
"include/fbgemm/FbgemmBuild.h",
Expand All @@ -52,7 +52,7 @@ def get_fbgemm_public_headers(with_fp16 = False):
"include/fbgemm/ConvUtils.h",
"include/fbgemm/Types.h",
"include/fbgemm/FbgemmI8Spmdm.h",
] + (["include/fbgemm/FbgemmFakeFP16.h"] if with_fp16 else [])
]

def get_fbgemm_avx2_srcs(msvc = False):
return [
Expand Down
11 changes: 11 additions & 0 deletions include/fbgemm/FbgemmConvert.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,15 @@ FBGEMM_API void Float16ToFloat_avx2(const float16* src, float* dst, int size);
*/
FBGEMM_API void Float16ToFloat_avx512(const float16* src, float* dst, int size);

/**
* @brief Transform all entries in a matrix from fp32 to float16 and back to
* fp32.
*/
FBGEMM_API void RoundToFloat16(
const float* input,
float* output,
int len,
bool clamp = false,
bool clamp_denorms = false);

}; // namespace fbgemm
Loading

0 comments on commit 20b6cf1

Please sign in to comment.