forked from intel/caffe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
a bunch of updates. to be checked on durian. does not build.
- Loading branch information
Showing
15 changed files
with
28,877 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,7 @@ | |
*.lai | ||
*.la | ||
*.a | ||
|
||
# Compiled protocol buffers | ||
*.pb.h | ||
*.pb.cc |
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,59 @@ | ||
# | ||
# The following defines a variable named "NAME" with a value of "myprogram". By convention, | ||
# a lowercase prefix (in this case "program") and an uppercased suffix (in this case "NAME"), separated | ||
# by an underscore is used to name attributes for a common element. Think of this like | ||
# using program.NAME, program.C_SRCS, etc. There are no structs in Make, so we use this convention | ||
# to keep track of attributes that all belong to the same target or program. | ||
# | ||
CXX := nvcc | ||
|
||
PROJECT := caffeine | ||
NAME := lib$(PROJECT).so | ||
TEST_NAME := test_$(PROJECT) | ||
CXX_SRCS := $(shell find . ! -name "test_*.cpp" -name "*.cpp") | ||
TEST_SRCS := $(shell find . -name "test_*.cpp") | ||
PROTO_SRCS := $(wildcard caffeine/proto/*.proto) | ||
PROTO_GEN_HEADER := ${PROTO_SRCS:.proto=.pb.h} | ||
PROTO_GEN_CC := ${PROTO_SRCS:.proto=.pb.cc} | ||
CXX_OBJS := ${CXX_SRCS:.cpp=.o} | ||
PROTO_OBJS := ${PROTO_SRCS:.proto=.pb.o} | ||
OBJS := $(CXX_OBJS) $(PROTO_OBJS) | ||
TEST_OBJS := ${TEST_SRCS:.cpp=.o} | ||
|
||
CUDA_DIR = /usr/local/cuda | ||
|
||
CUDA_INCLUDE_DIR = $(CUDA_DIR)/include | ||
CUDA_LIB_DIR = $(CUDA_DIR)/lib | ||
|
||
INCLUDE_DIRS := . $(CUDA_INCLUDE_DIR) | ||
LIBRARY_DIRS := . $(CUDA_LIB_DIR) | ||
LIBRARIES := cuda cudart cublas protobuf | ||
WARNINGS := -Wall | ||
|
||
CPPFLAGS += $(foreach includedir,$(INCLUDE_DIRS),-I$(includedir)) | ||
LDFLAGS += $(foreach librarydir,$(LIBRARY_DIRS),-L$(librarydir)) | ||
LDFLAGS += $(foreach library,$(LIBRARIES),-l$(library)) | ||
|
||
LINK = $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $(WARNINGS) | ||
|
||
.PHONY: all test clean distclean | ||
|
||
all: $(NAME) | ||
|
||
test: $(TEST_NAME) | ||
|
||
$(TEST_NAME): $(TEST_OBJS) $(OBJS) | ||
$(LINK) -o $(TEST_NAME) -l$(PROJECT) $(CXX_SRCS) $(TEST_SRCS) gtest/gtest-all.cc | ||
|
||
$(NAME): $(PROTO_GEN_CC) $(OBJS) | ||
$(LINK) -shared $(OBJS) -o $(NAME) | ||
|
||
$(PROTO_GEN_CC): $(PROTO_SRCS) | ||
protoc $(PROTO_SRCS) --cpp_out=. | ||
|
||
clean: | ||
$(RM) $(NAME) | ||
$(RM) $(OBJS) | ||
$(RM) $(PROTO_GEN_HEADER) $(PROTO_GEN_CC) | ||
|
||
distclean: clean |
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,36 @@ | ||
#ifndef CAFFEINE_BASE_H_ | ||
#define CAFFEINE_BASE_H_ | ||
|
||
#include <vector> | ||
#include "caffeine/blob.hpp" | ||
#include "caffeine/proto/layer_param.pb.h" | ||
|
||
using std::vector; | ||
|
||
namespace caffeine { | ||
|
||
template <typename Dtype> | ||
class Layer { | ||
public: | ||
explicit Layer(const LayerParameter& param) | ||
: initialized_(false), layer_param_(param) {}; | ||
~Layer(); | ||
virtual void SetUp(vector<const Blob<Dtype>*>& bottom, | ||
vector<Blob<Dtype>*>* top) = 0; | ||
virtual void Forward(vector<const Blob<Dtype>*>& bottom, | ||
vector<Blob<Dtype>*>* top) = 0; | ||
virtual void Predict(vector<const Blob<Dtype>*>& bottom, | ||
vector<Blob<Dtype>*>* top) = 0; | ||
virtual void Backward(vector<const Blob<Dtype>*>& bottom, | ||
vector<Blob<Dtype>*>* top, bool propagate_down) = 0; | ||
protected: | ||
bool initialized_; | ||
// The protobuf that stores the layer parameters | ||
LayerParameter layer_param_; | ||
// The vector that stores the parameters as a set of blobs. | ||
vector<Blob<Dtype> > blobs; | ||
}; // class Layer | ||
|
||
} // namespace caffeine | ||
|
||
#endif // CAFFEINE_BASE_H_ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include "caffeine/base.h" | ||
|
||
namespace caffeine { | ||
|
||
|
||
} // namespace caffeine |
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,5 @@ | ||
package caffeine; | ||
|
||
message LayerParameter { | ||
required string name = 1; | ||
} |
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 |
---|---|---|
|
@@ -79,4 +79,5 @@ inline void* SyncedMemory::mutable_gpu_data() { | |
} | ||
|
||
|
||
} // namespace caffeine | ||
} // namespace caffeine | ||
|
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "gtest/gtest.h" | ||
#include "caffeine/syncedmem.hpp" | ||
|
||
namespace caffeine { | ||
|
||
class SyncedMemoryTest : public ::testing::Test {}; | ||
|
||
TEST_F(SyncedMemoryTest, TestInitialization) { | ||
SyncedMemory mem(10); | ||
EXPECT_EQ(mem.head(), SyncedMemory::UNINITIALIZED); | ||
} | ||
|
||
TEST_F(SyncedMemoryTest, TestAllocation) { | ||
SyncedMemory mem(10); | ||
EXPECT_NE(mem.cpu_data(), (void*)NULL); | ||
EXPECT_NE(mem.gpu_data(), (void*)NULL); | ||
} | ||
|
||
} | ||
|
||
int main(int argc, char** argv) { | ||
::testing::InitGoogleTest(&argc, argv); | ||
return RUN_ALL_TESTS(); | ||
} |
Oops, something went wrong.