Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ else()
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${warning_flags} ${TORCH_CXX_FLAGS}")

# Ensure that torchaudio is torch ABI stable.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTORCH_TARGET_VERSION=0x020a000000000000")

find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
message(STATUS "Found ccache")
Expand Down
13 changes: 13 additions & 0 deletions src/libtorchaudio/cuctc/src/python_binding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,25 @@
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

// It is safe to temporarily disable TORCH_TARGET_VERSION for pybind11
// as it is a header-only library.
#ifdef TORCH_TARGET_VERSION
#define SAVE_TORCH_TARGET_VERSION TORCH_TARGET_VERSION
#undef TORCH_TARGET_VERSION
#endif
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#ifdef SAVE_TORCH_TARGET_VERSION
#define TORCH_TARGET_VERSION SAVE_TORCH_TARGET_VERSION
#undef SAVE_TORCH_TARGET_VERSION
#endif

#include <tuple>
#include <utility>
#include <vector>
#include "include/ctc_prefix_decoder.h"

namespace py = pybind11;

std::tuple<size_t, std::vector<std::vector<std::pair<float, std::vector<int>>>>>
Expand Down
11 changes: 11 additions & 0 deletions src/libtorchaudio/pybind/pybind.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
#include <libtorchaudio/utils.h>

// It is safe to temporarily disable TORCH_TARGET_VERSION for pybind11
// as it is a header-only library.
#ifdef TORCH_TARGET_VERSION
#define SAVE_TORCH_TARGET_VERSION TORCH_TARGET_VERSION
#undef TORCH_TARGET_VERSION
#endif
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#ifdef SAVE_TORCH_TARGET_VERSION
#define TORCH_TARGET_VERSION SAVE_TORCH_TARGET_VERSION
#undef SAVE_TORCH_TARGET_VERSION
#endif

namespace torchaudio {
namespace {
Expand Down
Loading