Skip to content

Merge from upstream #140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Aug 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d4832f1
More fixes for hidden visibility (#10624)
orionr Aug 20, 2018
db7b7f1
fix typo
ssnl Aug 20, 2018
0cce462
Fix backend/device-type comparison with MKLDNN.
gchanan Aug 20, 2018
aa9f328
Nomnigraph - DAG matching (#10549)
duc0 Aug 20, 2018
2e563c4
Nomnigraph - rename some APIs that invole Subtree to Subgraph (#10551)
duc0 Aug 20, 2018
3d07574
Fix EnsureCPUOutputOp (#10651)
jerryzh168 Aug 20, 2018
7832e9d
Add a bisect percentile operator (#10563)
olittle Aug 20, 2018
b4684db
Add support for Log()
Aug 20, 2018
39a3dcc
Fix #10698 build failure (#10704)
ezyang Aug 20, 2018
585e6b5
Allow method-style casts on tensors (#10641)
Aug 20, 2018
15d7f49
Adding ATEN_NO_TEST option to root level cmake for propogation to aten
pjh5 Aug 20, 2018
826550a
Update the onnx Gemm op to FC/FCTransposed logic in caffe2 onnx backe…
JerryShih Aug 20, 2018
e449a27
Fix issues link in Caffe2 readme (#10711)
duc0 Aug 20, 2018
5c0d9a2
Soumith's last few patches to v0.4.1
pjh5 Aug 21, 2018
9e75ec1
Make empty list literals construct empty Tensor[] (#10705)
suo Aug 21, 2018
f0d8a36
Completely remove build_aten and use_aten (#10469)
mingzhe09088 Aug 21, 2018
4c7c4b5
Merge remote-tracking branch 'upstream/master'
iotamudelta Aug 21, 2018
44ee7de
Skip test for now, it crashes w/ the latest master integration.
iotamudelta Aug 21, 2018
03da1b8
Move files to have unique names compared to the C2 MIOpen integration.
iotamudelta Aug 22, 2018
58b67f4
Try preferred way: use original file name and annotate with inline.
iotamudelta Aug 22, 2018
1769229
Redo.
iotamudelta Aug 22, 2018
803dec3
Correct typo.
iotamudelta Aug 22, 2018
5df0714
Skip this test as well - fails on CI now.
iotamudelta Aug 22, 2018
68438e2
Merge remote-tracking branch 'rocm_upstream/master'
iotamudelta Aug 22, 2018
d371a06
Also fails on CI now. Disable.
iotamudelta Aug 22, 2018
5e4e316
No idea why the test gets executed - mark as skipping.
iotamudelta Aug 22, 2018
8598eca
Also fails on CI - disable.
iotamudelta Aug 22, 2018
44f3d9f
Also fails on the CI now.
iotamudelta Aug 23, 2018
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
2 changes: 1 addition & 1 deletion .jenkins/caffe2/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ if [[ $BUILD_ENVIRONMENT == *rocm* ]]; then
export HCC_AMDGPU_TARGET=gfx900

########## HIPIFY Caffe2 operators
${PYTHON} "${ROOT_DIR}/tools/amd_build/build_pytorch_amd.py"
${PYTHON} "${ROOT_DIR}/tools/amd_build/build_caffe2_amd.py"
fi

Expand Down Expand Up @@ -190,7 +191,6 @@ else
fi



###############################################################################
# Configure and make
###############################################################################
Expand Down
2 changes: 1 addition & 1 deletion .jenkins/pytorch/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ cmake --version
pip install -r requirements.txt || true

if [[ "$BUILD_ENVIRONMENT" == *rocm* ]]; then
export MAX_JOBS=4
# This is necessary in order to cross compile (or else we'll have missing GPU device).
export HCC_AMDGPU_TARGET=gfx900

Expand All @@ -48,6 +47,7 @@ if [[ "$BUILD_ENVIRONMENT" == *rocm* ]]; then
sudo apt-get install libc++abi1

python tools/amd_build/build_pytorch_amd.py
python tools/amd_build/build_caffe2_amd.py
USE_ROCM=1 python setup.py install --user
exit 0
fi
Expand Down
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ endif()
include(CMakeDependentOption)
option(BUILD_TORCH "Build Torch" OFF)
option(BUILD_CAFFE2 "Build Caffe2" ON)
option(BUILD_ATEN "Build ATen" OFF)
option(ATEN_NO_TEST "Do not build ATen test binaries" OFF)
option(BUILD_ATEN_MOBILE "Build ATen for Android and iOS" OFF)
option(BUILD_BINARY "Build C++ binaries" ON)
option(BUILD_DOCS "Build Caffe2 documentation" OFF)
option(BUILD_CUSTOM_PROTOBUF "Build and use Caffe2's own protobuf under third_party" ON)
Expand All @@ -75,7 +76,6 @@ cmake_dependent_option(
"BUILD_TEST" OFF)
option(USE_ACL "Use ARM Compute Library" OFF)
option(USE_ASAN "Use Address Sanitizer" OFF)
option(USE_ATEN "Use ATen" OFF)
option(USE_CUDA "Use CUDA" ON)
option(USE_ROCM "Use ROCm" OFF)
option(CAFFE2_STATIC_LINK_CUDA "Statically link CUDA libraries" OFF)
Expand Down Expand Up @@ -145,8 +145,8 @@ option(USE_DISTRIBUTED_MW "Use THD (distributed) master worker" OFF)
# Used when building Caffe2 through setup.py
option(BUILDING_WITH_TORCH_LIBS "Tell cmake if Caffe2 is being built alongside torch libs" OFF)

if (USE_ATEN)
set(BUILD_ATEN ${USE_ATEN})
if (ANDROID OR IOS)
set(BUILD_ATEN_MOBILE ON)
endif()

# ---[ CMake scripts + modules
Expand Down
13 changes: 5 additions & 8 deletions aten/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
if (CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO)
if (NOT BUILD_ATEN)
return()
endif()
else()
if (NOT CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO)
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(ATen CXX C)
include(CMakeDependentOption)
Expand All @@ -14,9 +10,10 @@ else()
USE_CUDNN "Use cuDNN" ON
"USE_CUDA" OFF)
option(ATEN_NO_TEST "Do not build ATen test binaries" OFF)

# Flag for shared dependencies
set(BUILD_ATEN ON)
else()
if (BUILD_ATEN_MOBILE)
return()
endif()
endif()

# Find modules
Expand Down
2 changes: 1 addition & 1 deletion aten/src/ATen/ATenGeneral.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
#include "ATen/core/Macros.h"

// TODO: Merge the *_API macros.
#define AT_API AT_CORE_API
#define AT_API AT_CORE_API
17 changes: 0 additions & 17 deletions aten/src/ATen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,6 @@ IF(NOT MSVC)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-absolute-value")
ENDIF(NOT MSVC)

################################################################################
# Helper functions
################################################################################

function(filter_list output input)
unset(result)
foreach(filename ${${input}})
foreach(pattern ${ARGN})
if("${filename}" MATCHES "${pattern}")
list(APPEND result "${filename}")
endif()
endforeach()
endforeach()
set(${output} ${result} PARENT_SCOPE)
endfunction()


# Can be compiled standalone
IF(NOT AT_INSTALL_BIN_DIR OR NOT AT_INSTALL_LIB_DIR OR NOT AT_INSTALL_INCLUDE_DIR OR NOT AT_INSTALL_SHARE_DIR)
SET(AT_INSTALL_BIN_DIR "bin" CACHE PATH "AT install binary subdirectory")
Expand Down
2 changes: 1 addition & 1 deletion aten/src/ATen/cuda/ATenCUDAGeneral.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#ifdef _WIN32
# if defined(ATen_cuda_EXPORTS) || defined(caffe2_gpu_EXPORTS)
# if defined(ATen_cuda_EXPORTS) || defined(caffe2_gpu_EXPORTS) || defined(CAFFE2_BUILD_MAIN_LIB)
# define AT_CUDA_API __declspec(dllexport)
# else
# define AT_CUDA_API __declspec(dllimport)
Expand Down
2 changes: 1 addition & 1 deletion aten/src/ATen/native/Convolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ auto ConvParams::use_miopen(const at::Tensor& input) const -> bool {

auto ConvParams::use_mkldnn(const at::Tensor& input) const -> bool {
#if AT_MKLDNN_ENABLED()
return input.type().backend() == kCPU &&
return input.type().backend() == at::Backend::CPU &&
input.type().scalarType() == kFloat && // only on CPU Float Tensors
!is_dilated() && // doesn't support dilation
!transposed && // or transposed tensors
Expand Down
9 changes: 6 additions & 3 deletions aten/src/ATen/native/cuda/SpectralOps.cu
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@ using namespace at::native::detail;
// counting_iterator => index to fill
struct cnt_to_dst_idx_functor : public thrust::unary_function<int64_t, int64_t>
{
const int64_t last_dim_size;
const int64_t last_dim_start_slice;
const int64_t last_dim_to_fill_size;
int64_t last_dim_size;
int64_t last_dim_start_slice;
int64_t last_dim_to_fill_size;

cnt_to_dst_idx_functor(int64_t last_dim_size, int64_t last_dim_start_slice) :
last_dim_size(last_dim_size), last_dim_start_slice(last_dim_start_slice),
last_dim_to_fill_size(last_dim_size - last_dim_start_slice) {}

__host__ __device__
cnt_to_dst_idx_functor & operator=(const cnt_to_dst_idx_functor&) = default;

__host__ __device__ __forceinline__
int64_t operator()(const int64_t& i) const
Expand Down
4 changes: 2 additions & 2 deletions aten/src/THC/THCBlas.cu
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ void THCudaBlas_Dgetrf(THCState *state, int n, double **a, int lda, int *pivot,
THCublasCheck(cublasDgetrfBatched(handle, n, a, lda, pivot, info, batchSize));
}

THC_API void THCudaBlas_Sgetrs(THCState *state, char transa, int n, int nrhs, const float **a, int lda, int *pivot, float **b, int ldb, int *info, int batchSize)
void THCudaBlas_Sgetrs(THCState *state, char transa, int n, int nrhs, const float **a, int lda, int *pivot, float **b, int ldb, int *info, int batchSize)
{
if( (n >= INT_MAX) || (nrhs >= INT_MAX) || (lda >= INT_MAX) || (ldb >= INT_MAX) || (batchSize >= INT_MAX) )
{
Expand All @@ -531,7 +531,7 @@ THC_API void THCudaBlas_Sgetrs(THCState *state, char transa, int n, int nrhs, co
}


THC_API void THCudaBlas_Dgetrs(THCState *state, char transa, int n, int nrhs, const double **a, int lda, int *pivot, double **b, int ldb, int *info, int batchSize)
void THCudaBlas_Dgetrs(THCState *state, char transa, int n, int nrhs, const double **a, int lda, int *pivot, double **b, int ldb, int *info, int batchSize)
{
if( (n >= INT_MAX) || (nrhs >= INT_MAX) || (lda >= INT_MAX) || (ldb >= INT_MAX) || (batchSize >= INT_MAX) )
{
Expand Down
2 changes: 1 addition & 1 deletion aten/src/THC/THCGeneral.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#endif

#ifdef _WIN32
# if defined(ATen_cuda_EXPORTS) || defined(caffe2_gpu_EXPORTS)
# if defined(ATen_cuda_EXPORTS) || defined(caffe2_gpu_EXPORTS) || defined(CAFFE2_BUILD_MAIN_LIB)
# define THC_API THC_EXTERNC __declspec(dllexport)
# define THC_CLASS __declspec(dllexport)
# else
Expand Down
2 changes: 1 addition & 1 deletion aten/src/THC/THCSleep.cu
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ __global__ void spin_kernel(int64_t cycles)
}
}

THC_API void THC_sleep(THCState* state, int64_t cycles)
void THC_sleep(THCState* state, int64_t cycles)
{
dim3 grid(1);
dim3 block(1);
Expand Down
38 changes: 21 additions & 17 deletions caffe2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ include(../cmake/Codegen.cmake)
add_subdirectory(utils)

# ---[ ATen build
if(BUILD_ATEN)
if (NOT BUILD_ATEN_MOBILE)
set(__caffe2_CMAKE_POSITION_INDEPENDENT_CODE ${CMAKE_POSITION_INDEPENDENT_CODE})
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(AT_LINK_STYLE INTERFACE)
Expand Down Expand Up @@ -49,7 +49,7 @@ if(BUILD_ATEN)

IF(USE_ROCM)
# Set the HIP Variables
set(Caffe2_HIP_SRCS ${ATen_CUDA_SRCS})
set(Caffe2_HIP_SRCS ${Caffe2_HIP_SRCS} ${ATen_CUDA_SRCS})
set(Caffe2_HIP_INCLUDES ${Caffe2_HIP_INCLUDES} ${Caffe2_GPU_INCLUDE})
ENDIF(USE_ROCM)
else()
Expand Down Expand Up @@ -340,6 +340,12 @@ if(USE_CUDA)
target_compile_options(caffe2_gpu PUBLIC "-DAT_CORE_STATIC_WINDOWS=1")
endif()

# NB: This must be target_compile_definitions, not target_compile_options,
# as the latter is not respected by nvcc
if (MSVC)
target_compile_definitions(caffe2_gpu PRIVATE "-DCAFFE2_BUILD_MAIN_LIB")
endif()

# Set standard properties on the target
aten_set_target_props(caffe2_gpu)

Expand All @@ -351,21 +357,19 @@ endif()
# ---[ Caffe2 HIP sources.
if(USE_ROCM)
# Call again since Caffe2_HIP_INCLUDES is extended with ATen include dirs.
if(BUILD_ATEN)
# Get Compile Definitions from the directory (FindHIP.cmake bug)
get_directory_property(MY_DEFINITIONS COMPILE_DEFINITIONS)
if(MY_DEFINITIONS)
foreach(_item ${MY_DEFINITIONS})
LIST(APPEND HIP_HCC_FLAGS "-D${_item}")
endforeach()
endif()

# Call again since Caffe2_HIP_INCLUDES is extended with ATen include dirs.
hip_include_directories(${Caffe2_HIP_INCLUDES})
# Get Compile Definitions from the directory (FindHIP.CMake bug)
get_directory_property(MY_DEFINITIONS COMPILE_DEFINITIONS)
if(MY_DEFINITIONS)
foreach(_item ${MY_DEFINITIONS})
LIST(APPEND HIP_HCC_FLAGS "-D${_item}")
endforeach()
endif()
IF(BUILD_CAFFE2)
set_source_files_properties(${Caffe2_HIP_SRCS} PROPERTIES HIP_SOURCE_PROPERTY_FORMAT 1)
ENDIF()

# Call again since Caffe2_HIP_INCLUDES is extended with ATen include dirs.
hip_include_directories(${Caffe2_HIP_INCLUDES})

filter_list(__caffe2_hip_srcs_cpp Caffe2_HIP_SRCS "\\.(cc|cpp|cu)$")
set_source_files_properties(${__caffe2_hip_srcs_cpp} PROPERTIES HIP_SOURCE_PROPERTY_FORMAT 1)

# FindHIP.CMake checks if the SHARED flag is set and adds extra logic accordingly.
hip_add_library(caffe2_hip ${Caffe2_HIP_SRCS})
Expand Down Expand Up @@ -444,7 +448,7 @@ if(BUILD_CAFFE2)
set(__aten_test_dir "test/aten")
endif()
# Todo - Set up ATen tests for ROCm in an upcoming PR
if(BUILD_ATEN AND NOT USE_ROCM)
if(NOT USE_ROCM)
foreach(test_src ${ATen_CPU_TEST_SRCS})
get_filename_component(test_name ${test_src} NAME_WE)
add_executable(${test_name} "${test_src}")
Expand Down
2 changes: 1 addition & 1 deletion caffe2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Caffe2 is a lightweight, modular, and scalable deep learning framework. Building

## Questions and Feedback

Please use Github issues (https://github.com/caffe2/caffe2/issues) to ask questions, report bugs, and request new features.
Please use Github issues (https://github.com/pytorch/pytorch/issues) to ask questions, report bugs, and request new features.

### Further Resources on [Caffe2.ai](http://caffe2.ai)

Expand Down
2 changes: 1 addition & 1 deletion caffe2/contrib/aten/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if(BUILD_ATEN)
if(NOT BUILD_ATEN_MOBILE)
# Add source generated by Codegen.cmake and pass to parent
list(APPEND Caffe2_CPU_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/aten_op.cc)
list(APPEND Caffe2_GPU_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/aten_op_cuda.cc)
Expand Down
17 changes: 0 additions & 17 deletions caffe2/core/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,6 @@ using std::vector;
#define CAFFE2_NORETURN __attribute__((noreturn))
#endif

/**
* Macro for marking functions as having public visibility.
* Ported from folly/CPortability.h
*/
#ifndef __GNUC_PREREQ
#if defined __GNUC__ && defined __GNUC_MINOR__
#define __GNUC_PREREQ(maj, min) \
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
#else
#define __GNUC_PREREQ(maj, min) 0
#endif
#endif

// Defines CAFFE2_EXPORT and CAFFE2_IMPORT. On Windows, this corresponds to
// different declarations (dllexport and dllimport). On Linux/Mac, it just
// resolves to the same "default visibility" setting.
Expand All @@ -120,11 +107,7 @@ using std::vector;
#endif
#else
#if defined(__GNUC__)
#if __GNUC_PREREQ(4, 9)
#define CAFFE2_EXPORT [[gnu::visibility("default")]]
#else
#define CAFFE2_EXPORT __attribute__((__visibility__("default")))
#endif
#else
#define CAFFE2_EXPORT
#endif
Expand Down
10 changes: 5 additions & 5 deletions caffe2/core/graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace transform {
/**
* Graph representation of an operator.
*/
struct Node {
struct CAFFE2_API Node {
public:
// Empty constructor for resize
Node() {}
Expand Down Expand Up @@ -45,7 +45,7 @@ struct Node {
/**
* Graph representation of a Netdef.
*/
struct Graph {
struct CAFFE2_API Graph {
public:
/**
* Given a subgraph, gets all of the parents of the subgraph, as well as
Expand Down Expand Up @@ -155,7 +155,7 @@ struct Graph {

// Adds an operator def to a netdef.
// Returns the ptr, if you want to add anything extra (such as device_option)
OperatorDef* AddOp(
CAFFE2_API OperatorDef* AddOp(
NetDef* netdef_ptr,
string op_type,
std::vector<string> inputs,
Expand All @@ -168,12 +168,12 @@ OperatorDef* AddOp(
* For example, if we wanted to match an operator to Conv or FC, we can give:
* "Conv|FC" as the type() of that op.
*/
bool MatchStrings(string p, string s);
CAFFE2_API bool MatchStrings(string p, string s);

/**
* This ensures that each named arg that exists in the pattern exists in g_op,
* is equal in value.
*/
bool MatchArguments(const OperatorDef& p_op, const OperatorDef& g_op);
CAFFE2_API bool MatchArguments(const OperatorDef& p_op, const OperatorDef& g_op);

} // namespace caffe2
2 changes: 1 addition & 1 deletion caffe2/core/net_simple.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace caffe2 {
// This is the very basic structure you need to run a network - all it
// does is simply to run everything in sequence. If you want more fancy control
// such as a DAG-like execution, check out other better net implementations.
class SimpleNet : public NetBase {
class CAFFE2_API SimpleNet : public NetBase {
public:
SimpleNet(const std::shared_ptr<const NetDef>& net_def, Workspace* ws);
bool SupportsAsync() override {
Expand Down
5 changes: 3 additions & 2 deletions caffe2/core/nomnigraph/Representations/NeuralNet.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,13 @@ NNNodeMatchCriteria matchAnyNode() {
[](NNGraph::NodeRef /* unused */) { return true; }, "matchAnyNode");
}

NNMatchGraph::NodeRef operatorTree(
NNMatchGraph::NodeRef operatorSubgraph(
NNMatchGraph& g,
const NNNodeMatchCriteria& root,
const std::vector<NNMatchGraph::NodeRef>& childrenCriteria,
int count) {
return tree(g, matchAnyNode(), {tree(g, root, childrenCriteria)}, count);
return subgraph(
g, matchAnyNode(), {subgraph(g, root, childrenCriteria)}, count);
}

} // namespace nn
Expand Down
4 changes: 4 additions & 0 deletions caffe2/core/nomnigraph/include/nomnigraph/Graph/Graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,10 @@ class Graph {
return result;
}

size_t getEdgesCount() const {
return (size_t)edges_.size();
}

private:
std::list<Node<T, U...>> nodes_;
std::list<Edge<T, U...>> edges_;
Expand Down
Loading