diff --git a/Jenkinsfile b/Jenkinsfile index 49633d484981..370c2b397626 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -105,6 +105,7 @@ try { node('mxnetlinux') { ws('workspace/sanity') { init_git() + sh "python tools/license_header.py check" make('lint', 'cpplint rcpplint jnilint') make('lint', 'pylint') } diff --git a/amalgamation/amalgamation.py b/amalgamation/amalgamation.py index b33b81c62b4a..22b421d79fba 100644 --- a/amalgamation/amalgamation.py +++ b/amalgamation/amalgamation.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import sys import os.path, re, StringIO @@ -8,7 +25,7 @@ 'kvstore_dist.h', 'mach/clock.h', 'mach/mach.h', 'malloc.h', 'mkl.h', 'mkl_cblas.h', 'mkl_vsl.h', 'mkl_vsl_functions.h', 'nvml.h', 'opencv2/opencv.hpp', 'sys/stat.h', 'sys/types.h', 'cuda.h', 'cuda_fp16.h', - 'omp.h', 'execinfo.h', 'packet/sse-inl.h', 'emmintrin.h', 'thrust/device_vector.h', + 'omp.h', 'execinfo.h', 'packet/sse-inl.h', 'emmintrin.h', 'thrust/device_vector.h', 'cusolverDn.h' ] diff --git a/amalgamation/dmlc-minimum0.cc b/amalgamation/dmlc-minimum0.cc index bce61129ed2e..3f7a97bb0139 100644 --- a/amalgamation/dmlc-minimum0.cc +++ b/amalgamation/dmlc-minimum0.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright 2015 by Contributors. * \brief Mininum DMLC library Amalgamation, used for easy plugin of dmlc lib. * Normally this is not needed. */ diff --git a/amalgamation/jni/org_dmlc_mxnet_Predictor.h b/amalgamation/jni/org_dmlc_mxnet_Predictor.h index e5a68ed0d9d7..1bdf80d9ce6f 100644 --- a/amalgamation/jni/org_dmlc_mxnet_Predictor.h +++ b/amalgamation/jni/org_dmlc_mxnet_Predictor.h @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /* DO NOT EDIT THIS FILE - it is machine generated */ #include /* Header for class org_dmlc_mxnet_Predictor */ diff --git a/amalgamation/jni/predictor.cc b/amalgamation/jni/predictor.cc index b6cc9370b1f9..1936daf99f3d 100644 --- a/amalgamation/jni/predictor.cc +++ b/amalgamation/jni/predictor.cc @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + #include #include "org_dmlc_mxnet_Predictor.h" diff --git a/amalgamation/mxnet_predict0.cc b/amalgamation/mxnet_predict0.cc index ca1b581ce195..badf23771dbc 100644 --- a/amalgamation/mxnet_predict0.cc +++ b/amalgamation/mxnet_predict0.cc @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + // mxnet.cc #define MSHADOW_FORCE_STREAM diff --git a/amalgamation/python/mxnet_predict.py b/amalgamation/python/mxnet_predict.py index 684f23119d62..3dd6b387936f 100644 --- a/amalgamation/python/mxnet_predict.py +++ b/amalgamation/python/mxnet_predict.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable=invalid-name, too-many-arguments """Lightweight API for mxnet prediction. diff --git a/cmake/Modules/FindAccelerate.cmake b/cmake/Modules/FindAccelerate.cmake index 8c9938246e54..695538ac924c 100644 --- a/cmake/Modules/FindAccelerate.cmake +++ b/cmake/Modules/FindAccelerate.cmake @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # Find the Apple Accelerate framework # # The following are set after configuration is done: diff --git a/cmake/Modules/FindAtlas.cmake b/cmake/Modules/FindAtlas.cmake index 350bbe9df5dc..27aaa0e856ab 100644 --- a/cmake/Modules/FindAtlas.cmake +++ b/cmake/Modules/FindAtlas.cmake @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # Find the Atlas (and Lapack) libraries # # The following variables are optionally searched for defaults diff --git a/cmake/Modules/FindJeMalloc.cmake b/cmake/Modules/FindJeMalloc.cmake index 8b965cf6c3bb..57f47448f0a0 100644 --- a/cmake/Modules/FindJeMalloc.cmake +++ b/cmake/Modules/FindJeMalloc.cmake @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # Copyright (c) 2014 Thomas Heller # Copyright (c) 2007-2012 Hartmut Kaiser diff --git a/cmake/Modules/FindMKL.cmake b/cmake/Modules/FindMKL.cmake index 9679f3d72e60..743a871ee7cd 100644 --- a/cmake/Modules/FindMKL.cmake +++ b/cmake/Modules/FindMKL.cmake @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # Find the MKL libraries # # Options: diff --git a/cmake/Modules/FindOpenBLAS.cmake b/cmake/Modules/FindOpenBLAS.cmake index b63817a29d3e..7c5272b7f779 100644 --- a/cmake/Modules/FindOpenBLAS.cmake +++ b/cmake/Modules/FindOpenBLAS.cmake @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + if(MKL_FOUND) message(ERROR " OpenBLAS is not required since MKL is enabled") endif() diff --git a/cmake/Utils.cmake b/cmake/Utils.cmake index c367edb75a74..ac6ce3926c37 100644 --- a/cmake/Utils.cmake +++ b/cmake/Utils.cmake @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # For cmake_parse_arguments include(CMakeParseArguments) diff --git a/cpp-package/example/feature_extract/run.sh b/cpp-package/example/feature_extract/run.sh index afac492b0a9d..dc6665604b1e 100755 --- a/cpp-package/example/feature_extract/run.sh +++ b/cpp-package/example/feature_extract/run.sh @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + ### To run the this example, ### ### 1. diff --git a/cpp-package/example/get_mnist.sh b/cpp-package/example/get_mnist.sh index 2bbe7a801872..40379621025d 100755 --- a/cpp-package/example/get_mnist.sh +++ b/cpp-package/example/get_mnist.sh @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + if [ ! -d "./mnist_data" ]; then mkdir mnist_data (cd mnist_data; wget http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz) diff --git a/cpp-package/example/run_lenet_with_mxdataiter.sh b/cpp-package/example/run_lenet_with_mxdataiter.sh index fffc355865bc..cafad3201635 100755 --- a/cpp-package/example/run_lenet_with_mxdataiter.sh +++ b/cpp-package/example/run_lenet_with_mxdataiter.sh @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + if [ ! -f "./mnist.zip" ]; then wget http://webdocs.cs.ualberta.ca/~bx3/data/mnist.zip unzip -u mnist.zip diff --git a/cpp-package/include/mxnet-cpp/MxNetCpp.h b/cpp-package/include/mxnet-cpp/MxNetCpp.h index 5d61b823baa2..882bbead51e5 100644 --- a/cpp-package/include/mxnet-cpp/MxNetCpp.h +++ b/cpp-package/include/mxnet-cpp/MxNetCpp.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file MxNetCpp.h * \brief meta include file for mxnet.cpp * \author Chuntao Hong, Zhang Chen diff --git a/cpp-package/include/mxnet-cpp/base.h b/cpp-package/include/mxnet-cpp/base.h index b684986a6f54..19375c0f81e8 100644 --- a/cpp-package/include/mxnet-cpp/base.h +++ b/cpp-package/include/mxnet-cpp/base.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! -* Copyright (c) 2016 by Contributors * \file base.h * \brief base definitions for mxnetcpp * \author Chuntao Hong, Zhang Chen diff --git a/cpp-package/include/mxnet-cpp/executor.h b/cpp-package/include/mxnet-cpp/executor.h index 67eec0100b65..7e45ef56ab95 100644 --- a/cpp-package/include/mxnet-cpp/executor.h +++ b/cpp-package/include/mxnet-cpp/executor.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! -* Copyright (c) 2016 by Contributors * \file executor.h * \brief executor definition * \author Chuntao Hong, Zhang Chen diff --git a/cpp-package/include/mxnet-cpp/initializer.h b/cpp-package/include/mxnet-cpp/initializer.h index f28656577482..e5bfa4da8eed 100644 --- a/cpp-package/include/mxnet-cpp/initializer.h +++ b/cpp-package/include/mxnet-cpp/initializer.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file initializer.h * \brief random initializer * \author Zhang Chen diff --git a/cpp-package/include/mxnet-cpp/io.h b/cpp-package/include/mxnet-cpp/io.h index 727a96467c63..7281416ae36a 100644 --- a/cpp-package/include/mxnet-cpp/io.h +++ b/cpp-package/include/mxnet-cpp/io.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! -* Copyright (c) 2016 by Contributors * \file operator.h * \brief definition of io, such as DataIter * \author Zhang Chen diff --git a/cpp-package/include/mxnet-cpp/kvstore.h b/cpp-package/include/mxnet-cpp/kvstore.h index 9bb33a4733dd..9c3c81f37ff7 100644 --- a/cpp-package/include/mxnet-cpp/kvstore.h +++ b/cpp-package/include/mxnet-cpp/kvstore.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! -* Copyright (c) 2016 by Contributors * \file kvstore.h * \brief definition of kvstore * \author Chuntao Hong diff --git a/cpp-package/include/mxnet-cpp/lr_scheduler.h b/cpp-package/include/mxnet-cpp/lr_scheduler.h index 4c56b7ab3f0b..b9381a830a88 100644 --- a/cpp-package/include/mxnet-cpp/lr_scheduler.h +++ b/cpp-package/include/mxnet-cpp/lr_scheduler.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! -* Copyright (c) 2017 by Contributors * \file lr_scheduler.h * \brief Scheduling learning rate */ diff --git a/cpp-package/include/mxnet-cpp/metric.h b/cpp-package/include/mxnet-cpp/metric.h index eda927199ca8..6dbb197dae49 100644 --- a/cpp-package/include/mxnet-cpp/metric.h +++ b/cpp-package/include/mxnet-cpp/metric.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! -* Copyright (c) 2016 by Contributors * \file base.h * \brief metrics defined * \author Zhang Chen diff --git a/cpp-package/include/mxnet-cpp/model.h b/cpp-package/include/mxnet-cpp/model.h index e4cb1a9aee95..c8af6a476a52 100644 --- a/cpp-package/include/mxnet-cpp/model.h +++ b/cpp-package/include/mxnet-cpp/model.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! -* Copyright (c) 2016 by Contributors * \file model.h * \brief MXNET.cpp model module * \author Zhang Chen diff --git a/cpp-package/include/mxnet-cpp/monitor.h b/cpp-package/include/mxnet-cpp/monitor.h index afe030cbd5d8..33ef4855c1a9 100644 --- a/cpp-package/include/mxnet-cpp/monitor.h +++ b/cpp-package/include/mxnet-cpp/monitor.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! -* Copyright (c) 2017 by Contributors * \file monitor.h * \brief monitor definition * \author Xin Li diff --git a/cpp-package/include/mxnet-cpp/ndarray.h b/cpp-package/include/mxnet-cpp/ndarray.h index 52451faa94cc..9e196d0730a8 100644 --- a/cpp-package/include/mxnet-cpp/ndarray.h +++ b/cpp-package/include/mxnet-cpp/ndarray.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! -* Copyright (c) 2016 by Contributors * \file ndarray.h * \brief definition of ndarray * \author Chuntao Hong, Zhang Chen diff --git a/cpp-package/include/mxnet-cpp/op_map.h b/cpp-package/include/mxnet-cpp/op_map.h index ea75a8ca7b4c..b54cc0ae2c01 100644 --- a/cpp-package/include/mxnet-cpp/op_map.h +++ b/cpp-package/include/mxnet-cpp/op_map.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! -* Copyright (c) 2016 by Contributors * \file op_map.h * \brief definition of OpMap * \author Chuntao Hong diff --git a/cpp-package/include/mxnet-cpp/op_suppl.h b/cpp-package/include/mxnet-cpp/op_suppl.h index b66521bc0654..52cdae772a68 100644 --- a/cpp-package/include/mxnet-cpp/op_suppl.h +++ b/cpp-package/include/mxnet-cpp/op_suppl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! -* Copyright (c) 2016 by Contributors * \file op_suppl.h * \brief A supplement and amendment of the operators from op.h * \author Zhang Chen, zhubuntu, Xin Li diff --git a/cpp-package/include/mxnet-cpp/op_util.h b/cpp-package/include/mxnet-cpp/op_util.h index 5a737480d469..20e06a851814 100644 --- a/cpp-package/include/mxnet-cpp/op_util.h +++ b/cpp-package/include/mxnet-cpp/op_util.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! -* Copyright (c) 2017 by Contributors * \file op_util.h * \brief operator helper functions * \author Chris Olivier diff --git a/cpp-package/include/mxnet-cpp/operator.h b/cpp-package/include/mxnet-cpp/operator.h index 4fc45bbc9f04..02bd21ebe8c9 100644 --- a/cpp-package/include/mxnet-cpp/operator.h +++ b/cpp-package/include/mxnet-cpp/operator.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! -* Copyright (c) 2016 by Contributors * \file operator.h * \brief definition of operator * \author Chuntao Hong, Zhang Chen diff --git a/cpp-package/include/mxnet-cpp/optimizer.h b/cpp-package/include/mxnet-cpp/optimizer.h index 1bc36d58fd1a..e57da5d95ceb 100644 --- a/cpp-package/include/mxnet-cpp/optimizer.h +++ b/cpp-package/include/mxnet-cpp/optimizer.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! -* Copyright (c) 2016 by Contributors * \file optimizer.h * \brief definition of optimizer * \author Chuntao Hong, Zhang Chen diff --git a/cpp-package/include/mxnet-cpp/shape.h b/cpp-package/include/mxnet-cpp/shape.h index d30ea9df2531..2793e436c072 100644 --- a/cpp-package/include/mxnet-cpp/shape.h +++ b/cpp-package/include/mxnet-cpp/shape.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! -* Copyright (c) 2016 by Contributors * \file shape.h * \brief definition of shape * \author Chuntao Hong, Zhang Chen diff --git a/cpp-package/include/mxnet-cpp/symbol.h b/cpp-package/include/mxnet-cpp/symbol.h index c04ae2a03d29..888aebd6f3ad 100644 --- a/cpp-package/include/mxnet-cpp/symbol.h +++ b/cpp-package/include/mxnet-cpp/symbol.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! -* Copyright (c) 2016 by Contributors * \file symbol.h * \brief definition of symbol * \author Chuntao Hong, Zhang Chen diff --git a/cpp-package/scripts/OpWrapperGenerator.py b/cpp-package/scripts/OpWrapperGenerator.py index 8f762368d0a4..83495febcc63 100644 --- a/cpp-package/scripts/OpWrapperGenerator.py +++ b/cpp-package/scripts/OpWrapperGenerator.py @@ -1,4 +1,21 @@ -# -*- coding: utf-8 -*- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# -*- coding: utf-8 -*- # This is a python script that generates operator wrappers such as FullyConnected, # based on current libmxnet.dll. This script is written so that we don't need to # write new operator wrappers when new ones are added to the library. diff --git a/cpp-package/scripts/lint.py b/cpp-package/scripts/lint.py index 89492eda4d82..f9f284ffc005 100644 --- a/cpp-package/scripts/lint.py +++ b/cpp-package/scripts/lint.py @@ -1,4 +1,22 @@ #!/usr/bin/env python + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: disable=protected-access, unused-variable, locally-disabled, redefined-variable-type """Lint helper to generate lint summary of source. Copyright by Contributors diff --git a/cpp-package/tests/ci_test.sh b/cpp-package/tests/ci_test.sh index 29d0a9df340a..3b2af35bf1be 100755 --- a/cpp-package/tests/ci_test.sh +++ b/cpp-package/tests/ci_test.sh @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + set -e # exit on the first error cd $(dirname $(readlink -f $0))/../example echo $PWD diff --git a/cpp-package/tests/travis/run_test.sh b/cpp-package/tests/travis/run_test.sh index 27506584f40c..4925b3526bf3 100755 --- a/cpp-package/tests/travis/run_test.sh +++ b/cpp-package/tests/travis/run_test.sh @@ -1,5 +1,23 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + if [ ${TASK} == "lint" ]; then make lint || exit -1 echo "Check documentations of c++ code..." diff --git a/cpp-package/tests/travis/setup.sh b/cpp-package/tests/travis/setup.sh index 4238c7654fe4..5a3813ee34eb 100755 --- a/cpp-package/tests/travis/setup.sh +++ b/cpp-package/tests/travis/setup.sh @@ -1,5 +1,23 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + if [ ${TASK} == "lint" ]; then pip install cpplint 'pylint==1.4.4' 'astroid==1.3.6' --user fi diff --git a/docker/Dockerfiles/Dockerfile.in.scala b/docker/Dockerfiles/Dockerfile.in.scala index 6898126c7cb2..1fe93652920b 100644 --- a/docker/Dockerfiles/Dockerfile.in.scala +++ b/docker/Dockerfiles/Dockerfile.in.scala @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + # -*- mode: dockerfile -*- # part of the dockerfile to install the scala binding diff --git a/docker/install/cpp.sh b/docker/install/cpp.sh index f30ab52f9a52..1aa55acfc977 100755 --- a/docker/install/cpp.sh +++ b/docker/install/cpp.sh @@ -1,4 +1,22 @@ #!/usr/bin/env bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # libraries for building mxnet c++ core on ubuntu apt-get update && apt-get install -y \ diff --git a/docker/install/julia.sh b/docker/install/julia.sh index 604a1bc2c234..e6fe49bd5acc 100755 --- a/docker/install/julia.sh +++ b/docker/install/julia.sh @@ -1,4 +1,22 @@ #!/usr/bin/env bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # install libraries for mxnet's julia package on ubuntu # the julia version shipped with ubuntu (version 0.4) is too low. so download a diff --git a/docker/install/perl.sh b/docker/install/perl.sh index da4df67a464a..a981746bc18d 100755 --- a/docker/install/perl.sh +++ b/docker/install/perl.sh @@ -1,4 +1,22 @@ #!/usr/bin/env bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # install libraries for mxnet's perl package on ubuntu apt-get update && apt-get install -y libmouse-perl pdl cpanminus swig libgraphviz-perl cpanm -q Function::Parameters diff --git a/docker/install/python.sh b/docker/install/python.sh index 0459bb9198c4..763f27b8282f 100755 --- a/docker/install/python.sh +++ b/docker/install/python.sh @@ -1,4 +1,22 @@ #!/usr/bin/env bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # install libraries for mxnet's python package on ubuntu apt-get update && apt-get install -y python-dev python3-dev diff --git a/docker/install/r.sh b/docker/install/r.sh index 9351763ddcee..a0fa27359ba5 100755 --- a/docker/install/r.sh +++ b/docker/install/r.sh @@ -1,4 +1,22 @@ #!/usr/bin/env bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # install libraries for mxnet's r package on ubuntu echo "deb http://cran.rstudio.com/bin/linux/ubuntu trusty/" >> /etc/apt/sources.list diff --git a/docker/install/scala.sh b/docker/install/scala.sh index 8cbe91199463..bb0bb9c900d4 100755 --- a/docker/install/scala.sh +++ b/docker/install/scala.sh @@ -1,4 +1,22 @@ #!/usr/bin/env bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # install libraries for mxnet's scala package on ubuntu apt-get install -y maven default-jdk diff --git a/docker/run.sh b/docker/run.sh index b13e13caa5fc..f570f706d9ec 100644 --- a/docker/run.sh +++ b/docker/run.sh @@ -1,4 +1,22 @@ #!/usr/bin/env bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # Build and push all docker containers DEVICES=('cpu' 'gpu') diff --git a/docker/tool.sh b/docker/tool.sh index 222d428fb68b..d8ab9dba0f26 100755 --- a/docker/tool.sh +++ b/docker/tool.sh @@ -1,4 +1,22 @@ #!/usr/bin/env bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # # Script to build, test and push a docker container # diff --git a/docs/build_version_doc/AddVersion.py b/docs/build_version_doc/AddVersion.py index ee46ef5ffd12..38ce48f63c2f 100644 --- a/docs/build_version_doc/AddVersion.py +++ b/docs/build_version_doc/AddVersion.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import os import argparse from bs4 import BeautifulSoup as bs @@ -55,4 +72,4 @@ navbar_mobile.append(version_str_mobile) outstr = str(content).replace('<', '<').replace('>', '>') with open(os.path.join(path, name), "w") as outf: - outf.write(outstr) \ No newline at end of file + outf.write(outstr) diff --git a/docs/build_version_doc/build_doc.sh b/docs/build_version_doc/build_doc.sh index 99b6bd81b517..c5b59ba1df92 100755 --- a/docs/build_version_doc/build_doc.sh +++ b/docs/build_version_doc/build_doc.sh @@ -1,12 +1,30 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + web_url="$1" web_folder="VersionedWeb" local_build="latest" web_branch="$2" git clone $web_url $web_folder cd $web_folder -git checkout $web_branch +git checkout $web_branch cd .. mkdir "$local_build" @@ -14,7 +32,7 @@ mkdir "$local_build" tag_list_file="tag_list.txt" cp "$web_folder/tag.txt" "$tag_list_file" tag_list=() -while read -r line +while read -r line do tag_list+=("$line") done < "$tag_list_file" diff --git a/docs/conf.py b/docs/conf.py index 7a1059e10948..ad51323f01e9 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # -*- coding: utf-8 -*- import sys, os, re, subprocess import mock diff --git a/docs/mxdoc.py b/docs/mxdoc.py index 25f6af779ef6..2726a1ca0676 100644 --- a/docs/mxdoc.py +++ b/docs/mxdoc.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """A sphnix-doc plugin to build mxnet docs""" import subprocess import re diff --git a/example/adversary/data.py b/example/adversary/data.py index d39821f52145..0ca8e1fd6653 100644 --- a/example/adversary/data.py +++ b/example/adversary/data.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file """ data iterator for mnist """ import sys diff --git a/example/autoencoder/autoencoder.py b/example/autoencoder/autoencoder.py index ca8db7a70289..a84b2718f748 100644 --- a/example/autoencoder/autoencoder.py +++ b/example/autoencoder/autoencoder.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file import mxnet as mx from mxnet import misc diff --git a/example/autoencoder/data.py b/example/autoencoder/data.py index ecd117d86218..d6a25edce886 100644 --- a/example/autoencoder/data.py +++ b/example/autoencoder/data.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import os import numpy as np from sklearn.datasets import fetch_mldata diff --git a/example/autoencoder/mnist_sae.py b/example/autoencoder/mnist_sae.py index 538d8b976d0c..552594823a93 100644 --- a/example/autoencoder/mnist_sae.py +++ b/example/autoencoder/mnist_sae.py @@ -1,27 +1,44 @@ -# pylint: skip-file -from __future__ import print_function -import mxnet as mx -import numpy as np -import logging -import data -from autoencoder import AutoEncoderModel - - -if __name__ == '__main__': - # set to INFO to see less information during training - logging.basicConfig(level=logging.DEBUG) - ae_model = AutoEncoderModel(mx.gpu(0), [784,500,500,2000,10], pt_dropout=0.2, - internal_act='relu', output_act='relu') - - X, _ = data.get_mnist() - train_X = X[:60000] - val_X = X[60000:] - - ae_model.layerwise_pretrain(train_X, 256, 50000, 'sgd', l_rate=0.1, decay=0.0, - lr_scheduler=mx.misc.FactorScheduler(20000,0.1)) - ae_model.finetune(train_X, 256, 100000, 'sgd', l_rate=0.1, decay=0.0, - lr_scheduler=mx.misc.FactorScheduler(20000,0.1)) - ae_model.save('mnist_pt.arg') - ae_model.load('mnist_pt.arg') - print("Training error:", ae_model.eval(train_X)) - print("Validation error:", ae_model.eval(val_X)) +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# pylint: skip-file +from __future__ import print_function +import mxnet as mx +import numpy as np +import logging +import data +from autoencoder import AutoEncoderModel + + +if __name__ == '__main__': + # set to INFO to see less information during training + logging.basicConfig(level=logging.DEBUG) + ae_model = AutoEncoderModel(mx.gpu(0), [784,500,500,2000,10], pt_dropout=0.2, + internal_act='relu', output_act='relu') + + X, _ = data.get_mnist() + train_X = X[:60000] + val_X = X[60000:] + + ae_model.layerwise_pretrain(train_X, 256, 50000, 'sgd', l_rate=0.1, decay=0.0, + lr_scheduler=mx.misc.FactorScheduler(20000,0.1)) + ae_model.finetune(train_X, 256, 100000, 'sgd', l_rate=0.1, decay=0.0, + lr_scheduler=mx.misc.FactorScheduler(20000,0.1)) + ae_model.save('mnist_pt.arg') + ae_model.load('mnist_pt.arg') + print("Training error:", ae_model.eval(train_X)) + print("Validation error:", ae_model.eval(val_X)) diff --git a/example/autoencoder/model.py b/example/autoencoder/model.py index 85fb48c5797b..1aaae1b5fdad 100644 --- a/example/autoencoder/model.py +++ b/example/autoencoder/model.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file import mxnet as mx import numpy as np diff --git a/example/autoencoder/solver.py b/example/autoencoder/solver.py index 21c5da2ed4c7..5589c5a14010 100644 --- a/example/autoencoder/solver.py +++ b/example/autoencoder/solver.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file import mxnet as mx import numpy as np diff --git a/example/bayesian-methods/algos.py b/example/bayesian-methods/algos.py index 81df9c5d8534..e47a18f398e9 100644 --- a/example/bayesian-methods/algos.py +++ b/example/bayesian-methods/algos.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import print_function import mxnet as mx import mxnet.ndarray as nd diff --git a/example/bayesian-methods/bdk_demo.py b/example/bayesian-methods/bdk_demo.py index 77e9b945cb14..145dac10e2a6 100644 --- a/example/bayesian-methods/bdk_demo.py +++ b/example/bayesian-methods/bdk_demo.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import print_function import mxnet as mx import mxnet.ndarray as nd diff --git a/example/bayesian-methods/data_loader.py b/example/bayesian-methods/data_loader.py index 90b01e0144cc..2649eb560b68 100644 --- a/example/bayesian-methods/data_loader.py +++ b/example/bayesian-methods/data_loader.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import print_function import numpy import os diff --git a/example/bayesian-methods/utils.py b/example/bayesian-methods/utils.py index 4a2f41d7e149..a2744373e87d 100644 --- a/example/bayesian-methods/utils.py +++ b/example/bayesian-methods/utils.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx import mxnet.ndarray as nd import numpy @@ -169,4 +186,4 @@ def pred_test(testing_data, exe, param_list=None, save_path=""): ret[i, 1] = pred.std()**2 numpy.savetxt(save_path, ret) mse = numpy.square(ret[:, 0] - testing_data[:, 0] **3).mean() - return mse, ret \ No newline at end of file + return mse, ret diff --git a/example/bi-lstm-sort/infer_sort.py b/example/bi-lstm-sort/infer_sort.py index 0f5ef07a269b..b074c03d1159 100644 --- a/example/bi-lstm-sort/infer_sort.py +++ b/example/bi-lstm-sort/infer_sort.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: disable=C0111,too-many-arguments,too-many-instance-attributes,too-many-locals,redefined-outer-name,fixme # pylint: disable=superfluous-parens, no-member, invalid-name import sys @@ -31,7 +48,7 @@ def MakeInput(char, vocab, arr): rvocab = {} for k, v in vocab.items(): rvocab[v] = k - + _, arg_params, __ = mx.model.load_checkpoint("sort", 1) model = BiLSTMInferenceModel(5, len(vocab), @@ -42,9 +59,9 @@ def MakeInput(char, vocab, arr): data = np.zeros((1, len(tks))) for k in range(len(tks)): data[0][k] = vocab[tks[k]] - + data = mx.nd.array(data) prob = model.forward(data) - for k in range(len(tks)): + for k in range(len(tks)): print(rvocab[np.argmax(prob, axis = 1)[k]]) - + diff --git a/example/bi-lstm-sort/lstm.py b/example/bi-lstm-sort/lstm.py index 61687124266d..a082092b0351 100644 --- a/example/bi-lstm-sort/lstm.py +++ b/example/bi-lstm-sort/lstm.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint:skip-file import sys sys.path.insert(0, "../../python") @@ -64,7 +81,7 @@ def bi_lstm_unroll(seq_len, input_size, embed = mx.sym.Embedding(data=data, input_dim=input_size, weight=embed_weight, output_dim=num_embed, name='embed') wordvec = mx.sym.SliceChannel(data=embed, num_outputs=seq_len, squeeze_axis=1) - + forward_hidden = [] for seqidx in range(seq_len): hidden = wordvec[seqidx] @@ -87,7 +104,7 @@ def bi_lstm_unroll(seq_len, input_size, hidden = next_state.h last_states[1] = next_state backward_hidden.insert(0, hidden) - + hidden_all = [] for i in range(seq_len): hidden_all.append(mx.sym.Concat(*[forward_hidden[i], backward_hidden[i]], dim=1)) @@ -109,7 +126,7 @@ def bi_lstm_inference_symbol(input_size, seq_len, embed_weight=mx.sym.Variable("embed_weight") cls_weight = mx.sym.Variable("cls_weight") cls_bias = mx.sym.Variable("cls_bias") - last_states = [LSTMState(c = mx.sym.Variable("l0_init_c"), h = mx.sym.Variable("l0_init_h")), + last_states = [LSTMState(c = mx.sym.Variable("l0_init_c"), h = mx.sym.Variable("l0_init_h")), LSTMState(c = mx.sym.Variable("l1_init_c"), h = mx.sym.Variable("l1_init_h"))] forward_param = LSTMParam(i2h_weight=mx.sym.Variable("l0_i2h_weight"), i2h_bias=mx.sym.Variable("l0_i2h_bias"), @@ -143,7 +160,7 @@ def bi_lstm_inference_symbol(input_size, seq_len, hidden = next_state.h last_states[1] = next_state backward_hidden.insert(0, hidden) - + hidden_all = [] for i in range(seq_len): hidden_all.append(mx.sym.Concat(*[forward_hidden[i], backward_hidden[i]], dim=1)) diff --git a/example/bi-lstm-sort/lstm_sort.py b/example/bi-lstm-sort/lstm_sort.py index fe8c38b559bd..aef88b899ce3 100644 --- a/example/bi-lstm-sort/lstm_sort.py +++ b/example/bi-lstm-sort/lstm_sort.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: disable=C0111,too-many-arguments,too-many-instance-attributes,too-many-locals,redefined-outer-name,fixme # pylint: disable=superfluous-parens, no-member, invalid-name import sys diff --git a/example/bi-lstm-sort/rnn_model.py b/example/bi-lstm-sort/rnn_model.py index a253e862fcce..202aae608726 100644 --- a/example/bi-lstm-sort/rnn_model.py +++ b/example/bi-lstm-sort/rnn_model.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: disable=C0111,too-many-arguments,too-many-instance-attributes,too-many-locals,redefined-outer-name,fixme # pylint: disable=superfluous-parens, no-member, invalid-name import sys @@ -25,7 +42,7 @@ def __init__(self, batch_size = 1 init_c = [('l%d_init_c'%l, (batch_size, num_hidden)) for l in range(2)] init_h = [('l%d_init_h'%l, (batch_size, num_hidden)) for l in range(2)] - + data_shape = [("data", (batch_size, seq_len, ))] input_shapes = dict(init_c + init_h + data_shape) diff --git a/example/bi-lstm-sort/sort_io.py b/example/bi-lstm-sort/sort_io.py index 8e1152173ac7..8cb44c678a72 100644 --- a/example/bi-lstm-sort/sort_io.py +++ b/example/bi-lstm-sort/sort_io.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: disable=C0111,too-many-arguments,too-many-instance-attributes,too-many-locals,redefined-outer-name,fixme # pylint: disable=superfluous-parens, no-member, invalid-name from __future__ import print_function diff --git a/example/caffe/caffe_net.py b/example/caffe/caffe_net.py index c91d37bcbecb..0dc4770a24f0 100644 --- a/example/caffe/caffe_net.py +++ b/example/caffe/caffe_net.py @@ -1,5 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx -from data import get_iterator +from data import get_iterator import argparse import train_model diff --git a/example/caffe/data.py b/example/caffe/data.py index 723e7da02b85..fac8e11989dc 100644 --- a/example/caffe/data.py +++ b/example/caffe/data.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import sys import os # code to automatically download dataset diff --git a/example/caffe/train_model.py b/example/caffe/train_model.py index 9a51f07bda87..2eadd869e70e 100644 --- a/example/caffe/train_model.py +++ b/example/caffe/train_model.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx import logging import os diff --git a/example/cnn_text_classification/data_helpers.py b/example/cnn_text_classification/data_helpers.py index b3ece2d4825b..3812683e7a5d 100644 --- a/example/cnn_text_classification/data_helpers.py +++ b/example/cnn_text_classification/data_helpers.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import numpy as np import re import itertools diff --git a/example/cnn_text_classification/old/text_cnn.py b/example/cnn_text_classification/old/text_cnn.py index e41af36cf2ff..8d82d6ef7945 100644 --- a/example/cnn_text_classification/old/text_cnn.py +++ b/example/cnn_text_classification/old/text_cnn.py @@ -1,4 +1,22 @@ #!/usr/bin/env python + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # -*- coding: utf-8 -*- from __future__ import print_function import sys,os @@ -242,7 +260,7 @@ def train_without_pretrained_embedding(): print('train shape:', x_train.shape) print('dev shape:', x_dev.shape) print('vocab_size', vocab_size) - + batch_size = 50 num_embed = 300 sentence_size = x_train.shape[1] diff --git a/example/cnn_text_classification/text_cnn.py b/example/cnn_text_classification/text_cnn.py index 16d3dca260fd..d88a8e699420 100644 --- a/example/cnn_text_classification/text_cnn.py +++ b/example/cnn_text_classification/text_cnn.py @@ -1,4 +1,22 @@ #!/usr/bin/env python + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # -*- coding: utf-8 -*- import sys @@ -77,7 +95,7 @@ def data_iter(batch_size, num_embed, pre_trained_word2vec=False): x_train, y_train, batch_size, shuffle=True) valid = mx.io.NDArrayIter( x_dev, y_dev, batch_size) - + return (train, valid, sentence_size, embed_size, vocab_size) def sym_gen(batch_size, sentence_size, num_embed, vocab_size, @@ -121,7 +139,7 @@ def sym_gen(batch_size, sentence_size, num_embed, vocab_size, # softmax output sm = mx.sym.SoftmaxOutput(data=fc, label=input_y, name='softmax') - return sm, ('data',), ('softmax_label',) + return sm, ('data',), ('softmax_label',) def train(symbol, train_iter, valid_iter, data_names, label_names): devs = mx.cpu() if args.gpus is None or args.gpus is '' else [ diff --git a/example/ctc/lstm.py b/example/ctc/lstm.py index 9c493bbfb500..7e18c8699492 100644 --- a/example/ctc/lstm.py +++ b/example/ctc/lstm.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint:skip-file import sys diff --git a/example/ctc/lstm_ocr.py b/example/ctc/lstm_ocr.py index 7d437bfdc424..c9928aa43ab8 100644 --- a/example/ctc/lstm_ocr.py +++ b/example/ctc/lstm_ocr.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: disable=C0111,too-many-arguments,too-many-instance-attributes,too-many-locals,redefined-outer-name,fixme # pylint: disable=superfluous-parens, no-member, invalid-name from __future__ import print_function diff --git a/example/ctc/ocr_predict.py b/example/ctc/ocr_predict.py index a07733ef55e0..3096a664a20f 100644 --- a/example/ctc/ocr_predict.py +++ b/example/ctc/ocr_predict.py @@ -1,4 +1,22 @@ #!/usr/bin/env python2.7 + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding=utf-8 from __future__ import print_function import sys, os diff --git a/example/dec/dec.py b/example/dec/dec.py index d8a45149d2e8..ac6545abb1de 100644 --- a/example/dec/dec.py +++ b/example/dec/dec.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file from __future__ import print_function import sys @@ -154,4 +171,4 @@ def mnist_exp(xpu): if __name__ == '__main__': logging.basicConfig(level=logging.INFO) mnist_exp(mx.gpu(0)) - + diff --git a/example/dsd/mlp.py b/example/dsd/mlp.py index ccb094062f58..767e5924b294 100644 --- a/example/dsd/mlp.py +++ b/example/dsd/mlp.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx import os import logging diff --git a/example/dsd/sparse_sgd.py b/example/dsd/sparse_sgd.py index f11a2395c4c0..b21e9b9b89fc 100644 --- a/example/dsd/sparse_sgd.py +++ b/example/dsd/sparse_sgd.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from mxnet.ndarray import NDArray, topk, abs as NDabs from mxnet.optimizer import SGD, register import logging diff --git a/example/fcn-xs/data.py b/example/fcn-xs/data.py index 9de0d8d31c69..685b6f7da8f4 100644 --- a/example/fcn-xs/data.py +++ b/example/fcn-xs/data.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file """ file iterator for pasval voc 2012""" import mxnet as mx diff --git a/example/fcn-xs/fcn_xs.py b/example/fcn-xs/fcn_xs.py index 85961d92c694..53244a1759c3 100644 --- a/example/fcn-xs/fcn_xs.py +++ b/example/fcn-xs/fcn_xs.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file import sys, os import argparse diff --git a/example/fcn-xs/image_segmentaion.py b/example/fcn-xs/image_segmentaion.py index 6d619c198c0b..ddd850fe4e9d 100644 --- a/example/fcn-xs/image_segmentaion.py +++ b/example/fcn-xs/image_segmentaion.py @@ -1,58 +1,75 @@ -# pylint: skip-file -import numpy as np -import mxnet as mx -from PIL import Image - -def getpallete(num_cls): - # this function is to get the colormap for visualizing the segmentation mask - n = num_cls - pallete = [0]*(n*3) - for j in xrange(0,n): - lab = j - pallete[j*3+0] = 0 - pallete[j*3+1] = 0 - pallete[j*3+2] = 0 - i = 0 - while (lab > 0): - pallete[j*3+0] |= (((lab >> 0) & 1) << (7-i)) - pallete[j*3+1] |= (((lab >> 1) & 1) << (7-i)) - pallete[j*3+2] |= (((lab >> 2) & 1) << (7-i)) - i = i + 1 - lab >>= 3 - return pallete - -pallete = getpallete(256) -img = "./person_bicycle.jpg" -seg = img.replace("jpg", "png") -model_previx = "FCN8s_VGG16" -epoch = 19 -ctx = mx.gpu(0) - -def get_data(img_path): - """get the (1, 3, h, w) np.array data for the img_path""" - mean = np.array([123.68, 116.779, 103.939]) # (R,G,B) - img = Image.open(img_path) - img = np.array(img, dtype=np.float32) - reshaped_mean = mean.reshape(1, 1, 3) - img = img - reshaped_mean - img = np.swapaxes(img, 0, 2) - img = np.swapaxes(img, 1, 2) - img = np.expand_dims(img, axis=0) - return img - -def main(): - fcnxs, fcnxs_args, fcnxs_auxs = mx.model.load_checkpoint(model_previx, epoch) - fcnxs_args["data"] = mx.nd.array(get_data(img), ctx) - data_shape = fcnxs_args["data"].shape - label_shape = (1, data_shape[2]*data_shape[3]) - fcnxs_args["softmax_label"] = mx.nd.empty(label_shape, ctx) - exector = fcnxs.bind(ctx, fcnxs_args ,args_grad=None, grad_req="null", aux_states=fcnxs_args) - exector.forward(is_train=False) - output = exector.outputs[0] - out_img = np.uint8(np.squeeze(output.asnumpy().argmax(axis=1))) - out_img = Image.fromarray(out_img) - out_img.putpalette(pallete) - out_img.save(seg) - -if __name__ == "__main__": - main() +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# pylint: skip-file +import numpy as np +import mxnet as mx +from PIL import Image + +def getpallete(num_cls): + # this function is to get the colormap for visualizing the segmentation mask + n = num_cls + pallete = [0]*(n*3) + for j in xrange(0,n): + lab = j + pallete[j*3+0] = 0 + pallete[j*3+1] = 0 + pallete[j*3+2] = 0 + i = 0 + while (lab > 0): + pallete[j*3+0] |= (((lab >> 0) & 1) << (7-i)) + pallete[j*3+1] |= (((lab >> 1) & 1) << (7-i)) + pallete[j*3+2] |= (((lab >> 2) & 1) << (7-i)) + i = i + 1 + lab >>= 3 + return pallete + +pallete = getpallete(256) +img = "./person_bicycle.jpg" +seg = img.replace("jpg", "png") +model_previx = "FCN8s_VGG16" +epoch = 19 +ctx = mx.gpu(0) + +def get_data(img_path): + """get the (1, 3, h, w) np.array data for the img_path""" + mean = np.array([123.68, 116.779, 103.939]) # (R,G,B) + img = Image.open(img_path) + img = np.array(img, dtype=np.float32) + reshaped_mean = mean.reshape(1, 1, 3) + img = img - reshaped_mean + img = np.swapaxes(img, 0, 2) + img = np.swapaxes(img, 1, 2) + img = np.expand_dims(img, axis=0) + return img + +def main(): + fcnxs, fcnxs_args, fcnxs_auxs = mx.model.load_checkpoint(model_previx, epoch) + fcnxs_args["data"] = mx.nd.array(get_data(img), ctx) + data_shape = fcnxs_args["data"].shape + label_shape = (1, data_shape[2]*data_shape[3]) + fcnxs_args["softmax_label"] = mx.nd.empty(label_shape, ctx) + exector = fcnxs.bind(ctx, fcnxs_args ,args_grad=None, grad_req="null", aux_states=fcnxs_args) + exector.forward(is_train=False) + output = exector.outputs[0] + out_img = np.uint8(np.squeeze(output.asnumpy().argmax(axis=1))) + out_img = Image.fromarray(out_img) + out_img.putpalette(pallete) + out_img.save(seg) + +if __name__ == "__main__": + main() diff --git a/example/fcn-xs/init_fcnxs.py b/example/fcn-xs/init_fcnxs.py index c90a45bb4358..ede46b80d56c 100644 --- a/example/fcn-xs/init_fcnxs.py +++ b/example/fcn-xs/init_fcnxs.py @@ -1,89 +1,106 @@ -# pylint: skip-file -import mxnet as mx -import numpy as np -import sys -import logging - -logger = logging.getLogger() -logger.setLevel(logging.INFO) - -# make a bilinear interpolation kernel, return a numpy.ndarray -def upsample_filt(size): - factor = (size + 1) // 2 - if size % 2 == 1: - center = factor - 1.0 - else: - center = factor - 0.5 - og = np.ogrid[:size, :size] - return (1 - abs(og[0] - center) / factor) * \ - (1 - abs(og[1] - center) / factor) - -def init_from_vgg16(ctx, fcnxs_symbol, vgg16fc_args, vgg16fc_auxs): - fcnxs_args = vgg16fc_args.copy() - fcnxs_auxs = vgg16fc_auxs.copy() - for k,v in fcnxs_args.items(): - if(v.context != ctx): - fcnxs_args[k] = mx.nd.zeros(v.shape, ctx) - v.copyto(fcnxs_args[k]) - for k,v in fcnxs_auxs.items(): - if(v.context != ctx): - fcnxs_auxs[k] = mx.nd.zeros(v.shape, ctx) - v.copyto(fcnxs_auxs[k]) - data_shape=(1,3,500,500) - arg_names = fcnxs_symbol.list_arguments() - arg_shapes, _, _ = fcnxs_symbol.infer_shape(data=data_shape) - rest_params = dict([(x[0], mx.nd.zeros(x[1], ctx)) for x in zip(arg_names, arg_shapes) - if x[0] in ['score_weight', 'score_bias', 'score_pool4_weight', 'score_pool4_bias', \ - 'score_pool3_weight', 'score_pool3_bias']]) - fcnxs_args.update(rest_params) - deconv_params = dict([(x[0], x[1]) for x in zip(arg_names, arg_shapes) - if x[0] in ["bigscore_weight", 'score2_weight', 'score4_weight']]) - for k, v in deconv_params.items(): - filt = upsample_filt(v[3]) - initw = np.zeros(v) - initw[range(v[0]), range(v[1]), :, :] = filt # becareful here is the slice assing - fcnxs_args[k] = mx.nd.array(initw, ctx) - return fcnxs_args, fcnxs_auxs - -def init_from_fcnxs(ctx, fcnxs_symbol, fcnxs_args_from, fcnxs_auxs_from): - """ use zero initialization for better convergence, because it tends to oputut 0, - and the label 0 stands for background, which may occupy most size of one image. - """ - fcnxs_args = fcnxs_args_from.copy() - fcnxs_auxs = fcnxs_auxs_from.copy() - for k,v in fcnxs_args.items(): - if(v.context != ctx): - fcnxs_args[k] = mx.nd.zeros(v.shape, ctx) - v.copyto(fcnxs_args[k]) - for k,v in fcnxs_auxs.items(): - if(v.context != ctx): - fcnxs_auxs[k] = mx.nd.zeros(v.shape, ctx) - v.copyto(fcnxs_auxs[k]) - data_shape=(1,3,500,500) - arg_names = fcnxs_symbol.list_arguments() - arg_shapes, _, _ = fcnxs_symbol.infer_shape(data=data_shape) - rest_params = {} - deconv_params = {} - # this is fcn8s init from fcn16s - if 'score_pool3_weight' in arg_names: - rest_params = dict([(x[0], mx.nd.zeros(x[1], ctx)) for x in zip(arg_names, arg_shapes) - if x[0] in ['score_pool3_bias', 'score_pool3_weight']]) - deconv_params = dict([(x[0], x[1]) for x in zip(arg_names, arg_shapes) if x[0] \ - in ["bigscore_weight", 'score4_weight']]) - # this is fcn16s init from fcn32s - elif 'score_pool4_weight' in arg_names: - rest_params = dict([(x[0], mx.nd.zeros(x[1], ctx)) for x in zip(arg_names, arg_shapes) - if x[0] in ['score_pool4_weight', 'score_pool4_bias']]) - deconv_params = dict([(x[0], x[1]) for x in zip(arg_names, arg_shapes) if x[0] \ - in ["bigscore_weight", 'score2_weight']]) - # this is fcn32s init - else: - logging.error("you are init the fcn32s model, so you should use init_from_vgg16()") - sys.exit() - fcnxs_args.update(rest_params) - for k, v in deconv_params.items(): - filt = upsample_filt(v[3]) - initw = np.zeros(v) - initw[range(v[0]), range(v[1]), :, :] = filt # becareful here is the slice assing - fcnxs_args[k] = mx.nd.array(initw, ctx) - return fcnxs_args, fcnxs_auxs +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# pylint: skip-file +import mxnet as mx +import numpy as np +import sys +import logging + +logger = logging.getLogger() +logger.setLevel(logging.INFO) + +# make a bilinear interpolation kernel, return a numpy.ndarray +def upsample_filt(size): + factor = (size + 1) // 2 + if size % 2 == 1: + center = factor - 1.0 + else: + center = factor - 0.5 + og = np.ogrid[:size, :size] + return (1 - abs(og[0] - center) / factor) * \ + (1 - abs(og[1] - center) / factor) + +def init_from_vgg16(ctx, fcnxs_symbol, vgg16fc_args, vgg16fc_auxs): + fcnxs_args = vgg16fc_args.copy() + fcnxs_auxs = vgg16fc_auxs.copy() + for k,v in fcnxs_args.items(): + if(v.context != ctx): + fcnxs_args[k] = mx.nd.zeros(v.shape, ctx) + v.copyto(fcnxs_args[k]) + for k,v in fcnxs_auxs.items(): + if(v.context != ctx): + fcnxs_auxs[k] = mx.nd.zeros(v.shape, ctx) + v.copyto(fcnxs_auxs[k]) + data_shape=(1,3,500,500) + arg_names = fcnxs_symbol.list_arguments() + arg_shapes, _, _ = fcnxs_symbol.infer_shape(data=data_shape) + rest_params = dict([(x[0], mx.nd.zeros(x[1], ctx)) for x in zip(arg_names, arg_shapes) + if x[0] in ['score_weight', 'score_bias', 'score_pool4_weight', 'score_pool4_bias', \ + 'score_pool3_weight', 'score_pool3_bias']]) + fcnxs_args.update(rest_params) + deconv_params = dict([(x[0], x[1]) for x in zip(arg_names, arg_shapes) + if x[0] in ["bigscore_weight", 'score2_weight', 'score4_weight']]) + for k, v in deconv_params.items(): + filt = upsample_filt(v[3]) + initw = np.zeros(v) + initw[range(v[0]), range(v[1]), :, :] = filt # becareful here is the slice assing + fcnxs_args[k] = mx.nd.array(initw, ctx) + return fcnxs_args, fcnxs_auxs + +def init_from_fcnxs(ctx, fcnxs_symbol, fcnxs_args_from, fcnxs_auxs_from): + """ use zero initialization for better convergence, because it tends to oputut 0, + and the label 0 stands for background, which may occupy most size of one image. + """ + fcnxs_args = fcnxs_args_from.copy() + fcnxs_auxs = fcnxs_auxs_from.copy() + for k,v in fcnxs_args.items(): + if(v.context != ctx): + fcnxs_args[k] = mx.nd.zeros(v.shape, ctx) + v.copyto(fcnxs_args[k]) + for k,v in fcnxs_auxs.items(): + if(v.context != ctx): + fcnxs_auxs[k] = mx.nd.zeros(v.shape, ctx) + v.copyto(fcnxs_auxs[k]) + data_shape=(1,3,500,500) + arg_names = fcnxs_symbol.list_arguments() + arg_shapes, _, _ = fcnxs_symbol.infer_shape(data=data_shape) + rest_params = {} + deconv_params = {} + # this is fcn8s init from fcn16s + if 'score_pool3_weight' in arg_names: + rest_params = dict([(x[0], mx.nd.zeros(x[1], ctx)) for x in zip(arg_names, arg_shapes) + if x[0] in ['score_pool3_bias', 'score_pool3_weight']]) + deconv_params = dict([(x[0], x[1]) for x in zip(arg_names, arg_shapes) if x[0] \ + in ["bigscore_weight", 'score4_weight']]) + # this is fcn16s init from fcn32s + elif 'score_pool4_weight' in arg_names: + rest_params = dict([(x[0], mx.nd.zeros(x[1], ctx)) for x in zip(arg_names, arg_shapes) + if x[0] in ['score_pool4_weight', 'score_pool4_bias']]) + deconv_params = dict([(x[0], x[1]) for x in zip(arg_names, arg_shapes) if x[0] \ + in ["bigscore_weight", 'score2_weight']]) + # this is fcn32s init + else: + logging.error("you are init the fcn32s model, so you should use init_from_vgg16()") + sys.exit() + fcnxs_args.update(rest_params) + for k, v in deconv_params.items(): + filt = upsample_filt(v[3]) + initw = np.zeros(v) + initw[range(v[0]), range(v[1]), :, :] = filt # becareful here is the slice assing + fcnxs_args[k] = mx.nd.array(initw, ctx) + return fcnxs_args, fcnxs_auxs diff --git a/example/fcn-xs/run_fcnxs.sh b/example/fcn-xs/run_fcnxs.sh index 926f3f840415..df9a880b8396 100755 --- a/example/fcn-xs/run_fcnxs.sh +++ b/example/fcn-xs/run_fcnxs.sh @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # train fcn-32s model python -u fcn_xs.py --model=fcn32s --prefix=VGG_FC_ILSVRC_16_layers \ --epoch=74 --init-type=vgg16 diff --git a/example/fcn-xs/solver.py b/example/fcn-xs/solver.py index dd78e73b9b84..cf7298b83c8c 100644 --- a/example/fcn-xs/solver.py +++ b/example/fcn-xs/solver.py @@ -1,126 +1,143 @@ -# pylint: skip-file -import numpy as np -import mxnet as mx -import time -import logging -from collections import namedtuple -from mxnet import optimizer as opt -from mxnet.optimizer import get_updater -from mxnet import metric - -# Parameter to pass to batch_end_callback -BatchEndParam = namedtuple('BatchEndParams', ['epoch', 'nbatch', 'eval_metric']) -class Solver(object): - def __init__(self, symbol, ctx=None, - begin_epoch=0, num_epoch=None, - arg_params=None, aux_params=None, - optimizer='sgd', **kwargs): - self.symbol = symbol - if ctx is None: - ctx = mx.cpu() - self.ctx = ctx - self.begin_epoch = begin_epoch - self.num_epoch = num_epoch - self.arg_params = arg_params - self.aux_params = aux_params - self.optimizer = optimizer - self.kwargs = kwargs.copy() - - def fit(self, train_data, eval_data=None, - eval_metric='acc', - grad_req='write', - epoch_end_callback=None, - batch_end_callback=None, - kvstore='local', - logger=None): - if logger is None: - logger = logging - logging.info('Start training with %s', str(self.ctx)) - arg_shapes, out_shapes, aux_shapes = self.symbol.infer_shape(data=train_data.provide_data[0][1]) - arg_names = self.symbol.list_arguments() - if grad_req != 'null': - self.grad_params = {} - for name, shape in zip(arg_names, arg_shapes): - if not (name.endswith('data') or name.endswith('label')): - self.grad_params[name] = mx.nd.zeros(shape, self.ctx) - else: - self.grad_params = None - aux_names = self.symbol.list_auxiliary_states() - self.aux_params = {k : nd.zeros(s) for k, s in zip(aux_names, aux_shapes)} - data_name = train_data.data_name - label_name = train_data.label_name - input_names = [data_name, label_name] - self.optimizer = opt.create(self.optimizer, rescale_grad=(1.0/train_data.get_batch_size()), **(self.kwargs)) - self.updater = get_updater(self.optimizer) - eval_metric = metric.create(eval_metric) - # begin training - for epoch in range(self.begin_epoch, self.num_epoch): - nbatch = 0 - train_data.reset() - eval_metric.reset() - for data in train_data: - nbatch += 1 - label_shape = data[label_name].shape - self.arg_params[data_name] = mx.nd.array(data[data_name], self.ctx) - self.arg_params[label_name] = mx.nd.array(data[label_name].reshape(label_shape[0], \ - label_shape[1]*label_shape[2]), self.ctx) - output_names = self.symbol.list_outputs() - self.exector = self.symbol.bind(self.ctx, self.arg_params, - args_grad=self.grad_params, - grad_req=grad_req, - aux_states=self.aux_params) - assert len(self.symbol.list_arguments()) == len(self.exector.grad_arrays) - update_dict = {name: nd for name, nd in zip(self.symbol.list_arguments(), \ - self.exector.grad_arrays) if nd is not None} - output_dict = {} - output_buff = {} - for key, arr in zip(self.symbol.list_outputs(), self.exector.outputs): - output_dict[key] = arr - output_buff[key] = mx.nd.empty(arr.shape, ctx=mx.cpu()) - self.exector.forward(is_train=True) - for key in output_dict: - output_dict[key].copyto(output_buff[key]) - self.exector.backward() - for key, arr in update_dict.items(): - if key != "bigscore_weight": - self.updater(key, arr, self.arg_params[key]) - pred_shape = self.exector.outputs[0].shape - label = mx.nd.array(data[label_name].reshape(label_shape[0], label_shape[1]*label_shape[2])) - pred = mx.nd.array(output_buff["softmax_output"].asnumpy().reshape(pred_shape[0], \ - pred_shape[1], pred_shape[2]*pred_shape[3])) - eval_metric.update([label], [pred]) - self.exector.outputs[0].wait_to_read() - batch_end_params = BatchEndParam(epoch=epoch, nbatch=nbatch, eval_metric=eval_metric) - batch_end_callback(batch_end_params) - if epoch_end_callback is not None: - epoch_end_callback(epoch, self.symbol, self.arg_params, self.aux_params) - name, value = eval_metric.get() - logger.info(" --->Epoch[%d] Train-%s=%f", epoch, name, value) - # evaluation - if eval_data: - logger.info(" in eval process...") - nbatch = 0 - eval_data.reset() - eval_metric.reset() - for data in eval_data: - nbatch += 1 - label_shape = data[label_name].shape - self.arg_params[data_name] = mx.nd.array(data[data_name], self.ctx) - self.arg_params[label_name] = mx.nd.array(data[label_name].reshape(label_shape[0], \ - label_shape[1]*label_shape[2]), self.ctx) - exector = self.symbol.bind(self.ctx, self.arg_params, - args_grad=self.grad_params, - grad_req=grad_req, - aux_states=self.aux_params) - cpu_output_array = mx.nd.zeros(exector.outputs[0].shape) - exector.forward(is_train=False) - exector.outputs[0].copyto(cpu_output_array) - pred_shape = cpu_output_array.shape - label = mx.nd.array(data[label_name].reshape(label_shape[0], \ - label_shape[1]*label_shape[2])) - pred = mx.nd.array(cpu_output_array.asnumpy().reshape(pred_shape[0], \ - pred_shape[1], pred_shape[2]*pred_shape[3])) - eval_metric.update([label], [pred]) - exector.outputs[0].wait_to_read() - name, value = eval_metric.get() - logger.info('batch[%d] Validation-%s=%f', nbatch, name, value) +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# pylint: skip-file +import numpy as np +import mxnet as mx +import time +import logging +from collections import namedtuple +from mxnet import optimizer as opt +from mxnet.optimizer import get_updater +from mxnet import metric + +# Parameter to pass to batch_end_callback +BatchEndParam = namedtuple('BatchEndParams', ['epoch', 'nbatch', 'eval_metric']) +class Solver(object): + def __init__(self, symbol, ctx=None, + begin_epoch=0, num_epoch=None, + arg_params=None, aux_params=None, + optimizer='sgd', **kwargs): + self.symbol = symbol + if ctx is None: + ctx = mx.cpu() + self.ctx = ctx + self.begin_epoch = begin_epoch + self.num_epoch = num_epoch + self.arg_params = arg_params + self.aux_params = aux_params + self.optimizer = optimizer + self.kwargs = kwargs.copy() + + def fit(self, train_data, eval_data=None, + eval_metric='acc', + grad_req='write', + epoch_end_callback=None, + batch_end_callback=None, + kvstore='local', + logger=None): + if logger is None: + logger = logging + logging.info('Start training with %s', str(self.ctx)) + arg_shapes, out_shapes, aux_shapes = self.symbol.infer_shape(data=train_data.provide_data[0][1]) + arg_names = self.symbol.list_arguments() + if grad_req != 'null': + self.grad_params = {} + for name, shape in zip(arg_names, arg_shapes): + if not (name.endswith('data') or name.endswith('label')): + self.grad_params[name] = mx.nd.zeros(shape, self.ctx) + else: + self.grad_params = None + aux_names = self.symbol.list_auxiliary_states() + self.aux_params = {k : nd.zeros(s) for k, s in zip(aux_names, aux_shapes)} + data_name = train_data.data_name + label_name = train_data.label_name + input_names = [data_name, label_name] + self.optimizer = opt.create(self.optimizer, rescale_grad=(1.0/train_data.get_batch_size()), **(self.kwargs)) + self.updater = get_updater(self.optimizer) + eval_metric = metric.create(eval_metric) + # begin training + for epoch in range(self.begin_epoch, self.num_epoch): + nbatch = 0 + train_data.reset() + eval_metric.reset() + for data in train_data: + nbatch += 1 + label_shape = data[label_name].shape + self.arg_params[data_name] = mx.nd.array(data[data_name], self.ctx) + self.arg_params[label_name] = mx.nd.array(data[label_name].reshape(label_shape[0], \ + label_shape[1]*label_shape[2]), self.ctx) + output_names = self.symbol.list_outputs() + self.exector = self.symbol.bind(self.ctx, self.arg_params, + args_grad=self.grad_params, + grad_req=grad_req, + aux_states=self.aux_params) + assert len(self.symbol.list_arguments()) == len(self.exector.grad_arrays) + update_dict = {name: nd for name, nd in zip(self.symbol.list_arguments(), \ + self.exector.grad_arrays) if nd is not None} + output_dict = {} + output_buff = {} + for key, arr in zip(self.symbol.list_outputs(), self.exector.outputs): + output_dict[key] = arr + output_buff[key] = mx.nd.empty(arr.shape, ctx=mx.cpu()) + self.exector.forward(is_train=True) + for key in output_dict: + output_dict[key].copyto(output_buff[key]) + self.exector.backward() + for key, arr in update_dict.items(): + if key != "bigscore_weight": + self.updater(key, arr, self.arg_params[key]) + pred_shape = self.exector.outputs[0].shape + label = mx.nd.array(data[label_name].reshape(label_shape[0], label_shape[1]*label_shape[2])) + pred = mx.nd.array(output_buff["softmax_output"].asnumpy().reshape(pred_shape[0], \ + pred_shape[1], pred_shape[2]*pred_shape[3])) + eval_metric.update([label], [pred]) + self.exector.outputs[0].wait_to_read() + batch_end_params = BatchEndParam(epoch=epoch, nbatch=nbatch, eval_metric=eval_metric) + batch_end_callback(batch_end_params) + if epoch_end_callback is not None: + epoch_end_callback(epoch, self.symbol, self.arg_params, self.aux_params) + name, value = eval_metric.get() + logger.info(" --->Epoch[%d] Train-%s=%f", epoch, name, value) + # evaluation + if eval_data: + logger.info(" in eval process...") + nbatch = 0 + eval_data.reset() + eval_metric.reset() + for data in eval_data: + nbatch += 1 + label_shape = data[label_name].shape + self.arg_params[data_name] = mx.nd.array(data[data_name], self.ctx) + self.arg_params[label_name] = mx.nd.array(data[label_name].reshape(label_shape[0], \ + label_shape[1]*label_shape[2]), self.ctx) + exector = self.symbol.bind(self.ctx, self.arg_params, + args_grad=self.grad_params, + grad_req=grad_req, + aux_states=self.aux_params) + cpu_output_array = mx.nd.zeros(exector.outputs[0].shape) + exector.forward(is_train=False) + exector.outputs[0].copyto(cpu_output_array) + pred_shape = cpu_output_array.shape + label = mx.nd.array(data[label_name].reshape(label_shape[0], \ + label_shape[1]*label_shape[2])) + pred = mx.nd.array(cpu_output_array.asnumpy().reshape(pred_shape[0], \ + pred_shape[1], pred_shape[2]*pred_shape[3])) + eval_metric.update([label], [pred]) + exector.outputs[0].wait_to_read() + name, value = eval_metric.get() + logger.info('batch[%d] Validation-%s=%f', nbatch, name, value) diff --git a/example/fcn-xs/symbol_fcnxs.py b/example/fcn-xs/symbol_fcnxs.py index a9c4f3b712ec..56888fc94822 100644 --- a/example/fcn-xs/symbol_fcnxs.py +++ b/example/fcn-xs/symbol_fcnxs.py @@ -1,189 +1,206 @@ -# pylint: skip-file -import mxnet as mx - -def filter_map(kernel=1, stride=1, pad=0): - return (stride, (kernel-stride)/2-pad) - -def compose_fp(fp_first, fp_second): - return (fp_first[0]*fp_second[0], fp_first[0]*fp_second[1]+fp_first[1]) - -def compose_fp_list(fp_list): - fp_out = (1.0, 0.0) - for fp in fp_list: - fp_out = compose_fp(fp_out, fp) - return fp_out - -def inv_fp(fp_in): - return (1.0/fp_in[0], -1.0*fp_in[1]/fp_in[0]) - -def offset(): - conv1_1_fp = filter_map(kernel=3, pad=100) - conv1_2_fp = conv2_1_fp = conv2_2_fp = conv3_1_fp = conv3_2_fp = conv3_3_fp \ - = conv4_1_fp = conv4_2_fp = conv4_3_fp = conv5_1_fp = conv5_2_fp \ - = conv5_3_fp = filter_map(kernel=3, pad=1) - pool1_fp = pool2_fp = pool3_fp = pool4_fp = pool5_fp = filter_map(kernel=2, stride=2) - fc6_fp = filter_map(kernel=7) - fc7_fp = score_fp = score_pool4_fp = score_pool3_fp = filter_map() - # for fcn-32s - fcn32s_upscore_fp = inv_fp(filter_map(kernel=64, stride=32)) - fcn32s_upscore_list = [conv1_1_fp, conv1_2_fp, pool1_fp, conv2_1_fp, conv2_2_fp, - pool2_fp, conv3_1_fp, conv3_2_fp, conv3_3_fp, pool3_fp, - conv4_1_fp, conv4_2_fp, conv4_3_fp, pool4_fp, conv5_1_fp, - conv5_2_fp, conv5_3_fp, pool5_fp, fc6_fp, fc7_fp, score_fp, - fcn32s_upscore_fp] - crop = {} - crop["fcn32s_upscore"] = (-int(round(compose_fp_list(fcn32s_upscore_list)[1])), - -int(round(compose_fp_list(fcn32s_upscore_list)[1]))) - # for fcn-16s - score2_fp = inv_fp(filter_map(kernel=4, stride=2)) - fcn16s_upscore_fp = inv_fp(filter_map(kernel=32, stride=16)) - score_pool4c_fp_list = [inv_fp(score2_fp), inv_fp(score_fp), inv_fp(fc7_fp), inv_fp(fc6_fp), - inv_fp(pool5_fp), inv_fp(conv5_3_fp), inv_fp(conv5_2_fp), - inv_fp(conv5_1_fp), score_pool4_fp] - crop["score_pool4c"] = (-int(round(compose_fp_list(score_pool4c_fp_list)[1])), - -int(round(compose_fp_list(score_pool4c_fp_list)[1]))) - fcn16s_upscore_list = [conv1_1_fp, conv1_2_fp, pool1_fp, conv2_1_fp, conv2_2_fp, - pool2_fp, conv3_1_fp, conv3_2_fp, conv3_3_fp, pool3_fp, - conv4_1_fp, conv4_2_fp, conv4_3_fp, pool4_fp, score_pool4_fp, - inv_fp((1, -crop["score_pool4c"][0])), fcn16s_upscore_fp] - crop["fcn16s_upscore"] = (-int(round(compose_fp_list(fcn16s_upscore_list)[1])), - -int(round(compose_fp_list(fcn16s_upscore_list)[1]))) - # for fcn-8s - score4_fp = inv_fp(filter_map(kernel=4, stride=2)) - fcn8s_upscore_fp = inv_fp(filter_map(kernel=16, stride=8)) - score_pool3c_fp_list = [inv_fp(score4_fp), (1, -crop["score_pool4c"][0]), inv_fp(score_pool4_fp), - inv_fp(pool4_fp), inv_fp(conv4_3_fp), inv_fp(conv4_2_fp), - inv_fp(conv4_1_fp), score_pool3_fp, score_pool3_fp] - crop["score_pool3c"] = (-int(round(compose_fp_list(score_pool3c_fp_list)[1])), - -int(round(compose_fp_list(score_pool3c_fp_list)[1]))) - fcn8s_upscore_list = [conv1_1_fp, conv1_2_fp, pool1_fp, conv2_1_fp, conv2_2_fp, pool2_fp, - conv3_1_fp, conv3_2_fp, conv3_3_fp, pool3_fp, score_pool3_fp, - inv_fp((1, -crop["score_pool3c"][0])), fcn8s_upscore_fp] - crop["fcn8s_upscore"] = (-int(round(compose_fp_list(fcn8s_upscore_list)[1])), - -int(round(compose_fp_list(fcn8s_upscore_list)[1]))) - return crop - -def vgg16_pool3(input, workspace_default=1024): - # group 1 - conv1_1 = mx.symbol.Convolution(data=input, kernel=(3, 3), pad=(100, 100), num_filter=64, - workspace=workspace_default, name="conv1_1") - relu1_1 = mx.symbol.Activation(data=conv1_1, act_type="relu", name="relu1_1") - conv1_2 = mx.symbol.Convolution(data=relu1_1, kernel=(3, 3), pad=(1, 1), num_filter=64, - workspace=workspace_default, name="conv1_2") - relu1_2 = mx.symbol.Activation(data=conv1_2, act_type="relu", name="relu1_2") - pool1 = mx.symbol.Pooling(data=relu1_2, pool_type="max", kernel=(2, 2), stride=(2,2), name="pool1") - # group 2 - conv2_1 = mx.symbol.Convolution(data=pool1, kernel=(3, 3), pad=(1, 1), num_filter=128, - workspace=workspace_default, name="conv2_1") - relu2_1 = mx.symbol.Activation(data=conv2_1, act_type="relu", name="relu2_1") - conv2_2 = mx.symbol.Convolution(data=relu2_1, kernel=(3, 3), pad=(1, 1), num_filter=128, - workspace=workspace_default, name="conv2_2") - relu2_2 = mx.symbol.Activation(data=conv2_2, act_type="relu", name="relu2_2") - pool2 = mx.symbol.Pooling(data=relu2_2, pool_type="max", kernel=(2, 2), stride=(2,2), name="pool2") - # group 3 - conv3_1 = mx.symbol.Convolution(data=pool2, kernel=(3, 3), pad=(1, 1), num_filter=256, - workspace=workspace_default, name="conv3_1") - relu3_1 = mx.symbol.Activation(data=conv3_1, act_type="relu", name="relu3_1") - conv3_2 = mx.symbol.Convolution(data=relu3_1, kernel=(3, 3), pad=(1, 1), num_filter=256, - workspace=workspace_default, name="conv3_2") - relu3_2 = mx.symbol.Activation(data=conv3_2, act_type="relu", name="relu3_2") - conv3_3 = mx.symbol.Convolution(data=relu3_2, kernel=(3, 3), pad=(1, 1), num_filter=256, - workspace=workspace_default, name="conv3_3") - relu3_3 = mx.symbol.Activation(data=conv3_3, act_type="relu", name="relu3_3") - pool3 = mx.symbol.Pooling(data=relu3_3, pool_type="max", kernel=(2, 2), stride=(2,2), name="pool3") - return pool3 - -def vgg16_pool4(input, workspace_default=1024): - # group 4 - conv4_1 = mx.symbol.Convolution(data=input, kernel=(3, 3), pad=(1, 1), num_filter=512, - workspace=workspace_default, name="conv4_1") - relu4_1 = mx.symbol.Activation(data=conv4_1, act_type="relu", name="relu4_1") - conv4_2 = mx.symbol.Convolution(data=relu4_1, kernel=(3, 3), pad=(1, 1), num_filter=512, - workspace=workspace_default, name="conv4_2") - relu4_2 = mx.symbol.Activation(data=conv4_2, act_type="relu", name="relu4_2") - conv4_3 = mx.symbol.Convolution(data=relu4_2, kernel=(3, 3), pad=(1, 1), num_filter=512, - workspace=workspace_default, name="conv4_3") - relu4_3 = mx.symbol.Activation(data=conv4_3, act_type="relu", name="relu4_3") - pool4 = mx.symbol.Pooling(data=relu4_3, pool_type="max", kernel=(2, 2), stride=(2,2), name="pool4") - return pool4 - -def vgg16_score(input, numclass, workspace_default=1024): - # group 5 - conv5_1 = mx.symbol.Convolution(data=input, kernel=(3, 3), pad=(1, 1), num_filter=512, - workspace=workspace_default, name="conv5_1") - relu5_1 = mx.symbol.Activation(data=conv5_1, act_type="relu", name="relu5_1") - conv5_2 = mx.symbol.Convolution(data=relu5_1, kernel=(3, 3), pad=(1, 1), num_filter=512, - workspace=workspace_default, name="conv5_2") - relu5_2 = mx.symbol.Activation(data=conv5_2, act_type="relu", name="relu5_2") - conv5_3 = mx.symbol.Convolution(data=relu5_2, kernel=(3, 3), pad=(1, 1), num_filter=512, - workspace=workspace_default, name="conv5_3") - relu5_3 = mx.symbol.Activation(data=conv5_3, act_type="relu", name="relu5_3") - pool5 = mx.symbol.Pooling(data=relu5_3, pool_type="max", kernel=(2, 2), stride=(2,2), name="pool5") - # group 6 - fc6 = mx.symbol.Convolution(data=pool5, kernel=(7, 7), num_filter=4096, - workspace=workspace_default, name="fc6") - relu6 = mx.symbol.Activation(data=fc6, act_type="relu", name="relu6") - drop6 = mx.symbol.Dropout(data=relu6, p=0.5, name="drop6") - # group 7 - fc7 = mx.symbol.Convolution(data=drop6, kernel=(1, 1), num_filter=4096, - workspace=workspace_default, name="fc7") - relu7 = mx.symbol.Activation(data=fc7, act_type="relu", name="relu7") - drop7 = mx.symbol.Dropout(data=relu7, p=0.5, name="drop7") - # group 8 - score = mx.symbol.Convolution(data=drop7, kernel=(1, 1), num_filter=numclass, - workspace=workspace_default, name="score") - return score - -def fcnxs_score(input, crop, offset, kernel=(64,64), stride=(32,32), numclass=21, workspace_default=1024): - # score out - bigscore = mx.symbol.Deconvolution(data=input, kernel=kernel, stride=stride, adj=(stride[0]-1, stride[1]-1), - num_filter=numclass, workspace=workspace_default, name="bigscore") - upscore = mx.symbol.Crop(*[bigscore, crop], offset=offset, name="upscore") - # upscore = mx.symbol.Crop(*[input, crop], offset=offset, name="upscore") - softmax = mx.symbol.SoftmaxOutput(data=upscore, multi_output=True, use_ignore=True, ignore_label=255, name="softmax") - return softmax - -def get_fcn32s_symbol(numclass=21, workspace_default=1024): - data = mx.symbol.Variable(name="data") - pool3 = vgg16_pool3(data, workspace_default) - pool4 = vgg16_pool4(pool3, workspace_default) - score = vgg16_score(pool4, numclass, workspace_default) - softmax = fcnxs_score(score, data, offset()["fcn32s_upscore"], (64,64), (32,32), numclass, workspace_default) - return softmax - -def get_fcn16s_symbol(numclass=21, workspace_default=1024): - data = mx.symbol.Variable(name="data") - pool3 = vgg16_pool3(data, workspace_default) - pool4 = vgg16_pool4(pool3, workspace_default) - score = vgg16_score(pool4, numclass, workspace_default) - # score 2X - score2 = mx.symbol.Deconvolution(data=score, kernel=(4, 4), stride=(2, 2), num_filter=numclass, - adj=(1, 1), workspace=workspace_default, name="score2") # 2X - score_pool4 = mx.symbol.Convolution(data=pool4, kernel=(1, 1), num_filter=numclass, - workspace=workspace_default, name="score_pool4") - score_pool4c = mx.symbol.Crop(*[score_pool4, score2], offset=offset()["score_pool4c"], name="score_pool4c") - score_fused = score2 + score_pool4c - softmax = fcnxs_score(score_fused, data, offset()["fcn16s_upscore"], (32, 32), (16, 16), numclass, workspace_default) - return softmax - -def get_fcn8s_symbol(numclass=21, workspace_default=1024): - data = mx.symbol.Variable(name="data") - pool3 = vgg16_pool3(data, workspace_default) - pool4 = vgg16_pool4(pool3, workspace_default) - score = vgg16_score(pool4, numclass, workspace_default) - # score 2X - score2 = mx.symbol.Deconvolution(data=score, kernel=(4, 4), stride=(2, 2),num_filter=numclass, - adj=(1, 1), workspace=workspace_default, name="score2") # 2X - score_pool4 = mx.symbol.Convolution(data=pool4, kernel=(1, 1), num_filter=numclass, - workspace=workspace_default, name="score_pool4") - score_pool4c = mx.symbol.Crop(*[score_pool4, score2], offset=offset()["score_pool4c"], name="score_pool4c") - score_fused = score2 + score_pool4c - # score 4X - score4 = mx.symbol.Deconvolution(data=score_fused, kernel=(4, 4), stride=(2, 2),num_filter=numclass, - adj=(1, 1), workspace=workspace_default, name="score4") # 4X - score_pool3 = mx.symbol.Convolution(data=pool3, kernel=(1, 1), num_filter=numclass, - workspace=workspace_default, name="score_pool3") - score_pool3c = mx.symbol.Crop(*[score_pool3, score4], offset=offset()["score_pool3c"], name="score_pool3c") - score_final = score4 + score_pool3c - softmax = fcnxs_score(score_final, data, offset()["fcn8s_upscore"], (16, 16), (8, 8), numclass, workspace_default) - return softmax +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# pylint: skip-file +import mxnet as mx + +def filter_map(kernel=1, stride=1, pad=0): + return (stride, (kernel-stride)/2-pad) + +def compose_fp(fp_first, fp_second): + return (fp_first[0]*fp_second[0], fp_first[0]*fp_second[1]+fp_first[1]) + +def compose_fp_list(fp_list): + fp_out = (1.0, 0.0) + for fp in fp_list: + fp_out = compose_fp(fp_out, fp) + return fp_out + +def inv_fp(fp_in): + return (1.0/fp_in[0], -1.0*fp_in[1]/fp_in[0]) + +def offset(): + conv1_1_fp = filter_map(kernel=3, pad=100) + conv1_2_fp = conv2_1_fp = conv2_2_fp = conv3_1_fp = conv3_2_fp = conv3_3_fp \ + = conv4_1_fp = conv4_2_fp = conv4_3_fp = conv5_1_fp = conv5_2_fp \ + = conv5_3_fp = filter_map(kernel=3, pad=1) + pool1_fp = pool2_fp = pool3_fp = pool4_fp = pool5_fp = filter_map(kernel=2, stride=2) + fc6_fp = filter_map(kernel=7) + fc7_fp = score_fp = score_pool4_fp = score_pool3_fp = filter_map() + # for fcn-32s + fcn32s_upscore_fp = inv_fp(filter_map(kernel=64, stride=32)) + fcn32s_upscore_list = [conv1_1_fp, conv1_2_fp, pool1_fp, conv2_1_fp, conv2_2_fp, + pool2_fp, conv3_1_fp, conv3_2_fp, conv3_3_fp, pool3_fp, + conv4_1_fp, conv4_2_fp, conv4_3_fp, pool4_fp, conv5_1_fp, + conv5_2_fp, conv5_3_fp, pool5_fp, fc6_fp, fc7_fp, score_fp, + fcn32s_upscore_fp] + crop = {} + crop["fcn32s_upscore"] = (-int(round(compose_fp_list(fcn32s_upscore_list)[1])), + -int(round(compose_fp_list(fcn32s_upscore_list)[1]))) + # for fcn-16s + score2_fp = inv_fp(filter_map(kernel=4, stride=2)) + fcn16s_upscore_fp = inv_fp(filter_map(kernel=32, stride=16)) + score_pool4c_fp_list = [inv_fp(score2_fp), inv_fp(score_fp), inv_fp(fc7_fp), inv_fp(fc6_fp), + inv_fp(pool5_fp), inv_fp(conv5_3_fp), inv_fp(conv5_2_fp), + inv_fp(conv5_1_fp), score_pool4_fp] + crop["score_pool4c"] = (-int(round(compose_fp_list(score_pool4c_fp_list)[1])), + -int(round(compose_fp_list(score_pool4c_fp_list)[1]))) + fcn16s_upscore_list = [conv1_1_fp, conv1_2_fp, pool1_fp, conv2_1_fp, conv2_2_fp, + pool2_fp, conv3_1_fp, conv3_2_fp, conv3_3_fp, pool3_fp, + conv4_1_fp, conv4_2_fp, conv4_3_fp, pool4_fp, score_pool4_fp, + inv_fp((1, -crop["score_pool4c"][0])), fcn16s_upscore_fp] + crop["fcn16s_upscore"] = (-int(round(compose_fp_list(fcn16s_upscore_list)[1])), + -int(round(compose_fp_list(fcn16s_upscore_list)[1]))) + # for fcn-8s + score4_fp = inv_fp(filter_map(kernel=4, stride=2)) + fcn8s_upscore_fp = inv_fp(filter_map(kernel=16, stride=8)) + score_pool3c_fp_list = [inv_fp(score4_fp), (1, -crop["score_pool4c"][0]), inv_fp(score_pool4_fp), + inv_fp(pool4_fp), inv_fp(conv4_3_fp), inv_fp(conv4_2_fp), + inv_fp(conv4_1_fp), score_pool3_fp, score_pool3_fp] + crop["score_pool3c"] = (-int(round(compose_fp_list(score_pool3c_fp_list)[1])), + -int(round(compose_fp_list(score_pool3c_fp_list)[1]))) + fcn8s_upscore_list = [conv1_1_fp, conv1_2_fp, pool1_fp, conv2_1_fp, conv2_2_fp, pool2_fp, + conv3_1_fp, conv3_2_fp, conv3_3_fp, pool3_fp, score_pool3_fp, + inv_fp((1, -crop["score_pool3c"][0])), fcn8s_upscore_fp] + crop["fcn8s_upscore"] = (-int(round(compose_fp_list(fcn8s_upscore_list)[1])), + -int(round(compose_fp_list(fcn8s_upscore_list)[1]))) + return crop + +def vgg16_pool3(input, workspace_default=1024): + # group 1 + conv1_1 = mx.symbol.Convolution(data=input, kernel=(3, 3), pad=(100, 100), num_filter=64, + workspace=workspace_default, name="conv1_1") + relu1_1 = mx.symbol.Activation(data=conv1_1, act_type="relu", name="relu1_1") + conv1_2 = mx.symbol.Convolution(data=relu1_1, kernel=(3, 3), pad=(1, 1), num_filter=64, + workspace=workspace_default, name="conv1_2") + relu1_2 = mx.symbol.Activation(data=conv1_2, act_type="relu", name="relu1_2") + pool1 = mx.symbol.Pooling(data=relu1_2, pool_type="max", kernel=(2, 2), stride=(2,2), name="pool1") + # group 2 + conv2_1 = mx.symbol.Convolution(data=pool1, kernel=(3, 3), pad=(1, 1), num_filter=128, + workspace=workspace_default, name="conv2_1") + relu2_1 = mx.symbol.Activation(data=conv2_1, act_type="relu", name="relu2_1") + conv2_2 = mx.symbol.Convolution(data=relu2_1, kernel=(3, 3), pad=(1, 1), num_filter=128, + workspace=workspace_default, name="conv2_2") + relu2_2 = mx.symbol.Activation(data=conv2_2, act_type="relu", name="relu2_2") + pool2 = mx.symbol.Pooling(data=relu2_2, pool_type="max", kernel=(2, 2), stride=(2,2), name="pool2") + # group 3 + conv3_1 = mx.symbol.Convolution(data=pool2, kernel=(3, 3), pad=(1, 1), num_filter=256, + workspace=workspace_default, name="conv3_1") + relu3_1 = mx.symbol.Activation(data=conv3_1, act_type="relu", name="relu3_1") + conv3_2 = mx.symbol.Convolution(data=relu3_1, kernel=(3, 3), pad=(1, 1), num_filter=256, + workspace=workspace_default, name="conv3_2") + relu3_2 = mx.symbol.Activation(data=conv3_2, act_type="relu", name="relu3_2") + conv3_3 = mx.symbol.Convolution(data=relu3_2, kernel=(3, 3), pad=(1, 1), num_filter=256, + workspace=workspace_default, name="conv3_3") + relu3_3 = mx.symbol.Activation(data=conv3_3, act_type="relu", name="relu3_3") + pool3 = mx.symbol.Pooling(data=relu3_3, pool_type="max", kernel=(2, 2), stride=(2,2), name="pool3") + return pool3 + +def vgg16_pool4(input, workspace_default=1024): + # group 4 + conv4_1 = mx.symbol.Convolution(data=input, kernel=(3, 3), pad=(1, 1), num_filter=512, + workspace=workspace_default, name="conv4_1") + relu4_1 = mx.symbol.Activation(data=conv4_1, act_type="relu", name="relu4_1") + conv4_2 = mx.symbol.Convolution(data=relu4_1, kernel=(3, 3), pad=(1, 1), num_filter=512, + workspace=workspace_default, name="conv4_2") + relu4_2 = mx.symbol.Activation(data=conv4_2, act_type="relu", name="relu4_2") + conv4_3 = mx.symbol.Convolution(data=relu4_2, kernel=(3, 3), pad=(1, 1), num_filter=512, + workspace=workspace_default, name="conv4_3") + relu4_3 = mx.symbol.Activation(data=conv4_3, act_type="relu", name="relu4_3") + pool4 = mx.symbol.Pooling(data=relu4_3, pool_type="max", kernel=(2, 2), stride=(2,2), name="pool4") + return pool4 + +def vgg16_score(input, numclass, workspace_default=1024): + # group 5 + conv5_1 = mx.symbol.Convolution(data=input, kernel=(3, 3), pad=(1, 1), num_filter=512, + workspace=workspace_default, name="conv5_1") + relu5_1 = mx.symbol.Activation(data=conv5_1, act_type="relu", name="relu5_1") + conv5_2 = mx.symbol.Convolution(data=relu5_1, kernel=(3, 3), pad=(1, 1), num_filter=512, + workspace=workspace_default, name="conv5_2") + relu5_2 = mx.symbol.Activation(data=conv5_2, act_type="relu", name="relu5_2") + conv5_3 = mx.symbol.Convolution(data=relu5_2, kernel=(3, 3), pad=(1, 1), num_filter=512, + workspace=workspace_default, name="conv5_3") + relu5_3 = mx.symbol.Activation(data=conv5_3, act_type="relu", name="relu5_3") + pool5 = mx.symbol.Pooling(data=relu5_3, pool_type="max", kernel=(2, 2), stride=(2,2), name="pool5") + # group 6 + fc6 = mx.symbol.Convolution(data=pool5, kernel=(7, 7), num_filter=4096, + workspace=workspace_default, name="fc6") + relu6 = mx.symbol.Activation(data=fc6, act_type="relu", name="relu6") + drop6 = mx.symbol.Dropout(data=relu6, p=0.5, name="drop6") + # group 7 + fc7 = mx.symbol.Convolution(data=drop6, kernel=(1, 1), num_filter=4096, + workspace=workspace_default, name="fc7") + relu7 = mx.symbol.Activation(data=fc7, act_type="relu", name="relu7") + drop7 = mx.symbol.Dropout(data=relu7, p=0.5, name="drop7") + # group 8 + score = mx.symbol.Convolution(data=drop7, kernel=(1, 1), num_filter=numclass, + workspace=workspace_default, name="score") + return score + +def fcnxs_score(input, crop, offset, kernel=(64,64), stride=(32,32), numclass=21, workspace_default=1024): + # score out + bigscore = mx.symbol.Deconvolution(data=input, kernel=kernel, stride=stride, adj=(stride[0]-1, stride[1]-1), + num_filter=numclass, workspace=workspace_default, name="bigscore") + upscore = mx.symbol.Crop(*[bigscore, crop], offset=offset, name="upscore") + # upscore = mx.symbol.Crop(*[input, crop], offset=offset, name="upscore") + softmax = mx.symbol.SoftmaxOutput(data=upscore, multi_output=True, use_ignore=True, ignore_label=255, name="softmax") + return softmax + +def get_fcn32s_symbol(numclass=21, workspace_default=1024): + data = mx.symbol.Variable(name="data") + pool3 = vgg16_pool3(data, workspace_default) + pool4 = vgg16_pool4(pool3, workspace_default) + score = vgg16_score(pool4, numclass, workspace_default) + softmax = fcnxs_score(score, data, offset()["fcn32s_upscore"], (64,64), (32,32), numclass, workspace_default) + return softmax + +def get_fcn16s_symbol(numclass=21, workspace_default=1024): + data = mx.symbol.Variable(name="data") + pool3 = vgg16_pool3(data, workspace_default) + pool4 = vgg16_pool4(pool3, workspace_default) + score = vgg16_score(pool4, numclass, workspace_default) + # score 2X + score2 = mx.symbol.Deconvolution(data=score, kernel=(4, 4), stride=(2, 2), num_filter=numclass, + adj=(1, 1), workspace=workspace_default, name="score2") # 2X + score_pool4 = mx.symbol.Convolution(data=pool4, kernel=(1, 1), num_filter=numclass, + workspace=workspace_default, name="score_pool4") + score_pool4c = mx.symbol.Crop(*[score_pool4, score2], offset=offset()["score_pool4c"], name="score_pool4c") + score_fused = score2 + score_pool4c + softmax = fcnxs_score(score_fused, data, offset()["fcn16s_upscore"], (32, 32), (16, 16), numclass, workspace_default) + return softmax + +def get_fcn8s_symbol(numclass=21, workspace_default=1024): + data = mx.symbol.Variable(name="data") + pool3 = vgg16_pool3(data, workspace_default) + pool4 = vgg16_pool4(pool3, workspace_default) + score = vgg16_score(pool4, numclass, workspace_default) + # score 2X + score2 = mx.symbol.Deconvolution(data=score, kernel=(4, 4), stride=(2, 2),num_filter=numclass, + adj=(1, 1), workspace=workspace_default, name="score2") # 2X + score_pool4 = mx.symbol.Convolution(data=pool4, kernel=(1, 1), num_filter=numclass, + workspace=workspace_default, name="score_pool4") + score_pool4c = mx.symbol.Crop(*[score_pool4, score2], offset=offset()["score_pool4c"], name="score_pool4c") + score_fused = score2 + score_pool4c + # score 4X + score4 = mx.symbol.Deconvolution(data=score_fused, kernel=(4, 4), stride=(2, 2),num_filter=numclass, + adj=(1, 1), workspace=workspace_default, name="score4") # 4X + score_pool3 = mx.symbol.Convolution(data=pool3, kernel=(1, 1), num_filter=numclass, + workspace=workspace_default, name="score_pool3") + score_pool3c = mx.symbol.Crop(*[score_pool3, score4], offset=offset()["score_pool3c"], name="score_pool3c") + score_final = score4 + score_pool3c + softmax = fcnxs_score(score_final, data, offset()["fcn8s_upscore"], (16, 16), (8, 8), numclass, workspace_default) + return softmax diff --git a/example/gan/dcgan.py b/example/gan/dcgan.py index 5faff9aa5d9f..981f4a4778e3 100644 --- a/example/gan/dcgan.py +++ b/example/gan/dcgan.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import print_function import mxnet as mx import numpy as np diff --git a/example/gluon/actor_critic.py b/example/gluon/actor_critic.py index 9c475ce15017..6d4474b4f239 100644 --- a/example/gluon/actor_critic.py +++ b/example/gluon/actor_critic.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import print_function import argparse diff --git a/example/gluon/data.py b/example/gluon/data.py index 80a50bdce66b..c5ddd0af302b 100644 --- a/example/gluon/data.py +++ b/example/gluon/data.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file """ data iterator for mnist """ import os diff --git a/example/gluon/dcgan.py b/example/gluon/dcgan.py index f643b28f4bc1..ed814df61e99 100644 --- a/example/gluon/dcgan.py +++ b/example/gluon/dcgan.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import matplotlib as mpl mpl.use('Agg') from matplotlib import pyplot as plt diff --git a/example/gluon/image_classification.py b/example/gluon/image_classification.py index bb1fa8da8b2a..3f84ff8602ed 100644 --- a/example/gluon/image_classification.py +++ b/example/gluon/image_classification.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import division import argparse, time diff --git a/example/gluon/lstm_crf.py b/example/gluon/lstm_crf.py index 8344789faa6e..40c8c2be2784 100644 --- a/example/gluon/lstm_crf.py +++ b/example/gluon/lstm_crf.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx from mxnet import autograd as ag, ndarray as nd, gluon from mxnet.gluon import Block, nn, rnn diff --git a/example/gluon/mnist.py b/example/gluon/mnist.py index 9d567d5011cb..198d7ca5ab2a 100644 --- a/example/gluon/mnist.py +++ b/example/gluon/mnist.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file from __future__ import print_function diff --git a/example/gluon/super_resolution.py b/example/gluon/super_resolution.py index d61fb160e197..acc5ffa01d4a 100644 --- a/example/gluon/super_resolution.py +++ b/example/gluon/super_resolution.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import print_function import argparse, tarfile import math diff --git a/example/gluon/tree_lstm/dataset.py b/example/gluon/tree_lstm/dataset.py index f9cfce5c2bff..4a836ddb0eaf 100644 --- a/example/gluon/tree_lstm/dataset.py +++ b/example/gluon/tree_lstm/dataset.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import os import logging logging.basicConfig(level=logging.INFO) diff --git a/example/gluon/tree_lstm/fetch_and_preprocess.sh b/example/gluon/tree_lstm/fetch_and_preprocess.sh index dfbf82a872c1..f372392830d0 100755 --- a/example/gluon/tree_lstm/fetch_and_preprocess.sh +++ b/example/gluon/tree_lstm/fetch_and_preprocess.sh @@ -1,7 +1,25 @@ #!/bin/bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + set -e python2.7 scripts/download.py CLASSPATH="lib:lib/stanford-parser/stanford-parser.jar:lib/stanford-parser/stanford-parser-3.5.1-models.jar" javac -cp $CLASSPATH lib/*.java -python2.7 scripts/preprocess-sick.py \ No newline at end of file +python2.7 scripts/preprocess-sick.py diff --git a/example/gluon/tree_lstm/main.py b/example/gluon/tree_lstm/main.py index 7903e67a1441..f04a69f2671f 100644 --- a/example/gluon/tree_lstm/main.py +++ b/example/gluon/tree_lstm/main.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # This example is inspired by https://github.com/dasguptar/treelstm.pytorch import argparse, cPickle, math, os, random import logging diff --git a/example/gluon/tree_lstm/scripts/download.py b/example/gluon/tree_lstm/scripts/download.py index d38b3a46ecd8..7ea930370175 100644 --- a/example/gluon/tree_lstm/scripts/download.py +++ b/example/gluon/tree_lstm/scripts/download.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """ Downloads the following: - Stanford parser diff --git a/example/gluon/tree_lstm/scripts/preprocess-sick.py b/example/gluon/tree_lstm/scripts/preprocess-sick.py index fd28b58a5f7f..abbcc5fac844 100644 --- a/example/gluon/tree_lstm/scripts/preprocess-sick.py +++ b/example/gluon/tree_lstm/scripts/preprocess-sick.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """ Preprocessing script for SICK data. diff --git a/example/gluon/tree_lstm/tree_lstm.py b/example/gluon/tree_lstm/tree_lstm.py index ced7f7eeadf5..e96fe26bf9b6 100644 --- a/example/gluon/tree_lstm/tree_lstm.py +++ b/example/gluon/tree_lstm/tree_lstm.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx from mxnet.gluon import Block, nn from mxnet.gluon.parameter import Parameter diff --git a/example/gluon/word_language_model/data.py b/example/gluon/word_language_model/data.py index e3a283b64285..913963ec20cb 100644 --- a/example/gluon/word_language_model/data.py +++ b/example/gluon/word_language_model/data.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import os import numpy as np import mxnet as mx diff --git a/example/gluon/word_language_model/get_ptb_data.sh b/example/gluon/word_language_model/get_ptb_data.sh index 1ec009aa2f99..d2641cb32b81 100755 --- a/example/gluon/word_language_model/get_ptb_data.sh +++ b/example/gluon/word_language_model/get_ptb_data.sh @@ -1,5 +1,23 @@ #!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + RNN_DIR=$(cd `dirname $0`; pwd) DATA_DIR="${RNN_DIR}/data/" diff --git a/example/gluon/word_language_model/model.py b/example/gluon/word_language_model/model.py index 91378cee3cb4..40e7926ef8d6 100644 --- a/example/gluon/word_language_model/model.py +++ b/example/gluon/word_language_model/model.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx from mxnet import gluon from mxnet.gluon import nn, rnn diff --git a/example/gluon/word_language_model/train.py b/example/gluon/word_language_model/train.py index 5b34c00ecea0..0b504998bed2 100644 --- a/example/gluon/word_language_model/train.py +++ b/example/gluon/word_language_model/train.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import argparse import time import math diff --git a/example/image-classification/benchmark.py b/example/image-classification/benchmark.py index 5b040f3b09ff..3096fae07897 100644 --- a/example/image-classification/benchmark.py +++ b/example/image-classification/benchmark.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import print_function import logging import argparse diff --git a/example/image-classification/benchmark_score.py b/example/image-classification/benchmark_score.py index f54b6aebb750..aeacffa82b78 100644 --- a/example/image-classification/benchmark_score.py +++ b/example/image-classification/benchmark_score.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """ Benchmark the scoring performance on various CNNs """ diff --git a/example/image-classification/common/data.py b/example/image-classification/common/data.py index fe27ec26b939..eb694a45dc27 100755 --- a/example/image-classification/common/data.py +++ b/example/image-classification/common/data.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx import random from mxnet.io import DataBatch, DataIter diff --git a/example/image-classification/common/find_mxnet.py b/example/image-classification/common/find_mxnet.py index 24dcaf809a38..2ce07130a361 100644 --- a/example/image-classification/common/find_mxnet.py +++ b/example/image-classification/common/find_mxnet.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import os, sys try: import mxnet as mx diff --git a/example/image-classification/common/fit.py b/example/image-classification/common/fit.py index 69baed1ef4f6..73235fc2e4ef 100755 --- a/example/image-classification/common/fit.py +++ b/example/image-classification/common/fit.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx import logging import os diff --git a/example/image-classification/common/modelzoo.py b/example/image-classification/common/modelzoo.py index c2944cdc2827..1fe14ca4fcd2 100644 --- a/example/image-classification/common/modelzoo.py +++ b/example/image-classification/common/modelzoo.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import os from util import download_file diff --git a/example/image-classification/common/util.py b/example/image-classification/common/util.py index a25e2181be92..5f70411ab084 100644 --- a/example/image-classification/common/util.py +++ b/example/image-classification/common/util.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import subprocess import os import errno diff --git a/example/image-classification/data/caltech256.sh b/example/image-classification/data/caltech256.sh index 3befdac0c73a..3fc329a9b835 100755 --- a/example/image-classification/data/caltech256.sh +++ b/example/image-classification/data/caltech256.sh @@ -1,5 +1,23 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + # This file download the caltech 256 dataset # (http://www.vision.caltech.edu/Image_Datasets/Caltech256/), and split it into # the train and val rec files. diff --git a/example/image-classification/data/imagenet1k-val.sh b/example/image-classification/data/imagenet1k-val.sh index 51f8130103fd..13cb551140f8 100755 --- a/example/image-classification/data/imagenet1k-val.sh +++ b/example/image-classification/data/imagenet1k-val.sh @@ -1,5 +1,23 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + # This file download the imagnet-1k validation dataset and convert it into a rec # file. One need to provide the URL for the ILSVRC2012_img_val.tar, which can be # find at http://www.image-net.org/download-images diff --git a/example/image-classification/fine-tune.py b/example/image-classification/fine-tune.py index 5a2a04d2c73b..a5fb2434d958 100644 --- a/example/image-classification/fine-tune.py +++ b/example/image-classification/fine-tune.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import os import argparse import logging diff --git a/example/image-classification/predict-cpp/image-classification-predict.cc b/example/image-classification/predict-cpp/image-classification-predict.cc index a8652c4f0815..fb74ed9d7170 100644 --- a/example/image-classification/predict-cpp/image-classification-predict.cc +++ b/example/image-classification/predict-cpp/image-classification-predict.cc @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! * Copyright (c) 2015 by Xiao Liu, pertusa, caprice-j * \file image_classification-predict.cpp @@ -196,7 +215,7 @@ int main(int argc, char* argv[]) { const mx_uint input_shape_indptr[2] = { 0, 4 }; const mx_uint input_shape_data[4] = { 1, static_cast(channels), - static_cast(height), + static_cast(height), static_cast(width)}; PredictorHandle pred_hnd = 0; diff --git a/example/image-classification/score.py b/example/image-classification/score.py index d26ddddf9b83..f40e649f1f42 100644 --- a/example/image-classification/score.py +++ b/example/image-classification/score.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import argparse from common import modelzoo, find_mxnet import mxnet as mx diff --git a/example/image-classification/symbols/alexnet.py b/example/image-classification/symbols/alexnet.py index e2b512b195c8..f945b9f87cd9 100755 --- a/example/image-classification/symbols/alexnet.py +++ b/example/image-classification/symbols/alexnet.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """ Reference: diff --git a/example/image-classification/symbols/googlenet.py b/example/image-classification/symbols/googlenet.py index cc8c7adc6540..05f33da5d884 100644 --- a/example/image-classification/symbols/googlenet.py +++ b/example/image-classification/symbols/googlenet.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """References: Szegedy, Christian, Wei Liu, Yangqing Jia, Pierre Sermanet, Scott Reed, Dragomir diff --git a/example/image-classification/symbols/inception-bn.py b/example/image-classification/symbols/inception-bn.py index 7dae9ad053e0..84934a5f72aa 100644 --- a/example/image-classification/symbols/inception-bn.py +++ b/example/image-classification/symbols/inception-bn.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """ Inception + BN, suitable for images with around 224 x 224 diff --git a/example/image-classification/symbols/inception-resnet-v2.py b/example/image-classification/symbols/inception-resnet-v2.py index b2b0c6023ac1..5f313351eab2 100644 --- a/example/image-classification/symbols/inception-resnet-v2.py +++ b/example/image-classification/symbols/inception-resnet-v2.py @@ -1,9 +1,26 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """ -Contains the definition of the Inception Resnet V2 architecture. -As described in http://arxiv.org/abs/1602.07261. -Inception-v4, Inception-ResNet and the Impact of Residual Connections -on Learning -Christian Szegedy, Sergey Ioffe, Vincent Vanhoucke, Alex Alemi +Contains the definition of the Inception Resnet V2 architecture. +As described in http://arxiv.org/abs/1602.07261. +Inception-v4, Inception-ResNet and the Impact of Residual Connections +on Learning +Christian Szegedy, Sergey Ioffe, Vincent Vanhoucke, Alex Alemi """ import mxnet as mx diff --git a/example/image-classification/symbols/inception-v3.py b/example/image-classification/symbols/inception-v3.py index 35562d663745..5108579ffd3a 100644 --- a/example/image-classification/symbols/inception-v3.py +++ b/example/image-classification/symbols/inception-v3.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """ Inception V3, suitable for images with around 299 x 299 diff --git a/example/image-classification/symbols/inception-v4.py b/example/image-classification/symbols/inception-v4.py index eead5f7c7ea0..2b4fe6fbb0c7 100644 --- a/example/image-classification/symbols/inception-v4.py +++ b/example/image-classification/symbols/inception-v4.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # -*- coding:utf-8 -*- __author__ = 'zhangshuai' modified_date = '16/7/5' diff --git a/example/image-classification/symbols/lenet.py b/example/image-classification/symbols/lenet.py index 6df02991e4ad..f2cc106f60ac 100644 --- a/example/image-classification/symbols/lenet.py +++ b/example/image-classification/symbols/lenet.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """ LeCun, Yann, Leon Bottou, Yoshua Bengio, and Patrick Haffner. Gradient-based learning applied to document recognition. diff --git a/example/image-classification/symbols/mlp.py b/example/image-classification/symbols/mlp.py index cc569bc10917..4b190b29db9e 100644 --- a/example/image-classification/symbols/mlp.py +++ b/example/image-classification/symbols/mlp.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """ a simple multilayer perceptron """ diff --git a/example/image-classification/symbols/mobilenet.py b/example/image-classification/symbols/mobilenet.py index 8ad584a50768..42b963626164 100644 --- a/example/image-classification/symbols/mobilenet.py +++ b/example/image-classification/symbols/mobilenet.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx def Conv(data, num_filter=1, kernel=(1, 1), stride=(1, 1), pad=(0, 0), num_group=1, name=None, suffix=''): diff --git a/example/image-classification/symbols/resnet-v1.py b/example/image-classification/symbols/resnet-v1.py index 0d7bee1d16cd..e5752f775447 100755 --- a/example/image-classification/symbols/resnet-v1.py +++ b/example/image-classification/symbols/resnet-v1.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + ''' Adapted from https://github.com/tornadomeet/ResNet/blob/master/symbol_resnet.py (Original author Wei Wu) by Antti-Pekka Hynninen diff --git a/example/image-classification/symbols/resnet.py b/example/image-classification/symbols/resnet.py index 41cbc82bcb45..be498602f0b7 100644 --- a/example/image-classification/symbols/resnet.py +++ b/example/image-classification/symbols/resnet.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + ''' Adapted from https://github.com/tornadomeet/ResNet/blob/master/symbol_resnet.py Original author Wei Wu diff --git a/example/image-classification/symbols/resnext.py b/example/image-classification/symbols/resnext.py index bd5b65621722..59749430c76c 100644 --- a/example/image-classification/symbols/resnext.py +++ b/example/image-classification/symbols/resnext.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + ''' Adapted from https://github.com/tornadomeet/ResNet/blob/master/symbol_resnet.py Original author Wei Wu @@ -29,19 +46,19 @@ def residual_unit(data, num_filter, stride, dim_match, name, bottle_neck=True, n """ if bottle_neck: # the same as https://github.com/facebook/fb.resnet.torch#notes, a bit difference with origin paper - + conv1 = mx.sym.Convolution(data=data, num_filter=int(num_filter*0.5), kernel=(1,1), stride=(1,1), pad=(0,0), no_bias=True, workspace=workspace, name=name + '_conv1') bn1 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn1') act1 = mx.sym.Activation(data=bn1, act_type='relu', name=name + '_relu1') - + conv2 = mx.sym.Convolution(data=act1, num_filter=int(num_filter*0.5), num_group=num_group, kernel=(3,3), stride=stride, pad=(1,1), no_bias=True, workspace=workspace, name=name + '_conv2') bn2 = mx.sym.BatchNorm(data=conv2, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn2') act2 = mx.sym.Activation(data=bn2, act_type='relu', name=name + '_relu2') - + conv3 = mx.sym.Convolution(data=act2, num_filter=num_filter, kernel=(1,1), stride=(1,1), pad=(0,0), no_bias=True, workspace=workspace, name=name + '_conv3') bn3 = mx.sym.BatchNorm(data=conv3, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn3') @@ -58,13 +75,13 @@ def residual_unit(data, num_filter, stride, dim_match, name, bottle_neck=True, n eltwise = bn3 + shortcut return mx.sym.Activation(data=eltwise, act_type='relu', name=name + '_relu') else: - + conv1 = mx.sym.Convolution(data=data, num_filter=num_filter, kernel=(3,3), stride=stride, pad=(1,1), no_bias=True, workspace=workspace, name=name + '_conv1') bn1 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_bn1') act1 = mx.sym.Activation(data=bn1, act_type='relu', name=name + '_relu1') - + conv2 = mx.sym.Convolution(data=act1, num_filter=num_filter, kernel=(3,3), stride=(1,1), pad=(1,1), no_bias=True, workspace=workspace, name=name + '_conv2') bn2 = mx.sym.BatchNorm(data=conv2, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_bn2') @@ -124,12 +141,12 @@ def resnext(units, num_stages, filter_list, num_classes, num_group, image_shape, for i in range(num_stages): body = residual_unit(body, filter_list[i+1], (1 if i==0 else 2, 1 if i==0 else 2), False, - name='stage%d_unit%d' % (i + 1, 1), bottle_neck=bottle_neck, num_group=num_group, + name='stage%d_unit%d' % (i + 1, 1), bottle_neck=bottle_neck, num_group=num_group, bn_mom=bn_mom, workspace=workspace, memonger=memonger) for j in range(units[i]-1): body = residual_unit(body, filter_list[i+1], (1,1), True, name='stage%d_unit%d' % (i + 1, j + 2), bottle_neck=bottle_neck, num_group=num_group, bn_mom=bn_mom, workspace=workspace, memonger=memonger) - + pool1 = mx.sym.Pooling(data=body, global_pool=True, kernel=(7, 7), pool_type='avg', name='pool1') flat = mx.sym.Flatten(data=pool1) fc1 = mx.sym.FullyConnected(data=flat, num_hidden=num_classes, name='fc1') @@ -186,7 +203,7 @@ def get_symbol(num_classes, num_layers, image_shape, num_group=32, conv_workspac num_stages = num_stages, filter_list = filter_list, num_classes = num_classes, - num_group = num_group, + num_group = num_group, image_shape = image_shape, bottle_neck = bottle_neck, workspace = conv_workspace, diff --git a/example/image-classification/symbols/vgg.py b/example/image-classification/symbols/vgg.py index 8dae74f1c94f..ca1013621863 100644 --- a/example/image-classification/symbols/vgg.py +++ b/example/image-classification/symbols/vgg.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """References: Simonyan, Karen, and Andrew Zisserman. "Very deep convolutional networks for diff --git a/example/image-classification/test_score.py b/example/image-classification/test_score.py index 19a1d3072664..0789c9270fff 100644 --- a/example/image-classification/test_score.py +++ b/example/image-classification/test_score.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """ test pretrained models """ diff --git a/example/image-classification/train_cifar10.py b/example/image-classification/train_cifar10.py index 0186233d6ea2..7eb56ebce36d 100644 --- a/example/image-classification/train_cifar10.py +++ b/example/image-classification/train_cifar10.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import os import argparse import logging diff --git a/example/image-classification/train_imagenet.py b/example/image-classification/train_imagenet.py index 760ea6b22391..5760a9af3782 100644 --- a/example/image-classification/train_imagenet.py +++ b/example/image-classification/train_imagenet.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import os import argparse import logging diff --git a/example/image-classification/train_mnist.py b/example/image-classification/train_mnist.py index 31ecbfb463c4..2bc4289318d9 100644 --- a/example/image-classification/train_mnist.py +++ b/example/image-classification/train_mnist.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """ Train mnist, see more explanation at http://mxnet.io/tutorials/python/mnist.html """ @@ -53,9 +70,9 @@ def get_mnist_iter(args, kv): help='the number of classes') parser.add_argument('--num-examples', type=int, default=60000, help='the number of training examples') - + parser.add_argument('--add_stn', action="store_true", default=False, help='Add Spatial Transformer Network Layer (lenet only)') - + fit.add_fit_args(parser) parser.set_defaults( # network diff --git a/example/kaggle-ndsb1/gen_img_list.py b/example/kaggle-ndsb1/gen_img_list.py index 2da5d7097d96..adfc4fe09d68 100644 --- a/example/kaggle-ndsb1/gen_img_list.py +++ b/example/kaggle-ndsb1/gen_img_list.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import print_function import csv import os @@ -26,7 +43,7 @@ fo_name=os.path.join(args.out_folder+args.out_file) fo = csv.writer(open(fo_name, "w"), delimiter='\t', lineterminator='\n') - + if args.train: tr_fo_name=os.path.join(args.out_folder+"tr.lst") va_fo_name=os.path.join(args.out_folder+"va.lst") @@ -58,7 +75,7 @@ #write for item in img_lst: fo.writerow(item) - + ## If training, split into train and validation lists (tr.lst and va.lst) diff --git a/example/kaggle-ndsb1/predict_dsb.py b/example/kaggle-ndsb1/predict_dsb.py index 483243a430a7..2be2eccb2c88 100644 --- a/example/kaggle-ndsb1/predict_dsb.py +++ b/example/kaggle-ndsb1/predict_dsb.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import print_function import find_mxnet import submission_dsb diff --git a/example/kaggle-ndsb1/submission_dsb.py b/example/kaggle-ndsb1/submission_dsb.py index a2644f8d2a74..2695c1abb7ce 100644 --- a/example/kaggle-ndsb1/submission_dsb.py +++ b/example/kaggle-ndsb1/submission_dsb.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import print_function import pandas as pd import os @@ -14,9 +31,9 @@ def gen_sub(predictions,test_lst_path="test.lst",submission_path="submission.csv ## check sampleSubmission.csv from kaggle website to view submission format header = "acantharia_protist_big_center,acantharia_protist_halo,acantharia_protist,amphipods,appendicularian_fritillaridae,appendicularian_s_shape,appendicularian_slight_curve,appendicularian_straight,artifacts_edge,artifacts,chaetognath_non_sagitta,chaetognath_other,chaetognath_sagitta,chordate_type1,copepod_calanoid_eggs,copepod_calanoid_eucalanus,copepod_calanoid_flatheads,copepod_calanoid_frillyAntennae,copepod_calanoid_large_side_antennatucked,copepod_calanoid_large,copepod_calanoid_octomoms,copepod_calanoid_small_longantennae,copepod_calanoid,copepod_cyclopoid_copilia,copepod_cyclopoid_oithona_eggs,copepod_cyclopoid_oithona,copepod_other,crustacean_other,ctenophore_cestid,ctenophore_cydippid_no_tentacles,ctenophore_cydippid_tentacles,ctenophore_lobate,decapods,detritus_blob,detritus_filamentous,detritus_other,diatom_chain_string,diatom_chain_tube,echinoderm_larva_pluteus_brittlestar,echinoderm_larva_pluteus_early,echinoderm_larva_pluteus_typeC,echinoderm_larva_pluteus_urchin,echinoderm_larva_seastar_bipinnaria,echinoderm_larva_seastar_brachiolaria,echinoderm_seacucumber_auricularia_larva,echinopluteus,ephyra,euphausiids_young,euphausiids,fecal_pellet,fish_larvae_deep_body,fish_larvae_leptocephali,fish_larvae_medium_body,fish_larvae_myctophids,fish_larvae_thin_body,fish_larvae_very_thin_body,heteropod,hydromedusae_aglaura,hydromedusae_bell_and_tentacles,hydromedusae_h15,hydromedusae_haliscera_small_sideview,hydromedusae_haliscera,hydromedusae_liriope,hydromedusae_narco_dark,hydromedusae_narco_young,hydromedusae_narcomedusae,hydromedusae_other,hydromedusae_partial_dark,hydromedusae_shapeA_sideview_small,hydromedusae_shapeA,hydromedusae_shapeB,hydromedusae_sideview_big,hydromedusae_solmaris,hydromedusae_solmundella,hydromedusae_typeD_bell_and_tentacles,hydromedusae_typeD,hydromedusae_typeE,hydromedusae_typeF,invertebrate_larvae_other_A,invertebrate_larvae_other_B,jellies_tentacles,polychaete,protist_dark_center,protist_fuzzy_olive,protist_noctiluca,protist_other,protist_star,pteropod_butterfly,pteropod_theco_dev_seq,pteropod_triangle,radiolarian_chain,radiolarian_colony,shrimp_caridean,shrimp_sergestidae,shrimp_zoea,shrimp-like_other,siphonophore_calycophoran_abylidae,siphonophore_calycophoran_rocketship_adult,siphonophore_calycophoran_rocketship_young,siphonophore_calycophoran_sphaeronectes_stem,siphonophore_calycophoran_sphaeronectes_young,siphonophore_calycophoran_sphaeronectes,siphonophore_other_parts,siphonophore_partial,siphonophore_physonect_young,siphonophore_physonect,stomatopod,tornaria_acorn_worm_larvae,trichodesmium_bowtie,trichodesmium_multiple,trichodesmium_puff,trichodesmium_tuft,trochophore_larvae,tunicate_doliolid_nurse,tunicate_doliolid,tunicate_partial,tunicate_salp_chains,tunicate_salp,unknown_blobs_and_smudges,unknown_sticks,unknown_unclassified".split(',') - + # read first line to know the number of columns and column to use - img_lst = pd.read_csv(test_lst_path,sep="/",header=None, nrows=1) + img_lst = pd.read_csv(test_lst_path,sep="/",header=None, nrows=1) columns = img_lst.columns.tolist() # get the columns cols_to_use = columns[len(columns)-1] # drop the last one cols_to_use= map(int, str(cols_to_use)) ## convert scalar to list @@ -28,15 +45,15 @@ def gen_sub(predictions,test_lst_path="test.lst",submission_path="submission.csv df = pd.DataFrame(predictions,columns = header, index=img_lst) df.index.name = 'image' - + print("Saving csv to %s" % submission_path) df.to_csv(submission_path) - + print("Compress with gzip") os.system("gzip -f %s" % submission_path) - + print(" stored in %s.gz" % submission_path) - + diff --git a/example/kaggle-ndsb1/symbol_dsb.py b/example/kaggle-ndsb1/symbol_dsb.py index 43898a106c00..0a4db8f19ad5 100644 --- a/example/kaggle-ndsb1/symbol_dsb.py +++ b/example/kaggle-ndsb1/symbol_dsb.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import find_mxnet import mxnet as mx diff --git a/example/kaggle-ndsb1/train_dsb.py b/example/kaggle-ndsb1/train_dsb.py index 19beb022c8fa..5cec0f6d4fd4 100644 --- a/example/kaggle-ndsb1/train_dsb.py +++ b/example/kaggle-ndsb1/train_dsb.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import find_mxnet import mxnet as mx import logging @@ -23,7 +40,7 @@ help='clip min/max gradient to prevent extreme value') parser.add_argument('--num-epochs', type=int, default=100, help='the number of training epochs') -parser.add_argument('--load-epoch', type=int, +parser.add_argument('--load-epoch', type=int, help="load the model on an epoch using the model-prefix") parser.add_argument('--batch-size', type=int, default=64, help='the batch size') @@ -35,7 +52,7 @@ help='the number of training examples') parser.add_argument('--num-classes', type=int, default=121, help='the number of classes') -parser.add_argument('--log-file', type=str, +parser.add_argument('--log-file', type=str, help='the name of log file') parser.add_argument('--log-dir', type=str, default="/tmp/", help='directory of the log file') @@ -63,7 +80,7 @@ def get_iterator(args, kv): rand_crop = True, rand_mirror = True, ) - + # validate data iterator val = mx.io.ImageRecordIter( path_imgrec = args.data_dir + "va.rec", diff --git a/example/kaggle-ndsb1/training_curves.py b/example/kaggle-ndsb1/training_curves.py index e4ffd94081da..67f25f0042f6 100644 --- a/example/kaggle-ndsb1/training_curves.py +++ b/example/kaggle-ndsb1/training_curves.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + ## based on https://github.com/dmlc/mxnet/issues/1302 ## Parses the model fit log file and generates a train/val vs epoch plot import matplotlib.pyplot as plt diff --git a/example/kaggle-ndsb2/Preprocessing.py b/example/kaggle-ndsb2/Preprocessing.py index 64d15e036d6d..29b4ba009a9a 100644 --- a/example/kaggle-ndsb2/Preprocessing.py +++ b/example/kaggle-ndsb2/Preprocessing.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """Preprocessing script. This script walks over the directories and dump the frames into a csv file diff --git a/example/kaggle-ndsb2/Train.py b/example/kaggle-ndsb2/Train.py index 22aa3ed721e1..51e308a2e21c 100644 --- a/example/kaggle-ndsb2/Train.py +++ b/example/kaggle-ndsb2/Train.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """Training script, this is converted from a ipython notebook """ diff --git a/example/memcost/inception_memcost.py b/example/memcost/inception_memcost.py index 45e85901714b..c539e73b3c24 100644 --- a/example/memcost/inception_memcost.py +++ b/example/memcost/inception_memcost.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file import sys sys.path.append('../../python/') diff --git a/example/model-parallel-lstm/get_ptb_data.sh b/example/model-parallel-lstm/get_ptb_data.sh index 1ec009aa2f99..d2641cb32b81 100755 --- a/example/model-parallel-lstm/get_ptb_data.sh +++ b/example/model-parallel-lstm/get_ptb_data.sh @@ -1,5 +1,23 @@ #!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + RNN_DIR=$(cd `dirname $0`; pwd) DATA_DIR="${RNN_DIR}/data/" diff --git a/example/model-parallel-lstm/lstm.py b/example/model-parallel-lstm/lstm.py index 795eb6ef3bc1..c24017ff0d9c 100644 --- a/example/model-parallel-lstm/lstm.py +++ b/example/model-parallel-lstm/lstm.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint:skip-file import sys sys.path.insert(0, "../../python") @@ -152,7 +169,7 @@ def setup_rnn_model(default_ctx, models = {} buckets.reverse() for bucket_key in buckets: - # bind max_len first + # bind max_len first rnn_sym = lstm_unroll(num_lstm_layer=num_lstm_layer, num_hidden=num_hidden, seq_len=seq_len, @@ -190,7 +207,7 @@ def setup_rnn_model(default_ctx, args_grad[name] = mx.nd.zeros(shape, ctx) if not name.startswith("t"): print("%s group=%s, ctx=%s" % (name, group, str(ctx))) - + #bind with shared executor rnn_exec = None if max_len == bucket_key: @@ -220,7 +237,7 @@ def setup_rnn_model(default_ctx, h=arg_dict["l%d_init_h" % i]) for i in range(num_lstm_layer)] seq_data = [rnn_exec.arg_dict["t%d_data" % i] for i in range(seq_len)] - # we don't need to store the last state + # we don't need to store the last state last_states = None if concat_decode: @@ -235,7 +252,7 @@ def setup_rnn_model(default_ctx, seq_data=seq_data, seq_labels=seq_labels, seq_outputs=seq_outputs, param_blocks=param_blocks) models[bucket_key] = model - buckets.reverse() + buckets.reverse() return models @@ -256,7 +273,7 @@ def set_rnn_inputs(m, X, begin): def set_rnn_inputs_from_batch(m, batch, batch_seq_length, batch_size): X = batch.data for seqidx in range(batch_seq_length): - idx = seqidx + idx = seqidx next_idx = (seqidx + 1) % batch_seq_length x = X[idx, :] y = X[next_idx, :] @@ -295,20 +312,20 @@ def train_lstm(model, X_train_batch, X_val_batch, nbatch = 0 train_nll = 0 tic = time.time() - for data_batch in X_train_batch: + for data_batch in X_train_batch: batch_seq_length = data_batch.bucket_key m = model[batch_seq_length] # reset init state for state in m.init_states: state.c[:] = 0.0 state.h[:] = 0.0 - + head_grad = [] if use_loss: ctx = m.seq_outputs[0].context head_grad = [mx.nd.ones((1,), ctx) for x in m.seq_outputs] - set_rnn_inputs_from_batch(m, data_batch, batch_seq_length, batch_size) + set_rnn_inputs_from_batch(m, data_batch, batch_seq_length, batch_size) m.rnn_exec.forward(is_train=True) # probability of each label class, used to evaluate nll @@ -390,7 +407,7 @@ def train_lstm(model, X_train_batch, X_val_batch, else: val_nll += sum([x.asscalar() for x in seq_loss]) / batch_size nbatch += batch_size - + perp = np.exp(val_nll / nbatch) print("Iter [%d] Val: NLL=%.3f, Perp=%.3f" % ( iteration, val_nll / nbatch, np.exp(val_nll / nbatch))) @@ -401,7 +418,7 @@ def train_lstm(model, X_train_batch, X_val_batch, X_val_batch.reset() X_train_batch.reset() -# is this function being used? +# is this function being used? def setup_rnn_sample_model(ctx, params, num_lstm_layer, diff --git a/example/model-parallel-lstm/lstm_ptb.py b/example/model-parallel-lstm/lstm_ptb.py index 20ce89653fd8..0141338329e4 100644 --- a/example/model-parallel-lstm/lstm_ptb.py +++ b/example/model-parallel-lstm/lstm_ptb.py @@ -1,10 +1,27 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint:skip-file import lstm import sys sys.path.insert(0, "../../python") import mxnet as mx import numpy as np -# reuse the bucket_io library +# reuse the bucket_io library sys.path.insert(0, "../rnn") from bucket_io import BucketSentenceIter, default_build_vocab diff --git a/example/module/lstm_bucketing.py b/example/module/lstm_bucketing.py index dc00ef55aa7d..ecc7e7be0bca 100644 --- a/example/module/lstm_bucketing.py +++ b/example/module/lstm_bucketing.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: disable=C0111,too-many-arguments,too-many-instance-attributes,too-many-locals,redefined-outer-name,fixme # pylint: disable=superfluous-parens, no-member, invalid-name import sys diff --git a/example/module/mnist_mlp.py b/example/module/mnist_mlp.py index 6d9d6bff4cb5..d2737dc12af7 100644 --- a/example/module/mnist_mlp.py +++ b/example/module/mnist_mlp.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file import os, sys sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) diff --git a/example/module/python_loss.py b/example/module/python_loss.py index d139789fdf33..9680ac6cb091 100644 --- a/example/module/python_loss.py +++ b/example/module/python_loss.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file import numpy as np import mxnet as mx diff --git a/example/module/sequential_module.py b/example/module/sequential_module.py index 4659457c5113..48e1046a2067 100644 --- a/example/module/sequential_module.py +++ b/example/module/sequential_module.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file import os, sys sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) diff --git a/example/module/train_cifar10.py b/example/module/train_cifar10.py index ec3be57edb66..a96e8d92846b 100644 --- a/example/module/train_cifar10.py +++ b/example/module/train_cifar10.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """Train CIFAR-10 classifier in MXNet. Demonstrates using the Module class. """ @@ -132,7 +149,7 @@ def do_train(args, callback_args=None): (train, val) = get_iterator(args, kv) if args.gpus is None or args.gpus == '': - devs = mx.cpu() + devs = mx.cpu() elif type(args.gpus) == str: devs = [mx.gpu(int(i)) for i in args.gpus.split(',')] else: diff --git a/example/multi-task/data.py b/example/multi-task/data.py index d39821f52145..0ca8e1fd6653 100644 --- a/example/multi-task/data.py +++ b/example/multi-task/data.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file """ data iterator for mnist """ import sys diff --git a/example/multi-task/example_multi_task.py b/example/multi-task/example_multi_task.py index 8ee396f0daf4..853d435bbf0b 100644 --- a/example/multi-task/example_multi_task.py +++ b/example/multi-task/example_multi_task.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file import sys sys.path.insert(0, "../../python/") diff --git a/example/nce-loss/get_text8.sh b/example/nce-loss/get_text8.sh index ccd4a08e69bb..e1390eb6fe90 100755 --- a/example/nce-loss/get_text8.sh +++ b/example/nce-loss/get_text8.sh @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + mkdir -p ./data/ cd ./data/ wget http://mattmahoney.net/dc/text8.zip diff --git a/example/nce-loss/lstm_word.py b/example/nce-loss/lstm_word.py index 3b39207b58a3..23729917d939 100644 --- a/example/nce-loss/lstm_word.py +++ b/example/nce-loss/lstm_word.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint:skip-file from __future__ import print_function import logging @@ -55,7 +72,7 @@ def get_net(vocab_size, seq_len, num_label, num_lstm_layer, num_hidden): state = LSTMState(c=mx.sym.Variable("l%d_init_c" % i), h=mx.sym.Variable("l%d_init_h" % i)) last_states.append(state) - + data = mx.sym.Variable('data') label = mx.sym.Variable('label') label_weight = mx.sym.Variable('label_weight') @@ -76,7 +93,7 @@ def get_net(vocab_size, seq_len, num_label, num_lstm_layer, num_hidden): probs = [] for seqidx in range(seq_len): hidden = datavec[seqidx] - + for i in range(num_lstm_layer): next_state = lstm(num_hidden, indata = hidden, prev_state = last_states[i], @@ -84,7 +101,7 @@ def get_net(vocab_size, seq_len, num_label, num_lstm_layer, num_hidden): seqidx = seqidx, layeridx = i) hidden = next_state.h last_states[i] = next_state - + probs.append(nce_loss(data = hidden, label = labelvec[seqidx], label_weight = labelweightvec[seqidx], @@ -149,7 +166,7 @@ def __init__(self, name, batch_size, seq_len, num_label, init_states): self.provide_data = [('data', (batch_size, seq_len))] + init_states self.provide_label = [('label', (self.batch_size, seq_len, num_label)), ('label_weight', (self.batch_size, seq_len, num_label))] - + def sample_ne(self): return self.negative[random.randint(0, len(self.negative) - 1)] @@ -203,7 +220,7 @@ def reset(self): data_train = DataIter("./data/text8", batch_size, seq_len, num_label, init_states) - + network = get_net(data_train.vocab_size, seq_len, num_label, num_lstm_layer, num_hidden) options, args = parser.parse_args() devs = mx.cpu() @@ -216,7 +233,7 @@ def reset(self): momentum = 0.9, wd = 0.0000, initializer=mx.init.Xavier(factor_type="in", magnitude=2.34)) - + metric = NceLSTMAuc() model.fit(X = data_train, eval_metric = metric, diff --git a/example/nce-loss/nce.py b/example/nce-loss/nce.py index abe4135ef367..7f57dfdb751d 100644 --- a/example/nce-loss/nce.py +++ b/example/nce-loss/nce.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint:skip-file import sys sys.path.insert(0, "../../python") diff --git a/example/nce-loss/toy_nce.py b/example/nce-loss/toy_nce.py index 9770be093fbe..39da7c779031 100644 --- a/example/nce-loss/toy_nce.py +++ b/example/nce-loss/toy_nce.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint:skip-file import logging import sys, random, time @@ -19,7 +36,7 @@ def get_net(vocab_size, num_label): embed_weight = embed_weight, vocab_size = vocab_size, num_hidden = 100, - num_label = num_label) + num_label = num_label) return ret class SimpleBatch(object): @@ -91,10 +108,10 @@ def reset(self): vocab_size = 10000 feature_size = 100 num_label = 6 - + data_train = DataIter(100000, batch_size, vocab_size, num_label, feature_size) data_test = DataIter(1000, batch_size, vocab_size, num_label, feature_size) - + network = get_net(vocab_size, num_label) devs = [mx.cpu()] model = mx.model.FeedForward(ctx = devs, @@ -104,7 +121,7 @@ def reset(self): momentum = 0.9, wd = 0.00001, initializer=mx.init.Xavier(factor_type="in", magnitude=2.34)) - + metric = NceAccuracy() model.fit(X = data_train, eval_data = data_test, eval_metric = metric, diff --git a/example/nce-loss/toy_softmax.py b/example/nce-loss/toy_softmax.py index 66f9cdc0e113..ff6ff4327c8e 100644 --- a/example/nce-loss/toy_softmax.py +++ b/example/nce-loss/toy_softmax.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint:skip-file import logging import sys, random, time @@ -83,7 +100,7 @@ def reset(self): data_train = DataIter(100000, batch_size, vocab_size, num_label, feature_size) data_test = DataIter(1000, batch_size, vocab_size, num_label, feature_size) - + network = get_net(vocab_size) devs = mx.cpu() model = mx.model.FeedForward(ctx = devs, @@ -93,7 +110,7 @@ def reset(self): momentum = 0.9, wd = 0.0000, initializer=mx.init.Xavier(factor_type="in", magnitude=2.34)) - + model.fit(X = data_train, eval_data = data_test, batch_end_callback = mx.callback.Speedometer(batch_size, 50),) diff --git a/example/nce-loss/wordvec.py b/example/nce-loss/wordvec.py index 24b78305210d..887d586ff342 100644 --- a/example/nce-loss/wordvec.py +++ b/example/nce-loss/wordvec.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint:skip-file from __future__ import print_function import logging @@ -30,7 +47,7 @@ def get_net(vocab_size, num_input, num_label): embed_weight = embed_weight, vocab_size = vocab_size, num_hidden = 100, - num_label = num_label) + num_label = num_label) def load_data(name): buf = open(name).read() @@ -82,7 +99,7 @@ def __init__(self, name, batch_size, num_label): self.provide_data = [('data', (batch_size, num_label - 1))] self.provide_label = [('label', (self.batch_size, num_label)), ('label_weight', (self.batch_size, num_label))] - + def sample_ne(self): return self.negative[random.randint(0, len(self.negative) - 1)] @@ -126,11 +143,11 @@ def reset(self): help = "use gpu") batch_size = 256 num_label = 5 - + data_train = DataIter("./data/text8", batch_size, num_label) - + network = get_net(data_train.vocab_size, num_label - 1, num_label) - + options, args = parser.parse_args() devs = mx.cpu() if options.gpu == True: @@ -143,7 +160,7 @@ def reset(self): wd = 0.0000, initializer=mx.init.Xavier(factor_type="in", magnitude=2.34)) - + metric = NceAuc() model.fit(X = data_train, eval_metric = metric, diff --git a/example/nce-loss/wordvec_subwords.py b/example/nce-loss/wordvec_subwords.py index 049dc9d6ffcb..c8d46a1aeb3a 100644 --- a/example/nce-loss/wordvec_subwords.py +++ b/example/nce-loss/wordvec_subwords.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint:skip-file import logging import sys, random, time, math diff --git a/example/neural-style/download.sh b/example/neural-style/download.sh index a58640aa8142..d5303a72c5a6 100755 --- a/example/neural-style/download.sh +++ b/example/neural-style/download.sh @@ -1,5 +1,23 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + mkdir -p model cd model wget https://github.com/dmlc/web-data/raw/master/mxnet/neural-style/model/vgg19.params diff --git a/example/neural-style/end_to_end/basic.py b/example/neural-style/end_to_end/basic.py index ed9d3f601554..1763e884b984 100644 --- a/example/neural-style/end_to_end/basic.py +++ b/example/neural-style/end_to_end/basic.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import sys sys.path.insert(0, "../../mxnet/python/") diff --git a/example/neural-style/end_to_end/boost_inference.py b/example/neural-style/end_to_end/boost_inference.py index 72427bedc7a6..0ec8308f3054 100644 --- a/example/neural-style/end_to_end/boost_inference.py +++ b/example/neural-style/end_to_end/boost_inference.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import sys sys.path.insert(0, "../mxnet/python") diff --git a/example/neural-style/end_to_end/boost_train.py b/example/neural-style/end_to_end/boost_train.py index 9100cc1875a2..fa525e7e52c0 100644 --- a/example/neural-style/end_to_end/boost_train.py +++ b/example/neural-style/end_to_end/boost_train.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import sys sys.path.insert(0, "../../mxnet/python") diff --git a/example/neural-style/end_to_end/data_processing.py b/example/neural-style/end_to_end/data_processing.py index 80f1bcd5cfcd..1c1ab493edec 100644 --- a/example/neural-style/end_to_end/data_processing.py +++ b/example/neural-style/end_to_end/data_processing.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import numpy as np from skimage import io, transform from skimage.restoration import denoise_tv_chambolle diff --git a/example/neural-style/end_to_end/gen_v3.py b/example/neural-style/end_to_end/gen_v3.py index dbc83b1ea004..7962e68da2fd 100644 --- a/example/neural-style/end_to_end/gen_v3.py +++ b/example/neural-style/end_to_end/gen_v3.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 diff --git a/example/neural-style/end_to_end/gen_v4.py b/example/neural-style/end_to_end/gen_v4.py index 379e904b9690..fb4e6d1e1647 100644 --- a/example/neural-style/end_to_end/gen_v4.py +++ b/example/neural-style/end_to_end/gen_v4.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 diff --git a/example/neural-style/end_to_end/model_vgg19.py b/example/neural-style/end_to_end/model_vgg19.py index 6e287b55b2fa..0d369ae08f58 100644 --- a/example/neural-style/end_to_end/model_vgg19.py +++ b/example/neural-style/end_to_end/model_vgg19.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx import os, sys from collections import namedtuple diff --git a/example/neural-style/find_mxnet.py b/example/neural-style/find_mxnet.py index 2e3970ddd85d..b919a2a78715 100644 --- a/example/neural-style/find_mxnet.py +++ b/example/neural-style/find_mxnet.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + try: import mxnet as mx except ImportError: diff --git a/example/neural-style/model_vgg19.py b/example/neural-style/model_vgg19.py index 3344a274e827..aa83bc362e5c 100644 --- a/example/neural-style/model_vgg19.py +++ b/example/neural-style/model_vgg19.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import find_mxnet import mxnet as mx import os, sys diff --git a/example/neural-style/nstyle.py b/example/neural-style/nstyle.py index 3eec33d4cbf1..e3bc8bcc5684 100644 --- a/example/neural-style/nstyle.py +++ b/example/neural-style/nstyle.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import find_mxnet import mxnet as mx import numpy as np @@ -196,7 +213,7 @@ def train_nstyle(args, callback=None): img = mx.nd.zeros(content_np.shape, ctx=dev) img[:] = mx.rnd.uniform(-0.1, 0.1, img.shape) - lr = mx.lr_scheduler.FactorScheduler(step=args.lr_sched_delay, + lr = mx.lr_scheduler.FactorScheduler(step=args.lr_sched_delay, factor=args.lr_sched_factor) optimizer = mx.optimizer.NAG( diff --git a/example/numpy-ops/custom_softmax.py b/example/numpy-ops/custom_softmax.py index cbd9a027d7a6..162215f3b0d1 100644 --- a/example/numpy-ops/custom_softmax.py +++ b/example/numpy-ops/custom_softmax.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file import os from data import mnist_iterator @@ -23,7 +40,7 @@ def backward(self, req, out_grad, in_data, out_data, in_grad, aux): class SoftmaxProp(mx.operator.CustomOpProp): def __init__(self): super(SoftmaxProp, self).__init__(need_top_grad=False) - + def list_arguments(self): return ['data', 'label'] diff --git a/example/numpy-ops/data.py b/example/numpy-ops/data.py index d39821f52145..0ca8e1fd6653 100644 --- a/example/numpy-ops/data.py +++ b/example/numpy-ops/data.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file """ data iterator for mnist """ import sys diff --git a/example/numpy-ops/ndarray_softmax.py b/example/numpy-ops/ndarray_softmax.py index 5c3176833b63..aa8555e5ad3e 100644 --- a/example/numpy-ops/ndarray_softmax.py +++ b/example/numpy-ops/ndarray_softmax.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file from data import mnist_iterator import mxnet as mx @@ -10,7 +27,7 @@ def __init__(self): super(NDArraySoftmax, self).__init__(False) self.fwd_kernel = None self.bwd_kernel = None - + def list_arguments(self): return ['data', 'label'] diff --git a/example/numpy-ops/numpy_softmax.py b/example/numpy-ops/numpy_softmax.py index 3f9f6c8be849..f90783b494b4 100644 --- a/example/numpy-ops/numpy_softmax.py +++ b/example/numpy-ops/numpy_softmax.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file from data import mnist_iterator import mxnet as mx @@ -8,7 +25,7 @@ class NumpySoftmax(mx.operator.NumpyOp): def __init__(self): super(NumpySoftmax, self).__init__(False) - + def list_arguments(self): return ['data', 'label'] diff --git a/example/numpy-ops/weighted_logistic_regression.py b/example/numpy-ops/weighted_logistic_regression.py index 7094b3aca969..26b5fb2fda84 100644 --- a/example/numpy-ops/weighted_logistic_regression.py +++ b/example/numpy-ops/weighted_logistic_regression.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import os import numpy as np import mxnet as mx diff --git a/example/profiler/profiler_executor.py b/example/profiler/profiler_executor.py index e70574d41cb5..26e3e1ba2acd 100644 --- a/example/profiler/profiler_executor.py +++ b/example/profiler/profiler_executor.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx import argparse import os, sys diff --git a/example/profiler/profiler_imageiter.py b/example/profiler/profiler_imageiter.py index af4c5d11aee8..e16b9b7de45f 100644 --- a/example/profiler/profiler_imageiter.py +++ b/example/profiler/profiler_imageiter.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import os # uncomment to set the number of worker threads. # os.environ["MXNET_CPU_WORKER_NTHREADS"] = "4" @@ -8,7 +25,7 @@ def run_imageiter(path_rec, n, batch_size = 32): - + data = mx.img.ImageIter(batch_size=batch_size, data_shape=(3, 224, 224), path_imgrec=path_rec, @@ -26,4 +43,4 @@ def run_imageiter(path_rec, n, batch_size = 32): mx.profiler.profiler_set_config(mode='all', filename='profile_imageiter.json') mx.profiler.profiler_set_state('run') run_imageiter('test.rec', 20) # See http://mxnet.io/tutorials/python/image_io.html for how to create .rec files. - mx.profiler.profiler_set_state('stop') \ No newline at end of file + mx.profiler.profiler_set_state('stop') diff --git a/example/profiler/profiler_matmul.py b/example/profiler/profiler_matmul.py index baa962307461..1b1cf74f4187 100644 --- a/example/profiler/profiler_matmul.py +++ b/example/profiler/profiler_matmul.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import print_function import mxnet as mx import argparse diff --git a/example/profiler/profiler_ndarray.py b/example/profiler/profiler_ndarray.py index bb4d658275c0..67ea87b1ed62 100644 --- a/example/profiler/profiler_ndarray.py +++ b/example/profiler/profiler_ndarray.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import os import mxnet as mx import numpy as np diff --git a/example/python-howto/data.py b/example/python-howto/data.py index d39821f52145..0ca8e1fd6653 100644 --- a/example/python-howto/data.py +++ b/example/python-howto/data.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file """ data iterator for mnist """ import sys diff --git a/example/python-howto/data_iter.py b/example/python-howto/data_iter.py index 34e9a4181cd1..81c8988a8e51 100644 --- a/example/python-howto/data_iter.py +++ b/example/python-howto/data_iter.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """Create a Cifar data iterator. This example shows how to create a iterator reading from recordio, diff --git a/example/python-howto/debug_conv.py b/example/python-howto/debug_conv.py index 3c38d20b89fa..9de421d8e88e 100644 --- a/example/python-howto/debug_conv.py +++ b/example/python-howto/debug_conv.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx data_shape = (1,3,5,5) @@ -19,4 +36,4 @@ def __init__(self, data): input_data = mx.nd.ones(data_shape) mod.forward(data_batch=SimpleData([input_data])) res = mod.get_outputs()[0].asnumpy() -print(res) \ No newline at end of file +print(res) diff --git a/example/python-howto/monitor_weights.py b/example/python-howto/monitor_weights.py index 8dcca1fba70b..c54e64954535 100644 --- a/example/python-howto/monitor_weights.py +++ b/example/python-howto/monitor_weights.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file from data import mnist_iterator import mxnet as mx @@ -27,6 +44,6 @@ def norm_stat(d): return mx.nd.norm(d)/np.sqrt(d.size) mon = mx.mon.Monitor(100, norm_stat) -model.fit(X=train, eval_data=val, monitor=mon, +model.fit(X=train, eval_data=val, monitor=mon, batch_end_callback = mx.callback.Speedometer(100, 100)) diff --git a/example/python-howto/multiple_outputs.py b/example/python-howto/multiple_outputs.py index 97ce469d58a2..43b4538d1d79 100644 --- a/example/python-howto/multiple_outputs.py +++ b/example/python-howto/multiple_outputs.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """Create a Multiple output configuration. This example shows how to create a multiple output configuration. diff --git a/example/rcnn/demo.py b/example/rcnn/demo.py index 34ea327cffac..b59403379ddd 100644 --- a/example/rcnn/demo.py +++ b/example/rcnn/demo.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import argparse import os import cv2 diff --git a/example/rcnn/rcnn/config.py b/example/rcnn/rcnn/config.py index 445c2439b91e..17738f054b33 100644 --- a/example/rcnn/rcnn/config.py +++ b/example/rcnn/rcnn/config.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import numpy as np from easydict import EasyDict as edict diff --git a/example/rcnn/rcnn/core/callback.py b/example/rcnn/rcnn/core/callback.py index 5d48b9fc75d1..bacff9665e91 100644 --- a/example/rcnn/rcnn/core/callback.py +++ b/example/rcnn/rcnn/core/callback.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import time import logging import mxnet as mx diff --git a/example/rcnn/rcnn/core/loader.py b/example/rcnn/rcnn/core/loader.py index 3f5cf3c6c011..826ee20f080c 100644 --- a/example/rcnn/rcnn/core/loader.py +++ b/example/rcnn/rcnn/core/loader.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx import numpy as np from mxnet.executor_manager import _split_input_slice diff --git a/example/rcnn/rcnn/core/metric.py b/example/rcnn/rcnn/core/metric.py index 5808190e9d80..d33edb65beda 100644 --- a/example/rcnn/rcnn/core/metric.py +++ b/example/rcnn/rcnn/core/metric.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx import numpy as np diff --git a/example/rcnn/rcnn/core/module.py b/example/rcnn/rcnn/core/module.py index bf28f8ee56f1..337f0f35852b 100644 --- a/example/rcnn/rcnn/core/module.py +++ b/example/rcnn/rcnn/core/module.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """A `MutableModule` implement the `BaseModule` API, and allows input shape varying with training iterations. If shapes vary, executors will rebind, using shared arrays from the initial module binded with maximum shape. diff --git a/example/rcnn/rcnn/core/tester.py b/example/rcnn/rcnn/core/tester.py index 0ccc47df71eb..651b2a945e71 100644 --- a/example/rcnn/rcnn/core/tester.py +++ b/example/rcnn/rcnn/core/tester.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import cPickle import os import time diff --git a/example/rcnn/rcnn/cython/nms_kernel.cu b/example/rcnn/rcnn/cython/nms_kernel.cu index 038a59012f60..047a5e0c6d9f 100644 --- a/example/rcnn/rcnn/cython/nms_kernel.cu +++ b/example/rcnn/rcnn/cython/nms_kernel.cu @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + // ------------------------------------------------------------------ // Faster R-CNN // Copyright (c) 2015 Microsoft diff --git a/example/rcnn/rcnn/cython/setup.py b/example/rcnn/rcnn/cython/setup.py index 786460798fd2..e50478b2d967 100644 --- a/example/rcnn/rcnn/cython/setup.py +++ b/example/rcnn/rcnn/cython/setup.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # -------------------------------------------------------- # Fast R-CNN # Copyright (c) 2015 Microsoft diff --git a/example/rcnn/rcnn/dataset/__init__.py b/example/rcnn/rcnn/dataset/__init__.py index 266f344ede75..1a706e9e0c15 100644 --- a/example/rcnn/rcnn/dataset/__init__.py +++ b/example/rcnn/rcnn/dataset/__init__.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from imdb import IMDB from pascal_voc import PascalVOC from coco import coco diff --git a/example/rcnn/rcnn/dataset/coco.py b/example/rcnn/rcnn/dataset/coco.py index 00c4c41cf3ce..9ca5a74cc461 100644 --- a/example/rcnn/rcnn/dataset/coco.py +++ b/example/rcnn/rcnn/dataset/coco.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import cPickle import cv2 import os diff --git a/example/rcnn/rcnn/dataset/ds_utils.py b/example/rcnn/rcnn/dataset/ds_utils.py index 131644b726fc..e6f839b8fdb9 100644 --- a/example/rcnn/rcnn/dataset/ds_utils.py +++ b/example/rcnn/rcnn/dataset/ds_utils.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import numpy as np @@ -13,4 +30,4 @@ def filter_small_boxes(boxes, min_size): w = boxes[:, 2] - boxes[:, 0] h = boxes[:, 3] - boxes[:, 1] keep = np.where((w >= min_size) & (h > min_size))[0] - return keep \ No newline at end of file + return keep diff --git a/example/rcnn/rcnn/dataset/imdb.py b/example/rcnn/rcnn/dataset/imdb.py index acdcd50f8208..b9038c5da0a0 100644 --- a/example/rcnn/rcnn/dataset/imdb.py +++ b/example/rcnn/rcnn/dataset/imdb.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """ General image database An image database creates a list of relative image path called image_set_index and diff --git a/example/rcnn/rcnn/dataset/pascal_voc.py b/example/rcnn/rcnn/dataset/pascal_voc.py index 2135971faadf..091c4e8ea17b 100644 --- a/example/rcnn/rcnn/dataset/pascal_voc.py +++ b/example/rcnn/rcnn/dataset/pascal_voc.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """ Pascal VOC database This class loads ground truth notations from standard Pascal VOC XML data formats diff --git a/example/rcnn/rcnn/dataset/pascal_voc_eval.py b/example/rcnn/rcnn/dataset/pascal_voc_eval.py index 54fa12ddccd8..e584ed750304 100644 --- a/example/rcnn/rcnn/dataset/pascal_voc_eval.py +++ b/example/rcnn/rcnn/dataset/pascal_voc_eval.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """ given a pascal voc imdb, compute mAP """ diff --git a/example/rcnn/rcnn/io/image.py b/example/rcnn/rcnn/io/image.py index d4155a069d3e..e468e4647b97 100644 --- a/example/rcnn/rcnn/io/image.py +++ b/example/rcnn/rcnn/io/image.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import numpy as np import cv2 import os diff --git a/example/rcnn/rcnn/io/rcnn.py b/example/rcnn/rcnn/io/rcnn.py index 807447c61baa..f9613d68bda5 100644 --- a/example/rcnn/rcnn/io/rcnn.py +++ b/example/rcnn/rcnn/io/rcnn.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """ Fast R-CNN: data = diff --git a/example/rcnn/rcnn/io/rpn.py b/example/rcnn/rcnn/io/rpn.py index 52fe1a50c276..20cd1ce4e744 100644 --- a/example/rcnn/rcnn/io/rpn.py +++ b/example/rcnn/rcnn/io/rpn.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """ RPN: data = diff --git a/example/rcnn/rcnn/logger.py b/example/rcnn/rcnn/logger.py index 2806e1add180..e82201797942 100644 --- a/example/rcnn/rcnn/logger.py +++ b/example/rcnn/rcnn/logger.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import logging # set up logger diff --git a/example/rcnn/rcnn/processing/bbox_regression.py b/example/rcnn/rcnn/processing/bbox_regression.py index d5b48a71b754..d5330f409875 100644 --- a/example/rcnn/rcnn/processing/bbox_regression.py +++ b/example/rcnn/rcnn/processing/bbox_regression.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """ This file has functions about generating bounding box regression targets """ diff --git a/example/rcnn/rcnn/processing/bbox_transform.py b/example/rcnn/rcnn/processing/bbox_transform.py index 7a8667e14fe2..04fa81feda78 100644 --- a/example/rcnn/rcnn/processing/bbox_transform.py +++ b/example/rcnn/rcnn/processing/bbox_transform.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import numpy as np from ..cython.bbox import bbox_overlaps_cython diff --git a/example/rcnn/rcnn/processing/generate_anchor.py b/example/rcnn/rcnn/processing/generate_anchor.py index 8996a3aaab48..0e97d6ef2ba6 100644 --- a/example/rcnn/rcnn/processing/generate_anchor.py +++ b/example/rcnn/rcnn/processing/generate_anchor.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """ Generate base anchors on index 0 """ diff --git a/example/rcnn/rcnn/processing/nms.py b/example/rcnn/rcnn/processing/nms.py index 230139c413ec..eca8d58626d3 100644 --- a/example/rcnn/rcnn/processing/nms.py +++ b/example/rcnn/rcnn/processing/nms.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import numpy as np from ..cython.cpu_nms import cpu_nms try: diff --git a/example/rcnn/rcnn/pycocotools/__init__.py b/example/rcnn/rcnn/pycocotools/__init__.py index 3f7d85bba884..2f4e0d430df9 100644 --- a/example/rcnn/rcnn/pycocotools/__init__.py +++ b/example/rcnn/rcnn/pycocotools/__init__.py @@ -1 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + __author__ = 'tylin' diff --git a/example/rcnn/rcnn/pycocotools/coco.py b/example/rcnn/rcnn/pycocotools/coco.py index ca35cc0b053b..5cc835a05633 100644 --- a/example/rcnn/rcnn/pycocotools/coco.py +++ b/example/rcnn/rcnn/pycocotools/coco.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + __author__ = 'tylin' __version__ = '2.0' # Interface for accessing the Microsoft COCO dataset. @@ -425,4 +442,4 @@ def annToMask(self, ann): """ rle = self.annToRLE(ann) m = maskUtils.decode(rle) - return m \ No newline at end of file + return m diff --git a/example/rcnn/rcnn/pycocotools/cocoeval.py b/example/rcnn/rcnn/pycocotools/cocoeval.py index a5dd1852912d..8b78026d39e4 100644 --- a/example/rcnn/rcnn/pycocotools/cocoeval.py +++ b/example/rcnn/rcnn/pycocotools/cocoeval.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + __author__ = 'tsungyi' import numpy as np @@ -525,4 +542,4 @@ def __init__(self, iouType='segm'): raise Exception('iouType not supported') self.iouType = iouType # useSegm is deprecated - self.useSegm = None \ No newline at end of file + self.useSegm = None diff --git a/example/rcnn/rcnn/pycocotools/mask.py b/example/rcnn/rcnn/pycocotools/mask.py index f49b8736b280..48c050c594b6 100644 --- a/example/rcnn/rcnn/pycocotools/mask.py +++ b/example/rcnn/rcnn/pycocotools/mask.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + __author__ = 'tsungyi' import _mask @@ -100,4 +117,4 @@ def toBbox(rleObjs): if type(rleObjs) == list: return _mask.toBbox(rleObjs) else: - return _mask.toBbox([rleObjs])[0] \ No newline at end of file + return _mask.toBbox([rleObjs])[0] diff --git a/example/rcnn/rcnn/pycocotools/maskApi.h b/example/rcnn/rcnn/pycocotools/maskApi.h index ebc7892da382..56b4c0c4c704 100644 --- a/example/rcnn/rcnn/pycocotools/maskApi.h +++ b/example/rcnn/rcnn/pycocotools/maskApi.h @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /************************************************************************** * Microsoft COCO Toolbox. version 2.0 * Data, paper, and tutorials available at: http://mscoco.org/ diff --git a/example/rcnn/rcnn/pycocotools/setup.py b/example/rcnn/rcnn/pycocotools/setup.py index 5e836f1b4b6b..d7074e910ee5 100644 --- a/example/rcnn/rcnn/pycocotools/setup.py +++ b/example/rcnn/rcnn/pycocotools/setup.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from distutils.core import setup from Cython.Build import cythonize from distutils.extension import Extension diff --git a/example/rcnn/rcnn/symbol/__init__.py b/example/rcnn/rcnn/symbol/__init__.py index f359ed821b8c..113b52c98abd 100644 --- a/example/rcnn/rcnn/symbol/__init__.py +++ b/example/rcnn/rcnn/symbol/__init__.py @@ -1,2 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from symbol_vgg import * from symbol_resnet import * diff --git a/example/rcnn/rcnn/symbol/proposal.py b/example/rcnn/rcnn/symbol/proposal.py index dd0bb15f5168..64981513980b 100644 --- a/example/rcnn/rcnn/symbol/proposal.py +++ b/example/rcnn/rcnn/symbol/proposal.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """ Proposal Operator transform anchor coordinates into ROI coordinates with prediction results on classification probability and bounding box prediction results, and image size and scale information. diff --git a/example/rcnn/rcnn/symbol/proposal_target.py b/example/rcnn/rcnn/symbol/proposal_target.py index 6f1a6ffbc440..e0444f978b33 100644 --- a/example/rcnn/rcnn/symbol/proposal_target.py +++ b/example/rcnn/rcnn/symbol/proposal_target.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """ Proposal Target Operator selects foreground and background roi and assigns label, bbox_transform to them. """ diff --git a/example/rcnn/rcnn/symbol/symbol_resnet.py b/example/rcnn/rcnn/symbol/symbol_resnet.py index ad60de9e854d..f914d117eb18 100644 --- a/example/rcnn/rcnn/symbol/symbol_resnet.py +++ b/example/rcnn/rcnn/symbol/symbol_resnet.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx import proposal import proposal_target diff --git a/example/rcnn/rcnn/symbol/symbol_vgg.py b/example/rcnn/rcnn/symbol/symbol_vgg.py index 34860a49e883..f04ba89dc1d4 100644 --- a/example/rcnn/rcnn/symbol/symbol_vgg.py +++ b/example/rcnn/rcnn/symbol/symbol_vgg.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx import proposal import proposal_target @@ -130,7 +147,7 @@ def get_vgg_rcnn_test(num_classes=config.NUM_CLASSES): # shared convolutional layer relu5_3 = get_vgg_conv(data) - + # Fast R-CNN pool5 = mx.symbol.ROIPooling( name='roi_pool5', data=relu5_3, rois=rois, pooled_size=(7, 7), spatial_scale=1.0 / config.RCNN_FEAT_STRIDE) diff --git a/example/rcnn/rcnn/tools/reeval.py b/example/rcnn/rcnn/tools/reeval.py index 22e5e206f4d0..a7ae898f41bd 100644 --- a/example/rcnn/rcnn/tools/reeval.py +++ b/example/rcnn/rcnn/tools/reeval.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import argparse import cPickle import os diff --git a/example/rcnn/rcnn/tools/test_rcnn.py b/example/rcnn/rcnn/tools/test_rcnn.py index 83a9fac03e67..2c5c22223f14 100644 --- a/example/rcnn/rcnn/tools/test_rcnn.py +++ b/example/rcnn/rcnn/tools/test_rcnn.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import argparse import pprint import mxnet as mx diff --git a/example/rcnn/rcnn/tools/test_rpn.py b/example/rcnn/rcnn/tools/test_rpn.py index 09f6af74368f..f2244a568d6a 100644 --- a/example/rcnn/rcnn/tools/test_rpn.py +++ b/example/rcnn/rcnn/tools/test_rpn.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import argparse import pprint import mxnet as mx diff --git a/example/rcnn/rcnn/tools/train_rcnn.py b/example/rcnn/rcnn/tools/train_rcnn.py index 3f1cde380e8c..c5417b34c2dc 100644 --- a/example/rcnn/rcnn/tools/train_rcnn.py +++ b/example/rcnn/rcnn/tools/train_rcnn.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import argparse import pprint import mxnet as mx diff --git a/example/rcnn/rcnn/tools/train_rpn.py b/example/rcnn/rcnn/tools/train_rpn.py index 87b92c8229ef..aaaf570a1fc3 100644 --- a/example/rcnn/rcnn/tools/train_rpn.py +++ b/example/rcnn/rcnn/tools/train_rpn.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import argparse import pprint import mxnet as mx diff --git a/example/rcnn/rcnn/utils/combine_model.py b/example/rcnn/rcnn/utils/combine_model.py index 5518dda4a989..eabe937be20c 100644 --- a/example/rcnn/rcnn/utils/combine_model.py +++ b/example/rcnn/rcnn/utils/combine_model.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from load_model import load_checkpoint from save_model import save_checkpoint diff --git a/example/rcnn/rcnn/utils/load_data.py b/example/rcnn/rcnn/utils/load_data.py index 4700229e65af..816b3b3a405e 100644 --- a/example/rcnn/rcnn/utils/load_data.py +++ b/example/rcnn/rcnn/utils/load_data.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import numpy as np from ..logger import logger from ..config import config diff --git a/example/rcnn/rcnn/utils/load_model.py b/example/rcnn/rcnn/utils/load_model.py index 6f8354869b66..0dc0752600c4 100644 --- a/example/rcnn/rcnn/utils/load_model.py +++ b/example/rcnn/rcnn/utils/load_model.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx diff --git a/example/rcnn/rcnn/utils/save_model.py b/example/rcnn/rcnn/utils/save_model.py index 1c9886973bd6..f27fb61b0f7a 100644 --- a/example/rcnn/rcnn/utils/save_model.py +++ b/example/rcnn/rcnn/utils/save_model.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx diff --git a/example/rcnn/script/additional_deps.sh b/example/rcnn/script/additional_deps.sh index 17e3d0bb0610..0e6599c77fd2 100755 --- a/example/rcnn/script/additional_deps.sh +++ b/example/rcnn/script/additional_deps.sh @@ -1,5 +1,23 @@ #!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + # install additional depts sudo apt install python-pip python-dev unzip python-matplotlib sudo pip install cython scikit-image easydict diff --git a/example/rcnn/script/get_coco.sh b/example/rcnn/script/get_coco.sh index d49046cc6c19..a2f8f90e8a6d 100755 --- a/example/rcnn/script/get_coco.sh +++ b/example/rcnn/script/get_coco.sh @@ -1,5 +1,23 @@ #!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + # make a data folder if ! [ -e data ] then diff --git a/example/rcnn/script/get_pretrained_model.sh b/example/rcnn/script/get_pretrained_model.sh index f63128d800da..746be0b7ddd8 100755 --- a/example/rcnn/script/get_pretrained_model.sh +++ b/example/rcnn/script/get_pretrained_model.sh @@ -1,5 +1,23 @@ #!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + # make a model folder if ! [ -e model ] then diff --git a/example/rcnn/script/get_selective_search.sh b/example/rcnn/script/get_selective_search.sh index 728bd8fffc60..487c653b23a7 100755 --- a/example/rcnn/script/get_selective_search.sh +++ b/example/rcnn/script/get_selective_search.sh @@ -1,5 +1,23 @@ #!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + # make a data folder if ! [ -e data ] then diff --git a/example/rcnn/script/get_voc.sh b/example/rcnn/script/get_voc.sh index c0cefa9a5f77..060b79336619 100755 --- a/example/rcnn/script/get_voc.sh +++ b/example/rcnn/script/get_voc.sh @@ -1,5 +1,23 @@ #!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + # make a data folder if ! [ -e data ] then diff --git a/example/rcnn/script/resnet_voc07.sh b/example/rcnn/script/resnet_voc07.sh index a5d16ec250ac..3cb421f016c0 100755 --- a/example/rcnn/script/resnet_voc07.sh +++ b/example/rcnn/script/resnet_voc07.sh @@ -1,5 +1,23 @@ #!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + # run this experiment with # nohup bash script/resnet_voc07.sh 0,1 &> resnet_voc07.log & # to use gpu 0,1 to train, gpu 0 to test and write logs to resnet_voc07.log diff --git a/example/rcnn/script/resnet_voc0712.sh b/example/rcnn/script/resnet_voc0712.sh index c993d49589b5..aa2bd39499a4 100755 --- a/example/rcnn/script/resnet_voc0712.sh +++ b/example/rcnn/script/resnet_voc0712.sh @@ -1,5 +1,23 @@ #!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + # run this experiment with # nohup bash script/resnet_voc00712.sh 0,1 &> resnet_voc0712.log & # to use gpu 0,1 to train, gpu 0 to test and write logs to resnet_voc0712.log diff --git a/example/rcnn/script/vgg_alter_voc07.sh b/example/rcnn/script/vgg_alter_voc07.sh index 1345f4fd2a43..72ee0cddea2f 100755 --- a/example/rcnn/script/vgg_alter_voc07.sh +++ b/example/rcnn/script/vgg_alter_voc07.sh @@ -1,5 +1,23 @@ #!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + # run this experiment with # nohup bash script/vgg_alter_voc07.sh 0,1 &> vgg_voc07.log & # to use gpu 0,1 to train, gpu 0 to test and write logs to vgg_voc07.log diff --git a/example/rcnn/script/vgg_fast_rcnn.sh b/example/rcnn/script/vgg_fast_rcnn.sh index 7d863b5f73ad..cafd2ea66b3e 100755 --- a/example/rcnn/script/vgg_fast_rcnn.sh +++ b/example/rcnn/script/vgg_fast_rcnn.sh @@ -1,5 +1,23 @@ #!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + # run this experiment with # nohup bash script/vgg_fast_rcnn.sh 0,1 &> vgg_fast_rcnn.log & # to use gpu 0,1 to train, gpu 0 to test and write logs to vgg_fast_rcnn.log diff --git a/example/rcnn/script/vgg_voc07.sh b/example/rcnn/script/vgg_voc07.sh index 4b70f7c9705f..22249e153838 100755 --- a/example/rcnn/script/vgg_voc07.sh +++ b/example/rcnn/script/vgg_voc07.sh @@ -1,5 +1,23 @@ #!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + # run this experiment with # nohup bash script/vgg_voc07.sh 0,1 &> vgg_voc07.log & # to use gpu 0,1 to train, gpu 0 to test and write logs to vgg_voc07.log diff --git a/example/rcnn/script/vgg_voc0712.sh b/example/rcnn/script/vgg_voc0712.sh index ff2490492b2e..22416dad4878 100755 --- a/example/rcnn/script/vgg_voc0712.sh +++ b/example/rcnn/script/vgg_voc0712.sh @@ -1,5 +1,23 @@ #!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + # run this experiment with # nohup bash script/vgg_voc00712.sh 0,1 &> vgg_voc0712.log & # to use gpu 0,1 to train, gpu 0 to test and write logs to vgg_voc0712.log diff --git a/example/rcnn/test.py b/example/rcnn/test.py index 12fe6973fbcf..2989bc02a4f7 100644 --- a/example/rcnn/test.py +++ b/example/rcnn/test.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import argparse import mxnet as mx from rcnn.logger import logger diff --git a/example/rcnn/train_alternate.py b/example/rcnn/train_alternate.py index 74f16b9980aa..715816087a61 100644 --- a/example/rcnn/train_alternate.py +++ b/example/rcnn/train_alternate.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import argparse import mxnet as mx diff --git a/example/rcnn/train_end2end.py b/example/rcnn/train_end2end.py index b8b1c5c3a410..5c942936aa4c 100644 --- a/example/rcnn/train_end2end.py +++ b/example/rcnn/train_end2end.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import argparse import pprint import mxnet as mx diff --git a/example/recommenders/crossentropy.py b/example/recommenders/crossentropy.py index 79fee7439438..51648b0eb157 100644 --- a/example/recommenders/crossentropy.py +++ b/example/recommenders/crossentropy.py @@ -1,4 +1,22 @@ #!/usr/bin/env python + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """Cross-entropy loss layer for MXNet. """ import os @@ -12,13 +30,13 @@ class CrossEntropyLoss(mx.operator.CustomOp): """An output layer that calculates gradient for cross-entropy loss y * log(p) + (1-y) * log(p) for label "y" and prediction "p". - However, the output of this layer is the original prediction -- same as + However, the output of this layer is the original prediction -- same as the "data" input, making it useful for tasks like "predict". If you actually want to use the calculated loss, see CrossEntropyLoss op. This is useful for multi-label prediction where each possible output label is considered independently. - Cross-entropy loss provides a very large penalty for guessing + Cross-entropy loss provides a very large penalty for guessing the wrong answer (0 or 1) confidently. The gradient calculation is optimized for y only being 0 or 1. """ @@ -93,7 +111,7 @@ def infer_shape(self, in_shape): print("Simple test of cross-entropy") data = mx.symbol.Variable('data') labs = mx.symbol.Variable('labs') - net = mx.symbol.Custom(data=data, label=labs, name='ce', + net = mx.symbol.Custom(data=data, label=labs, name='ce', op_type='CrossEntropyLoss') rand = np.random.RandomState(seed=123) for i in range(20): diff --git a/example/recommenders/matrix_fact.py b/example/recommenders/matrix_fact.py index 90be41ed7f36..73f561a87959 100644 --- a/example/recommenders/matrix_fact.py +++ b/example/recommenders/matrix_fact.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import math import mxnet as mx import numpy as np diff --git a/example/recommenders/movielens_data.py b/example/recommenders/movielens_data.py index 157e8c209978..3d664fbb02aa 100644 --- a/example/recommenders/movielens_data.py +++ b/example/recommenders/movielens_data.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """MovieLens data handling: download, parse, and expose as DataIter """ @@ -22,13 +39,13 @@ def load_mldata_iter(filename, batch_size): user = mx.nd.array(user) item = mx.nd.array(item) score = mx.nd.array(score) - return mx.io.NDArrayIter(data={'user':user,'item':item},label={'score':score}, + return mx.io.NDArrayIter(data={'user':user,'item':item},label={'score':score}, batch_size=batch_size, shuffle=True) def ensure_local_data(prefix): if not os.path.exists("%s.zip" % prefix): print("Downloading MovieLens data: %s" % prefix) - os.system("wget http://files.grouplens.org/datasets/movielens/%s.zip" % prefix) + os.system("wget http://files.grouplens.org/datasets/movielens/%s.zip" % prefix) os.system("unzip %s.zip" % prefix) @@ -36,7 +53,7 @@ def get_data_iter(batch_size, prefix='ml-100k'): """Returns a pair of NDArrayDataIter, one for train, one for test. """ ensure_local_data(prefix) - return (load_mldata_iter('./%s/u1.base' % prefix, batch_size), + return (load_mldata_iter('./%s/u1.base' % prefix, batch_size), load_mldata_iter('./%s/u1.test' % prefix, batch_size)) def max_id(fname): diff --git a/example/recommenders/negativesample.py b/example/recommenders/negativesample.py index ecbd85e6f407..0b4ea8477b6f 100644 --- a/example/recommenders/negativesample.py +++ b/example/recommenders/negativesample.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """DataIter for negative sampling. """ import mxnet as mx @@ -8,7 +25,7 @@ class NegativeSamplingDataIter(mx.io.DataIter): Assumes that all the relevant inputs are in data, not labels. Drops (replaces) any labels in the original DataIter. - It only shuffles one of the input data columns, specified in the + It only shuffles one of the input data columns, specified in the constructor as shuffle_data_idx. So if the original input data has three columns, ('item_ids', 'item_words', 'users') and you want to keep the two "item_*" together, then set `shuffle_data_idx=2` @@ -46,7 +63,7 @@ def _clear_queue(self): self._sampled_queue = [] def _push_queue(self, data_list, labels): - """Takes a list of numpy arrays for data, + """Takes a list of numpy arrays for data, and a numpy array for labels. Converts to minibatches and puts it on the queue. """ diff --git a/example/recommenders/randomproj.py b/example/recommenders/randomproj.py index 539f50e0f647..ba080a07ec38 100644 --- a/example/recommenders/randomproj.py +++ b/example/recommenders/randomproj.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """Random projection layers in MXNet as custom python ops. Currently slow and memory-inefficient, but functional. """ @@ -34,7 +51,7 @@ def random_unit_vecs(self, num_vecs, num_dims, rs): def _get_mask(self, idx, in_data): """Returns the mask by which to multiply the parts of the embedding layer. - In this version, we have no weights to apply. + In this version, we have no weights to apply. """ mask = idx >= 0 # bool False for -1 values that should be removed. shape=(b,mnz) mask = np.expand_dims(mask,2) # shape = (b,mnz,1) @@ -98,7 +115,7 @@ def _get_mask(self, idx, in_data): mask = np.expand_dims(mask,2) # shape = (b,mnz,1) mask = np.repeat(mask, self._proj_dim, axis=2) # shape = (b,mnz,d) return mask - + @mx.operator.register("SparseRandomProjection") class SparseRandomProjectionProp(RandomBagOfWordsProjectionProp): @@ -121,8 +138,8 @@ def infer_shape(self, in_shape): print("Simple test of proj layer") data = mx.symbol.Variable('data') vals = mx.symbol.Variable('vals') - net = mx.symbol.Custom(indexes=data, values=vals, name='rproj', - op_type='SparseRandomProjection', + net = mx.symbol.Custom(indexes=data, values=vals, name='rproj', + op_type='SparseRandomProjection', vocab_size=999, output_dim=29) d = mx.nd.zeros(shape=(3,100)) v = mx.nd.ones(shape=(3,100)) diff --git a/example/recommenders/recotools.py b/example/recommenders/recotools.py index f3681709db02..250baa5c07cf 100644 --- a/example/recommenders/recotools.py +++ b/example/recommenders/recotools.py @@ -1,7 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx from negativesample import NegativeSamplingDataIter -import randomproj +import randomproj import crossentropy def CosineLoss(a, b, label): diff --git a/example/recommenders/symbol_alexnet.py b/example/recommenders/symbol_alexnet.py index 20a3547db460..e5d02f0412cd 100644 --- a/example/recommenders/symbol_alexnet.py +++ b/example/recommenders/symbol_alexnet.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """ Reference: diff --git a/example/reinforcement-learning/a3c/a3c.py b/example/reinforcement-learning/a3c/a3c.py index 19ab2305fb5e..4d89a24852c8 100644 --- a/example/reinforcement-learning/a3c/a3c.py +++ b/example/reinforcement-learning/a3c/a3c.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import print_function import mxnet as mx import numpy as np @@ -76,7 +93,7 @@ def train(): if args.kv_store == 'dist_sync': epoch_size /= kv.num_workers - + # disable kvstore for single device if 'local' in kv.type and ( args.gpus is None or len(args.gpus.split(',')) is 1): @@ -164,7 +181,7 @@ def train(): print('h', h[0].asnumpy()) err += (adv**2).mean() score += r[i] - final_score *= (1-D[i]) + final_score *= (1-D[i]) final_score += score * D[i] score *= 1-D[i] T += D[i].sum() diff --git a/example/reinforcement-learning/a3c/launcher.py b/example/reinforcement-learning/a3c/launcher.py index 8a4a7d17c73e..e0bda21891f0 100644 --- a/example/reinforcement-learning/a3c/launcher.py +++ b/example/reinforcement-learning/a3c/launcher.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """Submission job for local jobs.""" # pylint: disable=invalid-name from __future__ import absolute_import diff --git a/example/reinforcement-learning/a3c/rl_data.py b/example/reinforcement-learning/a3c/rl_data.py index 0d16bca793a4..ad78975753bd 100644 --- a/example/reinforcement-learning/a3c/rl_data.py +++ b/example/reinforcement-learning/a3c/rl_data.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import print_function import mxnet as mx import numpy as np diff --git a/example/reinforcement-learning/a3c/sym.py b/example/reinforcement-learning/a3c/sym.py index d3e1767ea5b2..c48d752d2d0c 100644 --- a/example/reinforcement-learning/a3c/sym.py +++ b/example/reinforcement-learning/a3c/sym.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx def get_symbol_atari(act_dim): diff --git a/example/reinforcement-learning/ddpg/ddpg.py b/example/reinforcement-learning/ddpg/ddpg.py index 4ded9b952273..aa34e4d92804 100644 --- a/example/reinforcement-learning/ddpg/ddpg.py +++ b/example/reinforcement-learning/ddpg/ddpg.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from replay_mem import ReplayMem from utils import discount_return, sample_rewards import rllab.misc.logger as logger diff --git a/example/reinforcement-learning/ddpg/policies.py b/example/reinforcement-learning/ddpg/policies.py index 2a625c8872b3..2bae8f68cf0c 100644 --- a/example/reinforcement-learning/ddpg/policies.py +++ b/example/reinforcement-learning/ddpg/policies.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from utils import define_policy import mxnet as mx @@ -40,7 +57,7 @@ def __init__( self.obs = mx.symbol.Variable("obs") self.act = define_policy( - self.obs, + self.obs, self.env_spec.action_space.flat_dim) def get_output_symbol(self): @@ -59,7 +76,7 @@ def define_loss(self, loss_exp): raise NotImplementedError - def define_exe(self, ctx, init, updater, input_shapes=None, args=None, + def define_exe(self, ctx, init, updater, input_shapes=None, args=None, grad_req=None): # define an executor, initializer and updater for batch version @@ -71,7 +88,7 @@ def define_exe(self, ctx, init, updater, input_shapes=None, args=None, for name, arr in self.arg_dict.items(): if name not in input_shapes: init(name, arr) - + self.updater = updater # define an executor for sampled single observation @@ -110,4 +127,4 @@ def get_action(self, obs): - \ No newline at end of file + diff --git a/example/reinforcement-learning/ddpg/qfuncs.py b/example/reinforcement-learning/ddpg/qfuncs.py index 21957c47e351..7dbc1d601d30 100644 --- a/example/reinforcement-learning/ddpg/qfuncs.py +++ b/example/reinforcement-learning/ddpg/qfuncs.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from utils import define_qfunc import mxnet as mx @@ -47,7 +64,7 @@ def define_loss(self, loss_exp): self.loss = mx.symbol.MakeLoss(loss_exp, name="qfunc_loss") self.loss = mx.symbol.Group([self.loss, mx.symbol.BlockGrad(self.qval)]) - def define_exe(self, ctx, init, updater, input_shapes=None, args=None, + def define_exe(self, ctx, init, updater, input_shapes=None, args=None, grad_req=None): # define an executor, initializer and updater for batch version loss @@ -55,11 +72,11 @@ def define_exe(self, ctx, init, updater, input_shapes=None, args=None, self.arg_arrays = self.exe.arg_arrays self.grad_arrays = self.exe.grad_arrays self.arg_dict = self.exe.arg_dict - + for name, arr in self.arg_dict.items(): if name not in input_shapes: init(name, arr) - + self.updater = updater def update_params(self, obs, act, yval): diff --git a/example/reinforcement-learning/ddpg/replay_mem.py b/example/reinforcement-learning/ddpg/replay_mem.py index 885d7da301f0..47e9bc843ac0 100644 --- a/example/reinforcement-learning/ddpg/replay_mem.py +++ b/example/reinforcement-learning/ddpg/replay_mem.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import print_function import numpy as np @@ -5,7 +22,7 @@ class ReplayMem(object): def __init__( - self, + self, obs_dim, act_dim, memory_size=1000000): diff --git a/example/reinforcement-learning/ddpg/run.py b/example/reinforcement-learning/ddpg/run.py index 0cd162ff5e9e..043cd997e647 100644 --- a/example/reinforcement-learning/ddpg/run.py +++ b/example/reinforcement-learning/ddpg/run.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from ddpg import DDPG from rllab.envs.box2d.cartpole_env import CartpoleEnv from rllab.envs.normalized_env import normalize @@ -32,4 +49,4 @@ policy_lr=1e-4, seed=SEED) -algo.train() \ No newline at end of file +algo.train() diff --git a/example/reinforcement-learning/ddpg/strategies.py b/example/reinforcement-learning/ddpg/strategies.py index c346e9e2a133..d73ad060cc87 100644 --- a/example/reinforcement-learning/ddpg/strategies.py +++ b/example/reinforcement-learning/ddpg/strategies.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import numpy as np @@ -28,7 +45,7 @@ def __init__(self, env_spec, mu=0, theta=0.15, sigma=0.3): self.sigma = sigma self.action_space = env_spec.action_space self.state = np.ones(self.action_space.flat_dim) * self.mu - + def evolve_state(self): x = self.state @@ -47,9 +64,9 @@ def get_action(self, obs, policy): obs = obs.reshape((1, -1)) action = policy.get_action(obs) increment = self.evolve_state() - - return np.clip(action + increment, - self.action_space.low, + + return np.clip(action + increment, + self.action_space.low, self.action_space.high) diff --git a/example/reinforcement-learning/ddpg/utils.py b/example/reinforcement-learning/ddpg/utils.py index 8c063db76506..a9a445632fd2 100644 --- a/example/reinforcement-learning/ddpg/utils.py +++ b/example/reinforcement-learning/ddpg/utils.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx import numpy as np diff --git a/example/reinforcement-learning/dqn/atari_game.py b/example/reinforcement-learning/dqn/atari_game.py index 369016fe134f..5c1314ffcf6c 100644 --- a/example/reinforcement-learning/dqn/atari_game.py +++ b/example/reinforcement-learning/dqn/atari_game.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + __author__ = 'sxjscience' import mxnet as mx diff --git a/example/reinforcement-learning/dqn/base.py b/example/reinforcement-learning/dqn/base.py index f433d5d7cbc0..ce82f2b1ad6c 100644 --- a/example/reinforcement-learning/dqn/base.py +++ b/example/reinforcement-learning/dqn/base.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import absolute_import, division, print_function import mxnet as mx diff --git a/example/reinforcement-learning/dqn/dqn_demo.py b/example/reinforcement-learning/dqn/dqn_demo.py index 000a796b5821..750da7a69a7c 100644 --- a/example/reinforcement-learning/dqn/dqn_demo.py +++ b/example/reinforcement-learning/dqn/dqn_demo.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx import mxnet.ndarray as nd import numpy diff --git a/example/reinforcement-learning/dqn/dqn_run_test.py b/example/reinforcement-learning/dqn/dqn_run_test.py index 1a918eb92aab..2abf273978fa 100644 --- a/example/reinforcement-learning/dqn/dqn_run_test.py +++ b/example/reinforcement-learning/dqn/dqn_run_test.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx import mxnet.ndarray as nd import numpy diff --git a/example/reinforcement-learning/dqn/game.py b/example/reinforcement-learning/dqn/game.py index 0e1b7f1bd651..e17cc6f03f41 100644 --- a/example/reinforcement-learning/dqn/game.py +++ b/example/reinforcement-learning/dqn/game.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + DEFAULT_MAX_EPISODE_STEP = 1000000 @@ -29,4 +46,4 @@ def current_state(self): return self.replay_memory.latest_slice() def play(self, a): - raise NotImplementedError \ No newline at end of file + raise NotImplementedError diff --git a/example/reinforcement-learning/dqn/operators.py b/example/reinforcement-learning/dqn/operators.py index e8180c4d3f10..0c9b588f1685 100644 --- a/example/reinforcement-learning/dqn/operators.py +++ b/example/reinforcement-learning/dqn/operators.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx import mxnet.ndarray as nd import numpy diff --git a/example/reinforcement-learning/dqn/replay_memory.py b/example/reinforcement-learning/dqn/replay_memory.py index 42f4866c2a08..02691a01888a 100644 --- a/example/reinforcement-learning/dqn/replay_memory.py +++ b/example/reinforcement-learning/dqn/replay_memory.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import absolute_import, division, print_function import mxnet as mx diff --git a/example/reinforcement-learning/dqn/utils.py b/example/reinforcement-learning/dqn/utils.py index 7d84bba74524..bae11e18021d 100644 --- a/example/reinforcement-learning/dqn/utils.py +++ b/example/reinforcement-learning/dqn/utils.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import absolute_import, division, print_function import os diff --git a/example/reinforcement-learning/parallel_actor_critic/config.py b/example/reinforcement-learning/parallel_actor_critic/config.py index 48ef1d0c5a38..e962cf99be1f 100644 --- a/example/reinforcement-learning/parallel_actor_critic/config.py +++ b/example/reinforcement-learning/parallel_actor_critic/config.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx diff --git a/example/reinforcement-learning/parallel_actor_critic/envs.py b/example/reinforcement-learning/parallel_actor_critic/envs.py index 09f30d73cf2d..a537df6a7630 100644 --- a/example/reinforcement-learning/parallel_actor_critic/envs.py +++ b/example/reinforcement-learning/parallel_actor_critic/envs.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import numpy as np diff --git a/example/reinforcement-learning/parallel_actor_critic/model.py b/example/reinforcement-learning/parallel_actor_critic/model.py index 8fba78f7b950..b90af6790544 100644 --- a/example/reinforcement-learning/parallel_actor_critic/model.py +++ b/example/reinforcement-learning/parallel_actor_critic/model.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from itertools import chain import numpy as np import scipy.signal diff --git a/example/reinforcement-learning/parallel_actor_critic/train.py b/example/reinforcement-learning/parallel_actor_critic/train.py index d559ff346774..128a55030258 100644 --- a/example/reinforcement-learning/parallel_actor_critic/train.py +++ b/example/reinforcement-learning/parallel_actor_critic/train.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """Trains an `Agent` using trajectories from multiple environments.""" import argparse diff --git a/example/rnn-time-major/bucket_io.py b/example/rnn-time-major/bucket_io.py index 5cf2c81967a8..950b0c05cfca 100644 --- a/example/rnn-time-major/bucket_io.py +++ b/example/rnn-time-major/bucket_io.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: disable=C0111,too-many-arguments,too-many-instance-attributes,too-many-locals,redefined-outer-name,fixme # pylint: disable=superfluous-parens, no-member, invalid-name from __future__ import print_function @@ -58,7 +75,7 @@ def default_gen_buckets(sentences, batch_size, the_vocab): tl = 0 buckets = [] - for l, n in len_dict.items(): # TODO: There are better heuristic ways to do this + for l, n in len_dict.items(): # TODO: There are better heuristic ways to do this if n + tl >= batch_size: buckets.append(l) tl = 0 @@ -217,7 +234,7 @@ def __iter__(self): i_idx = self.bucket_curr_idx[i_bucket] idx = self.bucket_idx_all[i_bucket][i_idx:i_idx+self.batch_size] self.bucket_curr_idx[i_bucket] += self.batch_size - + init_state_names = [x[0] for x in self.init_states] if self.time_major: diff --git a/example/rnn-time-major/get_ptb_data.sh b/example/rnn-time-major/get_ptb_data.sh index 1ec009aa2f99..d2641cb32b81 100755 --- a/example/rnn-time-major/get_ptb_data.sh +++ b/example/rnn-time-major/get_ptb_data.sh @@ -1,5 +1,23 @@ #!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + RNN_DIR=$(cd `dirname $0`; pwd) DATA_DIR="${RNN_DIR}/data/" diff --git a/example/rnn-time-major/rnn_cell_demo.py b/example/rnn-time-major/rnn_cell_demo.py index cb69c55770e0..c29d1ddea4e3 100644 --- a/example/rnn-time-major/rnn_cell_demo.py +++ b/example/rnn-time-major/rnn_cell_demo.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """A simple demo of new RNN cell with PTB language model.""" ################################################################################ @@ -100,7 +117,7 @@ def sym_gen(seq_len): # RNN cell takes input of shape (time, batch, feature) rnn = mx.sym.RNN(data=embed, state_size=num_hidden, num_layers=num_lstm_layer, mode='lstm', - name='LSTM', + name='LSTM', # The following params can be omitted # provided we do not need to apply the # workarounds mentioned above @@ -134,7 +151,7 @@ def sym_gen(seq_len): if len(buckets) == 1: mod = mx.mod.Module(*sym_gen(buckets[0]), context=contexts) else: - mod = mx.mod.BucketingModule(sym_gen, + mod = mx.mod.BucketingModule(sym_gen, default_bucket_key=data_train.default_bucket_key, context=contexts) diff --git a/example/rnn/cudnn_lstm_bucketing.py b/example/rnn/cudnn_lstm_bucketing.py index fbf32bbacb42..e9c3237f26fc 100644 --- a/example/rnn/cudnn_lstm_bucketing.py +++ b/example/rnn/cudnn_lstm_bucketing.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import numpy as np import mxnet as mx import argparse diff --git a/example/rnn/get_ptb_data.sh b/example/rnn/get_ptb_data.sh index 1ec009aa2f99..d2641cb32b81 100755 --- a/example/rnn/get_ptb_data.sh +++ b/example/rnn/get_ptb_data.sh @@ -1,5 +1,23 @@ #!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + RNN_DIR=$(cd `dirname $0`; pwd) DATA_DIR="${RNN_DIR}/data/" diff --git a/example/rnn/lstm_bucketing.py b/example/rnn/lstm_bucketing.py index 609276a11f19..2e7bc65d437a 100644 --- a/example/rnn/lstm_bucketing.py +++ b/example/rnn/lstm_bucketing.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import numpy as np import mxnet as mx import argparse diff --git a/example/rnn/old/bucket_io.py b/example/rnn/old/bucket_io.py index f515e348c4f4..21f96ef196fa 100644 --- a/example/rnn/old/bucket_io.py +++ b/example/rnn/old/bucket_io.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: disable=C0111,too-many-arguments,too-many-instance-attributes,too-many-locals,redefined-outer-name,fixme # pylint: disable=superfluous-parens, no-member, invalid-name from __future__ import print_function @@ -58,7 +75,7 @@ def default_gen_buckets(sentences, batch_size, the_vocab): tl = 0 buckets = [] - for l, n in len_dict.items(): # TODO: There are better heuristic ways to do this + for l, n in len_dict.items(): # TODO: There are better heuristic ways to do this if n + tl >= batch_size: buckets.append(l) tl = 0 @@ -210,7 +227,7 @@ def make_data_iter_plan(self): self.data_buffer.append(data) if self.model_parallel: - # Transpose data if model parallel + # Transpose data if model parallel for i in range(len(self.data)): bucket_data = self.data[i] self.data[i] = np.transpose(bucket_data) @@ -222,8 +239,8 @@ def __iter__(self): i_idx = self.bucket_curr_idx[i_bucket] idx = self.bucket_idx_all[i_bucket][i_idx:i_idx+self.batch_size] self.bucket_curr_idx[i_bucket] += self.batch_size - - # Model parallelism + + # Model parallelism if self.model_parallel: if self.data[i_bucket][:, idx].shape[1] == 0: print("WARNING: detected shape " + str(self.data[i_bucket][:, idx].shape)) @@ -231,7 +248,7 @@ def __iter__(self): data[:] = self.data[i_bucket][:, idx] data_batch = ModelParallelBatch(data, self.buckets[i_bucket]) yield data_batch - + # Data parallelism else: init_state_names = [x[0] for x in self.init_states] @@ -239,7 +256,7 @@ def __iter__(self): for sentence in data: assert len(sentence) == self.buckets[i_bucket] - + label = self.label_buffer[i_bucket] label[:, :-1] = data[:, 1:] label[:, -1] = 0 @@ -255,4 +272,4 @@ def __iter__(self): def reset(self): - self.bucket_curr_idx = [0 for x in self.data] \ No newline at end of file + self.bucket_curr_idx = [0 for x in self.data] diff --git a/example/rnn/old/get_ptb_data.sh b/example/rnn/old/get_ptb_data.sh index 1ec009aa2f99..d2641cb32b81 100755 --- a/example/rnn/old/get_ptb_data.sh +++ b/example/rnn/old/get_ptb_data.sh @@ -1,5 +1,23 @@ #!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + RNN_DIR=$(cd `dirname $0`; pwd) DATA_DIR="${RNN_DIR}/data/" diff --git a/example/rnn/old/gru.py b/example/rnn/old/gru.py index 5b5138bd0388..e6ec0952334b 100644 --- a/example/rnn/old/gru.py +++ b/example/rnn/old/gru.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: disable=C0111,too-many-arguments,too-many-instance-attributes,too-many-locals,redefined-outer-name,fixme # pylint: disable=superfluous-parens, no-member, invalid-name import sys diff --git a/example/rnn/old/gru_bucketing.py b/example/rnn/old/gru_bucketing.py index 859d449121a2..226018c02685 100644 --- a/example/rnn/old/gru_bucketing.py +++ b/example/rnn/old/gru_bucketing.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: disable=C0111,too-many-arguments,too-many-instance-attributes,too-many-locals,redefined-outer-name,fixme # pylint: disable=superfluous-parens, no-member, invalid-name import sys diff --git a/example/rnn/old/lstm.py b/example/rnn/old/lstm.py index d67b0dbe5790..84509a3daf3d 100644 --- a/example/rnn/old/lstm.py +++ b/example/rnn/old/lstm.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint:skip-file import sys sys.path.insert(0, "../../python") diff --git a/example/rnn/old/lstm_bucketing.py b/example/rnn/old/lstm_bucketing.py index 78fa4f89480e..3e3494776dc3 100644 --- a/example/rnn/old/lstm_bucketing.py +++ b/example/rnn/old/lstm_bucketing.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: disable=C0111,too-many-arguments,too-many-instance-attributes,too-many-locals,redefined-outer-name,fixme # pylint: disable=superfluous-parens, no-member, invalid-name import sys diff --git a/example/rnn/old/rnn.py b/example/rnn/old/rnn.py index 136c40380b53..fe7bdbd922fa 100644 --- a/example/rnn/old/rnn.py +++ b/example/rnn/old/rnn.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import sys sys.path.insert(0, "../../python/") import mxnet as mx diff --git a/example/rnn/old/rnn_cell_demo.py b/example/rnn/old/rnn_cell_demo.py index 2c798e2c9c13..3223e936c37f 100644 --- a/example/rnn/old/rnn_cell_demo.py +++ b/example/rnn/old/rnn_cell_demo.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """A simple demo of new RNN cell with PTB language model.""" import os @@ -87,12 +104,12 @@ def sym_gen(seq_len): # RNN cell takes input of shape (time, batch, feature) rnn = mx.sym.RNN(data=embed_tm, state_size=num_hidden, num_layers=num_lstm_layer, mode='lstm', - name='LSTM', + name='LSTM', # The following params can be omitted # provided we do not need to apply the # workarounds mentioned above state=rnn_h_init, - state_cell=rnn_c_init, + state_cell=rnn_c_init, parameters=rnn_params) # the RNN cell output is of shape (time, batch, dim) diff --git a/example/rnn/old/rnn_model.py b/example/rnn/old/rnn_model.py index 2135abd357c9..6fe0d22ef3c9 100644 --- a/example/rnn/old/rnn_model.py +++ b/example/rnn/old/rnn_model.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: disable=C0111,too-many-arguments,too-many-instance-attributes,too-many-locals,redefined-outer-name,fixme # pylint: disable=superfluous-parens, no-member, invalid-name diff --git a/example/speech-demo/config_util.py b/example/speech-demo/config_util.py index 9e2ecc45abd7..6fd6a50a19fb 100644 --- a/example/speech-demo/config_util.py +++ b/example/speech-demo/config_util.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import re import os import sys diff --git a/example/speech-demo/decode_mxnet.py b/example/speech-demo/decode_mxnet.py index 4680fbe904df..deb9c30d79c7 100644 --- a/example/speech-demo/decode_mxnet.py +++ b/example/speech-demo/decode_mxnet.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import re import sys sys.path.insert(0, "../../python") @@ -80,7 +97,7 @@ def prepare_data(args): num_epoch = args.config.getint('train', 'num_epoch') model_name = get_checkpoint_path(args) logging.basicConfig(level=logging.DEBUG, format='%(asctime)-15s %(message)s') - + # load the model sym, arg_params, aux_params = mx.model.load_checkpoint(model_name, num_epoch) @@ -89,7 +106,7 @@ def prepare_data(args): buckets = list(map(int, re.split(r'\W+', buckets))) data_test = BucketSentenceIter(test_sets, buckets, batch_size, init_states, feat_dim=feat_dim, has_label=False) def sym_gen(seq_len): - sym = lstm_unroll(num_lstm_layer, seq_len, feat_dim, num_hidden=num_hidden, + sym = lstm_unroll(num_lstm_layer, seq_len, feat_dim, num_hidden=num_hidden, num_label=label_dim, take_softmax=True, num_hidden_proj=num_hidden_proj) data_names = ['data'] + state_names label_names = ['softmax_label'] @@ -102,7 +119,7 @@ def sym_gen(seq_len): data_test = SimpleIter(test_sets, batch_size, init_states, feat_dim=feat_dim, label_dim=label_dim, label_mean_sets=label_mean_sets, has_label=False) def sym_gen(seq_len): - sym = lstm_unroll(num_lstm_layer, seq_len, feat_dim, num_hidden=num_hidden, + sym = lstm_unroll(num_lstm_layer, seq_len, feat_dim, num_hidden=num_hidden, num_label=label_dim, take_softmax=False, num_hidden_proj=num_hidden_proj) data_names = ['data'] + state_names label_names = [] @@ -127,7 +144,7 @@ def sym_gen(seq_len): # set the parameters module.bind(data_shapes=data_test.provide_data, label_shapes=None, for_training=False) module.set_params(arg_params=arg_params, aux_params=aux_params) - + kaldiWriter = KaldiWriteOut(None, out_file) kaldiWriter.open_or_fd() for preds, i_batch, batch in module.iter_predict(data_test): diff --git a/example/speech-demo/decode_mxnet.sh b/example/speech-demo/decode_mxnet.sh index e5209b8c76d5..d300d0e91c40 100755 --- a/example/speech-demo/decode_mxnet.sh +++ b/example/speech-demo/decode_mxnet.sh @@ -1,14 +1,32 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + # Copyright 2012-2013 Karel Vesely, Daniel Povey # 2015 Yu Zhang # Apache 2.0 -# Begin configuration section. +# Begin configuration section. nnet= # Optionally pre-select network to use for getting state-likelihoods feature_transform= # Optionally pre-select feature transform (in front of nnet) model= # Optionally pre-select transition model -class_frame_counts= # Optionally pre-select class-counts used to compute PDF priors +class_frame_counts= # Optionally pre-select class-counts used to compute PDF priors stage=0 # stage=1 skips lattice generation nj=4 @@ -44,7 +62,7 @@ mkdir -p $dir/log echo $nj > $dir/num_jobs if [ -z "$model" ]; then # if --model was not specified on the command line... - if [ -z $iter ]; then model=$srcdir/final.mdl; + if [ -z $iter ]; then model=$srcdir/final.mdl; else model=$srcdir/$iter.mdl; fi fi diff --git a/example/speech-demo/io_func/convert2kaldi.py b/example/speech-demo/io_func/convert2kaldi.py index ffa8c4d6b3a9..eac8ee695a9b 100644 --- a/example/speech-demo/io_func/convert2kaldi.py +++ b/example/speech-demo/io_func/convert2kaldi.py @@ -1,4 +1,21 @@ -# Copyright 2013 Yajie Miao Carnegie Mellon University +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Copyright 2013 Yajie Miao Carnegie Mellon University # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -28,7 +45,7 @@ def _nnet2kaldi(nnet_spec, set_layer_num = -1, filein='nnet.in', _nnet2kaldi_main(nnet_spec, set_layer_num=set_layer_num, filein=filein, fileout=fileout, activation=activation, withfinal=withfinal, maxout=False) -def _nnet2kaldi_maxout(nnet_spec, pool_size = 1, set_layer_num = -1, +def _nnet2kaldi_maxout(nnet_spec, pool_size = 1, set_layer_num = -1, filein='nnet.in', fileout='nnet.out', activation='sigmoid', withfinal=True): _nnet2kaldi_main(nnet_spec, set_layer_num=set_layer_num, filein=filein, fileout=fileout, activation=activation, withfinal=withfinal, @@ -110,4 +127,4 @@ def _nnet2kaldi_main(nnet_spec, set_layer_num = -1, filein='nnet.in', fout.write('[ ' + b_layer.strip() + ' ]' + '\n') fout.write(' ' + str(output_size) + ' ' + str(output_size) + '\n') - fout.close(); \ No newline at end of file + fout.close(); diff --git a/example/speech-demo/io_func/feat_io.py b/example/speech-demo/io_func/feat_io.py index 83d417eb0ffb..6a7e424d1e65 100644 --- a/example/speech-demo/io_func/feat_io.py +++ b/example/speech-demo/io_func/feat_io.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import print_function import os import sys diff --git a/example/speech-demo/io_func/feat_readers/common.py b/example/speech-demo/io_func/feat_readers/common.py index a7b6413082ce..742d3e25a1c7 100644 --- a/example/speech-demo/io_func/feat_readers/common.py +++ b/example/speech-demo/io_func/feat_readers/common.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import numpy import os @@ -55,4 +72,4 @@ def getReader(fileformat, featureFile, labelFile): return reader_kaldi.kaldiReader(featureFile, labelFile) else: msg = "Error: Specified format '{}' is not supported".format(fileformat) - raise Exception(msg) \ No newline at end of file + raise Exception(msg) diff --git a/example/speech-demo/io_func/feat_readers/reader_atrack.py b/example/speech-demo/io_func/feat_readers/reader_atrack.py index 0bf1deeac95e..e8db0fd14da2 100644 --- a/example/speech-demo/io_func/feat_readers/reader_atrack.py +++ b/example/speech-demo/io_func/feat_readers/reader_atrack.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import numpy import numpy as num import stats @@ -30,11 +47,11 @@ def Read(self): -1.677172 -1076449904 -1867655489 -1.562828 -1077409088 -1073035073 """ - + f = open(self.featureFile, "rb") header = num.fromfile(f, dtype=num.dtype('>i4'), count=7) self.checkHeader(header) - + frameSize = header[1] numSamples = header[2] @@ -46,4 +63,4 @@ def Read(self): self._markDone() - return a, ReadLabel(self.labelFile) \ No newline at end of file + return a, ReadLabel(self.labelFile) diff --git a/example/speech-demo/io_func/feat_readers/reader_bvec.py b/example/speech-demo/io_func/feat_readers/reader_bvec.py index ac68bf477c05..3a0f745b92ea 100644 --- a/example/speech-demo/io_func/feat_readers/reader_bvec.py +++ b/example/speech-demo/io_func/feat_readers/reader_bvec.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import print_function import struct import array @@ -22,7 +39,7 @@ def Read(self): print('Num samples = {}'.format(numSamples)) print('dim = {}'.format(dim)) - dt = numpy.dtype([('sample',(numpy.float32,dim))]) + dt = numpy.dtype([('sample',(numpy.float32,dim))]) samples = numpy.fromfile(f,dt.newbyteorder('>'),count=numSamples) self._markDone() diff --git a/example/speech-demo/io_func/feat_readers/reader_htk.py b/example/speech-demo/io_func/feat_readers/reader_htk.py index b04d6f3e52ee..dca24d9bd35c 100644 --- a/example/speech-demo/io_func/feat_readers/reader_htk.py +++ b/example/speech-demo/io_func/feat_readers/reader_htk.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import numpy import stats from common import * @@ -24,7 +41,7 @@ def Read(self): # print 'Sample period = {}'.format(sampPeriod) # print 'Sample size = {}'.format(sampSize) # print 'Sample kind = {}'.format(sampKind) - dt = numpy.dtype([('sample',(numpy.float32,sampSize/4))]) + dt = numpy.dtype([('sample',(numpy.float32,sampSize/4))]) samples = numpy.fromfile(f,dt.newbyteorder('>' if self.byteOrder==ByteOrder.BigEndian else '<'),count=numSamples) self._markDone() @@ -33,5 +50,5 @@ def Read(self): labels = None else: labels = ReadLabel(self.labelFile) - + return samples[:]['sample'], labels diff --git a/example/speech-demo/io_func/feat_readers/reader_kaldi.py b/example/speech-demo/io_func/feat_readers/reader_kaldi.py index bad6a9d3e989..345934a91790 100644 --- a/example/speech-demo/io_func/feat_readers/reader_kaldi.py +++ b/example/speech-demo/io_func/feat_readers/reader_kaldi.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from common import * import random @@ -95,7 +112,7 @@ def Read(self): feat_rows = kaldi.MatrixF_NumRows(feat_value) feat_cols = kaldi.MatrixF_NumCols(feat_value) feat_data = kaldi.MatrixF_Data(feat_value) - + # never use numpy.ndarray(buf=) or numpy.ctypeslib.as_array # because you don't know if Python or C owns buffer # (even if you numpy.copy() resulting array) @@ -114,7 +131,7 @@ def Read(self): if self.targets_rspecifier is not None: if kaldi.RAPReader_HasKey(self.targets_reader, utt): tgt_value = kaldi.RAPReader_Value(self.targets_reader, utt) - + tgts = numpy.empty((feat_rows,), dtype=numpy.int32) # ok to use memmove because this is 1-dimensional array I made in C (no stride) tgts_numpy_ptr = ctypes.cast(tgts.ctypes.data, c_int_ptr) @@ -125,7 +142,7 @@ def Read(self): tgts = None else: tgts = None - + kaldi.SBFMReader_Next(self.feature_reader) #print "FEATS:", feats[0:5][0:5] diff --git a/example/speech-demo/io_func/feat_readers/stats.py b/example/speech-demo/io_func/feat_readers/stats.py index 70033ebae456..a2c847359dc9 100644 --- a/example/speech-demo/io_func/feat_readers/stats.py +++ b/example/speech-demo/io_func/feat_readers/stats.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import print_function import numpy diff --git a/example/speech-demo/io_func/feat_readers/writer_kaldi.py b/example/speech-demo/io_func/feat_readers/writer_kaldi.py index f331160a4f3d..0f8fb938087f 100644 --- a/example/speech-demo/io_func/feat_readers/writer_kaldi.py +++ b/example/speech-demo/io_func/feat_readers/writer_kaldi.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import sys import numpy import struct diff --git a/example/speech-demo/io_func/info.py b/example/speech-demo/io_func/info.py index 64bb77d49736..eaf95ab983bb 100644 --- a/example/speech-demo/io_func/info.py +++ b/example/speech-demo/io_func/info.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import os _mydir = os.path.dirname(__file__) or '.' diff --git a/example/speech-demo/io_func/kaldi_parser.py b/example/speech-demo/io_func/kaldi_parser.py index 8b1d67893b79..10a373d7138f 100644 --- a/example/speech-demo/io_func/kaldi_parser.py +++ b/example/speech-demo/io_func/kaldi_parser.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import print_function import struct import numpy as num @@ -199,4 +216,4 @@ def file2nnet_binary(filename): fout.write(' ' + str(int(layers[i + 1])) + ' ' + str(output_size) + '\n') else: fout.write(' ' + str(output_size) + ' ' + str(output_size) + '\n') -""" \ No newline at end of file +""" diff --git a/example/speech-demo/io_func/model_io.py b/example/speech-demo/io_func/model_io.py index 18496634e462..8b6e0436c22b 100755 --- a/example/speech-demo/io_func/model_io.py +++ b/example/speech-demo/io_func/model_io.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import print_function import numpy as np import os @@ -59,7 +76,7 @@ def _nnet2file(layers, set_layer_num = -1, filename='nnet.out', activation='sigm nnet_dict[dict_a] = array_2_string(layers[i].delta_params[0].get_value()) dict_a = str(i) + ' ' + activation + ' db' nnet_dict[dict_a] = array_2_string(layers[i].delta_params[1].get_value()) - + if layers[i].kahan: logger.info("Loading hidden kahan") dict_a = str(i) + ' ' + activation + ' W_carry' @@ -71,9 +88,9 @@ def _nnet2file(layers, set_layer_num = -1, filename='nnet.out', activation='sigm #dict_a = str(i) + ' ' + activation + ' db_carry' #nnet_dict[dict_a] = array_2_string(layers[i].delta_params_carry[1].get_value()) - if withfinal: + if withfinal: logger.info("Saving final layer ") - + dict_a = 'logreg W' nnet_dict[dict_a] = array_2_string((1.0 - factor[-1]) * layers[-1].params[0].get_value()) dict_a = 'logreg b' @@ -96,7 +113,7 @@ def _nnet2file(layers, set_layer_num = -1, filename='nnet.out', activation='sigm #dict_a = 'logreg db_carry' #nnet_dict[dict_a] = array_2_string(layers[-1].delta_params_carry[1].get_value()) - utils.pickle_save(nnet_dict, filename) + utils.pickle_save(nnet_dict, filename) def zero(x): x.set_value(np.zeros_like(x.get_value(borrow=True), dtype=theano.config.floatX)) @@ -147,14 +164,14 @@ def _file2nnet(layers, set_layer_num = -1, filename='nnet.in', activation='sigmo dict_key = str(i) + ' ' + activation + ' W' layers[i].params[0].set_value(factors[i] * factor * np.asarray(string_2_array(nnet_dict[dict_key]), dtype=theano.config.floatX)) - dict_key = str(i) + ' ' + activation + ' b' + dict_key = str(i) + ' ' + activation + ' b' layers[i].params[1].set_value(np.asarray(string_2_array(nnet_dict[dict_key]), dtype=theano.config.floatX)) if gradients: dict_key = str(i) + ' ' + activation + ' dW' layers[i].delta_params[0].set_value(np.asarray(string_2_array(nnet_dict[dict_key]), dtype=theano.config.floatX)) - dict_key = str(i) + ' ' + activation + ' db' - layers[i].delta_params[1].set_value(np.asarray(string_2_array(nnet_dict[dict_key]), dtype=theano.config.floatX)) + dict_key = str(i) + ' ' + activation + ' db' + layers[i].delta_params[1].set_value(np.asarray(string_2_array(nnet_dict[dict_key]), dtype=theano.config.floatX)) else: zero(layers[i].delta_params[0]) zero(layers[i].delta_params[1]) @@ -164,12 +181,12 @@ def _file2nnet(layers, set_layer_num = -1, filename='nnet.in', activation='sigmo logger.info("Loading hidden kahan") dict_key = str(i) + ' ' + activation + ' W_carry' layers[i].params_carry[0].set_value(np.asarray(string_2_array(nnet_dict[dict_key]), dtype=theano.config.floatX)) - dict_key = str(i) + ' ' + activation + ' b_carry' - layers[i].params_carry[1].set_value(np.asarray(string_2_array(nnet_dict[dict_key]), dtype=theano.config.floatX)) + dict_key = str(i) + ' ' + activation + ' b_carry' + layers[i].params_carry[1].set_value(np.asarray(string_2_array(nnet_dict[dict_key]), dtype=theano.config.floatX)) #dict_key = str(i) + ' ' + activation + ' dW_carry' #layers[i].delta_params_carry[0].set_value(np.asarray(string_2_array(nnet_dict[dict_key]), dtype=theano.config.floatX)) - #dict_key = str(i) + ' ' + activation + ' db_carry' - #layers[i].delta_params_carry[1].set_value(np.asarray(string_2_array(nnet_dict[dict_key]), dtype=theano.config.floatX)) + #dict_key = str(i) + ' ' + activation + ' db_carry' + #layers[i].delta_params_carry[1].set_value(np.asarray(string_2_array(nnet_dict[dict_key]), dtype=theano.config.floatX)) if layers[i].sync: layers[i].params_sync[0].set_value(layers[i].params[0].get_value().astype('float32')) @@ -197,12 +214,12 @@ def _file2nnet(layers, set_layer_num = -1, filename='nnet.in', activation='sigmo logger.info("Loading softmax kahan") dict_key = 'logreg W_carry' layers[-1].params_carry[0].set_value(np.asarray(string_2_array(nnet_dict[dict_key]), dtype=theano.config.floatX)) - dict_key = 'logreg b_carry' - layers[-1].params_carry[1].set_value(np.asarray(string_2_array(nnet_dict[dict_key]), dtype=theano.config.floatX)) + dict_key = 'logreg b_carry' + layers[-1].params_carry[1].set_value(np.asarray(string_2_array(nnet_dict[dict_key]), dtype=theano.config.floatX)) #dict_key = 'logreg dW_carry' #layers[-1].delta_params_carry[0].set_value(np.asarray(string_2_array(nnet_dict[dict_key]), dtype=theano.config.floatX)) - #dict_key = 'logreg db_carry' - #layers[-1].delta_params_carry[1].set_value(np.asarray(string_2_array(nnet_dict[dict_key]), dtype=theano.config.floatX)) + #dict_key = 'logreg db_carry' + #layers[-1].delta_params_carry[1].set_value(np.asarray(string_2_array(nnet_dict[dict_key]), dtype=theano.config.floatX)) if layers[-1].sync: layers[-1].params_sync[0].set_value(layers[-1].params[0].get_value().astype('float32')) @@ -220,10 +237,10 @@ def _cnn2file(conv_layers, filename='nnet.out', activation='sigmoid', withfinal= for i in xrange(n_layers): conv_layer = conv_layers[i] filter_shape = conv_layer.filter_shape - + for next_X in xrange(filter_shape[0]): for this_X in xrange(filter_shape[1]): - dict_a = 'W ' + str(i) + ' ' + str(next_X) + ' ' + str(this_X) + dict_a = 'W ' + str(i) + ' ' + str(next_X) + ' ' + str(this_X) if i == 0: nnet_dict[dict_a] = array_2_string(input_factor * (conv_layer.W.get_value())[next_X, this_X]) else: @@ -231,7 +248,7 @@ def _cnn2file(conv_layers, filename='nnet.out', activation='sigmoid', withfinal= dict_a = 'b ' + str(i) nnet_dict[dict_a] = array_2_string(conv_layer.b.get_value()) - + with open(filename, 'wb') as fp: json.dump(nnet_dict, fp, indent=2, sort_keys = True) fp.flush() @@ -252,7 +269,7 @@ def _file2cnn(conv_layers, filename='nnet.in', activation='sigmoid', withfinal=T dict_a = 'W ' + str(i) + ' ' + str(next_X) + ' ' + str(this_X) W_array[next_X, this_X, :, :] = factor * np.asarray(string_2_array(nnet_dict[dict_a])) - conv_layer.W.set_value(W_array) + conv_layer.W.set_value(W_array) dict_a = 'b ' + str(i) - conv_layer.b.set_value(np.asarray(string_2_array(nnet_dict[dict_a]), dtype=theano.config.floatX)) + conv_layer.b.set_value(np.asarray(string_2_array(nnet_dict[dict_a]), dtype=theano.config.floatX)) diff --git a/example/speech-demo/io_func/regr_feat_io.py b/example/speech-demo/io_func/regr_feat_io.py index 2f3c4ec9ffd0..a1737bf9ab32 100644 --- a/example/speech-demo/io_func/regr_feat_io.py +++ b/example/speech-demo/io_func/regr_feat_io.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import os import sys import random @@ -36,7 +53,7 @@ def read_by_matrix(self): def make_shared(self): self.input.make_shared() self.output.make_shared() - + def get_shared(self): iret = self.input.get_shared() oret = self.output.get_shared() @@ -56,13 +73,13 @@ def current_utt_id(self): def load_next_block(self): a = self.input.load_next_block() - b = self.output.load_next_block() + b = self.output.load_next_block() assert(a == b) return a def get_state(self): a = self.input.get_state() - b = self.output.get_state() + b = self.output.get_state() assert(a[0] == b[0]) assert(a[2] == b[2]) assert(a[3] == b[3]) @@ -72,4 +89,4 @@ def get_state(self): def set_state(self, state): self.input.set_state(state) - self.output.set_state(state) + self.output.set_state(state) diff --git a/example/speech-demo/io_func/utils.py b/example/speech-demo/io_func/utils.py index 513261ea6f4f..4ba8496c7fb7 100644 --- a/example/speech-demo/io_func/utils.py +++ b/example/speech-demo/io_func/utils.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import sys, subprocess, pickle, os, json, logging, socket import logging.config import datetime diff --git a/example/speech-demo/io_util.py b/example/speech-demo/io_util.py index 926f20fbb58d..e5bd74cb6fa7 100644 --- a/example/speech-demo/io_util.py +++ b/example/speech-demo/io_util.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx import numpy as np import sys @@ -310,7 +327,7 @@ def __init__(self, train_sets, batch_size, init_states, truncate_len=20, delay=5 self.data = [mx.nd.zeros((batch_size, truncate_len, feat_dim))] if has_label: self.label = [mx.nd.zeros((batch_size, truncate_len))] - + self.init_state_names = [x[0] for x in init_states] self.init_state_arrays = [mx.nd.zeros(x[1]) for x in init_states] @@ -368,14 +385,14 @@ def __iter__(self): next_utt_idx = self.batch_size is_pad = [False] * self.batch_size pad = 0 - + if self.time_major: np_data_buffer = np.zeros((self.truncate_len, self.batch_size, self.feat_dim)) np_label_buffer = np.zeros((self.truncate_len, self.batch_size)) else: np_data_buffer = np.zeros((self.batch_size, self.truncate_len, self.feat_dim)) np_label_buffer = np.zeros((self.batch_size, self.truncate_len)) - + utt_id_buffer = [None] * self.batch_size data_names = [self.data_name] + self.init_state_names @@ -432,7 +449,7 @@ def __iter__(self): else: np_data_buffer[i, :n_take, :] = fea_utt[idx_take] np_label_buffer[i, :n_take] = self.labels[idx][idx_take] - + if n_take < self.truncate_len: if self.time_major: np_data_buffer[n_take:, i, :] = 0 @@ -440,7 +457,7 @@ def __iter__(self): else: np_data_buffer[i, n_take:, :] = 0 np_label_buffer[i, n_take:] = 0 - + effective_sample_count -= self.truncate_len - n_take utt_inside_idx[i] += n_take @@ -450,11 +467,11 @@ def __iter__(self): if pad == self.batch_size: # finished all the senteces break - + self.data[0][:] = np_data_buffer self.label[0][:] = np_label_buffer - - data_batch = SimpleBatch(data_names, + + data_batch = SimpleBatch(data_names, self.data + self.init_state_arrays, label_names, self.label, bucket_key=None, utt_id=utt_id_buffer, diff --git a/example/speech-demo/lstm_proj.py b/example/speech-demo/lstm_proj.py index ae2271c800b7..a27518c604b0 100644 --- a/example/speech-demo/lstm_proj.py +++ b/example/speech-demo/lstm_proj.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint:skip-file import mxnet as mx import numpy as np @@ -17,7 +34,7 @@ def lstm(num_hidden, indata, prev_state, param, seqidx, layeridx, dropout=0., nu """LSTM Cell symbol""" if dropout > 0.: indata = mx.sym.Dropout(data=indata, p=dropout) - + i2h = mx.sym.FullyConnected(data=indata, weight=param.i2h_weight, bias=param.i2h_bias, @@ -115,7 +132,7 @@ def lstm_unroll(num_lstm_layer, seq_len, input_size, pred = mx.sym.Reshape(pred, shape=(-1, num_label)) label = mx.sym.Reshape(label, shape=(-1,)) if take_softmax: - sm = mx.sym.SoftmaxOutput(data=pred, label=label, ignore_label=0, + sm = mx.sym.SoftmaxOutput(data=pred, label=label, ignore_label=0, use_ignore=True, name='softmax') else: sm = pred diff --git a/example/speech-demo/make_stats.py b/example/speech-demo/make_stats.py index 440f514729d0..64991db20ad8 100644 --- a/example/speech-demo/make_stats.py +++ b/example/speech-demo/make_stats.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import re import sys sys.path.insert(0, "../../python") diff --git a/example/speech-demo/python_wrap/ctypes.cc b/example/speech-demo/python_wrap/ctypes.cc index cd77d471ba08..a2c79468ed30 100644 --- a/example/speech-demo/python_wrap/ctypes.cc +++ b/example/speech-demo/python_wrap/ctypes.cc @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + #include #include "util/table-types.h" @@ -143,7 +162,7 @@ extern "C" { RAPReader* RAPReader_new_char(char * rspecifier) { return new RAPReader(rspecifier); - } + } //bool HasKey (const std::string &key) int RAPReader_HasKey(RAPReader* r, char * key) { @@ -178,7 +197,7 @@ extern "C" { } vals[row] = pair.first; } - + return vals; } diff --git a/example/speech-demo/python_wrap/example_usage/example.py b/example/speech-demo/python_wrap/example_usage/example.py index 766bb6ebb3b5..d930327f196d 100644 --- a/example/speech-demo/python_wrap/example_usage/example.py +++ b/example/speech-demo/python_wrap/example_usage/example.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import print_function import ctypes import numpy @@ -53,7 +70,7 @@ def decl(f, restype, argtypes): print("-------- Kaldi SBFMReader and MatrixF class example --------") reader = kaldi.SBFMReader_new_char("scp:data.scp") - + # data.scp has exactly one utterance, assert it's there assert(not kaldi.SBFMReader_Done(reader)) @@ -63,7 +80,7 @@ def decl(f, restype, argtypes): feat_rows = kaldi.MatrixF_NumRows(feat_value) feat_cols = kaldi.MatrixF_NumCols(feat_value) feat_data = kaldi.MatrixF_Data(feat_value) - + # never use numpy.ndarray(buf=) or numpy.ctypeslib.as_array # because you don't know if Python or C owns buffer # (even if you numpy.copy() resulting array) diff --git a/example/speech-demo/run_ami.sh b/example/speech-demo/run_ami.sh index 6c4dc13bf0ff..0103fd1832ac 100755 --- a/example/speech-demo/run_ami.sh +++ b/example/speech-demo/run_ami.sh @@ -1,5 +1,23 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + # This script trains and evaluate LSTM models. There is no # discriminative training yet. # In this recipe, MXNet directly read Kaldi features and labels, diff --git a/example/speech-demo/run_timit.sh b/example/speech-demo/run_timit.sh index 4bc037dd62de..023ae6f2291f 100755 --- a/example/speech-demo/run_timit.sh +++ b/example/speech-demo/run_timit.sh @@ -1,5 +1,23 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + # This script trains and evaluate LSTM models. There is no # discriminative training yet. # In this recipe, MXNet directly read Kaldi features and labels, diff --git a/example/speech-demo/speechSGD.py b/example/speech-demo/speechSGD.py index 37fb89d51ead..931f40afc062 100644 --- a/example/speech-demo/speechSGD.py +++ b/example/speech-demo/speechSGD.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx from mxnet.ndarray import NDArray, zeros, clip, sqrt @@ -44,7 +61,7 @@ def create_state(self, index, weight): return None else: return zeros(weight.shape, weight.context, dtype=weight.dtype) - + def _get_lr(self, index): """get learning rate for index. diff --git a/example/speech-demo/tests/test_nothing.py b/example/speech-demo/tests/test_nothing.py index 1436522acd3a..d6e810f6e9e1 100644 --- a/example/speech-demo/tests/test_nothing.py +++ b/example/speech-demo/tests/test_nothing.py @@ -1,2 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + def test_nothing(): - pass \ No newline at end of file + pass diff --git a/example/speech-demo/tests/test_system.py b/example/speech-demo/tests/test_system.py index 9d2a4b9a0f18..a64879ae44ba 100644 --- a/example/speech-demo/tests/test_system.py +++ b/example/speech-demo/tests/test_system.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import print_function from pdnn.run_DNN import run_DNN from pdnn.run_RBM import run_RBM @@ -37,7 +54,7 @@ def test_rbm_dnn(): "with_final": 1 } mnist_conf["train_rbm"]["max_iters"] = 0 - run_RBM(mnist_conf) + run_RBM(mnist_conf) def test_sda_dnn(): banner("sda dnn") @@ -60,7 +77,7 @@ def test_sda_dnn(): "with_final": 1 } mnist_conf["train_sda"]["max_iters"] = 1 - run_SDA(mnist_conf) + run_SDA(mnist_conf) def test_dnn_eval(): banner("dnn cv") @@ -82,7 +99,7 @@ def test_dnn_eval(): eval_DNN(mnist_conf) mnist_conf["eval_dnn"] = {"mode": "per-feat", "batch_size": 1024} - eval_DNN(mnist_conf) + eval_DNN(mnist_conf) def test_dropout(): banner("dropout") diff --git a/example/speech-demo/train_lstm_proj.py b/example/speech-demo/train_lstm_proj.py index d2a7a2744253..5749b0c39df7 100644 --- a/example/speech-demo/train_lstm_proj.py +++ b/example/speech-demo/train_lstm_proj.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import re import sys sys.path.insert(0, "../../python") @@ -129,7 +146,7 @@ def do_training(training_method, args, module, data_train, data_val): mkpath(os.path.dirname(get_checkpoint_path(args))) batch_size = data_train.batch_size - batch_end_callbacks = [mx.callback.Speedometer(batch_size, + batch_end_callbacks = [mx.callback.Speedometer(batch_size, args.config.getint('train', 'show_every'))] eval_allow_extra = True if training_method == METHOD_TBPTT else False eval_metric = [mx.metric.np(CrossEntropy, allow_extra_outputs=eval_allow_extra), diff --git a/example/speech_recognition/arch_deepspeech.py b/example/speech_recognition/arch_deepspeech.py index 4288b246f3e5..e5b3d43ac07d 100644 --- a/example/speech_recognition/arch_deepspeech.py +++ b/example/speech_recognition/arch_deepspeech.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: disable=C0111, too-many-statements, too-many-locals # pylint: too-many-arguments,too-many-instance-attributes,too-many-locals,redefined-outer-name,fixme # pylint: disable=superfluous-parens, no-member, invalid-name diff --git a/example/speech_recognition/config_util.py b/example/speech_recognition/config_util.py index e8b7fda23506..09733917f924 100644 --- a/example/speech_recognition/config_util.py +++ b/example/speech_recognition/config_util.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import argparse import os import re diff --git a/example/speech_recognition/flac_to_wav.sh b/example/speech_recognition/flac_to_wav.sh index a622b60963e5..7fd53f8719e1 100644 --- a/example/speech_recognition/flac_to_wav.sh +++ b/example/speech_recognition/flac_to_wav.sh @@ -1,8 +1,25 @@ -# Convert all .flac files within this folder to .wav files - -find . -iname "*.flac" | wc - -for flacfile in `find . -iname "*.flac"` -do - sox "${flacfile%.*}.flac" -e signed -b 16 -c 1 -r 16000 "${flacfile%.*}.wav" -done +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Convert all .flac files within this folder to .wav files + +find . -iname "*.flac" | wc + +for flacfile in `find . -iname "*.flac"` +do + sox "${flacfile%.*}.flac" -e signed -b 16 -c 1 -r 16000 "${flacfile%.*}.wav" +done diff --git a/example/speech_recognition/label_util.py b/example/speech_recognition/label_util.py index 3eb56c516e04..dab1d1ef1b40 100644 --- a/example/speech_recognition/label_util.py +++ b/example/speech_recognition/label_util.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # -*- coding: utf-8 -*- import csv diff --git a/example/speech_recognition/log_util.py b/example/speech_recognition/log_util.py index 097cfbd1a00a..e61407f5f4d5 100644 --- a/example/speech_recognition/log_util.py +++ b/example/speech_recognition/log_util.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import logging import logging.handlers diff --git a/example/speech_recognition/main.py b/example/speech_recognition/main.py index 4ecb1168b51f..e45026343de7 100644 --- a/example/speech_recognition/main.py +++ b/example/speech_recognition/main.py @@ -1,351 +1,368 @@ -import json -import os -import sys -from collections import namedtuple -from datetime import datetime -from config_util import parse_args, parse_contexts, generate_file_path -from train import do_training -import mxnet as mx -from stt_io_iter import STTIter -from label_util import LabelUtil -from log_util import LogUtil -import numpy as np -from stt_datagenerator import DataGenerator -from stt_metric import STTMetric -from stt_bi_graphemes_util import generate_bi_graphemes_dictionary -from stt_bucketing_module import STTBucketingModule -from stt_io_bucketingiter import BucketSTTIter -sys.path.insert(0, "../../python") - -# os.environ['MXNET_ENGINE_TYPE'] = "NaiveEngine" -os.environ['MXNET_ENGINE_TYPE'] = "ThreadedEnginePerDevice" -os.environ['MXNET_ENABLE_GPU_P2P'] = "0" - -class WHCS: - width = 0 - height = 0 - channel = 0 - stride = 0 - -class ConfigLogger(object): - def __init__(self, log): - self.__log = log - - def __call__(self, config): - self.__log.info("Config:") - config.write(self) - - def write(self, data): - # stripping the data makes the output nicer and avoids empty lines - line = data.strip() - self.__log.info(line) - -def load_labelutil(labelUtil, is_bi_graphemes, language="en"): - if language == "en": - if is_bi_graphemes: - try: - labelUtil.load_unicode_set("resources/unicodemap_en_baidu_bi_graphemes.csv") - except: - raise Exception("There is no resources/unicodemap_en_baidu_bi_graphemes.csv." + - " Please set overwrite_bi_graphemes_dictionary True at train section") - else: - labelUtil.load_unicode_set("resources/unicodemap_en_baidu.csv") - else: - raise Exception("Error: Language Type: %s" % language) - - - -def load_data(args): - mode = args.config.get('common', 'mode') - if mode not in ['train', 'predict', 'load']: - raise Exception('mode must be the one of the followings - train,predict,load') - batch_size = args.config.getint('common', 'batch_size') - - whcs = WHCS() - whcs.width = args.config.getint('data', 'width') - whcs.height = args.config.getint('data', 'height') - whcs.channel = args.config.getint('data', 'channel') - whcs.stride = args.config.getint('data', 'stride') - save_dir = 'checkpoints' - model_name = args.config.get('common', 'prefix') - is_bi_graphemes = args.config.getboolean('common', 'is_bi_graphemes') - overwrite_meta_files = args.config.getboolean('train', 'overwrite_meta_files') - overwrite_bi_graphemes_dictionary = args.config.getboolean('train', 'overwrite_bi_graphemes_dictionary') - max_duration = args.config.getfloat('data', 'max_duration') - language = args.config.get('data', 'language') - - log = LogUtil().getlogger() - labelUtil = LabelUtil.getInstance() - if mode == "train" or mode == "load": - data_json = args.config.get('data', 'train_json') - val_json = args.config.get('data', 'val_json') - datagen = DataGenerator(save_dir=save_dir, model_name=model_name) - datagen.load_train_data(data_json, max_duration=max_duration) - datagen.load_validation_data(val_json, max_duration=max_duration) - if is_bi_graphemes: - if not os.path.isfile("resources/unicodemap_en_baidu_bi_graphemes.csv") or overwrite_bi_graphemes_dictionary: - load_labelutil(labelUtil=labelUtil, is_bi_graphemes=False, language=language) - generate_bi_graphemes_dictionary(datagen.train_texts+datagen.val_texts) - load_labelutil(labelUtil=labelUtil, is_bi_graphemes=is_bi_graphemes, language=language) - args.config.set('arch', 'n_classes', str(labelUtil.get_count())) - - if mode == "train": - if overwrite_meta_files: - log.info("Generate mean and std from samples") - normalize_target_k = args.config.getint('train', 'normalize_target_k') - datagen.sample_normalize(normalize_target_k, True) - else: - log.info("Read mean and std from meta files") - datagen.get_meta_from_file( - np.loadtxt(generate_file_path(save_dir, model_name, 'feats_mean')), - np.loadtxt(generate_file_path(save_dir, model_name, 'feats_std'))) - elif mode == "load": - # get feat_mean and feat_std to normalize dataset - datagen.get_meta_from_file( - np.loadtxt(generate_file_path(save_dir, model_name, 'feats_mean')), - np.loadtxt(generate_file_path(save_dir, model_name, 'feats_std'))) - - elif mode == 'predict': - test_json = args.config.get('data', 'test_json') - datagen = DataGenerator(save_dir=save_dir, model_name=model_name) - datagen.load_train_data(test_json, max_duration=max_duration) - labelutil = load_labelutil(labelUtil, is_bi_graphemes, language="en") - args.config.set('arch', 'n_classes', str(labelUtil.get_count())) - datagen.get_meta_from_file( - np.loadtxt(generate_file_path(save_dir, model_name, 'feats_mean')), - np.loadtxt(generate_file_path(save_dir, model_name, 'feats_std'))) - - is_batchnorm = args.config.getboolean('arch', 'is_batchnorm') - if batch_size == 1 and is_batchnorm and (mode == 'train' or mode == 'load'): - raise Warning('batch size 1 is too small for is_batchnorm') - - # sort file paths by its duration in ascending order to implement sortaGrad - if mode == "train" or mode == "load": - max_t_count = datagen.get_max_seq_length(partition="train") - max_label_length = \ - datagen.get_max_label_length(partition="train", is_bi_graphemes=is_bi_graphemes) - elif mode == "predict": - max_t_count = datagen.get_max_seq_length(partition="test") - max_label_length = \ - datagen.get_max_label_length(partition="test", is_bi_graphemes=is_bi_graphemes) - - args.config.set('arch', 'max_t_count', str(max_t_count)) - args.config.set('arch', 'max_label_length', str(max_label_length)) - from importlib import import_module - prepare_data_template = import_module(args.config.get('arch', 'arch_file')) - init_states = prepare_data_template.prepare_data(args) - sort_by_duration = (mode == "train") - is_bucketing = args.config.getboolean('arch', 'is_bucketing') - save_feature_as_csvfile = args.config.getboolean('train', 'save_feature_as_csvfile') - if is_bucketing: - buckets = json.loads(args.config.get('arch', 'buckets')) - data_loaded = BucketSTTIter(partition="train", - count=datagen.count, - datagen=datagen, - batch_size=batch_size, - num_label=max_label_length, - init_states=init_states, - seq_length=max_t_count, - width=whcs.width, - height=whcs.height, - sort_by_duration=sort_by_duration, - is_bi_graphemes=is_bi_graphemes, - buckets=buckets, - save_feature_as_csvfile=save_feature_as_csvfile) - else: - data_loaded = STTIter(partition="train", - count=datagen.count, - datagen=datagen, - batch_size=batch_size, - num_label=max_label_length, - init_states=init_states, - seq_length=max_t_count, - width=whcs.width, - height=whcs.height, - sort_by_duration=sort_by_duration, - is_bi_graphemes=is_bi_graphemes, - save_feature_as_csvfile=save_feature_as_csvfile) - - if mode == 'train' or mode == 'load': - if is_bucketing: - validation_loaded = BucketSTTIter(partition="validation", - count=datagen.val_count, - datagen=datagen, - batch_size=batch_size, - num_label=max_label_length, - init_states=init_states, - seq_length=max_t_count, - width=whcs.width, - height=whcs.height, - sort_by_duration=False, - is_bi_graphemes=is_bi_graphemes, - buckets=buckets, - save_feature_as_csvfile=save_feature_as_csvfile) - else: - validation_loaded = STTIter(partition="validation", - count=datagen.val_count, - datagen=datagen, - batch_size=batch_size, - num_label=max_label_length, - init_states=init_states, - seq_length=max_t_count, - width=whcs.width, - height=whcs.height, - sort_by_duration=False, - is_bi_graphemes=is_bi_graphemes, - save_feature_as_csvfile=save_feature_as_csvfile) - return data_loaded, validation_loaded, args - elif mode == 'predict': - return data_loaded, args - - -def load_model(args, contexts, data_train): - # load model from model_name prefix and epoch of model_num_epoch with gpu contexts of contexts - mode = args.config.get('common', 'mode') - load_optimizer_states = args.config.getboolean('load', 'load_optimizer_states') - is_start_from_batch = args.config.getboolean('load', 'is_start_from_batch') - - from importlib import import_module - symbol_template = import_module(args.config.get('arch', 'arch_file')) - is_bucketing = args.config.getboolean('arch', 'is_bucketing') - - if mode == 'train': - if is_bucketing: - bucketing_arch = symbol_template.BucketingArch(args) - model_loaded = bucketing_arch.get_sym_gen() - else: - model_loaded = symbol_template.arch(args) - model_num_epoch = None - elif mode == 'load' or mode == 'predict': - model_file = args.config.get('common', 'model_file') - model_name = os.path.splitext(model_file)[0] - model_num_epoch = int(model_name[-4:]) - if is_bucketing: - bucketing_arch = symbol_template.BucketingArch(args) - model_loaded = bucketing_arch.get_sym_gen() - else: - model_path = 'checkpoints/' + str(model_name[:-5]) - - data_names = [x[0] for x in data_train.provide_data] - label_names = [x[0] for x in data_train.provide_label] - - model_loaded = mx.module.Module.load( - prefix=model_path, epoch=model_num_epoch, context=contexts, - data_names=data_names, label_names=label_names, - load_optimizer_states=load_optimizer_states) - if is_start_from_batch: - import re - model_num_epoch = int(re.findall('\d+', model_file)[0]) - - return model_loaded, model_num_epoch - - -if __name__ == '__main__': - if len(sys.argv) <= 1: - raise Exception('cfg file path must be provided. ' + - 'ex)python main.py --configfile examplecfg.cfg') - args = parse_args(sys.argv[1]) - # set parameters from cfg file - # give random seed - random_seed = args.config.getint('common', 'random_seed') - mx_random_seed = args.config.getint('common', 'mx_random_seed') - # random seed for shuffling data list - if random_seed != -1: - np.random.seed(random_seed) - # set mx.random.seed to give seed for parameter initialization - if mx_random_seed != -1: - mx.random.seed(mx_random_seed) - else: - mx.random.seed(hash(datetime.now())) - # set log file name - log_filename = args.config.get('common', 'log_filename') - log = LogUtil(filename=log_filename).getlogger() - - # set parameters from data section(common) - mode = args.config.get('common', 'mode') - if mode not in ['train', 'predict', 'load']: - raise Exception( - 'Define mode in the cfg file first. ' + - 'train or predict or load can be the candidate for the mode.') - - # get meta file where character to number conversions are defined - - contexts = parse_contexts(args) - num_gpu = len(contexts) - batch_size = args.config.getint('common', 'batch_size') - # check the number of gpus is positive divisor of the batch size for data parallel - if batch_size % num_gpu != 0: - raise Exception('num_gpu should be positive divisor of batch_size') - if mode == "train" or mode == "load": - data_train, data_val, args = load_data(args) - elif mode == "predict": - data_train, args = load_data(args) - is_batchnorm = args.config.getboolean('arch', 'is_batchnorm') - is_bucketing = args.config.getboolean('arch', 'is_bucketing') - - # log current config - config_logger = ConfigLogger(log) - config_logger(args.config) - - # load model - model_loaded, model_num_epoch = load_model(args, contexts, data_train) - # if mode is 'train', it trains the model - if mode == 'train': - if is_bucketing: - module = STTBucketingModule( - sym_gen=model_loaded, - default_bucket_key=data_train.default_bucket_key, - context=contexts - ) - else: - data_names = [x[0] for x in data_train.provide_data] - label_names = [x[0] for x in data_train.provide_label] - module = mx.mod.Module(model_loaded, context=contexts, - data_names=data_names, label_names=label_names) - do_training(args=args, module=module, data_train=data_train, data_val=data_val) - # if mode is 'load', it loads model from the checkpoint and continues the training. - elif mode == 'load': - do_training(args=args, module=model_loaded, data_train=data_train, data_val=data_val, - begin_epoch=model_num_epoch + 1) - # if mode is 'predict', it predict label from the input by the input model - elif mode == 'predict': - # predict through data - if is_bucketing: - max_t_count = args.config.getint('arch', 'max_t_count') - load_optimizer_states = args.config.getboolean('load', 'load_optimizer_states') - model_file = args.config.get('common', 'model_file') - model_name = os.path.splitext(model_file)[0] - model_num_epoch = int(model_name[-4:]) - - model_path = 'checkpoints/' + str(model_name[:-5]) - model = STTBucketingModule( - sym_gen=model_loaded, - default_bucket_key=data_train.default_bucket_key, - context=contexts - ) - - model.bind(data_shapes=data_train.provide_data, - label_shapes=data_train.provide_label, - for_training=True) - _, arg_params, aux_params = mx.model.load_checkpoint(model_path, model_num_epoch) - model.set_params(arg_params, aux_params) - model_loaded = model - else: - model_loaded.bind(for_training=False, data_shapes=data_train.provide_data, - label_shapes=data_train.provide_label) - max_t_count = args.config.getint('arch', 'max_t_count') - eval_metric = STTMetric(batch_size=batch_size, num_gpu=num_gpu) - if is_batchnorm: - for nbatch, data_batch in enumerate(data_train): - model_loaded.forward(data_batch, is_train=False) - model_loaded.update_metric(eval_metric, data_batch.label) - else: - #model_loaded.score(eval_data=data_train, num_batch=None, - # eval_metric=eval_metric, reset=True) - for nbatch, data_batch in enumerate(data_train): - model_loaded.forward(data_batch, is_train=False) - model_loaded.update_metric(eval_metric, data_batch.label) - else: - raise Exception( - 'Define mode in the cfg file first. ' + - 'train or predict or load can be the candidate for the mode') +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +import json +import os +import sys +from collections import namedtuple +from datetime import datetime +from config_util import parse_args, parse_contexts, generate_file_path +from train import do_training +import mxnet as mx +from stt_io_iter import STTIter +from label_util import LabelUtil +from log_util import LogUtil +import numpy as np +from stt_datagenerator import DataGenerator +from stt_metric import STTMetric +from stt_bi_graphemes_util import generate_bi_graphemes_dictionary +from stt_bucketing_module import STTBucketingModule +from stt_io_bucketingiter import BucketSTTIter +sys.path.insert(0, "../../python") + +# os.environ['MXNET_ENGINE_TYPE'] = "NaiveEngine" +os.environ['MXNET_ENGINE_TYPE'] = "ThreadedEnginePerDevice" +os.environ['MXNET_ENABLE_GPU_P2P'] = "0" + +class WHCS: + width = 0 + height = 0 + channel = 0 + stride = 0 + +class ConfigLogger(object): + def __init__(self, log): + self.__log = log + + def __call__(self, config): + self.__log.info("Config:") + config.write(self) + + def write(self, data): + # stripping the data makes the output nicer and avoids empty lines + line = data.strip() + self.__log.info(line) + +def load_labelutil(labelUtil, is_bi_graphemes, language="en"): + if language == "en": + if is_bi_graphemes: + try: + labelUtil.load_unicode_set("resources/unicodemap_en_baidu_bi_graphemes.csv") + except: + raise Exception("There is no resources/unicodemap_en_baidu_bi_graphemes.csv." + + " Please set overwrite_bi_graphemes_dictionary True at train section") + else: + labelUtil.load_unicode_set("resources/unicodemap_en_baidu.csv") + else: + raise Exception("Error: Language Type: %s" % language) + + + +def load_data(args): + mode = args.config.get('common', 'mode') + if mode not in ['train', 'predict', 'load']: + raise Exception('mode must be the one of the followings - train,predict,load') + batch_size = args.config.getint('common', 'batch_size') + + whcs = WHCS() + whcs.width = args.config.getint('data', 'width') + whcs.height = args.config.getint('data', 'height') + whcs.channel = args.config.getint('data', 'channel') + whcs.stride = args.config.getint('data', 'stride') + save_dir = 'checkpoints' + model_name = args.config.get('common', 'prefix') + is_bi_graphemes = args.config.getboolean('common', 'is_bi_graphemes') + overwrite_meta_files = args.config.getboolean('train', 'overwrite_meta_files') + overwrite_bi_graphemes_dictionary = args.config.getboolean('train', 'overwrite_bi_graphemes_dictionary') + max_duration = args.config.getfloat('data', 'max_duration') + language = args.config.get('data', 'language') + + log = LogUtil().getlogger() + labelUtil = LabelUtil.getInstance() + if mode == "train" or mode == "load": + data_json = args.config.get('data', 'train_json') + val_json = args.config.get('data', 'val_json') + datagen = DataGenerator(save_dir=save_dir, model_name=model_name) + datagen.load_train_data(data_json, max_duration=max_duration) + datagen.load_validation_data(val_json, max_duration=max_duration) + if is_bi_graphemes: + if not os.path.isfile("resources/unicodemap_en_baidu_bi_graphemes.csv") or overwrite_bi_graphemes_dictionary: + load_labelutil(labelUtil=labelUtil, is_bi_graphemes=False, language=language) + generate_bi_graphemes_dictionary(datagen.train_texts+datagen.val_texts) + load_labelutil(labelUtil=labelUtil, is_bi_graphemes=is_bi_graphemes, language=language) + args.config.set('arch', 'n_classes', str(labelUtil.get_count())) + + if mode == "train": + if overwrite_meta_files: + log.info("Generate mean and std from samples") + normalize_target_k = args.config.getint('train', 'normalize_target_k') + datagen.sample_normalize(normalize_target_k, True) + else: + log.info("Read mean and std from meta files") + datagen.get_meta_from_file( + np.loadtxt(generate_file_path(save_dir, model_name, 'feats_mean')), + np.loadtxt(generate_file_path(save_dir, model_name, 'feats_std'))) + elif mode == "load": + # get feat_mean and feat_std to normalize dataset + datagen.get_meta_from_file( + np.loadtxt(generate_file_path(save_dir, model_name, 'feats_mean')), + np.loadtxt(generate_file_path(save_dir, model_name, 'feats_std'))) + + elif mode == 'predict': + test_json = args.config.get('data', 'test_json') + datagen = DataGenerator(save_dir=save_dir, model_name=model_name) + datagen.load_train_data(test_json, max_duration=max_duration) + labelutil = load_labelutil(labelUtil, is_bi_graphemes, language="en") + args.config.set('arch', 'n_classes', str(labelUtil.get_count())) + datagen.get_meta_from_file( + np.loadtxt(generate_file_path(save_dir, model_name, 'feats_mean')), + np.loadtxt(generate_file_path(save_dir, model_name, 'feats_std'))) + + is_batchnorm = args.config.getboolean('arch', 'is_batchnorm') + if batch_size == 1 and is_batchnorm and (mode == 'train' or mode == 'load'): + raise Warning('batch size 1 is too small for is_batchnorm') + + # sort file paths by its duration in ascending order to implement sortaGrad + if mode == "train" or mode == "load": + max_t_count = datagen.get_max_seq_length(partition="train") + max_label_length = \ + datagen.get_max_label_length(partition="train", is_bi_graphemes=is_bi_graphemes) + elif mode == "predict": + max_t_count = datagen.get_max_seq_length(partition="test") + max_label_length = \ + datagen.get_max_label_length(partition="test", is_bi_graphemes=is_bi_graphemes) + + args.config.set('arch', 'max_t_count', str(max_t_count)) + args.config.set('arch', 'max_label_length', str(max_label_length)) + from importlib import import_module + prepare_data_template = import_module(args.config.get('arch', 'arch_file')) + init_states = prepare_data_template.prepare_data(args) + sort_by_duration = (mode == "train") + is_bucketing = args.config.getboolean('arch', 'is_bucketing') + save_feature_as_csvfile = args.config.getboolean('train', 'save_feature_as_csvfile') + if is_bucketing: + buckets = json.loads(args.config.get('arch', 'buckets')) + data_loaded = BucketSTTIter(partition="train", + count=datagen.count, + datagen=datagen, + batch_size=batch_size, + num_label=max_label_length, + init_states=init_states, + seq_length=max_t_count, + width=whcs.width, + height=whcs.height, + sort_by_duration=sort_by_duration, + is_bi_graphemes=is_bi_graphemes, + buckets=buckets, + save_feature_as_csvfile=save_feature_as_csvfile) + else: + data_loaded = STTIter(partition="train", + count=datagen.count, + datagen=datagen, + batch_size=batch_size, + num_label=max_label_length, + init_states=init_states, + seq_length=max_t_count, + width=whcs.width, + height=whcs.height, + sort_by_duration=sort_by_duration, + is_bi_graphemes=is_bi_graphemes, + save_feature_as_csvfile=save_feature_as_csvfile) + + if mode == 'train' or mode == 'load': + if is_bucketing: + validation_loaded = BucketSTTIter(partition="validation", + count=datagen.val_count, + datagen=datagen, + batch_size=batch_size, + num_label=max_label_length, + init_states=init_states, + seq_length=max_t_count, + width=whcs.width, + height=whcs.height, + sort_by_duration=False, + is_bi_graphemes=is_bi_graphemes, + buckets=buckets, + save_feature_as_csvfile=save_feature_as_csvfile) + else: + validation_loaded = STTIter(partition="validation", + count=datagen.val_count, + datagen=datagen, + batch_size=batch_size, + num_label=max_label_length, + init_states=init_states, + seq_length=max_t_count, + width=whcs.width, + height=whcs.height, + sort_by_duration=False, + is_bi_graphemes=is_bi_graphemes, + save_feature_as_csvfile=save_feature_as_csvfile) + return data_loaded, validation_loaded, args + elif mode == 'predict': + return data_loaded, args + + +def load_model(args, contexts, data_train): + # load model from model_name prefix and epoch of model_num_epoch with gpu contexts of contexts + mode = args.config.get('common', 'mode') + load_optimizer_states = args.config.getboolean('load', 'load_optimizer_states') + is_start_from_batch = args.config.getboolean('load', 'is_start_from_batch') + + from importlib import import_module + symbol_template = import_module(args.config.get('arch', 'arch_file')) + is_bucketing = args.config.getboolean('arch', 'is_bucketing') + + if mode == 'train': + if is_bucketing: + bucketing_arch = symbol_template.BucketingArch(args) + model_loaded = bucketing_arch.get_sym_gen() + else: + model_loaded = symbol_template.arch(args) + model_num_epoch = None + elif mode == 'load' or mode == 'predict': + model_file = args.config.get('common', 'model_file') + model_name = os.path.splitext(model_file)[0] + model_num_epoch = int(model_name[-4:]) + if is_bucketing: + bucketing_arch = symbol_template.BucketingArch(args) + model_loaded = bucketing_arch.get_sym_gen() + else: + model_path = 'checkpoints/' + str(model_name[:-5]) + + data_names = [x[0] for x in data_train.provide_data] + label_names = [x[0] for x in data_train.provide_label] + + model_loaded = mx.module.Module.load( + prefix=model_path, epoch=model_num_epoch, context=contexts, + data_names=data_names, label_names=label_names, + load_optimizer_states=load_optimizer_states) + if is_start_from_batch: + import re + model_num_epoch = int(re.findall('\d+', model_file)[0]) + + return model_loaded, model_num_epoch + + +if __name__ == '__main__': + if len(sys.argv) <= 1: + raise Exception('cfg file path must be provided. ' + + 'ex)python main.py --configfile examplecfg.cfg') + args = parse_args(sys.argv[1]) + # set parameters from cfg file + # give random seed + random_seed = args.config.getint('common', 'random_seed') + mx_random_seed = args.config.getint('common', 'mx_random_seed') + # random seed for shuffling data list + if random_seed != -1: + np.random.seed(random_seed) + # set mx.random.seed to give seed for parameter initialization + if mx_random_seed != -1: + mx.random.seed(mx_random_seed) + else: + mx.random.seed(hash(datetime.now())) + # set log file name + log_filename = args.config.get('common', 'log_filename') + log = LogUtil(filename=log_filename).getlogger() + + # set parameters from data section(common) + mode = args.config.get('common', 'mode') + if mode not in ['train', 'predict', 'load']: + raise Exception( + 'Define mode in the cfg file first. ' + + 'train or predict or load can be the candidate for the mode.') + + # get meta file where character to number conversions are defined + + contexts = parse_contexts(args) + num_gpu = len(contexts) + batch_size = args.config.getint('common', 'batch_size') + # check the number of gpus is positive divisor of the batch size for data parallel + if batch_size % num_gpu != 0: + raise Exception('num_gpu should be positive divisor of batch_size') + if mode == "train" or mode == "load": + data_train, data_val, args = load_data(args) + elif mode == "predict": + data_train, args = load_data(args) + is_batchnorm = args.config.getboolean('arch', 'is_batchnorm') + is_bucketing = args.config.getboolean('arch', 'is_bucketing') + + # log current config + config_logger = ConfigLogger(log) + config_logger(args.config) + + # load model + model_loaded, model_num_epoch = load_model(args, contexts, data_train) + # if mode is 'train', it trains the model + if mode == 'train': + if is_bucketing: + module = STTBucketingModule( + sym_gen=model_loaded, + default_bucket_key=data_train.default_bucket_key, + context=contexts + ) + else: + data_names = [x[0] for x in data_train.provide_data] + label_names = [x[0] for x in data_train.provide_label] + module = mx.mod.Module(model_loaded, context=contexts, + data_names=data_names, label_names=label_names) + do_training(args=args, module=module, data_train=data_train, data_val=data_val) + # if mode is 'load', it loads model from the checkpoint and continues the training. + elif mode == 'load': + do_training(args=args, module=model_loaded, data_train=data_train, data_val=data_val, + begin_epoch=model_num_epoch + 1) + # if mode is 'predict', it predict label from the input by the input model + elif mode == 'predict': + # predict through data + if is_bucketing: + max_t_count = args.config.getint('arch', 'max_t_count') + load_optimizer_states = args.config.getboolean('load', 'load_optimizer_states') + model_file = args.config.get('common', 'model_file') + model_name = os.path.splitext(model_file)[0] + model_num_epoch = int(model_name[-4:]) + + model_path = 'checkpoints/' + str(model_name[:-5]) + model = STTBucketingModule( + sym_gen=model_loaded, + default_bucket_key=data_train.default_bucket_key, + context=contexts + ) + + model.bind(data_shapes=data_train.provide_data, + label_shapes=data_train.provide_label, + for_training=True) + _, arg_params, aux_params = mx.model.load_checkpoint(model_path, model_num_epoch) + model.set_params(arg_params, aux_params) + model_loaded = model + else: + model_loaded.bind(for_training=False, data_shapes=data_train.provide_data, + label_shapes=data_train.provide_label) + max_t_count = args.config.getint('arch', 'max_t_count') + eval_metric = STTMetric(batch_size=batch_size, num_gpu=num_gpu) + if is_batchnorm: + for nbatch, data_batch in enumerate(data_train): + model_loaded.forward(data_batch, is_train=False) + model_loaded.update_metric(eval_metric, data_batch.label) + else: + #model_loaded.score(eval_data=data_train, num_batch=None, + # eval_metric=eval_metric, reset=True) + for nbatch, data_batch in enumerate(data_train): + model_loaded.forward(data_batch, is_train=False) + model_loaded.update_metric(eval_metric, data_batch.label) + else: + raise Exception( + 'Define mode in the cfg file first. ' + + 'train or predict or load can be the candidate for the mode') diff --git a/example/speech_recognition/singleton.py b/example/speech_recognition/singleton.py index 16f129b41017..aa9531b9443c 100644 --- a/example/speech_recognition/singleton.py +++ b/example/speech_recognition/singleton.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import logging as log class Singleton: diff --git a/example/speech_recognition/stt_bi_graphemes_util.py b/example/speech_recognition/stt_bi_graphemes_util.py index b8246a09c137..7ac83142b7cf 100644 --- a/example/speech_recognition/stt_bi_graphemes_util.py +++ b/example/speech_recognition/stt_bi_graphemes_util.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import csv from collections import Counter diff --git a/example/speech_recognition/stt_bucketing_module.py b/example/speech_recognition/stt_bucketing_module.py index 796a3368a6ad..073f6bf649bf 100644 --- a/example/speech_recognition/stt_bucketing_module.py +++ b/example/speech_recognition/stt_bucketing_module.py @@ -1,13 +1,30 @@ -import mxnet as mx - - -class STTBucketingModule(mx.mod.BucketingModule): - - def save_checkpoint(self, prefix, epoch, save_optimizer_states=False): - symbol, data_names, label_names = self._sym_gen(self._default_bucket_key) - symbol.save('%s-symbol.json' % prefix) - param_name = '%s-%04d.params' % (prefix, epoch) - self.save_params(param_name) - if save_optimizer_states: - state_name = '%s-%04d.states' % (prefix, epoch) - self._curr_module.save_optimizer_states(state_name) \ No newline at end of file +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +import mxnet as mx + + +class STTBucketingModule(mx.mod.BucketingModule): + + def save_checkpoint(self, prefix, epoch, save_optimizer_states=False): + symbol, data_names, label_names = self._sym_gen(self._default_bucket_key) + symbol.save('%s-symbol.json' % prefix) + param_name = '%s-%04d.params' % (prefix, epoch) + self.save_params(param_name) + if save_optimizer_states: + state_name = '%s-%04d.states' % (prefix, epoch) + self._curr_module.save_optimizer_states(state_name) diff --git a/example/speech_recognition/stt_datagenerator.py b/example/speech_recognition/stt_datagenerator.py index d2a7b4b5cbae..8fafa7909377 100644 --- a/example/speech_recognition/stt_datagenerator.py +++ b/example/speech_recognition/stt_datagenerator.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import absolute_import, division, print_function import json @@ -55,7 +72,7 @@ def featurize(self, audio_clip, overwrite=False, save_feature_as_csvfile=False): """ return spectrogram_from_file( audio_clip, step=self.step, window=self.window, - max_freq=self.max_freq, overwrite=overwrite, + max_freq=self.max_freq, overwrite=overwrite, save_feature_as_csvfile=save_feature_as_csvfile) def load_metadata_from_desc_file(self, desc_file, partition='train', diff --git a/example/speech_recognition/stt_io_bucketingiter.py b/example/speech_recognition/stt_io_bucketingiter.py index 9655688f214f..41b93f3bb9e5 100644 --- a/example/speech_recognition/stt_io_bucketingiter.py +++ b/example/speech_recognition/stt_io_bucketingiter.py @@ -1,148 +1,165 @@ -from __future__ import print_function -import mxnet as mx -import sys -sys.path.insert(0, "../../python") - -import bisect -import random -import numpy as np - -BATCH_SIZE = 1 -SEQ_LENGTH = 0 -NUM_GPU = 1 - - -def get_label(buf, num_lable): - ret = np.zeros(num_lable) - for i in range(len(buf)): - ret[i] = int(buf[i]) - return ret - - -class BucketSTTIter(mx.io.DataIter): - def __init__(self, count, datagen, batch_size, num_label, init_states, seq_length, width, height, - sort_by_duration=True, - is_bi_graphemes=False, - partition="train", - buckets=[], - save_feature_as_csvfile=False - ): - super(BucketSTTIter, self).__init__() - - self.maxLabelLength = num_label - # global param - self.batch_size = batch_size - self.count = count - self.num_label = num_label - self.init_states = init_states - self.init_state_arrays = [mx.nd.zeros(x[1]) for x in init_states] - self.width = width - self.height = height - self.datagen = datagen - self.label = None - self.is_bi_graphemes = is_bi_graphemes - # self.partition = datagen.partition - if partition == 'train': - durations = datagen.train_durations - audio_paths = datagen.train_audio_paths - texts = datagen.train_texts - elif partition == 'validation': - durations = datagen.val_durations - audio_paths = datagen.val_audio_paths - texts = datagen.val_texts - elif partition == 'test': - durations = datagen.test_durations - audio_paths = datagen.test_audio_paths - texts = datagen.test_texts - else: - raise Exception("Invalid partition to load metadata. " - "Must be train/validation/test") - # if sortagrad - if sort_by_duration: - durations, audio_paths, texts = datagen.sort_by_duration(durations, - audio_paths, - texts) - else: - durations = durations - audio_paths = audio_paths - texts = texts - self.trainDataList = zip(durations, audio_paths, texts) - - self.trainDataIter = iter(self.trainDataList) - self.is_first_epoch = True - - data_lengths = [int(d*100) for d in durations] - if len(buckets) == 0: - buckets = [i for i, j in enumerate(np.bincount(data_lengths)) - if j >= batch_size] - if len(buckets) == 0: - raise Exception('There is no valid buckets. It may occured by large batch_size for each buckets. max bincount:%d batch_size:%d' % (max(np.bincount(data_lengths)), batch_size)) - buckets.sort() - ndiscard = 0 - self.data = [[] for _ in buckets] - for i, sent in enumerate(data_lengths): - buck = bisect.bisect_left(buckets, sent) - if buck == len(buckets): - ndiscard += 1 - continue - self.data[buck].append(self.trainDataList[i]) - if ndiscard != 0: - print("WARNING: discarded %d sentences longer than the largest bucket."% ndiscard) - - self.buckets = buckets - self.nddata = [] - self.ndlabel = [] - self.default_bucket_key = max(buckets) - - self.idx = [] - for i, buck in enumerate(self.data): - self.idx.extend([(i, j) for j in range(0, len(buck) - batch_size + 1, batch_size)]) - self.curr_idx = 0 - - self.provide_data = [('data', (self.batch_size, self.default_bucket_key , width * height))] + init_states - self.provide_label = [('label', (self.batch_size, self.maxLabelLength))] - self.save_feature_as_csvfile=save_feature_as_csvfile - - #self.reset() - - def reset(self): - """Resets the iterator to the beginning of the data.""" - self.curr_idx = 0 - random.shuffle(self.idx) - for buck in self.data: - np.random.shuffle(buck) - - def next(self): - """Returns the next batch of data.""" - if self.curr_idx == len(self.idx): - raise StopIteration - i, j = self.idx[self.curr_idx] - self.curr_idx += 1 - - audio_paths = [] - texts = [] - for duration, audio_path, text in self.data[i][j:j+self.batch_size]: - audio_paths.append(audio_path) - texts.append(text) - - if self.is_first_epoch: - data_set = self.datagen.prepare_minibatch(audio_paths, texts, overwrite=True, - is_bi_graphemes=self.is_bi_graphemes, - seq_length=self.buckets[i], - save_feature_as_csvfile=self.save_feature_as_csvfile) - else: - data_set = self.datagen.prepare_minibatch(audio_paths, texts, overwrite=False, - is_bi_graphemes=self.is_bi_graphemes, - seq_length=self.buckets[i], - save_feature_as_csvfile=self.save_feature_as_csvfile) - - data_all = [mx.nd.array(data_set['x'])] + self.init_state_arrays - label_all = [mx.nd.array(data_set['y'])] - - self.label = label_all - provide_data = [('data', (self.batch_size, self.buckets[i], self.width * self.height))] + self.init_states - - return mx.io.DataBatch(data_all, label_all, pad=0, - bucket_key=self.buckets[i], - provide_data=provide_data, - provide_label=self.provide_label) +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +from __future__ import print_function +import mxnet as mx +import sys +sys.path.insert(0, "../../python") + +import bisect +import random +import numpy as np + +BATCH_SIZE = 1 +SEQ_LENGTH = 0 +NUM_GPU = 1 + + +def get_label(buf, num_lable): + ret = np.zeros(num_lable) + for i in range(len(buf)): + ret[i] = int(buf[i]) + return ret + + +class BucketSTTIter(mx.io.DataIter): + def __init__(self, count, datagen, batch_size, num_label, init_states, seq_length, width, height, + sort_by_duration=True, + is_bi_graphemes=False, + partition="train", + buckets=[], + save_feature_as_csvfile=False + ): + super(BucketSTTIter, self).__init__() + + self.maxLabelLength = num_label + # global param + self.batch_size = batch_size + self.count = count + self.num_label = num_label + self.init_states = init_states + self.init_state_arrays = [mx.nd.zeros(x[1]) for x in init_states] + self.width = width + self.height = height + self.datagen = datagen + self.label = None + self.is_bi_graphemes = is_bi_graphemes + # self.partition = datagen.partition + if partition == 'train': + durations = datagen.train_durations + audio_paths = datagen.train_audio_paths + texts = datagen.train_texts + elif partition == 'validation': + durations = datagen.val_durations + audio_paths = datagen.val_audio_paths + texts = datagen.val_texts + elif partition == 'test': + durations = datagen.test_durations + audio_paths = datagen.test_audio_paths + texts = datagen.test_texts + else: + raise Exception("Invalid partition to load metadata. " + "Must be train/validation/test") + # if sortagrad + if sort_by_duration: + durations, audio_paths, texts = datagen.sort_by_duration(durations, + audio_paths, + texts) + else: + durations = durations + audio_paths = audio_paths + texts = texts + self.trainDataList = zip(durations, audio_paths, texts) + + self.trainDataIter = iter(self.trainDataList) + self.is_first_epoch = True + + data_lengths = [int(d*100) for d in durations] + if len(buckets) == 0: + buckets = [i for i, j in enumerate(np.bincount(data_lengths)) + if j >= batch_size] + if len(buckets) == 0: + raise Exception('There is no valid buckets. It may occured by large batch_size for each buckets. max bincount:%d batch_size:%d' % (max(np.bincount(data_lengths)), batch_size)) + buckets.sort() + ndiscard = 0 + self.data = [[] for _ in buckets] + for i, sent in enumerate(data_lengths): + buck = bisect.bisect_left(buckets, sent) + if buck == len(buckets): + ndiscard += 1 + continue + self.data[buck].append(self.trainDataList[i]) + if ndiscard != 0: + print("WARNING: discarded %d sentences longer than the largest bucket."% ndiscard) + + self.buckets = buckets + self.nddata = [] + self.ndlabel = [] + self.default_bucket_key = max(buckets) + + self.idx = [] + for i, buck in enumerate(self.data): + self.idx.extend([(i, j) for j in range(0, len(buck) - batch_size + 1, batch_size)]) + self.curr_idx = 0 + + self.provide_data = [('data', (self.batch_size, self.default_bucket_key , width * height))] + init_states + self.provide_label = [('label', (self.batch_size, self.maxLabelLength))] + self.save_feature_as_csvfile=save_feature_as_csvfile + + #self.reset() + + def reset(self): + """Resets the iterator to the beginning of the data.""" + self.curr_idx = 0 + random.shuffle(self.idx) + for buck in self.data: + np.random.shuffle(buck) + + def next(self): + """Returns the next batch of data.""" + if self.curr_idx == len(self.idx): + raise StopIteration + i, j = self.idx[self.curr_idx] + self.curr_idx += 1 + + audio_paths = [] + texts = [] + for duration, audio_path, text in self.data[i][j:j+self.batch_size]: + audio_paths.append(audio_path) + texts.append(text) + + if self.is_first_epoch: + data_set = self.datagen.prepare_minibatch(audio_paths, texts, overwrite=True, + is_bi_graphemes=self.is_bi_graphemes, + seq_length=self.buckets[i], + save_feature_as_csvfile=self.save_feature_as_csvfile) + else: + data_set = self.datagen.prepare_minibatch(audio_paths, texts, overwrite=False, + is_bi_graphemes=self.is_bi_graphemes, + seq_length=self.buckets[i], + save_feature_as_csvfile=self.save_feature_as_csvfile) + + data_all = [mx.nd.array(data_set['x'])] + self.init_state_arrays + label_all = [mx.nd.array(data_set['y'])] + + self.label = label_all + provide_data = [('data', (self.batch_size, self.buckets[i], self.width * self.height))] + self.init_states + + return mx.io.DataBatch(data_all, label_all, pad=0, + bucket_key=self.buckets[i], + provide_data=provide_data, + provide_label=self.provide_label) diff --git a/example/speech_recognition/stt_io_iter.py b/example/speech_recognition/stt_io_iter.py index 5ae65191c840..6c9bacd1a526 100644 --- a/example/speech_recognition/stt_io_iter.py +++ b/example/speech_recognition/stt_io_iter.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import print_function import sys diff --git a/example/speech_recognition/stt_layer_batchnorm.py b/example/speech_recognition/stt_layer_batchnorm.py index 5b73f4f9f890..eb61ba6e597e 100644 --- a/example/speech_recognition/stt_layer_batchnorm.py +++ b/example/speech_recognition/stt_layer_batchnorm.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx diff --git a/example/speech_recognition/stt_layer_conv.py b/example/speech_recognition/stt_layer_conv.py index ab0035e4803b..c34ddf21844d 100644 --- a/example/speech_recognition/stt_layer_conv.py +++ b/example/speech_recognition/stt_layer_conv.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx diff --git a/example/speech_recognition/stt_layer_fc.py b/example/speech_recognition/stt_layer_fc.py index f435922426c5..b3db1b163ffa 100644 --- a/example/speech_recognition/stt_layer_fc.py +++ b/example/speech_recognition/stt_layer_fc.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx from stt_layer_batchnorm import batchnorm diff --git a/example/speech_recognition/stt_layer_gru.py b/example/speech_recognition/stt_layer_gru.py index 89af1c72216d..0dd132825235 100644 --- a/example/speech_recognition/stt_layer_gru.py +++ b/example/speech_recognition/stt_layer_gru.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from collections import namedtuple import mxnet as mx diff --git a/example/speech_recognition/stt_layer_lstm.py b/example/speech_recognition/stt_layer_lstm.py index 93b4ca09b908..4adbbd4bec1f 100644 --- a/example/speech_recognition/stt_layer_lstm.py +++ b/example/speech_recognition/stt_layer_lstm.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint:skip-file from collections import namedtuple diff --git a/example/speech_recognition/stt_layer_slice.py b/example/speech_recognition/stt_layer_slice.py index 6b434ec1049b..ac7eae9ae884 100644 --- a/example/speech_recognition/stt_layer_slice.py +++ b/example/speech_recognition/stt_layer_slice.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx diff --git a/example/speech_recognition/stt_layer_warpctc.py b/example/speech_recognition/stt_layer_warpctc.py index 9f97adfe5de1..c821f9c666ab 100644 --- a/example/speech_recognition/stt_layer_warpctc.py +++ b/example/speech_recognition/stt_layer_warpctc.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx diff --git a/example/speech_recognition/stt_metric.py b/example/speech_recognition/stt_metric.py index 1c5f4408a60e..fc1916b40c38 100644 --- a/example/speech_recognition/stt_metric.py +++ b/example/speech_recognition/stt_metric.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx import numpy as np diff --git a/example/speech_recognition/stt_utils.py b/example/speech_recognition/stt_utils.py index 3c7ffce0f980..0539d59f37af 100644 --- a/example/speech_recognition/stt_utils.py +++ b/example/speech_recognition/stt_utils.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import logging import os import os.path @@ -104,7 +121,7 @@ def spectrogram_from_file(filename, step=10, window=20, max_freq=None, """ csvfilename = filename.replace(".wav", ".csv") - if (os.path.isfile(csvfilename) is False) or overwrite: + if (os.path.isfile(csvfilename) is False) or overwrite: with soundfile.SoundFile(filename) as sound_file: audio = sound_file.read(dtype='float32') sample_rate = sound_file.samplerate diff --git a/example/speech_recognition/train.py b/example/speech_recognition/train.py index f3a7555529e3..0d04e4e47a5f 100644 --- a/example/speech_recognition/train.py +++ b/example/speech_recognition/train.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import sys sys.path.insert(0, "../../python") diff --git a/example/ssd/config/config.py b/example/ssd/config/config.py index 278b770febe9..38a07b5e655d 100644 --- a/example/ssd/config/config.py +++ b/example/ssd/config/config.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import os from utils import DotDict, namedtuple_with_defaults, zip_namedtuple, config_as_dict diff --git a/example/ssd/config/utils.py b/example/ssd/config/utils.py index 1d66655e8bee..5c8af6a4dd93 100644 --- a/example/ssd/config/utils.py +++ b/example/ssd/config/utils.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import collections class DotDict(dict): diff --git a/example/ssd/data/demo/download_demo_images.py b/example/ssd/data/demo/download_demo_images.py index 8546aa5e939e..554ba7e4e1aa 100755 --- a/example/ssd/data/demo/download_demo_images.py +++ b/example/ssd/data/demo/download_demo_images.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import os wd = os.path.dirname(os.path.realpath(__file__)) diff --git a/example/ssd/dataset/concat_db.py b/example/ssd/dataset/concat_db.py index da9e151054c3..cb6c99e34fc1 100644 --- a/example/ssd/dataset/concat_db.py +++ b/example/ssd/dataset/concat_db.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from imdb import Imdb import random diff --git a/example/ssd/dataset/imdb.py b/example/ssd/dataset/imdb.py index 279fe9cab4a1..4fbb5d85c873 100644 --- a/example/ssd/dataset/imdb.py +++ b/example/ssd/dataset/imdb.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import numpy as np import os.path as osp diff --git a/example/ssd/dataset/iterator.py b/example/ssd/dataset/iterator.py index 5cefece1c147..8b6857b94edf 100644 --- a/example/ssd/dataset/iterator.py +++ b/example/ssd/dataset/iterator.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx import numpy as np import cv2 diff --git a/example/ssd/dataset/mscoco.py b/example/ssd/dataset/mscoco.py index b46b22745413..ff2a753ddc6f 100644 --- a/example/ssd/dataset/mscoco.py +++ b/example/ssd/dataset/mscoco.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import os import numpy as np from imdb import Imdb diff --git a/example/ssd/dataset/pascal_voc.py b/example/ssd/dataset/pascal_voc.py index 31e287e3cbac..d9868905514c 100644 --- a/example/ssd/dataset/pascal_voc.py +++ b/example/ssd/dataset/pascal_voc.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import print_function import os import numpy as np diff --git a/example/ssd/dataset/pycocotools/__init__.py b/example/ssd/dataset/pycocotools/__init__.py index 3f7d85bba884..2f4e0d430df9 100755 --- a/example/ssd/dataset/pycocotools/__init__.py +++ b/example/ssd/dataset/pycocotools/__init__.py @@ -1 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + __author__ = 'tylin' diff --git a/example/ssd/dataset/pycocotools/coco.py b/example/ssd/dataset/pycocotools/coco.py index a8939f64a38c..4dd54ad69d15 100755 --- a/example/ssd/dataset/pycocotools/coco.py +++ b/example/ssd/dataset/pycocotools/coco.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + __author__ = 'tylin' __version__ = '2.0' # Interface for accessing the Microsoft COCO dataset. diff --git a/example/ssd/dataset/testdb.py b/example/ssd/dataset/testdb.py index 7477d77c0aef..9a4b985d8e6b 100644 --- a/example/ssd/dataset/testdb.py +++ b/example/ssd/dataset/testdb.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import os from imdb import Imdb diff --git a/example/ssd/dataset/yolo_format.py b/example/ssd/dataset/yolo_format.py index ce6605f8c637..f1b73d032293 100644 --- a/example/ssd/dataset/yolo_format.py +++ b/example/ssd/dataset/yolo_format.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import os import numpy as np from imdb import Imdb diff --git a/example/ssd/demo.py b/example/ssd/demo.py index bda4606543d7..521267550b41 100644 --- a/example/ssd/demo.py +++ b/example/ssd/demo.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import argparse import tools.find_mxnet import mxnet as mx diff --git a/example/ssd/deploy.py b/example/ssd/deploy.py index aa70cac548c4..415f334fdc2d 100644 --- a/example/ssd/deploy.py +++ b/example/ssd/deploy.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import print_function import argparse import tools.find_mxnet diff --git a/example/ssd/detect/detector.py b/example/ssd/detect/detector.py index 19b78f63f561..b6adac110cf7 100644 --- a/example/ssd/detect/detector.py +++ b/example/ssd/detect/detector.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import print_function import mxnet as mx import numpy as np diff --git a/example/ssd/evaluate.py b/example/ssd/evaluate.py index 65e0b30b985c..4e7f0a4b9173 100644 --- a/example/ssd/evaluate.py +++ b/example/ssd/evaluate.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import argparse import tools.find_mxnet import mxnet as mx diff --git a/example/ssd/evaluate/eval_metric.py b/example/ssd/evaluate/eval_metric.py index bb03e0133ece..bb2b77b3d52b 100644 --- a/example/ssd/evaluate/eval_metric.py +++ b/example/ssd/evaluate/eval_metric.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx import numpy as np diff --git a/example/ssd/evaluate/eval_voc.py b/example/ssd/evaluate/eval_voc.py index d16856e35009..0ba7f7eaf843 100644 --- a/example/ssd/evaluate/eval_voc.py +++ b/example/ssd/evaluate/eval_voc.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """ given a pascal voc imdb, compute mAP """ diff --git a/example/ssd/evaluate/evaluate_net.py b/example/ssd/evaluate/evaluate_net.py index 4c629f892bd6..7f1a32dea518 100644 --- a/example/ssd/evaluate/evaluate_net.py +++ b/example/ssd/evaluate/evaluate_net.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import print_function import os import sys diff --git a/example/ssd/symbol/common.py b/example/ssd/symbol/common.py index 474d3ea944b9..ea58c1599add 100644 --- a/example/ssd/symbol/common.py +++ b/example/ssd/symbol/common.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx import numpy as np diff --git a/example/ssd/symbol/inceptionv3.py b/example/ssd/symbol/inceptionv3.py index 1c38ae6d57c9..6022ce505a8f 100644 --- a/example/ssd/symbol/inceptionv3.py +++ b/example/ssd/symbol/inceptionv3.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """ Inception V3, suitable for images with around 299 x 299 diff --git a/example/ssd/symbol/legacy_vgg16_ssd_300.py b/example/ssd/symbol/legacy_vgg16_ssd_300.py index 257fdd6acb7a..c1f8ea7cb88e 100644 --- a/example/ssd/symbol/legacy_vgg16_ssd_300.py +++ b/example/ssd/symbol/legacy_vgg16_ssd_300.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx from common import legacy_conv_act_layer from common import multibox_layer diff --git a/example/ssd/symbol/legacy_vgg16_ssd_512.py b/example/ssd/symbol/legacy_vgg16_ssd_512.py index 15424f93e643..6cc3aa274a73 100644 --- a/example/ssd/symbol/legacy_vgg16_ssd_512.py +++ b/example/ssd/symbol/legacy_vgg16_ssd_512.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx from common import legacy_conv_act_layer from common import multibox_layer diff --git a/example/ssd/symbol/resnet.py b/example/ssd/symbol/resnet.py index 9c121e8f9da7..d7dc3cc5bd76 100644 --- a/example/ssd/symbol/resnet.py +++ b/example/ssd/symbol/resnet.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + ''' Adapted from https://github.com/tornadomeet/ResNet/blob/master/symbol_resnet.py Original author Wei Wu diff --git a/example/ssd/symbol/symbol_builder.py b/example/ssd/symbol/symbol_builder.py index 48c9d1d53f34..4cd7f88ea312 100644 --- a/example/ssd/symbol/symbol_builder.py +++ b/example/ssd/symbol/symbol_builder.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx from common import multi_layer_feature, multibox_layer diff --git a/example/ssd/symbol/symbol_factory.py b/example/ssd/symbol/symbol_factory.py index ef156f194c88..c451cd61ab83 100644 --- a/example/ssd/symbol/symbol_factory.py +++ b/example/ssd/symbol/symbol_factory.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """Presets for various network configurations""" import logging import symbol_builder diff --git a/example/ssd/symbol/vgg16_reduced.py b/example/ssd/symbol/vgg16_reduced.py index c6a55b117cf8..16535e6dc22d 100644 --- a/example/ssd/symbol/vgg16_reduced.py +++ b/example/ssd/symbol/vgg16_reduced.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx def get_symbol(num_classes=1000, **kwargs): diff --git a/example/ssd/tools/caffe_converter/caffe_parse/parse_from_protobuf.py b/example/ssd/tools/caffe_converter/caffe_parse/parse_from_protobuf.py index b828ca28dff0..862049a770b1 100644 --- a/example/ssd/tools/caffe_converter/caffe_parse/parse_from_protobuf.py +++ b/example/ssd/tools/caffe_converter/caffe_parse/parse_from_protobuf.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from google.protobuf import text_format import numpy as np import caffe_parse.caffe_pb2 as caffe_pb2 diff --git a/example/ssd/tools/caffe_converter/convert_model.py b/example/ssd/tools/caffe_converter/convert_model.py index a06b655b53d9..f17a3f250ecf 100644 --- a/example/ssd/tools/caffe_converter/convert_model.py +++ b/example/ssd/tools/caffe_converter/convert_model.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import print_function import sys import os.path as osp diff --git a/example/ssd/tools/caffe_converter/convert_symbol.py b/example/ssd/tools/caffe_converter/convert_symbol.py index 63b044a46c97..10510aa92569 100644 --- a/example/ssd/tools/caffe_converter/convert_symbol.py +++ b/example/ssd/tools/caffe_converter/convert_symbol.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import print_function from google.protobuf import text_format import argparse diff --git a/example/ssd/tools/caffe_converter/mean_image.py b/example/ssd/tools/caffe_converter/mean_image.py index d28a750271e0..e07c6fb281c0 100644 --- a/example/ssd/tools/caffe_converter/mean_image.py +++ b/example/ssd/tools/caffe_converter/mean_image.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx import numpy as np import argparse diff --git a/example/ssd/tools/find_mxnet.py b/example/ssd/tools/find_mxnet.py index 66545f38ba0e..0ad64cca01d7 100644 --- a/example/ssd/tools/find_mxnet.py +++ b/example/ssd/tools/find_mxnet.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + try: import mxnet as mx except ImportError: diff --git a/example/ssd/tools/prepare_coco.sh b/example/ssd/tools/prepare_coco.sh index 1b11f9384946..fd34bd55513a 100644 --- a/example/ssd/tools/prepare_coco.sh +++ b/example/ssd/tools/prepare_coco.sh @@ -1,4 +1,22 @@ #!/usr/bin/env bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" python $DIR/prepare_dataset.py --dataset coco --set train2014,valminusminival2014 --target $DIR/../data/train.lst --root $DIR/../data/coco python $DIR/prepare_dataset.py --dataset coco --set minival2014 --target $DIR/../data/val.lst --shuffle False --root $DIR/../data/coco diff --git a/example/ssd/tools/prepare_dataset.py b/example/ssd/tools/prepare_dataset.py index 12b090c27841..9b4fceb221ca 100644 --- a/example/ssd/tools/prepare_dataset.py +++ b/example/ssd/tools/prepare_dataset.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import print_function import sys, os import argparse diff --git a/example/ssd/tools/prepare_pascal.sh b/example/ssd/tools/prepare_pascal.sh index 954327aeefa6..1c23cd5b85c9 100644 --- a/example/ssd/tools/prepare_pascal.sh +++ b/example/ssd/tools/prepare_pascal.sh @@ -1,4 +1,22 @@ #!/usr/bin/env bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" python $DIR/prepare_dataset.py --dataset pascal --year 2007,2012 --set trainval --target $DIR/../data/train.lst python $DIR/prepare_dataset.py --dataset pascal --year 2007 --set test --target $DIR/../data/val.lst --shuffle False diff --git a/example/ssd/tools/rand_sampler.py b/example/ssd/tools/rand_sampler.py index d2ed3ad9afe7..7f0cb6f8ba3d 100644 --- a/example/ssd/tools/rand_sampler.py +++ b/example/ssd/tools/rand_sampler.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import numpy as np import math diff --git a/example/ssd/tools/visualize_net.py b/example/ssd/tools/visualize_net.py index f72d6a6678fa..b3b714a7f49b 100644 --- a/example/ssd/tools/visualize_net.py +++ b/example/ssd/tools/visualize_net.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import print_function import find_mxnet import mxnet as mx diff --git a/example/ssd/train.py b/example/ssd/train.py index 62ad2c4e0a78..f08aafb97b8f 100644 --- a/example/ssd/train.py +++ b/example/ssd/train.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import argparse import tools.find_mxnet import mxnet as mx diff --git a/example/ssd/train/metric.py b/example/ssd/train/metric.py index c7d007832c4f..731f8fcc19f4 100644 --- a/example/ssd/train/metric.py +++ b/example/ssd/train/metric.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx import numpy as np diff --git a/example/ssd/train/train_net.py b/example/ssd/train/train_net.py index 54cae05a4421..767e3244d406 100644 Binary files a/example/ssd/train/train_net.py and b/example/ssd/train/train_net.py differ diff --git a/example/stochastic-depth/sd_cifar10.py b/example/stochastic-depth/sd_cifar10.py index 9c6f2736600d..c123562cf7ef 100644 --- a/example/stochastic-depth/sd_cifar10.py +++ b/example/stochastic-depth/sd_cifar10.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + ########################################################################################### # Implementation of the stochastic depth algorithm described in the paper # diff --git a/example/stochastic-depth/sd_mnist.py b/example/stochastic-depth/sd_mnist.py index 8a13d4bb532d..7eb93741ff5a 100644 --- a/example/stochastic-depth/sd_mnist.py +++ b/example/stochastic-depth/sd_mnist.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + ################################################################################ # A sanity check mainly for debugging purpose. See sd_cifar10.py for a non-trivial # example of stochastic depth on cifar10. diff --git a/example/stochastic-depth/sd_module.py b/example/stochastic-depth/sd_module.py index ae8cfe0ba255..f30913d550e2 100644 --- a/example/stochastic-depth/sd_module.py +++ b/example/stochastic-depth/sd_module.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import logging import mxnet as mx import numpy as np diff --git a/example/svm_mnist/svm_mnist.py b/example/svm_mnist/svm_mnist.py index ac2702e1260d..679540198d28 100644 --- a/example/svm_mnist/svm_mnist.py +++ b/example/svm_mnist/svm_mnist.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + ############################################################# ## Please read the README.md document for better reference ## diff --git a/example/torch/data.py b/example/torch/data.py index d39821f52145..0ca8e1fd6653 100644 --- a/example/torch/data.py +++ b/example/torch/data.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file """ data iterator for mnist """ import sys diff --git a/example/torch/torch_function.py b/example/torch/torch_function.py index 4ea4558475ec..af285de22713 100644 --- a/example/torch/torch_function.py +++ b/example/torch/torch_function.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import print_function import mxnet as mx x = mx.th.randn(2, 2, ctx=mx.cpu(0)) diff --git a/example/torch/torch_module.py b/example/torch/torch_module.py index 02eacc311d73..1595173b02d4 100644 --- a/example/torch/torch_module.py +++ b/example/torch/torch_module.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file from data import mnist_iterator import mxnet as mx diff --git a/example/utils/get_data.py b/example/utils/get_data.py index 64a753218225..861d16cdbad9 100644 --- a/example/utils/get_data.py +++ b/example/utils/get_data.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import os import mxnet as mx diff --git a/example/warpctc/infer_ocr.py b/example/warpctc/infer_ocr.py index 2d496f06b1f4..d469990ff937 100644 --- a/example/warpctc/infer_ocr.py +++ b/example/warpctc/infer_ocr.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding=utf-8 # pylint: disable=C0111,too-many-arguments,too-many-instance-attributes,too-many-locals,redefined-outer-name,fixme # pylint: disable=superfluous-parens, no-member, invalid-name diff --git a/example/warpctc/lstm.py b/example/warpctc/lstm.py index 4be4a0d914f1..9e0e05c9011d 100644 --- a/example/warpctc/lstm.py +++ b/example/warpctc/lstm.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint:skip-file import sys sys.path.insert(0, "../../python") diff --git a/example/warpctc/lstm_model.py b/example/warpctc/lstm_model.py index e9c8aa74365f..d359f1ae5a90 100644 --- a/example/warpctc/lstm_model.py +++ b/example/warpctc/lstm_model.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: disable=C0111,too-many-arguments,too-many-instance-attributes,too-many-locals,redefined-outer-name,fixme # pylint: disable=superfluous-parens, no-member, invalid-name @@ -51,4 +68,4 @@ def forward(self, input_data, new_seq=False): for key in self.states_dict.keys(): self.states_dict[key].copyto(self.executor.arg_dict[key]) prob = self.executor.outputs[0].asnumpy() - return prob \ No newline at end of file + return prob diff --git a/example/warpctc/lstm_ocr.py b/example/warpctc/lstm_ocr.py index 540c676f53e7..49df98a77236 100644 --- a/example/warpctc/lstm_ocr.py +++ b/example/warpctc/lstm_ocr.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: disable=C0111,too-many-arguments,too-many-instance-attributes,too-many-locals,redefined-outer-name,fixme # pylint: disable=superfluous-parens, no-member, invalid-name from __future__ import print_function @@ -80,8 +97,8 @@ def __iter__(self): label_all = [mx.nd.array(label)] data_names = ['data'] + init_state_names label_names = ['label'] - - + + data_batch = SimpleBatch(data_names, data_all, label_names, label_all) yield data_batch @@ -198,14 +215,14 @@ def sym_gen(seq_len): import logging head = '%(asctime)-15s %(message)s' logging.basicConfig(level=logging.DEBUG, format=head) - + print('begin fit') prefix = 'ocr' model.fit(X=data_train, eval_data=data_val, eval_metric = mx.metric.np(Accuracy), # Use the following eval_metric if your num_label >= 10, or varies in a wide range - # eval_metric = mx.metric.np(Accuracy_LCS), + # eval_metric = mx.metric.np(Accuracy_LCS), batch_end_callback=mx.callback.Speedometer(BATCH_SIZE, 50), epoch_end_callback = mx.callback.do_checkpoint(prefix, 1)) diff --git a/example/warpctc/ocr_predict.py b/example/warpctc/ocr_predict.py index a07733ef55e0..3096a664a20f 100644 --- a/example/warpctc/ocr_predict.py +++ b/example/warpctc/ocr_predict.py @@ -1,4 +1,22 @@ #!/usr/bin/env python2.7 + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding=utf-8 from __future__ import print_function import sys, os diff --git a/example/warpctc/toy_ctc.py b/example/warpctc/toy_ctc.py index 46bab5776018..c7b0ccc3df3d 100644 --- a/example/warpctc/toy_ctc.py +++ b/example/warpctc/toy_ctc.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: disable=C0111,too-many-arguments,too-many-instance-attributes,too-many-locals,redefined-outer-name,fixme # pylint: disable=superfluous-parens, no-member, invalid-name from __future__ import print_function @@ -68,13 +85,13 @@ def __iter__(self): num, img = gen_rand() data.append(img) label.append(get_label(num)) - + data_all = [mx.nd.array(data)] + self.init_state_arrays label_all = [mx.nd.array(label)] data_names = ['data'] + init_state_names label_names = ['label'] - - + + data_batch = SimpleBatch(data_names, data_all, label_names, label_all) yield data_batch @@ -94,7 +111,7 @@ def ctc_label(p): continue ret.append(c2) return ret - + def Accuracy(label, pred): global BATCH_SIZE @@ -154,7 +171,7 @@ def sym_gen(seq_len): import logging head = '%(asctime)-15s %(message)s' logging.basicConfig(level=logging.DEBUG, format=head) - + print('begin fit') model.fit(X=data_train, eval_data=data_val, diff --git a/include/mxnet/base.h b/include/mxnet/base.h index 739105b388bc..50642049b8f8 100644 --- a/include/mxnet/base.h +++ b/include/mxnet/base.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file base.h * \brief configuation of mxnet as well as basic data structure. */ diff --git a/include/mxnet/c_api.h b/include/mxnet/c_api.h index 3b8d54ce9725..7a45099b8da0 100644 --- a/include/mxnet/c_api.h +++ b/include/mxnet/c_api.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file c_api.h * \brief C API of mxnet */ diff --git a/include/mxnet/c_lapack_api.h b/include/mxnet/c_lapack_api.h index 440d284a8636..1ae90a9396d5 100644 --- a/include/mxnet/c_lapack_api.h +++ b/include/mxnet/c_lapack_api.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file c_lapack_api.h * \brief Unified interface for LAPACK calls from within mxnet. * Purpose is to hide the platform specific differences. diff --git a/include/mxnet/c_predict_api.h b/include/mxnet/c_predict_api.h index df60c84c7dfa..8cf153e7cae1 100644 --- a/include/mxnet/c_predict_api.h +++ b/include/mxnet/c_predict_api.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file c_predict_api.h * \brief C predict API of mxnet, contains a minimum API to run prediction. * This file is self-contained, and do not dependent on any other files. diff --git a/include/mxnet/engine.h b/include/mxnet/engine.h index ed46c84cfe83..e997a2b27253 100644 --- a/include/mxnet/engine.h +++ b/include/mxnet/engine.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file engine.h * \brief Engine that schedules all the operations according to dependency. */ diff --git a/include/mxnet/executor.h b/include/mxnet/executor.h index 9308587c8d72..a74d3b07b5be 100644 --- a/include/mxnet/executor.h +++ b/include/mxnet/executor.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file executor.h * \brief Symbolic executor interface of mxnet. * \author Min Lin, Bing Xu diff --git a/include/mxnet/io.h b/include/mxnet/io.h index b4429a951920..68c1ede65ada 100644 --- a/include/mxnet/io.h +++ b/include/mxnet/io.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file io.h * \brief mxnet io data structure and data iterator */ diff --git a/include/mxnet/kvstore.h b/include/mxnet/kvstore.h index 11db28e6cd20..d2924ecea1b5 100644 --- a/include/mxnet/kvstore.h +++ b/include/mxnet/kvstore.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file kvstore.h * \brief key-value store interface for mxnet */ diff --git a/include/mxnet/mxrtc.h b/include/mxnet/mxrtc.h index 9de59f63da2a..8d7facc5b82a 100644 --- a/include/mxnet/mxrtc.h +++ b/include/mxnet/mxrtc.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file mxrtc.h * \brief Wrapper for NVRTC * \author Junyuan Xie diff --git a/include/mxnet/ndarray.h b/include/mxnet/ndarray.h index e349b3091c56..d40b549d8740 100644 --- a/include/mxnet/ndarray.h +++ b/include/mxnet/ndarray.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file ndarray.h * \brief NDArray interface that handles array arithematics. */ diff --git a/include/mxnet/op_attr_types.h b/include/mxnet/op_attr_types.h index dbf9a07e0bcb..1ba07374d894 100644 --- a/include/mxnet/op_attr_types.h +++ b/include/mxnet/op_attr_types.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file op_attr_types.h * \brief Additional operator attributes * beside the ones provided by NNVM diff --git a/include/mxnet/operator.h b/include/mxnet/operator.h index 09a643390342..2245db0dbb93 100644 --- a/include/mxnet/operator.h +++ b/include/mxnet/operator.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file operator.h * \brief Operator interface of mxnet. * \author Naiyan Wang diff --git a/include/mxnet/operator_util.h b/include/mxnet/operator_util.h index 0f27b10368cf..92ef2ecc58f6 100644 --- a/include/mxnet/operator_util.h +++ b/include/mxnet/operator_util.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file operator_util.h * \brief Utility functions and registries to help quickly build new operators. * [Deprecated] diff --git a/include/mxnet/resource.h b/include/mxnet/resource.h index 93b8352b2617..1ca1fc6fa707 100644 --- a/include/mxnet/resource.h +++ b/include/mxnet/resource.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file resource.h * \brief Global resource allocation handling. */ diff --git a/include/mxnet/storage.h b/include/mxnet/storage.h index 1b765233947d..bfb42de8771a 100644 --- a/include/mxnet/storage.h +++ b/include/mxnet/storage.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file storage.h * \brief Storage manager across multiple devices. */ diff --git a/include/mxnet/tensor_blob.h b/include/mxnet/tensor_blob.h index 1928aa48c85f..18bf4fa780d9 100755 --- a/include/mxnet/tensor_blob.h +++ b/include/mxnet/tensor_blob.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2014 by Contributors * \file tensor_blob.h * \brief TBlob class that holds common representation of * arbirary dimension tensor, can be used to transformed diff --git a/matlab/get_inception_model.sh b/matlab/get_inception_model.sh index aa0092deb6d8..af2479b33b83 100755 --- a/matlab/get_inception_model.sh +++ b/matlab/get_inception_model.sh @@ -1,5 +1,23 @@ #!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + MATLAB_DIR=$(cd `dirname $0`; pwd) DATA_DIR="${MATLAB_DIR}/data/" diff --git a/perl-package/AI-MXNet/examples/get_ptb_data.sh b/perl-package/AI-MXNet/examples/get_ptb_data.sh index 1ec009aa2f99..d2641cb32b81 100755 --- a/perl-package/AI-MXNet/examples/get_ptb_data.sh +++ b/perl-package/AI-MXNet/examples/get_ptb_data.sh @@ -1,5 +1,23 @@ #!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + RNN_DIR=$(cd `dirname $0`; pwd) DATA_DIR="${RNN_DIR}/data/" diff --git a/perl-package/AI-MXNet/lib/AI/MXNet.pm b/perl-package/AI-MXNet/lib/AI/MXNet.pm index 54fb6b31e81f..1d2125354019 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet; use v5.14.0; use strict; diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/Base.pm b/perl-package/AI-MXNet/lib/AI/MXNet/Base.pm index 69f8e43af30c..d5ff0dd08ecc 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/Base.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/Base.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::Base; use strict; use warnings; @@ -12,7 +29,7 @@ use Exporter; use base qw(Exporter); use List::Util qw(shuffle); -@AI::MXNet::Base::EXPORT = qw(product enumerate assert zip check_call build_param_doc +@AI::MXNet::Base::EXPORT = qw(product enumerate assert zip check_call build_param_doc pdl cat dog svd bisect_left pdl_shuffle DTYPE_STR_TO_MX DTYPE_MX_TO_STR DTYPE_MX_TO_PDL DTYPE_PDL_TO_MX DTYPE_MX_TO_PERL GRAD_REQ_MAP); @@ -239,12 +256,12 @@ sub build_param_doc $remove_dup //= 1; my %param_keys; my @param_str; - zip(sub { + zip(sub { my ($key, $type_info, $desc) = @_; return if exists $param_keys{$key} and $remove_dup; $param_keys{$key} = 1; my $ret = sprintf("%s : %s", $key, $type_info); - $ret .= "\n ".$desc if length($desc); + $ret .= "\n ".$desc if length($desc); push @param_str, $ret; }, $arg_names, $arg_types, $arg_descs diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/CachedOp.pm b/perl-package/AI-MXNet/lib/AI/MXNet/CachedOp.pm index ede48265970f..f3c21ed17f30 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/CachedOp.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/CachedOp.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::CachedOp; =head1 NAME diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/Callback.pm b/perl-package/AI-MXNet/lib/AI/MXNet/Callback.pm index 04aaea06c47d..da3309700394 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/Callback.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/Callback.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::Callback; use strict; use warnings; @@ -92,7 +109,7 @@ extends 'AI::MXNet::Callback'; =head1 NAME - AI::MXNet::Speedometer - A callback that logs training speed + AI::MXNet::Speedometer - A callback that logs training speed =cut =head1 DESCRIPTION @@ -244,4 +261,4 @@ method LogValidationMetricsCallback() AI::MXNet::LogValidationMetricsCallback->new } -1; \ No newline at end of file +1; diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/Context.pm b/perl-package/AI-MXNet/lib/AI/MXNet/Context.pm index 68628a8cc14c..2eca42436dc7 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/Context.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/Context.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::Context; use strict; use warnings; diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/Contrib.pm b/perl-package/AI-MXNet/lib/AI/MXNet/Contrib.pm index cb6bc01008f9..a81030bdc6e0 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/Contrib.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/Contrib.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::Contrib; use strict; use warnings; @@ -9,4 +26,4 @@ sub symbol { 'AI::MXNet::Contrib::Symbol' } sub nd { 'AI::MXNet::Contrib::NDArray' } sub autograd { 'AI::MXNet::Contrib::AutoGrad' } -1; \ No newline at end of file +1; diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/Contrib/AutoGrad.pm b/perl-package/AI-MXNet/lib/AI/MXNet/Contrib/AutoGrad.pm index 6d9c10340939..ff659982b813 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/Contrib/AutoGrad.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/Contrib/AutoGrad.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::Contrib::AutoGrad; use strict; use warnings; @@ -224,4 +241,4 @@ method test_section(CodeRef $sub) __PACKAGE__->set_is_training(1) if $prev; } -1; \ No newline at end of file +1; diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/Contrib/NDArray.pm b/perl-package/AI-MXNet/lib/AI/MXNet/Contrib/NDArray.pm index 239f1c48e81f..78aed8fd59cc 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/Contrib/NDArray.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/Contrib/NDArray.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::Contrib::NDArray; use strict; use warnings; @@ -10,4 +27,4 @@ sub AUTOLOAD { return AI::MXNet::NDArray->$sub(@_); } -1; \ No newline at end of file +1; diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/Contrib/Symbol.pm b/perl-package/AI-MXNet/lib/AI/MXNet/Contrib/Symbol.pm index c67cdad4baa5..efe785d181f7 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/Contrib/Symbol.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/Contrib/Symbol.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::Contrib::Symbol; use strict; use warnings; @@ -10,4 +27,4 @@ sub AUTOLOAD { return AI::MXNet::Symbol->$sub(@_); } -1; \ No newline at end of file +1; diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/Executor.pm b/perl-package/AI-MXNet/lib/AI/MXNet/Executor.pm index a2ab786a62d1..20a6f580a3db 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/Executor.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/Executor.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::Executor; use strict; use warnings; @@ -9,7 +26,7 @@ use AI::MXNet::Function::Parameters; has 'handle' => (is => 'ro', isa => 'ExecutorHandle', required => 1); has 'arg_arrays' => (is => 'rw', isa => 'Maybe[ArrayRef[AI::MXNet::NDArray]]'); -has 'grad_arrays' => (is => 'rw', isa => 'Maybe[ArrayRef[Undef|AI::MXNet::NDArray]]'); +has 'grad_arrays' => (is => 'rw', isa => 'Maybe[ArrayRef[Undef|AI::MXNet::NDArray]]'); has 'aux_arrays' => (is => 'rw', isa => 'Maybe[ArrayRef[AI::MXNet::NDArray]]'); has '_symbol' => (is => 'rw', init_arg => 'symbol', isa => 'AI::MXNet::Symbol'); has '_ctx' => (is => 'rw', init_arg => 'ctx', isa => 'AI::MXNet::Context' ); @@ -420,7 +437,7 @@ method copy_params_from( method reshape(HashRef[Shape] $kwargs, Int :$partial_shaping=0, Int :$allow_up_sizing=0) { my ($arg_shapes, undef, $aux_shapes) = $self->_symbol->infer_shape(%{ $kwargs }); - confess("Insufficient argument shapes provided.") + confess("Insufficient argument shapes provided.") unless defined $arg_shapes; my %new_arg_dict; my %new_grad_dict; diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/Executor/Group.pm b/perl-package/AI-MXNet/lib/AI/MXNet/Executor/Group.pm index 35f1b57ee5fa..611c93148f25 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/Executor/Group.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/Executor/Group.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::Executor::Group; use strict; use warnings; diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/Function/Parameters.pm b/perl-package/AI-MXNet/lib/AI/MXNet/Function/Parameters.pm index 021252063c49..e4bbc90ca0a3 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/Function/Parameters.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/Function/Parameters.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::Function::Parameters; use strict; use warnings; @@ -32,4 +49,4 @@ sub import { }; } -1; \ No newline at end of file +1; diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/IO.pm b/perl-package/AI-MXNet/lib/AI/MXNet/IO.pm index 73a672eb4a5c..7a61cd9f1f1f 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/IO.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/IO.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::IO; use strict; use warnings; @@ -784,7 +801,7 @@ method _init_io_module() no strict 'refs'; { *{__PACKAGE__."::$name"} = $data_iter; - } + } } } } @@ -792,4 +809,4 @@ method _init_io_module() # Initialize the io in startups __PACKAGE__->_init_io_module; -1; \ No newline at end of file +1; diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/Image.pm b/perl-package/AI-MXNet/lib/AI/MXNet/Image.pm index 50e4a41f5cc1..b996b028dff2 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/Image.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/Image.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::Image; use strict; use warnings; diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/Initializer.pm b/perl-package/AI-MXNet/lib/AI/MXNet/Initializer.pm index e6beffb78372..182327dfccfe 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/Initializer.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/Initializer.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::InitDesc; use Mouse; use AI::MXNet::Function::Parameters; @@ -104,7 +121,7 @@ method register() { my $existing = $init_registry{ $name }; warn( - "WARNING: New initializer $self.$name" + "WARNING: New initializer $self.$name" ."is overriding existing initializer $existing.$name" ); } diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/KVStore.pm b/perl-package/AI-MXNet/lib/AI/MXNet/KVStore.pm index 465cfd65cf07..eff57a31dc53 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/KVStore.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/KVStore.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::KVStore; use strict; use warnings; @@ -13,7 +30,7 @@ use AI::MXNet::Function::Parameters; AI::MXNet::KVStore - Key value store interface of MXNet. -=head1 DESCRIPTION +=head1 DESCRIPTION Key value store interface of MXNet for parameter synchronization, over multiple devices. =cut diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/KVStoreServer.pm b/perl-package/AI-MXNet/lib/AI/MXNet/KVStoreServer.pm index 6b018afaf6e5..4c274b92c71f 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/KVStoreServer.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/KVStoreServer.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::KVStoreServer; use strict; use warnings; @@ -30,7 +47,7 @@ has 'init_logging' => (is => 'rw', isa => 'Int', default => 0); # return the server controller method _controller() { - return sub { + return sub { my ($cmd_id, $cmd_body) = @_; if (not $self->init_logging) { diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/LRScheduler.pm b/perl-package/AI-MXNet/lib/AI/MXNet/LRScheduler.pm index a9ffb37d6a69..27420f45167d 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/LRScheduler.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/LRScheduler.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::LRScheduler; use strict; use warnings; @@ -173,4 +190,4 @@ method call(Int $num_update) return $self->base_lr; } -1; \ No newline at end of file +1; diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/Logging.pm b/perl-package/AI-MXNet/lib/AI/MXNet/Logging.pm index d6d3744ef37f..f3039cc09bfd 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/Logging.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/Logging.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::Logging; ## TODO use Mouse; diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/Metric.pm b/perl-package/AI-MXNet/lib/AI/MXNet/Metric.pm index fbb93b006a6f..6504481ba8ea 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/Metric.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/Metric.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::Metric; use strict; use warnings; @@ -484,7 +501,7 @@ method update(ArrayRef[AI::MXNet::NDArray] $labels, ArrayRef[AI::MXNet::NDArray] my $label_shape = $label->shape->at(0); my $pred_shape = $pred->shape->at(-1); confess( - "Size of label $label_shape and + "Size of label $label_shape and .first dimension of pred $pred_shape do not match" ) unless $label_shape == $pred_shape; my $prob = $pred->index($label); @@ -599,4 +616,4 @@ method create(Metric|ArrayRef[Metric] $metric, %kwargs) } } -1; \ No newline at end of file +1; diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/Module.pm b/perl-package/AI-MXNet/lib/AI/MXNet/Module.pm index ba70fd059fbe..967a51142aac 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/Module.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/Module.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + ## TODO ## this class is here because of https://github.com/gfx/p5-Mouse/pull/67 ## once 2.4.7 version of Mouse in Ubuntu for affected Perl version @@ -173,7 +190,7 @@ has 'state_names' => (is => 'rw', isa => 'Maybe[ArrayRef[Str]]'); has 'logger' => (is => 'ro', default => sub { AI::MXNet::Logging->get_logger }); has '_p' => (is => 'rw', init_arg => undef); has 'context' => ( - is => 'ro', + is => 'ro', isa => 'AI::MXNet::Context|ArrayRef[AI::MXNet::Context]', default => sub { AI::MXNet::Context->cpu } ); @@ -952,4 +969,4 @@ method _kvstore() $self->_p->_kvstore; } -1; \ No newline at end of file +1; diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/Module/Base.pm b/perl-package/AI-MXNet/lib/AI/MXNet/Module/Base.pm index 293696db218f..7a9e3de090db 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/Module/Base.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/Module/Base.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::BatchEndParam; use Mouse; use AI::MXNet::Function::Parameters; diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/Module/Bucketing.pm b/perl-package/AI-MXNet/lib/AI/MXNet/Module/Bucketing.pm index af768f087025..531f41d58a3a 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/Module/Bucketing.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/Module/Bucketing.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::Module::Bucketing; use Mouse; use AI::MXNet::Function::Parameters; diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/Monitor.pm b/perl-package/AI-MXNet/lib/AI/MXNet/Monitor.pm index 7ac989c6e27f..993461713cb6 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/Monitor.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/Monitor.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::Monitor; use Mouse; use AI::MXNet::Function::Parameters; @@ -153,7 +170,7 @@ method toc() my $s = ''; for my $v (@{ $v_list }) { - confess("the argument must be NDArray") + confess("the argument must be NDArray") unless blessed($v) and $v->isa('AI::MXNet::NDArray'); if($v->size == 1) { diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/NDArray.pm b/perl-package/AI-MXNet/lib/AI/MXNet/NDArray.pm index edeb9b1ba1a2..1f58a74e2bba 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/NDArray.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/NDArray.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::NDArray; =head1 NAME @@ -68,7 +85,7 @@ method at(Index @indices) my $isize = @indices; confess("Dimensions size $dsize < indexes size $isize") if $dsize < $isize; - confess("Dimensions size $dsize = indexes size $isize, + confess("Dimensions size $dsize = indexes size $isize, ndarray only supports either ->at on dimension 0 or full crop") if $isize > 1 and $dsize != $isize; @@ -78,7 +95,7 @@ method at(Index @indices) confess("Dimension $i mismatch Idx: $idx >= Dim Size: $dim_size") if $idx >= $dim_size or ($idx + $dim_size) < 0; ++$i; - }, \@indices, $shape); + }, \@indices, $shape); $i = 0; for my $v (@indices) { @@ -181,7 +198,7 @@ method _sync_copyfrom(ArrayRef|PDL|PDL::Matrix $source_array) my $convert_func = $pdl_type->convertfunc; $source_array = $source_array->$convert_func; } - $source_array = pdl($pdl_type, [@{ $source_array->unpdl } ? $source_array->unpdl->[0] : 0 ]) + $source_array = pdl($pdl_type, [@{ $source_array->unpdl } ? $source_array->unpdl->[0] : 0 ]) unless @{ $source_array->shape->unpdl }; my $pdl_shape = $source_array->shape->unpdl; my $pdl_shape_str = join(',', ref($source_array) eq 'PDL' ? reverse @{ $pdl_shape } : @{ $pdl_shape }); @@ -222,7 +239,7 @@ method aspdl() my $pdl = PDL->new_from_specification($pdl_type, reverse @{ $self->shape }); my $perl_pack_type = DTYPE_MX_TO_PERL->{$dtype}; my $buf = pack("$perl_pack_type*", (0)x$self->size); - check_call(AI::MXNetCAPI::NDArraySyncCopyToCPU($self->handle, $buf, $self->size)); + check_call(AI::MXNetCAPI::NDArraySyncCopyToCPU($self->handle, $buf, $self->size)); ## special handling for float16 if($perl_pack_type eq 'S') { @@ -253,7 +270,7 @@ method asmpdl() my $pdl = PDL::Matrix->new_from_specification($pdl_type, @{ $self->shape }); my $perl_pack_type = DTYPE_MX_TO_PERL->{$dtype}; my $buf = pack("$perl_pack_type*", (0)x$self->size); - check_call(AI::MXNetCAPI::NDArraySyncCopyToCPU($self->handle, $buf, $self->size)); + check_call(AI::MXNetCAPI::NDArraySyncCopyToCPU($self->handle, $buf, $self->size)); ## special handling for float16 if($perl_pack_type eq 'S') { @@ -394,7 +411,7 @@ method moveaxis(Int $source, Int $dest) =head2 broadcast_to - Broadcasting the current NDArray into the given shape. + Broadcasting the current NDArray into the given shape. Parameters --------- @@ -404,7 +421,7 @@ method moveaxis(Int $source, Int $dest) method broadcast_to(Shape $shape) { my $cur_shape = $self->shape; - my $err_str = "operands could not be broadcast together with remapped shapes" + my $err_str = "operands could not be broadcast together with remapped shapes" ."[original->remapped]: [@$cur_shape] and requested shape [@$shape]"; if(@$shape < @$cur_shape) { @@ -494,7 +511,7 @@ method context() Returns ------- - a data type string ('float32', 'float64', 'float16', 'uint8', 'int32') + a data type string ('float32', 'float64', 'float16', 'uint8', 'int32') representing the data type of the ndarray. 'float32' is the default dtype for the ndarray class. =cut @@ -707,7 +724,7 @@ method stringify($other=, $reverse=) method iadd(AI::MXNet::NDArray|Num $other, $reverse=) { confess('trying to add to a readonly NDArray') unless $self->writable; - return ref $other + return ref $other ? __PACKAGE__->broadcast_add($self, $other, { out => $self }) : __PACKAGE__->_plus_scalar($self, $other, { out => $self }) } @@ -752,9 +769,9 @@ method multiply(AI::MXNet::NDArray|Num $other, $reverse=) method imultiply(AI::MXNet::NDArray|Num $other, $reverse=) { confess('trying to add to a readonly NDArray') unless $self->writable; - return ref $other - ? __PACKAGE__->broadcast_mul($self, $other, { out => $self }) - : __PACKAGE__->_mul_scalar($self, $other, { out => $self }) + return ref $other + ? __PACKAGE__->broadcast_mul($self, $other, { out => $self }) + : __PACKAGE__->_mul_scalar($self, $other, { out => $self }) } method divide(AI::MXNet::NDArray|Num $other, $reverse=) @@ -770,9 +787,9 @@ method divide(AI::MXNet::NDArray|Num $other, $reverse=) method idivide(AI::MXNet::NDArray|Num $other, $reverse=) { confess('trying to add to a readonly NDArray') unless $self->writable; - return ref $other - ? __PACKAGE__->broadcast_div($self, $other, { out => $self }) - : __PACKAGE__->_div_scalar($self, $other, { out => $self }) + return ref $other + ? __PACKAGE__->broadcast_div($self, $other, { out => $self }) + : __PACKAGE__->_div_scalar($self, $other, { out => $self }) } method power(AI::MXNet::NDArray|Num $other, $reverse=) @@ -1094,11 +1111,11 @@ method concatenate(ArrayRef[AI::MXNet::NDArray] $arrays, Index :$axis=0, :$alway $shape_axis += $arr->shape->[$axis]; my $arr_shape_rest1 = [@{ $arr->shape }[0..($axis-1)]]; my $arr_shape_rest2 = [@{ $arr->shape }[($axis+1)..(@{ $arr->shape }-1)]]; - confess("first array $arrays->[0] and $i array $arr do not match") + confess("first array $arrays->[0] and $i array $arr do not match") unless join(',',@$arr_shape_rest1) eq join(',',@$shape_rest1); - confess("first array $arrays->[0] and $i array $arr do not match") + confess("first array $arrays->[0] and $i array $arr do not match") unless join(',',@$arr_shape_rest2) eq join(',',@$shape_rest2); - confess("first array $arrays->[0] and $i array $arr dtypes do not match") + confess("first array $arrays->[0] and $i array $arr dtypes do not match") unless join(',',@$arr_shape_rest2) eq join(',',@$shape_rest2); $i++; } @@ -1118,8 +1135,8 @@ method concatenate(ArrayRef[AI::MXNet::NDArray] $arrays, Index :$axis=0, :$alway $begin->[$axis] = $idx; $end->[$axis] = $idx+$arr->shape->[$axis]; __PACKAGE__->_crop_assign( - $ret, $arr, - { + $ret, $arr, + { out => $ret, begin => $begin, end => $end diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/NDArray/Base.pm b/perl-package/AI-MXNet/lib/AI/MXNet/NDArray/Base.pm index 7fb6d0e61110..b51436157a82 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/NDArray/Base.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/NDArray/Base.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::NDArray::Base; use strict; use warnings; @@ -100,7 +117,7 @@ func _make_ndarray_function($handle, $func_name) } for my $key (keys %kwargs) { - $kwargs{ $key } = "(" .join(", ", @{ $kwargs{ $key } }) .")" + $kwargs{ $key } = "(" .join(", ", @{ $kwargs{ $key } }) .")" if ref $kwargs{ $key } eq 'ARRAY'; } my $out = check_call(AI::MXNetCAPI::ImperativeInvoke( diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/NDArray/Doc.pm b/perl-package/AI-MXNet/lib/AI/MXNet/NDArray/Doc.pm index a1a7812ca9a5..fc44812f2cff 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/NDArray/Doc.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/NDArray/Doc.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::NDArray::Doc; use strict; use warnings; diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/NDArray/Slice.pm b/perl-package/AI-MXNet/lib/AI/MXNet/NDArray/Slice.pm index a52f8eef7c1d..40312ebaa24f 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/NDArray/Slice.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/NDArray/Slice.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::NDArray::Slice; use strict; use warnings; @@ -13,7 +30,7 @@ use AI::MXNet::Function::Parameters; has parent => (is => 'ro', isa => 'AI::MXNet::NDArray', required => 1); has begin => (is => 'ro', isa => 'Shape', required => 1); has end => (is => 'ro', isa => 'Shape', required => 1); -use overload +use overload '.=' => \&set, '=' => sub { $_[0] }, '""' => \¬supported, @@ -37,10 +54,10 @@ method set(AcceptableInput $value, $reverse=) { confess("set value must be defined") unless defined $value; confess("${\ $self->parent } is not writable") unless $self->parent->writable; - my $shape = []; + my $shape = []; zip( sub { my ($begin, $end) = @_; push @$shape, ($end-$begin); }, - $self->begin, + $self->begin, $self->end ); if(ref $value) @@ -58,12 +75,12 @@ method set(AcceptableInput $value, $reverse=) $value = AI::MXNet::NDArray->array($value, ctx => $self->parent->context); } confess("value $value does not match slice dim sizes [@$shape]") - if @{$value->shape} != @$shape; + if @{$value->shape} != @$shape; zip( - sub { - my ($dsize, $vdsize) = @_; - confess("Slice [@$shape] != $value given as value") - if $dsize != $vdsize; + sub { + my ($dsize, $vdsize) = @_; + confess("Slice [@$shape] != $value given as value") + if $dsize != $vdsize; }, $shape, $value->shape diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/Optimizer.pm b/perl-package/AI-MXNet/lib/AI/MXNet/Optimizer.pm index 08b9565605eb..c6f682253833 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/Optimizer.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/Optimizer.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::Optimizer; use strict; use warnings; @@ -33,7 +50,7 @@ method register() { my $existing = $opt_registry{ $name }; warn( - "WARNING: New optimizer $self.$name" + "WARNING: New optimizer $self.$name" ."is overriding existing optimizer $existing.$name" ); } @@ -505,7 +522,7 @@ method update( if($self->clip_gradient) { $grad = AI::MXNet::NDArray->clip( - $grad, + $grad, -$self->clip_gradient, $self->clip_gradient ); @@ -566,7 +583,7 @@ method create_state(Index $index, AI::MXNet::NDArray $weight) } method update( - Index $index, + Index $index, AI::MXNet::NDArray $weight, AI::MXNet::NDArray $grad, AI::MXNet::NDArray|Undef $state @@ -678,7 +695,7 @@ method create_state(Index $index, AI::MXNet::NDArray $weight) } method update( - Index $index, + Index $index, AI::MXNet::NDArray $weight, AI::MXNet::NDArray $grad, ArrayRef[AI::MXNet::NDArray] $state @@ -748,7 +765,7 @@ has '+learning_rate' => (default => 0.05); method create_state(Index $index, AI::MXNet::NDArray $weight) { return AI::MXNet::NDArray->zeros( - $weight->shape, + $weight->shape, ctx => $weight->context ); # history } @@ -1025,7 +1042,7 @@ extends 'AI::MXNet::Optimizer'; method create_state(Index $index, AI::MXNet::NDArray $weight) { return AI::MXNet::NDArray->zeros( - $weight->shape, + $weight->shape, ctx => $weight->context ); } diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/Profiler.pm b/perl-package/AI-MXNet/lib/AI/MXNet/Profiler.pm index 6398fcb3e432..47d7a0ddf716 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/Profiler.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/Profiler.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::Profiler; use strict; use warnings; diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/RNN.pm b/perl-package/AI-MXNet/lib/AI/MXNet/RNN.pm index 13dc4f24de33..1ccab31fb7ac 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/RNN.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/RNN.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::RNN; use strict; use warnings; diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/RNN/Cell.pm b/perl-package/AI-MXNet/lib/AI/MXNet/RNN/Cell.pm index c7523aa86bbf..0221a90e7157 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/RNN/Cell.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/RNN/Cell.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::RNN::Params; use Mouse; use AI::MXNet::Function::Parameters; @@ -560,7 +577,7 @@ use Mouse; use AI::MXNet::Base; extends 'AI::MXNet::RNN::Cell'; -=head1 NAME +=head1 NAME AI::MXNet::RNN::LSTMCell =cut diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/RNN/IO.pm b/perl-package/AI-MXNet/lib/AI/MXNet/RNN/IO.pm index 731f7762b7a0..be3bdbd373cb 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/RNN/IO.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/RNN/IO.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::RNN::IO; use strict; use warnings; @@ -289,4 +306,4 @@ method next() ); } -1; \ No newline at end of file +1; diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/Random.pm b/perl-package/AI-MXNet/lib/AI/MXNet/Random.pm index dd17523e3cbf..9ca013c62348 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/Random.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/Random.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::Random; use strict; use warnings; @@ -59,4 +76,4 @@ for my $method ( } } -1; \ No newline at end of file +1; diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/RecordIO.pm b/perl-package/AI-MXNet/lib/AI/MXNet/RecordIO.pm index f0833bf77e5e..2027a901ec10 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/RecordIO.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/RecordIO.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::RecordIO; use strict; use warnings; @@ -24,7 +41,7 @@ use Mouse; has 'uri' => (is => 'ro', isa => 'Str', required => 1); has 'flag' => (is => 'ro', isa => enum([qw/r w/]), required => 1); has 'handle' => (is => 'rw', isa => 'RecordIOHandle'); -has [qw/writable +has [qw/writable is_open/] => (is => 'rw', isa => 'Bool'); sub BUILD @@ -336,4 +353,4 @@ method write_idx(Int $idx, Str $buf) push @{ $self->keys }, $idx; } -1; \ No newline at end of file +1; diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/Rtc.pm b/perl-package/AI-MXNet/lib/AI/MXNet/Rtc.pm index 92edcaf2b8c0..09dc66200322 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/Rtc.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/Rtc.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::Rtc; use strict; use warnings; @@ -124,4 +141,4 @@ method push( ); } -1; \ No newline at end of file +1; diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/Symbol.pm b/perl-package/AI-MXNet/lib/AI/MXNet/Symbol.pm index 8b14f4e2b1d3..a5298c7bc3af 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/Symbol.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/Symbol.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::Symbol; =head1 NAME @@ -340,7 +357,7 @@ method attr_dict() method _set_attr(Str @args) { - my %kwargs = @args; + my %kwargs = @args; while(my ($key, $val) = each(%kwargs)) { check_call( @@ -492,7 +509,7 @@ method list_inputs() method infer_type(Str|Undef @args) { - my ($positional_arguments, $kwargs, $kwargs_order) = _parse_arguments("Dtype", @args); + my ($positional_arguments, $kwargs, $kwargs_order) = _parse_arguments("Dtype", @args); my $sdata = []; my $keys = []; if(@$positional_arguments) @@ -710,7 +727,7 @@ method _get_ndarray_inputs( my ($arg_handles, $arg_arrays) = ([], []); if(ref $args eq 'ARRAY') { - confess("Length of $arg_key do not match number of arguments") + confess("Length of $arg_key do not match number of arguments") unless @$args == @$arg_names; @{ $arg_handles } = map { $_->handle } @{ $args }; $arg_arrays = $args; diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/Symbol/AttrScope.pm b/perl-package/AI-MXNet/lib/AI/MXNet/Symbol/AttrScope.pm index 017168439d7b..c728ed1b6ce8 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/Symbol/AttrScope.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/Symbol/AttrScope.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::Symbol::AttrScope; use strict; use warnings; diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/Symbol/Base.pm b/perl-package/AI-MXNet/lib/AI/MXNet/Symbol/Base.pm index 69ff952eca1a..4282f124a34b 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/Symbol/Base.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/Symbol/Base.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::Symbol::Base; use strict; use warnings; @@ -68,7 +85,7 @@ sub _compose # Create an atomic symbol function by handle and funciton name func _make_atomic_symbol_function($handle, $name) { - my ($real_name, $desc, $arg_names, + my ($real_name, $desc, $arg_names, $arg_types, $arg_descs, $key_var_num_args, $ret_type) = @{ check_call(AI::MXNetCAPI::SymbolGetAtomicSymbolInfo($handle)) }; $ret_type //= ''; @@ -76,7 +93,7 @@ func _make_atomic_symbol_function($handle, $name) my $doc_str = build_doc($func_name, $desc, $arg_names, - $arg_types, + $arg_types, $arg_descs, $key_var_num_args, $ret_type @@ -162,7 +179,7 @@ method _init_symbol_module() no strict 'refs'; { *{__PACKAGE__."::$name"} = $function; - } + } } } } diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/Symbol/Doc.pm b/perl-package/AI-MXNet/lib/AI/MXNet/Symbol/Doc.pm index 2485f21fe3a0..1d9a2c1288ea 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/Symbol/Doc.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/Symbol/Doc.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::Symbol::Doc; use strict; use warnings; diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/Symbol/NameManager.pm b/perl-package/AI-MXNet/lib/AI/MXNet/Symbol/NameManager.pm index 1e31730692a7..109949c79078 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/Symbol/NameManager.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/Symbol/NameManager.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::Symbol::NameManager; use strict; use warnings; diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/TestUtils.pm b/perl-package/AI-MXNet/lib/AI/MXNet/TestUtils.pm index 52050fa1ebdd..ea918c0cddf3 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/TestUtils.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/TestUtils.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::TestUtils; use strict; use warnings; @@ -399,4 +416,4 @@ func dies_like($code, $regexp) } } -1; \ No newline at end of file +1; diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/Types.pm b/perl-package/AI-MXNet/lib/AI/MXNet/Types.pm index 424591eb65a0..e48ae3c086ca 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/Types.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/Types.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::Types; use strict; use warnings; diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/Util/Printable.pm b/perl-package/AI-MXNet/lib/AI/MXNet/Util/Printable.pm index 4e8f8051ae10..1ae6c2d26c96 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/Util/Printable.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/Util/Printable.pm @@ -1,5 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::Util::Printable; use strict; use warnings; use Data::Dumper qw(); -use overload '""' => sub { print Data::Dumper->new([shift])->Purity(1)->Deepcopy(1)->Terse(1)->Dump }; \ No newline at end of file +use overload '""' => sub { print Data::Dumper->new([shift])->Purity(1)->Deepcopy(1)->Terse(1)->Dump }; diff --git a/perl-package/AI-MXNet/lib/AI/MXNet/Visualization.pm b/perl-package/AI-MXNet/lib/AI/MXNet/Visualization.pm index d6ea5aa97bf6..4cdc135c4206 100644 --- a/perl-package/AI-MXNet/lib/AI/MXNet/Visualization.pm +++ b/perl-package/AI-MXNet/lib/AI/MXNet/Visualization.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNet::Visualization; use strict; use warnings; @@ -37,7 +54,7 @@ use JSON::PP; my $softmax = mx->symbol->SoftmaxOutput(data => $fc2, name => 'softmax'); ## creates the image file working directory - mx->viz->plot_network($softmax, save_format => 'png')->render("network.png"); + mx->viz->plot_network($softmax, save_format => 'png')->render("network.png"); =head1 DESCRIPTION @@ -408,4 +425,4 @@ method render($output=) return $self->graph->$method($output); } -1; \ No newline at end of file +1; diff --git a/perl-package/AI-MXNetCAPI/lib/AI/MXNetCAPI.pm b/perl-package/AI-MXNetCAPI/lib/AI/MXNetCAPI.pm index 48ebe8090e4f..f09205733b1e 100644 --- a/perl-package/AI-MXNetCAPI/lib/AI/MXNetCAPI.pm +++ b/perl-package/AI-MXNetCAPI/lib/AI/MXNetCAPI.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::MXNetCAPI; use base qw(DynaLoader); bootstrap AI::MXNetCAPI; diff --git a/perl-package/AI-NNVMCAPI/lib/AI/NNVMCAPI.pm b/perl-package/AI-NNVMCAPI/lib/AI/NNVMCAPI.pm index 62d4dd2b09ab..134d922b4d8d 100644 --- a/perl-package/AI-NNVMCAPI/lib/AI/NNVMCAPI.pm +++ b/perl-package/AI-NNVMCAPI/lib/AI/NNVMCAPI.pm @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + package AI::NNVMCAPI; use base qw(DynaLoader); bootstrap AI::NNVMCAPI; diff --git a/perl-package/test.sh b/perl-package/test.sh index 5aef8e6b82b1..c8509c141920 100755 --- a/perl-package/test.sh +++ b/perl-package/test.sh @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + MXNET_HOME=${PWD} export LD_LIBRARY_PATH=${MXNET_HOME}/lib export PERL5LIB=${MXNET_HOME}/perl5/lib/perl5 diff --git a/plugin/caffe/caffe_blob.cc b/plugin/caffe/caffe_blob.cc index c6d5156ffbc4..697efbfa99f2 100644 --- a/plugin/caffe/caffe_blob.cc +++ b/plugin/caffe/caffe_blob.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file caffe_blob.cc * \brief Implementations of SetDataGradToBlob given various device/dimension * \author Haoran Wang diff --git a/plugin/caffe/caffe_blob.h b/plugin/caffe/caffe_blob.h index 3037031ad991..666d269fdae1 100644 --- a/plugin/caffe/caffe_blob.h +++ b/plugin/caffe/caffe_blob.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file caffe_blob.h * \brief conversion between tensor and caffeBlob * \author Haoran Wang diff --git a/plugin/caffe/caffe_common.cc b/plugin/caffe/caffe_common.cc index 722b19138f79..53513a17d6c8 100644 --- a/plugin/caffe/caffe_common.cc +++ b/plugin/caffe/caffe_common.cc @@ -1,8 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file caffe_common.h * \brief Common functions for caffeOp and caffeLoss symbols - * \author Haoran Wang + * \author Haoran Wang */ #include #include diff --git a/plugin/caffe/caffe_common.h b/plugin/caffe/caffe_common.h index 6ee3c26202b9..8565d9e2e27c 100644 --- a/plugin/caffe/caffe_common.h +++ b/plugin/caffe/caffe_common.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file caffe_common.h * \brief Common functions for caffeOp and caffeLoss symbols * \author Haoran Wang diff --git a/plugin/caffe/caffe_data_iter.cc b/plugin/caffe/caffe_data_iter.cc index ecf776270a91..2682298b4b3d 100644 --- a/plugin/caffe/caffe_data_iter.cc +++ b/plugin/caffe/caffe_data_iter.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file caffe_data_iter.cc * \brief register mnist iterator */ diff --git a/plugin/caffe/caffe_fieldentry.h b/plugin/caffe/caffe_fieldentry.h index a020cf9d7e77..47d246f4439f 100644 --- a/plugin/caffe/caffe_fieldentry.h +++ b/plugin/caffe/caffe_fieldentry.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file caffe_fieldentry.h * \brief Implement FieldEntry * \author Haoran Wang diff --git a/plugin/caffe/caffe_loss-inl.h b/plugin/caffe/caffe_loss-inl.h index 038ee1458bcd..37bfcf06be4a 100644 --- a/plugin/caffe/caffe_loss-inl.h +++ b/plugin/caffe/caffe_loss-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file caffe_loss-inl.h * \brief Caffe Operator * \author Haoran Wang diff --git a/plugin/caffe/caffe_loss.cc b/plugin/caffe/caffe_loss.cc index a51f12602991..ce697d6c8ff9 100644 --- a/plugin/caffe/caffe_loss.cc +++ b/plugin/caffe/caffe_loss.cc @@ -1,8 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file caffe_loss.cc - * \brief caffe loss - * \author Haoran Wang + * \brief caffe loss + * \author Haoran Wang */ #include "./caffe_loss-inl.h" diff --git a/plugin/caffe/caffe_loss.cu b/plugin/caffe/caffe_loss.cu index 55489cafc316..2002cf2c661d 100644 --- a/plugin/caffe/caffe_loss.cu +++ b/plugin/caffe/caffe_loss.cu @@ -1,8 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file caffe_loss_gpu.cc - * \brief caffe loss - * \author Haoran Wang + * \brief caffe loss + * \author Haoran Wang */ #include "./caffe_loss-inl.h" diff --git a/plugin/caffe/caffe_op-inl.h b/plugin/caffe/caffe_op-inl.h index 1950865b76c3..43b9b5a091af 100644 --- a/plugin/caffe/caffe_op-inl.h +++ b/plugin/caffe/caffe_op-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file caffe_op-inl.h * \brief Caffe Operator * \author Haoran Wang diff --git a/plugin/caffe/caffe_op.cc b/plugin/caffe/caffe_op.cc index 90cb4da44b0f..5198ccaac7c9 100644 --- a/plugin/caffe/caffe_op.cc +++ b/plugin/caffe/caffe_op.cc @@ -1,8 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file caffe_op.cc * \brief caffe operator - * \author Haoran Wang + * \author Haoran Wang */ #include "./caffe_op-inl.h" namespace mxnet { diff --git a/plugin/caffe/caffe_op.cu b/plugin/caffe/caffe_op.cu index c52f2b69fb63..be6c20a1084f 100644 --- a/plugin/caffe/caffe_op.cu +++ b/plugin/caffe/caffe_op.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file caffe_operator_gpu.cc * \brief caffe operator * \author Haoran Wang diff --git a/plugin/caffe/caffe_stream.cc b/plugin/caffe/caffe_stream.cc index 99202bf9c09c..03badda65ca2 100644 --- a/plugin/caffe/caffe_stream.cc +++ b/plugin/caffe/caffe_stream.cc @@ -1,8 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file caffe_stream.cc * \brief define stream opertors >> and << - * \author Haoran Wang + * \author Haoran Wang */ #include"caffe_stream.h" diff --git a/plugin/caffe/caffe_stream.h b/plugin/caffe/caffe_stream.h index de9edb84feb4..b9a08d028f38 100644 --- a/plugin/caffe/caffe_stream.h +++ b/plugin/caffe/caffe_stream.h @@ -1,8 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file caffe_stream.h * \brief define stream opertors >> and << - * \author Haoran Wang + * \author Haoran Wang */ #ifndef PLUGIN_CAFFE_CAFFE_STREAM_H_ #define PLUGIN_CAFFE_CAFFE_STREAM_H_ diff --git a/plugin/opencv/__init__.py b/plugin/opencv/__init__.py index 072575177e41..bcf6d1ebc969 100644 --- a/plugin/opencv/__init__.py +++ b/plugin/opencv/__init__.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable=wildcard-import diff --git a/plugin/opencv/cv_api.cc b/plugin/opencv/cv_api.cc index 78bec01548d4..b0bcbbce203e 100644 --- a/plugin/opencv/cv_api.cc +++ b/plugin/opencv/cv_api.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file cv_api.h * \brief C API for opencv * \author Junyuan Xie diff --git a/plugin/opencv/cv_api.h b/plugin/opencv/cv_api.h index fc224d0e1d05..e04357bf30b7 100644 --- a/plugin/opencv/cv_api.h +++ b/plugin/opencv/cv_api.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file cv_api.h * \brief C API for opencv * \author Junyuan Xie diff --git a/plugin/opencv/opencv.py b/plugin/opencv/opencv.py index 43b73b615cc8..52138af00660 100644 --- a/plugin/opencv/opencv.py +++ b/plugin/opencv/opencv.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable=too-many-arguments,no-member,invalid-name diff --git a/plugin/sframe/iter_sframe.cc b/plugin/sframe/iter_sframe.cc index d91c0ded1d88..2a987e2b10f2 100644 --- a/plugin/sframe/iter_sframe.cc +++ b/plugin/sframe/iter_sframe.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file iter_sframe_image.cc * \brief * \author Bing Xu diff --git a/plugin/torch/torch_base.cc b/plugin/torch/torch_base.cc index af102d672f9e..89f832ccdfae 100644 --- a/plugin/torch/torch_base.cc +++ b/plugin/torch/torch_base.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file torch_base.cc * \brief torch_state * \author Junyuan Xie diff --git a/plugin/torch/torch_base.h b/plugin/torch/torch_base.h index acfefe7ac382..3aaaa2f13902 100644 --- a/plugin/torch/torch_base.h +++ b/plugin/torch/torch_base.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file torch_base.h * \brief Torch interface. * \author Junyuan Xie diff --git a/plugin/torch/torch_criterion-inl.h b/plugin/torch/torch_criterion-inl.h index 174ebf2dd9dd..7f592f156226 100644 --- a/plugin/torch/torch_criterion-inl.h +++ b/plugin/torch/torch_criterion-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file torch_module-inl.h * \brief torch module operator * \author Min Lin diff --git a/plugin/torch/torch_criterion.cc b/plugin/torch/torch_criterion.cc index a54be46a936d..bdfb2f42e61a 100644 --- a/plugin/torch/torch_criterion.cc +++ b/plugin/torch/torch_criterion.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file activation.cc * \brief activation op * \author Junyuan Xie diff --git a/plugin/torch/torch_criterion.cu b/plugin/torch/torch_criterion.cu index 57730a0bd88b..68c519c7c9f1 100644 --- a/plugin/torch/torch_criterion.cu +++ b/plugin/torch/torch_criterion.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file activation.cc * \brief activation op * \author Bing Xu diff --git a/plugin/torch/torch_function.cc b/plugin/torch/torch_function.cc index b47ab56f68d2..a1c5ff578da7 100644 --- a/plugin/torch/torch_function.cc +++ b/plugin/torch/torch_function.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file torch_base.cc * \brief torch_state * \author Junyuan Xie diff --git a/plugin/torch/torch_function.h b/plugin/torch/torch_function.h index 0151d5aa9925..8fb2ccfde454 100644 --- a/plugin/torch/torch_function.h +++ b/plugin/torch/torch_function.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file torch_function.h * \brief Torch interface. * \author Junyuan Xie diff --git a/plugin/torch/torch_module-inl.h b/plugin/torch/torch_module-inl.h index 31138fdcf16b..15b569fbbeef 100644 --- a/plugin/torch/torch_module-inl.h +++ b/plugin/torch/torch_module-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file torch_module-inl.h * \brief torch module operator * \author Min Lin diff --git a/plugin/torch/torch_module.cc b/plugin/torch/torch_module.cc index 81dc481c6632..658669fb419c 100644 --- a/plugin/torch/torch_module.cc +++ b/plugin/torch/torch_module.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file activation.cc * \brief activation op * \author Bing Xu diff --git a/plugin/torch/torch_module.cu b/plugin/torch/torch_module.cu index a298a23ae37e..caf9eb19911a 100644 --- a/plugin/torch/torch_module.cu +++ b/plugin/torch/torch_module.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file activation.cc * \brief activation op * \author Bing Xu diff --git a/plugin/warpctc/warpctc-inl.h b/plugin/warpctc/warpctc-inl.h index 328c08b2db02..d492656b2f15 100644 --- a/plugin/warpctc/warpctc-inl.h +++ b/plugin/warpctc/warpctc-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file warpctc-inl.h * \brief warpctc operator * \author Liang Xiang diff --git a/plugin/warpctc/warpctc.cc b/plugin/warpctc/warpctc.cc index db88a3316c7e..0ff61be758c7 100644 --- a/plugin/warpctc/warpctc.cc +++ b/plugin/warpctc/warpctc.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file warpctc.cc * \brief warpctc op * \author Liang Xiang diff --git a/plugin/warpctc/warpctc.cu b/plugin/warpctc/warpctc.cu index 186c4d0c18f4..7562a12a3c9d 100644 --- a/plugin/warpctc/warpctc.cu +++ b/plugin/warpctc/warpctc.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file warpctc.cc * \brief warpctc op * \author Liang Xiang diff --git a/prepare_mkl.sh b/prepare_mkl.sh index a320c44320f0..9769731f5396 100755 --- a/prepare_mkl.sh +++ b/prepare_mkl.sh @@ -1,4 +1,22 @@ #!/bin/bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # set -ex # # All modification made by Intel Corporation: © 2016 Intel Corporation diff --git a/python/mxnet/__init__.py b/python/mxnet/__init__.py index d878f9bb0594..3c3ce76a9284 100644 --- a/python/mxnet/__init__.py +++ b/python/mxnet/__init__.py @@ -1,4 +1,22 @@ #!/usr/bin/env python + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 """MXNet: a concise, fast and flexible framework for deep learning.""" from __future__ import absolute_import diff --git a/python/mxnet/_ctypes/__init__.py b/python/mxnet/_ctypes/__init__.py index 2708cc5c1367..a9433ed06670 100644 --- a/python/mxnet/_ctypes/__init__.py +++ b/python/mxnet/_ctypes/__init__.py @@ -1 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + "ctypes module" diff --git a/python/mxnet/_ctypes/ndarray.py b/python/mxnet/_ctypes/ndarray.py index 396c57a41dfb..5a50f80498ec 100644 --- a/python/mxnet/_ctypes/ndarray.py +++ b/python/mxnet/_ctypes/ndarray.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable=invalid-name, protected-access, too-many-arguments # pylint: disable=global-statement, unused-import diff --git a/python/mxnet/_ctypes/symbol.py b/python/mxnet/_ctypes/symbol.py index 5cbff551cf55..3ec2ddcdc548 100644 --- a/python/mxnet/_ctypes/symbol.py +++ b/python/mxnet/_ctypes/symbol.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable=invalid-name, protected-access, too-many-arguments, global-statement """Symbolic configuration API.""" diff --git a/python/mxnet/_cy2/__init__.py b/python/mxnet/_cy2/__init__.py index 910cbe2e586b..1961cd9ff613 100644 --- a/python/mxnet/_cy2/__init__.py +++ b/python/mxnet/_cy2/__init__.py @@ -1 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """Namespace for cython generated modules for python2""" diff --git a/python/mxnet/_cy3/__init__.py b/python/mxnet/_cy3/__init__.py index e89f266a0535..44dcca5ac003 100644 --- a/python/mxnet/_cy3/__init__.py +++ b/python/mxnet/_cy3/__init__.py @@ -1 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """Namespace for cython generated modules for python3""" diff --git a/python/mxnet/_ndarray_internal.py b/python/mxnet/_ndarray_internal.py index 52ec16df4a8a..8f151f1b5b64 100644 --- a/python/mxnet/_ndarray_internal.py +++ b/python/mxnet/_ndarray_internal.py @@ -1 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """NDArray namespace used to register internal functions.""" diff --git a/python/mxnet/_symbol_internal.py b/python/mxnet/_symbol_internal.py index 58a8e4b2658a..cd6ae41c2a19 100644 --- a/python/mxnet/_symbol_internal.py +++ b/python/mxnet/_symbol_internal.py @@ -1 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """Symbol namespace used to register internal functions.""" diff --git a/python/mxnet/attribute.py b/python/mxnet/attribute.py index b8604024efa4..15d38f81f2e3 100644 --- a/python/mxnet/attribute.py +++ b/python/mxnet/attribute.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 """Attribute scoping support for symbolic API.""" from __future__ import absolute_import diff --git a/python/mxnet/autograd.py b/python/mxnet/autograd.py index 2c3feabd525c..7340851cdef6 100644 --- a/python/mxnet/autograd.py +++ b/python/mxnet/autograd.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 """Autograd for NDArray.""" from __future__ import absolute_import diff --git a/python/mxnet/base.py b/python/mxnet/base.py index ddaeb6e77d54..7d5a5bf8f889 100644 --- a/python/mxnet/base.py +++ b/python/mxnet/base.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable=invalid-name, no-member """ctypes library of mxnet and helper functions.""" diff --git a/python/mxnet/callback.py b/python/mxnet/callback.py index 12146009fe19..8c9f64a95144 100644 --- a/python/mxnet/callback.py +++ b/python/mxnet/callback.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 """Callback functions that can be used to track various status during epoch.""" from __future__ import absolute_import diff --git a/python/mxnet/context.py b/python/mxnet/context.py index 9822a6d86708..9798b480d235 100644 --- a/python/mxnet/context.py +++ b/python/mxnet/context.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 """Context management API of mxnet.""" from __future__ import absolute_import diff --git a/python/mxnet/contrib/__init__.py b/python/mxnet/contrib/__init__.py index c46fa2a24c7f..2730bc43863d 100644 --- a/python/mxnet/contrib/__init__.py +++ b/python/mxnet/contrib/__init__.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 """Experimental contributions""" diff --git a/python/mxnet/contrib/autograd.py b/python/mxnet/contrib/autograd.py index 9074e452c981..c7fb6e17803a 100644 --- a/python/mxnet/contrib/autograd.py +++ b/python/mxnet/contrib/autograd.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 """Autograd for NDArray.""" from __future__ import absolute_import diff --git a/python/mxnet/contrib/ndarray.py b/python/mxnet/contrib/ndarray.py index cf1815c99434..3c86fe7ba3fb 100644 --- a/python/mxnet/contrib/ndarray.py +++ b/python/mxnet/contrib/ndarray.py @@ -1,2 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 """NDArray namespace used to register contrib functions""" diff --git a/python/mxnet/contrib/symbol.py b/python/mxnet/contrib/symbol.py index 81c5ce889331..1d5334595f27 100644 --- a/python/mxnet/contrib/symbol.py +++ b/python/mxnet/contrib/symbol.py @@ -1,2 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 """Symbol namespace used to register contrib functions""" diff --git a/python/mxnet/contrib/tensorboard.py b/python/mxnet/contrib/tensorboard.py index 40e3104409a5..2bb766e7d69b 100644 --- a/python/mxnet/contrib/tensorboard.py +++ b/python/mxnet/contrib/tensorboard.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 """TensorBoard functions that can be used to log various status during epoch.""" from __future__ import absolute_import diff --git a/python/mxnet/executor.py b/python/mxnet/executor.py index d2b108cc04ed..baff834bb33a 100644 --- a/python/mxnet/executor.py +++ b/python/mxnet/executor.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable=invalid-name, protected-access, too-many-locals, too-many-arguments """Symbolic Executor component of MXNet.""" diff --git a/python/mxnet/executor_manager.py b/python/mxnet/executor_manager.py index 0fb9eb3baade..33c6c9762717 100644 --- a/python/mxnet/executor_manager.py +++ b/python/mxnet/executor_manager.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable=invalid-name, protected-access, too-many-locals, too-many-arguments, too-many-statements """Executor manager.""" diff --git a/python/mxnet/gluon/__init__.py b/python/mxnet/gluon/__init__.py index e3c341e97f02..089340efcd2c 100644 --- a/python/mxnet/gluon/__init__.py +++ b/python/mxnet/gluon/__init__.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable=wildcard-import """Neural network module.""" diff --git a/python/mxnet/gluon/block.py b/python/mxnet/gluon/block.py index cfc5e5744338..74a9058e98e0 100644 --- a/python/mxnet/gluon/block.py +++ b/python/mxnet/gluon/block.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable= arguments-differ """Base container class for all neural network models.""" diff --git a/python/mxnet/gluon/data/__init__.py b/python/mxnet/gluon/data/__init__.py index a0623257417c..23ae3e9b3be6 100644 --- a/python/mxnet/gluon/data/__init__.py +++ b/python/mxnet/gluon/data/__init__.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable=wildcard-import """Dataset utilities.""" diff --git a/python/mxnet/gluon/data/dataloader.py b/python/mxnet/gluon/data/dataloader.py index b251deb9bb56..6497c7eb9be9 100644 --- a/python/mxnet/gluon/data/dataloader.py +++ b/python/mxnet/gluon/data/dataloader.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable= """Dataset generator.""" diff --git a/python/mxnet/gluon/data/dataset.py b/python/mxnet/gluon/data/dataset.py index aefff0af16c9..f3dd691962bc 100644 --- a/python/mxnet/gluon/data/dataset.py +++ b/python/mxnet/gluon/data/dataset.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable= """Dataset container.""" diff --git a/python/mxnet/gluon/data/sampler.py b/python/mxnet/gluon/data/sampler.py index f6cedf051727..80f115e0333f 100644 --- a/python/mxnet/gluon/data/sampler.py +++ b/python/mxnet/gluon/data/sampler.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable= """Dataset sampler.""" diff --git a/python/mxnet/gluon/data/vision.py b/python/mxnet/gluon/data/vision.py index 36c4642e7665..4ddbbbdf48a2 100644 --- a/python/mxnet/gluon/data/vision.py +++ b/python/mxnet/gluon/data/vision.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable= """Dataset container.""" diff --git a/python/mxnet/gluon/loss.py b/python/mxnet/gluon/loss.py index 38fdcb820919..2b31840ad959 100644 --- a/python/mxnet/gluon/loss.py +++ b/python/mxnet/gluon/loss.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable=arguments-differ """ losses for training neural networks """ diff --git a/python/mxnet/gluon/model_zoo/__init__.py b/python/mxnet/gluon/model_zoo/__init__.py index aa5f148513bd..b8c32af38561 100644 --- a/python/mxnet/gluon/model_zoo/__init__.py +++ b/python/mxnet/gluon/model_zoo/__init__.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 """Predefined and pretrained models.""" diff --git a/python/mxnet/gluon/model_zoo/custom_layers.py b/python/mxnet/gluon/model_zoo/custom_layers.py index da1ca868dd76..cf91876888ee 100644 --- a/python/mxnet/gluon/model_zoo/custom_layers.py +++ b/python/mxnet/gluon/model_zoo/custom_layers.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable= arguments-differ """Custom neural network layers in model_zoo.""" diff --git a/python/mxnet/gluon/model_zoo/model_store.py b/python/mxnet/gluon/model_zoo/model_store.py index 6a11626795f9..e3c48ba2235a 100644 --- a/python/mxnet/gluon/model_zoo/model_store.py +++ b/python/mxnet/gluon/model_zoo/model_store.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 """Model zoo for pre-trained models.""" from __future__ import print_function diff --git a/python/mxnet/gluon/model_zoo/vision/__init__.py b/python/mxnet/gluon/model_zoo/vision/__init__.py index 56e46f9a0c74..e4016db2ea20 100644 --- a/python/mxnet/gluon/model_zoo/vision/__init__.py +++ b/python/mxnet/gluon/model_zoo/vision/__init__.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable=wildcard-import, arguments-differ r"""Module for pre-defined neural network models. diff --git a/python/mxnet/gluon/model_zoo/vision/alexnet.py b/python/mxnet/gluon/model_zoo/vision/alexnet.py index 86ff9324baca..4d5bc8c85b67 100644 --- a/python/mxnet/gluon/model_zoo/vision/alexnet.py +++ b/python/mxnet/gluon/model_zoo/vision/alexnet.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable= arguments-differ """Alexnet, implemented in Gluon.""" diff --git a/python/mxnet/gluon/model_zoo/vision/densenet.py b/python/mxnet/gluon/model_zoo/vision/densenet.py index 9e1ff7799892..57dbe5d188a7 100644 --- a/python/mxnet/gluon/model_zoo/vision/densenet.py +++ b/python/mxnet/gluon/model_zoo/vision/densenet.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable= arguments-differ """DenseNet, implemented in Gluon.""" diff --git a/python/mxnet/gluon/model_zoo/vision/inception.py b/python/mxnet/gluon/model_zoo/vision/inception.py index 8a28666d56cb..1afd3e346113 100644 --- a/python/mxnet/gluon/model_zoo/vision/inception.py +++ b/python/mxnet/gluon/model_zoo/vision/inception.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable= arguments-differ """Inception, implemented in Gluon.""" diff --git a/python/mxnet/gluon/model_zoo/vision/resnet.py b/python/mxnet/gluon/model_zoo/vision/resnet.py index 48ba07941acb..78bc726f41d9 100644 --- a/python/mxnet/gluon/model_zoo/vision/resnet.py +++ b/python/mxnet/gluon/model_zoo/vision/resnet.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable= arguments-differ """ResNets, implemented in Gluon.""" diff --git a/python/mxnet/gluon/model_zoo/vision/squeezenet.py b/python/mxnet/gluon/model_zoo/vision/squeezenet.py index bfcb5cbc9bae..1a14201c7998 100644 --- a/python/mxnet/gluon/model_zoo/vision/squeezenet.py +++ b/python/mxnet/gluon/model_zoo/vision/squeezenet.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable= arguments-differ """SqueezeNet, implemented in Gluon.""" diff --git a/python/mxnet/gluon/model_zoo/vision/vgg.py b/python/mxnet/gluon/model_zoo/vision/vgg.py index 96a4fa1f3700..2f4daf9f6437 100644 --- a/python/mxnet/gluon/model_zoo/vision/vgg.py +++ b/python/mxnet/gluon/model_zoo/vision/vgg.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable= arguments-differ """VGG, implemented in Gluon.""" diff --git a/python/mxnet/gluon/nn/__init__.py b/python/mxnet/gluon/nn/__init__.py index e4191b2a7dc2..0fc1ff12dd13 100644 --- a/python/mxnet/gluon/nn/__init__.py +++ b/python/mxnet/gluon/nn/__init__.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable=wildcard-import """Neural network layers.""" diff --git a/python/mxnet/gluon/nn/basic_layers.py b/python/mxnet/gluon/nn/basic_layers.py index afe2df7b5f4c..63411caf2be7 100644 --- a/python/mxnet/gluon/nn/basic_layers.py +++ b/python/mxnet/gluon/nn/basic_layers.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable= arguments-differ """Basic neural network layers.""" diff --git a/python/mxnet/gluon/nn/conv_layers.py b/python/mxnet/gluon/nn/conv_layers.py index 9094eddee3f3..e49340d27a4e 100644 --- a/python/mxnet/gluon/nn/conv_layers.py +++ b/python/mxnet/gluon/nn/conv_layers.py @@ -1,5 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 -# pylint: disable= arguments-differ +# pylint: disable= arguments-differ, too-many-lines """Convolutional neural network layers.""" from ..block import HybridBlock from ... import symbol diff --git a/python/mxnet/gluon/parameter.py b/python/mxnet/gluon/parameter.py index bdc967490dc5..69f60388fe25 100644 --- a/python/mxnet/gluon/parameter.py +++ b/python/mxnet/gluon/parameter.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable= """Neural network parameter.""" diff --git a/python/mxnet/gluon/rnn/__init__.py b/python/mxnet/gluon/rnn/__init__.py index b4554ad884cb..24cce542274c 100644 --- a/python/mxnet/gluon/rnn/__init__.py +++ b/python/mxnet/gluon/rnn/__init__.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable=wildcard-import """Recurrent neural network module.""" diff --git a/python/mxnet/gluon/rnn/rnn_cell.py b/python/mxnet/gluon/rnn/rnn_cell.py index 87c656c3020f..c9186fd3ce09 100644 --- a/python/mxnet/gluon/rnn/rnn_cell.py +++ b/python/mxnet/gluon/rnn/rnn_cell.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable=no-member, invalid-name, protected-access, no-self-use # pylint: disable=too-many-branches, too-many-arguments, no-self-use diff --git a/python/mxnet/gluon/rnn/rnn_layer.py b/python/mxnet/gluon/rnn/rnn_layer.py index deb6898be55c..a9bcee52a6d3 100644 --- a/python/mxnet/gluon/rnn/rnn_layer.py +++ b/python/mxnet/gluon/rnn/rnn_layer.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable=no-member, invalid-name, protected-access, no-self-use # pylint: disable=too-many-branches, too-many-arguments, no-self-use diff --git a/python/mxnet/gluon/trainer.py b/python/mxnet/gluon/trainer.py index e8aae71cfd99..bb2cc763b5ba 100644 --- a/python/mxnet/gluon/trainer.py +++ b/python/mxnet/gluon/trainer.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable= """Parameter optimizer.""" diff --git a/python/mxnet/gluon/utils.py b/python/mxnet/gluon/utils.py index 505fbc55248c..7d9c378fe76d 100644 --- a/python/mxnet/gluon/utils.py +++ b/python/mxnet/gluon/utils.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable= """Parallelization utility optimizer.""" diff --git a/python/mxnet/image/__init__.py b/python/mxnet/image/__init__.py index d484006ad7ce..9bb55fbfdddc 100644 --- a/python/mxnet/image/__init__.py +++ b/python/mxnet/image/__init__.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable=wildcard-import """Image Iterators and image augmentation functions""" diff --git a/python/mxnet/image/detection.py b/python/mxnet/image/detection.py index 0a16ac36fc98..142ba25cc564 100644 --- a/python/mxnet/image/detection.py +++ b/python/mxnet/image/detection.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: disable=unused-import """Read images and perform augmentations for object detection.""" diff --git a/python/mxnet/image/image.py b/python/mxnet/image/image.py index cf17ecf13ffb..02cd3cd0d551 100644 --- a/python/mxnet/image/image.py +++ b/python/mxnet/image/image.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: disable=no-member, too-many-lines, redefined-builtin, protected-access, unused-import, invalid-name # pylint: disable=too-many-arguments, too-many-locals, no-name-in-module, too-many-branches, too-many-statements """Read individual image files and perform augmentations.""" diff --git a/python/mxnet/initializer.py b/python/mxnet/initializer.py index a5962b664e6b..78afa2dbd29a 100755 --- a/python/mxnet/initializer.py +++ b/python/mxnet/initializer.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """Weight initializer.""" from __future__ import absolute_import, print_function diff --git a/python/mxnet/io.py b/python/mxnet/io.py index bb791cef035e..0404e34ea36c 100644 --- a/python/mxnet/io.py +++ b/python/mxnet/io.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """Data iterators for common data formats.""" from __future__ import absolute_import from collections import OrderedDict, namedtuple diff --git a/python/mxnet/kvstore.py b/python/mxnet/kvstore.py index 10b83b04db97..fd0091182aea 100644 --- a/python/mxnet/kvstore.py +++ b/python/mxnet/kvstore.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 """ Key value store interface of MXNet for parameter synchronization.""" from __future__ import absolute_import diff --git a/python/mxnet/kvstore_server.py b/python/mxnet/kvstore_server.py index c6d0b073f824..1bb995a45ca8 100644 --- a/python/mxnet/kvstore_server.py +++ b/python/mxnet/kvstore_server.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 """A server node for the key value store.""" from __future__ import absolute_import diff --git a/python/mxnet/libinfo.py b/python/mxnet/libinfo.py index a24756632c10..d6521c558ac4 100644 --- a/python/mxnet/libinfo.py +++ b/python/mxnet/libinfo.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 """Information about mxnet.""" from __future__ import absolute_import diff --git a/python/mxnet/log.py b/python/mxnet/log.py index 46d97f6c390c..6dcaedbe6fe7 100644 --- a/python/mxnet/log.py +++ b/python/mxnet/log.py @@ -1,4 +1,22 @@ #!/usr/bin/env python + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # -*- coding: utf-8 -*- # pylint: disable= protected-access, invalid-name """Logging utilities.""" diff --git a/python/mxnet/lr_scheduler.py b/python/mxnet/lr_scheduler.py index 9998fc8769a1..e4af77aa8690 100644 --- a/python/mxnet/lr_scheduler.py +++ b/python/mxnet/lr_scheduler.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """Scheduling learning rate.""" import logging diff --git a/python/mxnet/metric.py b/python/mxnet/metric.py index 2fe38ab751e0..1a8e67da5396 100644 --- a/python/mxnet/metric.py +++ b/python/mxnet/metric.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable=no-member, too-many-lines diff --git a/python/mxnet/misc.py b/python/mxnet/misc.py index b158981ecf97..13b7dc23b5f6 100644 --- a/python/mxnet/misc.py +++ b/python/mxnet/misc.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: disable=invalid-name """Learning rate scheduler.""" diff --git a/python/mxnet/model.py b/python/mxnet/model.py index 5780ac1b9f9d..01b3fa50e18f 100644 --- a/python/mxnet/model.py +++ b/python/mxnet/model.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: disable=fixme, invalid-name, too-many-arguments, too-many-locals, too-many-lines # pylint: disable=too-many-branches, too-many-statements """MXNet model module""" diff --git a/python/mxnet/module/__init__.py b/python/mxnet/module/__init__.py index 916413782a17..32ecbb9c8be3 100644 --- a/python/mxnet/module/__init__.py +++ b/python/mxnet/module/__init__.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """A module is like a FeedForward model. But we would like to make it easier to compose, similar to Torch modules. """ diff --git a/python/mxnet/module/base_module.py b/python/mxnet/module/base_module.py index cacce25ff083..3123462f9c7c 100644 --- a/python/mxnet/module/base_module.py +++ b/python/mxnet/module/base_module.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: disable=fixme, too-many-arguments, too-many-locals, too-many-public-methods, too-many-branches """`BaseModule` defines an API for modules.""" diff --git a/python/mxnet/module/bucketing_module.py b/python/mxnet/module/bucketing_module.py index 7a1be96d093c..f3c7ecbddc05 100644 --- a/python/mxnet/module/bucketing_module.py +++ b/python/mxnet/module/bucketing_module.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: disable=too-many-instance-attributes, too-many-arguments, protected-access # pylint: disable=too-many-public-methods """A `BucketingModule` implement the `BaseModule` API, and allows multiple diff --git a/python/mxnet/module/executor_group.py b/python/mxnet/module/executor_group.py index 169e81ee326e..0f3c079f8fcb 100755 --- a/python/mxnet/module/executor_group.py +++ b/python/mxnet/module/executor_group.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: disable=too-many-instance-attributes,too-many-locals # pylint: disable=too-many-branches,too-many-statements,too-many-arguments """Executor group is a convenient tool for managing a group of executors.""" diff --git a/python/mxnet/module/module.py b/python/mxnet/module/module.py index b31ea0ffa319..058edd57eb3d 100644 --- a/python/mxnet/module/module.py +++ b/python/mxnet/module/module.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: disable=too-many-instance-attributes, too-many-arguments, protected-access, too-many-branches # pylint: disable=too-many-public-methods """A `Module` implement the `BaseModule` API by wrapping a `Symbol` and one or diff --git a/python/mxnet/module/python_module.py b/python/mxnet/module/python_module.py index af7c76e646a1..2d4343c80c72 100644 --- a/python/mxnet/module/python_module.py +++ b/python/mxnet/module/python_module.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: disable=too-many-instance-attributes, too-many-arguments """Provide some handy classes for user to implement a simple computation module in Python easily. diff --git a/python/mxnet/module/sequential_module.py b/python/mxnet/module/sequential_module.py index b2644c8e3864..642a398c08d4 100644 --- a/python/mxnet/module/sequential_module.py +++ b/python/mxnet/module/sequential_module.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: disable=too-many-arguments, too-many-locals, too-many-instance-attributes """`SequentialModule` is a container module that chains a number of modules together.""" diff --git a/python/mxnet/monitor.py b/python/mxnet/monitor.py index 15be41d585a8..e3185a1281af 100644 --- a/python/mxnet/monitor.py +++ b/python/mxnet/monitor.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable=protected-access, logging-format-interpolation, invalid-name, no-member, too-many-branches """Monitor outputs, weights, and gradients for debugging.""" diff --git a/python/mxnet/name.py b/python/mxnet/name.py index 8003073f4d8a..966d38280ef7 100644 --- a/python/mxnet/name.py +++ b/python/mxnet/name.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 """Automatic naming support for symbolic API.""" from __future__ import absolute_import diff --git a/python/mxnet/ndarray.py b/python/mxnet/ndarray.py index d4a0cdbd8d51..42f0ff5e87cf 100644 --- a/python/mxnet/ndarray.py +++ b/python/mxnet/ndarray.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable= too-many-lines, redefined-builtin, protected-access # pylint: disable=import-error, no-name-in-module, undefined-variable @@ -764,7 +781,7 @@ def shape(self): def size(self): """Number of elements in the array. - Equivalent to the product of the array’s dimensions. + Equivalent to the product of the array's dimensions. Examples -------- @@ -803,7 +820,7 @@ def context(self): @property def dtype(self): - """Data-type of the array’s elements. + """Data-type of the array's elements. Returns ------- diff --git a/python/mxnet/ndarray_doc.py b/python/mxnet/ndarray_doc.py index 9cc4545b9fe3..0c51036d8208 100644 --- a/python/mxnet/ndarray_doc.py +++ b/python/mxnet/ndarray_doc.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable=unused-argument, too-many-arguments """Extra symbol documents""" diff --git a/python/mxnet/notebook/__init__.py b/python/mxnet/notebook/__init__.py index 71a30e3f037d..d605d7483330 100644 --- a/python/mxnet/notebook/__init__.py +++ b/python/mxnet/notebook/__init__.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: disable=invalid-name, missing-docstring, no-init, old-style-class, multiple-statements """MXNet notebook: an easy to use visualization platform""" diff --git a/python/mxnet/notebook/callback.py b/python/mxnet/notebook/callback.py index e9c6e97675aa..56321b715b40 100644 --- a/python/mxnet/notebook/callback.py +++ b/python/mxnet/notebook/callback.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: disable=fixme, invalid-name, missing-docstring, no-init, old-style-class, multiple-statements # pylint: disable=arguments-differ, too-many-arguments, no-member """Visualization callback function diff --git a/python/mxnet/operator.py b/python/mxnet/operator.py index 8274838a1f83..692c7fe827ee 100644 --- a/python/mxnet/operator.py +++ b/python/mxnet/operator.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable=invalid-name, protected-access, too-many-arguments, no-self-use, too-many-locals, broad-except """numpy interface for operators.""" diff --git a/python/mxnet/optimizer.py b/python/mxnet/optimizer.py index 934566ec9d17..1ef9cc845036 100644 --- a/python/mxnet/optimizer.py +++ b/python/mxnet/optimizer.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """Weight updating functions.""" import math import pickle diff --git a/python/mxnet/profiler.py b/python/mxnet/profiler.py index 0d4b8fb979ba..7356ed0fb8d0 100644 --- a/python/mxnet/profiler.py +++ b/python/mxnet/profiler.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable=fixme, invalid-name, too-many-arguments, too-many-locals, too-many-lines # pylint: disable=too-many-branches, too-many-statements diff --git a/python/mxnet/random.py b/python/mxnet/random.py index 91c2f5035ffa..29b250d980ce 100644 --- a/python/mxnet/random.py +++ b/python/mxnet/random.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable=no-member, protected-access, unused-import, no-name-in-module """Random number interface of MXNet.""" diff --git a/python/mxnet/recordio.py b/python/mxnet/recordio.py index 6661ac545b82..39f442b6aefc 100644 --- a/python/mxnet/recordio.py +++ b/python/mxnet/recordio.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """Read and write for the RecordIO data format.""" from __future__ import absolute_import from collections import namedtuple diff --git a/python/mxnet/registry.py b/python/mxnet/registry.py index fdd095e1ebb5..4a4f22fa142b 100644 --- a/python/mxnet/registry.py +++ b/python/mxnet/registry.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable=no-member diff --git a/python/mxnet/rnn/__init__.py b/python/mxnet/rnn/__init__.py index 99b0a2da0329..dbf382ecc411 100644 --- a/python/mxnet/rnn/__init__.py +++ b/python/mxnet/rnn/__init__.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable=wildcard-import """Recurrent neural network module.""" diff --git a/python/mxnet/rnn/io.py b/python/mxnet/rnn/io.py index 8cfce9647374..ab51b09c5710 100644 --- a/python/mxnet/rnn/io.py +++ b/python/mxnet/rnn/io.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable=too-many-arguments, too-many-locals """Definition of various recurrent neural network cells.""" diff --git a/python/mxnet/rnn/rnn.py b/python/mxnet/rnn/rnn.py index 10343c31bcb1..47307c55b042 100644 --- a/python/mxnet/rnn/rnn.py +++ b/python/mxnet/rnn/rnn.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable=too-many-arguments, no-member """Functions for constructing recurrent neural networks.""" diff --git a/python/mxnet/rnn/rnn_cell.py b/python/mxnet/rnn/rnn_cell.py index c8213a20f9ef..1c3452041494 100644 --- a/python/mxnet/rnn/rnn_cell.py +++ b/python/mxnet/rnn/rnn_cell.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable=no-member, invalid-name, protected-access, no-self-use # pylint: disable=too-many-branches, too-many-arguments, no-self-use diff --git a/python/mxnet/rtc.py b/python/mxnet/rtc.py index 759fc3d30042..9da38c6aaaf5 100644 --- a/python/mxnet/rtc.py +++ b/python/mxnet/rtc.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """Interface to runtime cuda kernel compile module.""" from __future__ import absolute_import diff --git a/python/mxnet/symbol.py b/python/mxnet/symbol.py index a6c2b0ab689d..14cb3811deeb 100644 --- a/python/mxnet/symbol.py +++ b/python/mxnet/symbol.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable=invalid-name, protected-access, too-many-arguments, too-many-lines # pylint: disable=import-error, no-name-in-module diff --git a/python/mxnet/symbol_doc.py b/python/mxnet/symbol_doc.py index dff5383e2682..3cb1997584d2 100644 --- a/python/mxnet/symbol_doc.py +++ b/python/mxnet/symbol_doc.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable=unused-argument, too-many-arguments """Extra symbol documents diff --git a/python/mxnet/test_utils.py b/python/mxnet/test_utils.py index 83c773f53fe2..c5587f8d80a8 100644 --- a/python/mxnet/test_utils.py +++ b/python/mxnet/test_utils.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """Tools for testing.""" # pylint: disable=too-many-lines from __future__ import absolute_import, print_function, division diff --git a/python/mxnet/torch.py b/python/mxnet/torch.py index 765c96bbfb60..b7fce6d5c8fd 100644 --- a/python/mxnet/torch.py +++ b/python/mxnet/torch.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 """Interface for NDArray functions executed by torch backend. Install Torch and compile with USE_TORCH=1 to use this module.""" diff --git a/python/mxnet/visualization.py b/python/mxnet/visualization.py index e67fee427be2..4dbf680c2e3a 100644 --- a/python/mxnet/visualization.py +++ b/python/mxnet/visualization.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # coding: utf-8 # pylint: disable=invalid-name, too-many-locals, fixme # pylint: disable=too-many-branches, too-many-statements diff --git a/python/setup.py b/python/setup.py index f5bd55de6cf6..14c8121d35ee 100644 --- a/python/setup.py +++ b/python/setup.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: disable=invalid-name, exec-used """Setup mxnet package.""" from __future__ import absolute_import diff --git a/scala-package/core/scripts/get_cifar_data.sh b/scala-package/core/scripts/get_cifar_data.sh index eba3a27805fa..9ec1c39a4f99 100755 --- a/scala-package/core/scripts/get_cifar_data.sh +++ b/scala-package/core/scripts/get_cifar_data.sh @@ -1,5 +1,23 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + set -e if [ ! -z "$MXNET_DATA_DIR" ]; then diff --git a/scala-package/core/scripts/get_mnist_data.sh b/scala-package/core/scripts/get_mnist_data.sh index a4cfe11e4b5a..97e151bf8333 100755 --- a/scala-package/core/scripts/get_mnist_data.sh +++ b/scala-package/core/scripts/get_mnist_data.sh @@ -1,5 +1,23 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + set -e if [ ! -z "$MXNET_DATA_DIR" ]; then diff --git a/scala-package/examples/scripts/customop/run_customop.sh b/scala-package/examples/scripts/customop/run_customop.sh index bd425edd5801..b11bb89a2d91 100644 --- a/scala-package/examples/scripts/customop/run_customop.sh +++ b/scala-package/examples/scripts/customop/run_customop.sh @@ -1,5 +1,23 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + MXNET_ROOT=$(cd "$(dirname $0)/../../../.."; pwd) CLASS_PATH=$MXNET_ROOT/scala-package/assembly/linux-x86_64-gpu/target/*:$MXNET_ROOT/scala-package/examples/target/*:$MXNET_ROOT/scala-package/examples/target/classes/lib/* diff --git a/scala-package/examples/scripts/customop/run_customopwithrtc.sh b/scala-package/examples/scripts/customop/run_customopwithrtc.sh index 6009193c8ebb..160525e4eb54 100644 --- a/scala-package/examples/scripts/customop/run_customopwithrtc.sh +++ b/scala-package/examples/scripts/customop/run_customopwithrtc.sh @@ -1,5 +1,23 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + MXNET_ROOT=$(cd "$(dirname $0)/../../../.."; pwd) CLASS_PATH=$MXNET_ROOT/scala-package/assembly/linux-x86_64-gpu/target/*:$MXNET_ROOT/scala-package/examples/target/*:$MXNET_ROOT/scala-package/examples/target/classes/lib/* diff --git a/scala-package/examples/scripts/module/mnist_mlp.sh b/scala-package/examples/scripts/module/mnist_mlp.sh index 0b450d7608a4..6bb9636e98da 100755 --- a/scala-package/examples/scripts/module/mnist_mlp.sh +++ b/scala-package/examples/scripts/module/mnist_mlp.sh @@ -1,4 +1,22 @@ #!/bin/bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + ROOT_DIR=$(cd `dirname $0`/../../..; pwd) CLASSPATH=$ROOT_DIR/assembly/osx-x86_64-cpu/target/*:$ROOT_DIR/examples/target/*:$ROOT_DIR/examples/target/classes/lib/* diff --git a/scala-package/examples/scripts/module/run_sequential_module.sh b/scala-package/examples/scripts/module/run_sequential_module.sh index 15cc7dda8ba2..9d9edb719dd5 100644 --- a/scala-package/examples/scripts/module/run_sequential_module.sh +++ b/scala-package/examples/scripts/module/run_sequential_module.sh @@ -1,4 +1,22 @@ #!/bin/bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + ROOT_DIR=$(cd `dirname $0`/../../..; pwd) CLASSPATH=$ROOT_DIR/assembly/linux-x86_64-cpu/target/*:$ROOT_DIR/examples/target/*:$ROOT_DIR/examples/target/classes/lib/* diff --git a/scala-package/examples/scripts/neuralstyle_end2end/run_test_end2end.sh b/scala-package/examples/scripts/neuralstyle_end2end/run_test_end2end.sh index 10bc2da4f9bf..1c683bfc9e34 100644 --- a/scala-package/examples/scripts/neuralstyle_end2end/run_test_end2end.sh +++ b/scala-package/examples/scripts/neuralstyle_end2end/run_test_end2end.sh @@ -1,9 +1,27 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + MXNET_ROOT=$(cd "$(dirname $0)/../../../.."; pwd) CLASS_PATH=$MXNET_ROOT/scala-package/assembly/linux-x86_64-gpu/target/*:$MXNET_ROOT/scala-package/examples/target/*:$MXNET_ROOT/scala-package/examples/target/classes/lib/* -INPUT_IMG=$1 +INPUT_IMG=$1 MODEL_DIR=$2 OUTPUT_DIR=$3 GPU=0 @@ -13,4 +31,4 @@ java -Xmx1024m -cp $CLASS_PATH \ --model-path $MODEL_DIR \ --input-image $INPUT_IMG \ --output-path $OUTPUT_DIR \ - --gpu $GPU \ No newline at end of file + --gpu $GPU diff --git a/scala-package/examples/scripts/neuralstyle_end2end/run_train_end2end.sh b/scala-package/examples/scripts/neuralstyle_end2end/run_train_end2end.sh index 3ede06a78b0b..fa08ff3713c8 100644 --- a/scala-package/examples/scripts/neuralstyle_end2end/run_train_end2end.sh +++ b/scala-package/examples/scripts/neuralstyle_end2end/run_train_end2end.sh @@ -1,12 +1,30 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + MXNET_ROOT=$(cd "$(dirname $0)/../../../.."; pwd) CLASS_PATH=$MXNET_ROOT/scala-package/assembly/linux-x86_64-gpu/target/*:$MXNET_ROOT/scala-package/examples/target/*:$MXNET_ROOT/scala-package/examples/target/classes/lib/* # more details please refer to # https://github.com/Ldpe2G/mxnet/blob/develop/example/neural-style/end_to_end/README.md -TRAIN_DATA_PATH=$1 -STYLE_IMG=$2 +TRAIN_DATA_PATH=$1 +STYLE_IMG=$2 VGG_MODEL_PATH=$3 SAVE_MODEL_DIR=$4 GPU=0 @@ -17,4 +35,4 @@ java -Xmx1024m -cp $CLASS_PATH \ --vgg--model-path $VGG_MODEL_PATH \ --save--model-path $SAVE_MODEL_DIR \ --style-image $STYLE_IMG \ - --gpu $GPU \ No newline at end of file + --gpu $GPU diff --git a/scala-package/examples/scripts/profiler/run_profiler_matmul.sh b/scala-package/examples/scripts/profiler/run_profiler_matmul.sh index b54a4226fb14..54aafafcfd61 100644 --- a/scala-package/examples/scripts/profiler/run_profiler_matmul.sh +++ b/scala-package/examples/scripts/profiler/run_profiler_matmul.sh @@ -1,5 +1,23 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + MXNET_ROOT=$(cd "$(dirname $0)/../../../.."; pwd) CLASS_PATH=$MXNET_ROOT/scala-package/assembly/linux-x86_64-gpu/target/*:$MXNET_ROOT/scala-package/examples/target/*:$MXNET_ROOT/scala-package/examples/target/classes/lib/* diff --git a/scala-package/examples/scripts/profiler/run_profiler_ndarray.sh b/scala-package/examples/scripts/profiler/run_profiler_ndarray.sh index 4a849c57b2ee..711fe5465404 100644 --- a/scala-package/examples/scripts/profiler/run_profiler_ndarray.sh +++ b/scala-package/examples/scripts/profiler/run_profiler_ndarray.sh @@ -1,5 +1,23 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + MXNET_ROOT=$(cd "$(dirname $0)/../../../.."; pwd) CLASS_PATH=$MXNET_ROOT/scala-package/assembly/linux-x86_64-gpu/target/*:$MXNET_ROOT/scala-package/examples/target/*:$MXNET_ROOT/scala-package/examples/target/classes/lib/* diff --git a/scala-package/examples/scripts/rnn/run_test_charrnn.sh b/scala-package/examples/scripts/rnn/run_test_charrnn.sh index 04eee3691435..a4ed91354e8c 100644 --- a/scala-package/examples/scripts/rnn/run_test_charrnn.sh +++ b/scala-package/examples/scripts/rnn/run_test_charrnn.sh @@ -1,5 +1,23 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + MXNET_ROOT=$(cd "$(dirname $0)/../../../.."; pwd) OS=$(uname) if [ "$OS" = "Darwin" ]; then diff --git a/scala-package/examples/scripts/rnn/run_train_charrnn.sh b/scala-package/examples/scripts/rnn/run_train_charrnn.sh index 07b7dda7d6e4..2e9a3a264c88 100755 --- a/scala-package/examples/scripts/rnn/run_train_charrnn.sh +++ b/scala-package/examples/scripts/rnn/run_train_charrnn.sh @@ -1,5 +1,23 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + MXNET_ROOT=$(cd "$(dirname $0)/../../../.."; pwd) OS=$(uname) if [ "$OS" = "Darwin" ]; then diff --git a/scala-package/examples/scripts/run_cnntextclassification.sh b/scala-package/examples/scripts/run_cnntextclassification.sh index a7cf7c0a6395..7939b0627422 100644 --- a/scala-package/examples/scripts/run_cnntextclassification.sh +++ b/scala-package/examples/scripts/run_cnntextclassification.sh @@ -1,16 +1,34 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + MXNET_ROOT=$(cd "$(dirname $0)/../../.."; pwd) CLASS_PATH=$MXNET_ROOT/scala-package/assembly/linux-x86_64-gpu/target/*:$MXNET_ROOT/scala-package/examples/target/*:$MXNET_ROOT/scala-package/examples/target/classes/lib/* # which gpu card to use, -1 means cpu GPU=$1 # the mr dataset path, you should put the pos and neg file in the same folder -MR_DATASET_PATH=$2 +MR_DATASET_PATH=$2 # the trained word2vec file path, binary or text format -W2V_FILE_PATH=$3 +W2V_FILE_PATH=$3 # whether the format of the word2vec file is binary,1 means binary, 0 means text -W2V_FORMAT_BIN=$4 +W2V_FORMAT_BIN=$4 BATCH_SIZE=$5 SAVE_MODEL_PATH=$6 diff --git a/scala-package/examples/scripts/run_gan_mnist.sh b/scala-package/examples/scripts/run_gan_mnist.sh index 2d3c545cf5d3..951241fb18b7 100644 --- a/scala-package/examples/scripts/run_gan_mnist.sh +++ b/scala-package/examples/scripts/run_gan_mnist.sh @@ -1,5 +1,23 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + MXNET_ROOT=$(cd "$(dirname $0)/../../.."; pwd) CLASS_PATH=$MXNET_ROOT/scala-package/assembly/linux-x86_64-gpu/target/*:$MXNET_ROOT/scala-package/examples/target/*:$MXNET_ROOT/scala-package/examples/target/classes/lib/* @@ -10,7 +28,7 @@ GPU=$1 # you can get the mnist data using the script core/scripts/get_mnist_data.sh MNIST_DATA_PATH=$2 -# the path to save the generated results +# the path to save the generated results OUTPUT_PATH=$3 java -Xmx4G -cp $CLASS_PATH \ diff --git a/scala-package/examples/scripts/run_multitask.sh b/scala-package/examples/scripts/run_multitask.sh index 1642cc8336f2..9e6a489e9fa7 100644 --- a/scala-package/examples/scripts/run_multitask.sh +++ b/scala-package/examples/scripts/run_multitask.sh @@ -1,5 +1,23 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + MXNET_ROOT=$(cd "$(dirname $0)/../../.."; pwd) CLASS_PATH=$MXNET_ROOT/scala-package/assembly/linux-x86_64-gpu/target/*:$MXNET_ROOT/scala-package/examples/target/*:$MXNET_ROOT/scala-package/examples/target/classes/lib/* diff --git a/scala-package/examples/scripts/run_neuralstyle.sh b/scala-package/examples/scripts/run_neuralstyle.sh index 5fbfc3227b7c..a9c2e5c1c1ea 100644 --- a/scala-package/examples/scripts/run_neuralstyle.sh +++ b/scala-package/examples/scripts/run_neuralstyle.sh @@ -1,9 +1,27 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + MXNET_ROOT=$(cd "$(dirname $0)/../../.."; pwd) CLASS_PATH=$MXNET_ROOT/scala-package/assembly/linux-x86_64-gpu/target/*:$MXNET_ROOT/scala-package/examples/target/*:$MXNET_ROOT/scala-package/examples/target/classes/lib/* -INPUT_IMG=$1 -STYLE_IMG=$2 +INPUT_IMG=$1 +STYLE_IMG=$2 MODEL_PATH=$MXNET_ROOT/example/neural-style/model/vgg19.params OUTPUT_DIR=$MXNET_ROOT/example/neural-style/output @@ -12,4 +30,4 @@ java -Xmx1024m -cp $CLASS_PATH \ --content-image $INPUT_IMG \ --style-image $STYLE_IMG \ --model-path $MODEL_PATH \ - --output-dir $OUTPUT_DIR + --output-dir $OUTPUT_DIR diff --git a/scala-package/examples/scripts/run_visualization.sh b/scala-package/examples/scripts/run_visualization.sh index 6f686adc06f5..a4b545e24484 100644 --- a/scala-package/examples/scripts/run_visualization.sh +++ b/scala-package/examples/scripts/run_visualization.sh @@ -1,5 +1,23 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + MXNET_ROOT=$(cd "$(dirname $0)/../../.."; pwd) CLASS_PATH=$MXNET_ROOT/scala-package/assembly/linux-x86_64-cpu/target/*:$MXNET_ROOT/scala-package/examples/target/*:$MXNET_ROOT/scala-package/examples/target/classes/lib/* @@ -15,4 +33,4 @@ NET=$2 java -Xmx1024m -cp $CLASS_PATH \ ml.dmlc.mxnetexamples.visualization.ExampleVis \ --out-dir $OUT_DIR \ - --net $NET + --net $NET diff --git a/scala-package/init-native/src/main/native/ml_dmlc_mxnet_init_native_c_api.cc b/scala-package/init-native/src/main/native/ml_dmlc_mxnet_init_native_c_api.cc index d6daa00eec9f..114510c66afb 100644 --- a/scala-package/init-native/src/main/native/ml_dmlc_mxnet_init_native_c_api.cc +++ b/scala-package/init-native/src/main/native/ml_dmlc_mxnet_init_native_c_api.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file ml_dmlc_mxnet_native_c_api.cc * \brief JNI function implementations */ diff --git a/scala-package/native/src/main/native/jni_helper_func.h b/scala-package/native/src/main/native/jni_helper_func.h index d1abd93d92e7..009bbec64e66 100644 --- a/scala-package/native/src/main/native/jni_helper_func.h +++ b/scala-package/native/src/main/native/jni_helper_func.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file jni_helper_func.h * \brief Helper functions for operating JVM objects */ diff --git a/scala-package/native/src/main/native/ml_dmlc_mxnet_native_c_api.cc b/scala-package/native/src/main/native/ml_dmlc_mxnet_native_c_api.cc index 07fd07596ee7..166f6b71eb9f 100644 --- a/scala-package/native/src/main/native/ml_dmlc_mxnet_native_c_api.cc +++ b/scala-package/native/src/main/native/ml_dmlc_mxnet_native_c_api.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file ml_dmlc_mxnet_native_c_api.cc * \brief JNI function implementations */ diff --git a/scala-package/spark/bin/run-mnist-example.sh b/scala-package/spark/bin/run-mnist-example.sh index dc2f3adbe7ac..cae19386a8ee 100755 --- a/scala-package/spark/bin/run-mnist-example.sh +++ b/scala-package/spark/bin/run-mnist-example.sh @@ -1,4 +1,22 @@ #!/bin/bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + CURR_DIR=$(cd `dirname $0`; pwd) MODULE_DIR=$(cd $CURR_DIR/../; pwd) ROOT_DIR=$(cd $CURR_DIR/../../; pwd) diff --git a/setup-utils/install-mxnet-amz-linux.sh b/setup-utils/install-mxnet-amz-linux.sh index b8564a56ed3d..66788a984da6 100644 --- a/setup-utils/install-mxnet-amz-linux.sh +++ b/setup-utils/install-mxnet-amz-linux.sh @@ -1,4 +1,22 @@ #!/usr/bin/env bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + ###################################################################### # This script installs MXNet for Python along with all required dependencies on a Amazon Linux Machine. ###################################################################### diff --git a/setup-utils/install-mxnet-fedora-python.sh b/setup-utils/install-mxnet-fedora-python.sh index 54b716b911db..86116665db88 100644 --- a/setup-utils/install-mxnet-fedora-python.sh +++ b/setup-utils/install-mxnet-fedora-python.sh @@ -1,4 +1,22 @@ #!/usr/bin/env bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + ###################################################################### # This script installs MXNet for Python along with all required dependencies on a Fedora Machine. # Tested on Fedora 21.0 + distro. @@ -24,8 +42,8 @@ sudo yum install numpy echo "Installing Python setuptools..." sudo yum install -y python-setuptools python-pip -echo "Adding MXNet path to your ~/.bashrc file" -echo "export PYTHONPATH=$MXNET_HOME/python:$PYTHONPATH" >> ~/.bashrc +echo "Adding MXNet path to your ~/.bashrc file" +echo "export PYTHONPATH=$MXNET_HOME/python:$PYTHONPATH" >> ~/.bashrc source ~/.bashrc echo "Install Graphviz for plotting MXNet network graph..." diff --git a/setup-utils/install-mxnet-osx-python.sh b/setup-utils/install-mxnet-osx-python.sh index f9e4e775534e..8bfb7dade7b1 100755 --- a/setup-utils/install-mxnet-osx-python.sh +++ b/setup-utils/install-mxnet-osx-python.sh @@ -1,4 +1,22 @@ #!/bin/bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # # This scripts installs the dependencies and compiles # MXNet source. @@ -12,7 +30,7 @@ export MXNET_GITPATH="https://github.com/dmlc/mxnet.git" if [ -z ${MXNET_TAG} ]; then # - # TODO: Change this to latest tag + # TODO: Change this to latest tag # to avoid updating this value for every release # export MXNET_TAG="v0.10.0" @@ -138,17 +156,17 @@ install_brew() { echo "END: Check/Install/Update Homebrew" echo $LINE echo " " - + echo "BEGIN: Install dependent brew packages for MXNet: ${BREW_PKGS}" - + chkret brew tap homebrew/science - + # install each individually to see progress for each for pkg in ${BREW_PKGS} do chkret brew_pkg_install ${pkg} done - + echo "END: Install dependent brew packages for MXNet: ${BREW_PKGS}" echo $LINE echo " " @@ -223,7 +241,7 @@ install_port () { # sudo mkdir -p /usr/local/opt/openblas/lib # sudo ln -s /opt/local/lib/libopenblas.a /usr/local/opt/openblas/lib/libopenblas.a #fi - + echo " " echo "END: Install dependent port packages for MXNet: ${PORT_PKGS}" echo $LINE @@ -265,9 +283,9 @@ install_mac_pkg_manager() { export PKG_MGR="" else export MAC_PKG_ASK=0 - + while true; do - echo "NOTE: Using the already installed package manager: $PKG_MGR" + echo "NOTE: Using the already installed package manager: $PKG_MGR" read -p "Do you want to continue? (y/n): " response echo " " case $response in @@ -368,7 +386,7 @@ compile_mxnet() { echo "BEGIN: Compile MXNet" cd ${MXNET_HOME} chkret cp make/osx.mk ./config.mk.tmp - + touch ./config.mk # rm any old setting of USE_BLAS, if present in config file egrep -v "^USE_BLAS" ./config.mk.tmp >> ./config.mk @@ -386,7 +404,7 @@ compile_mxnet() { echo "ADD_LDFLAGS += -L/usr/local/lib/graphviz/" >> ./config.mk fi echo " " - + echo "NOTE: The following compile-time configurations will be used." echo " If you want to change any of them, edit the following file" echo " in another terminal window and then press enter to continue." @@ -452,7 +470,7 @@ END echo " " echo $LINE echo " " - rm -f mxnet_test.log mxnet_test.expected + rm -f mxnet_test.log mxnet_test.expected exit 0 else echo " " diff --git a/setup-utils/install-mxnet-ubuntu-python.sh b/setup-utils/install-mxnet-ubuntu-python.sh index ba060745da8f..8aa0d0256a79 100644 --- a/setup-utils/install-mxnet-ubuntu-python.sh +++ b/setup-utils/install-mxnet-ubuntu-python.sh @@ -1,4 +1,22 @@ #!/usr/bin/env bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + ###################################################################### # This script installs MXNet for Python along with all required dependencies on a Ubuntu Machine. # Tested on Ubuntu 14.0 + distro. diff --git a/setup-utils/install-mxnet-ubuntu-r.sh b/setup-utils/install-mxnet-ubuntu-r.sh index 8f4c07d0325d..ca46d7b37016 100644 --- a/setup-utils/install-mxnet-ubuntu-r.sh +++ b/setup-utils/install-mxnet-ubuntu-r.sh @@ -1,4 +1,22 @@ #!/usr/bin/env bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + ###################################################################### # This script installs MXNet for R along with all required dependencies on a Ubuntu Machine. # Tested on Ubuntu 14.04+ distro. @@ -32,7 +50,7 @@ sudo apt-get -y install libcurl4-openssl-dev libssl-dev # Needed for R XML sudo apt-get install libxml2-dev -# Needed for R Cairo +# Needed for R Cairo sudo apt-get install libxt-dev sudo Rscript -e "install.packages('devtools', repo = 'https://cran.rstudio.com')" diff --git a/src/c_api/c_api.cc b/src/c_api/c_api.cc index 214e6ede5292..93458d21ac5a 100644 --- a/src/c_api/c_api.cc +++ b/src/c_api/c_api.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file c_api.cc * \brief C API of mxnet */ diff --git a/src/c_api/c_api_common.h b/src/c_api/c_api_common.h index d8857f80635d..846b53973b07 100644 --- a/src/c_api/c_api_common.h +++ b/src/c_api/c_api_common.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file c_api_error.h * \brief Error handling for C API. */ diff --git a/src/c_api/c_api_error.cc b/src/c_api/c_api_error.cc index 4ee6a35363c5..4d93b908fb31 100644 --- a/src/c_api/c_api_error.cc +++ b/src/c_api/c_api_error.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file c_api_error.cc * \brief C error handling */ diff --git a/src/c_api/c_api_executor.cc b/src/c_api/c_api_executor.cc index 3ba3154f2d97..a4c48e426879 100644 --- a/src/c_api/c_api_executor.cc +++ b/src/c_api/c_api_executor.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file c_api_executor.cc * \brief C API of mxnet */ diff --git a/src/c_api/c_api_ndarray.cc b/src/c_api/c_api_ndarray.cc index a37e3144c303..89605183e748 100644 --- a/src/c_api/c_api_ndarray.cc +++ b/src/c_api/c_api_ndarray.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file c_api_symbolic.cc * \brief C API of mxnet */ diff --git a/src/c_api/c_api_symbolic.cc b/src/c_api/c_api_symbolic.cc index d3603e94b2a1..e2c29b888ada 100644 --- a/src/c_api/c_api_symbolic.cc +++ b/src/c_api/c_api_symbolic.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file c_api_symbolic.cc * \brief C API of mxnet */ diff --git a/src/c_api/c_predict_api.cc b/src/c_api/c_predict_api.cc index 1dd784ba2249..5ca01492800e 100644 --- a/src/c_api/c_predict_api.cc +++ b/src/c_api/c_predict_api.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file c_predict_api.cc * \brief C predict API of mxnet */ diff --git a/src/common/cuda_utils.h b/src/common/cuda_utils.h index d0defc30ffa6..3c4d1a88de8e 100644 --- a/src/common/cuda_utils.h +++ b/src/common/cuda_utils.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file cuda_utils.h * \brief CUDA debugging utilities. */ diff --git a/src/common/lazy_alloc_array.h b/src/common/lazy_alloc_array.h index 61b81e5ce407..aa2cd4a139ee 100644 --- a/src/common/lazy_alloc_array.h +++ b/src/common/lazy_alloc_array.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file lazy_alloc_array.h * \brief An array that lazily allocate elements as * First time the cell get visited. diff --git a/src/common/mxrtc.cc b/src/common/mxrtc.cc index e808e11215bf..e72ac0bacdde 100644 --- a/src/common/mxrtc.cc +++ b/src/common/mxrtc.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file mxrtc.cc * \brief Wrapper for NVRTC * \author Junyuan Xie diff --git a/src/common/object_pool.h b/src/common/object_pool.h index 5e22d49a9e9b..6e11ce5ca785 100644 --- a/src/common/object_pool.h +++ b/src/common/object_pool.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors */ #ifndef MXNET_COMMON_OBJECT_POOL_H_ #define MXNET_COMMON_OBJECT_POOL_H_ diff --git a/src/common/utils.h b/src/common/utils.h index 5f50aab4781f..85e30970f1a0 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file utils.h * \brief Basic utilility functions. */ diff --git a/src/engine/engine.cc b/src/engine/engine.cc index ae72861260e1..d6196085bee9 100644 --- a/src/engine/engine.cc +++ b/src/engine/engine.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file engine.cc * \brief Implementation of engine. */ diff --git a/src/engine/engine_impl.h b/src/engine/engine_impl.h index 9d3fc4cd09f7..cf727366f6d9 100644 --- a/src/engine/engine_impl.h +++ b/src/engine/engine_impl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file engine_impl.h * \brief Internal implementation header of engine components. */ diff --git a/src/engine/naive_engine.cc b/src/engine/naive_engine.cc index 11ff7c8138bf..85ec3ae672e2 100644 --- a/src/engine/naive_engine.cc +++ b/src/engine/naive_engine.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file naive_engine.cc * \brief Implementation of NaiveEngine */ diff --git a/src/engine/profiler.cc b/src/engine/profiler.cc index 44099c397783..99504f61ce17 100644 --- a/src/engine/profiler.cc +++ b/src/engine/profiler.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file profiler.cc * \brief implements profiler */ diff --git a/src/engine/profiler.h b/src/engine/profiler.h index f28d691e250d..b7f8e0e1f01a 100644 --- a/src/engine/profiler.h +++ b/src/engine/profiler.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file profiler.h * \brief implements profiler */ diff --git a/src/engine/stream_manager.h b/src/engine/stream_manager.h index 2d684bbb7b9a..1a66277bb4ec 100644 --- a/src/engine/stream_manager.h +++ b/src/engine/stream_manager.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors */ #ifndef MXNET_ENGINE_STREAM_MANAGER_H_ #define MXNET_ENGINE_STREAM_MANAGER_H_ diff --git a/src/engine/thread_pool.h b/src/engine/thread_pool.h index 060f4734a675..b6fe3c2d5d6a 100644 --- a/src/engine/thread_pool.h +++ b/src/engine/thread_pool.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors */ #ifndef MXNET_ENGINE_THREAD_POOL_H_ #define MXNET_ENGINE_THREAD_POOL_H_ diff --git a/src/engine/threaded_engine.cc b/src/engine/threaded_engine.cc index 3632a46ba80b..5f348fbb44a7 100644 --- a/src/engine/threaded_engine.cc +++ b/src/engine/threaded_engine.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file threaded_engine.cc * \brief implements base threaded engine. * \author Yutian Li diff --git a/src/engine/threaded_engine.h b/src/engine/threaded_engine.h index 4612cc6e02bf..9b7b74ddd631 100644 --- a/src/engine/threaded_engine.h +++ b/src/engine/threaded_engine.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file threaded_engine.h * \brief Implements base class of threaded engine * that tracks the dependency and pushes actions to execute. diff --git a/src/engine/threaded_engine_perdevice.cc b/src/engine/threaded_engine_perdevice.cc index 97356ae91e0d..66cfc9de1468 100644 --- a/src/engine/threaded_engine_perdevice.cc +++ b/src/engine/threaded_engine_perdevice.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file threaded_engine_perdevice.cc * \brief ThreadedEngine that uses fix amount of thread for each device. */ diff --git a/src/engine/threaded_engine_pooled.cc b/src/engine/threaded_engine_pooled.cc index d806c382390c..6db7c4bb7a92 100644 --- a/src/engine/threaded_engine_pooled.cc +++ b/src/engine/threaded_engine_pooled.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file threaded_engine_pooled.cc * \brief Pooled threaded engine * \author Yutian Li diff --git a/src/executor/attach_op_execs_pass.cc b/src/executor/attach_op_execs_pass.cc index c4b3a1895ad8..13b0018b6dae 100644 --- a/src/executor/attach_op_execs_pass.cc +++ b/src/executor/attach_op_execs_pass.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file attach_op_execs_pass.cc * \brief Operator executor to execute each operator. */ diff --git a/src/executor/attach_op_resource_pass.cc b/src/executor/attach_op_resource_pass.cc index 73c8f4807b77..ef26a3575c25 100644 --- a/src/executor/attach_op_resource_pass.cc +++ b/src/executor/attach_op_resource_pass.cc @@ -1,6 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file attach_op_resource_pass.cc * \brief Pass to attach resource to OpExecVector of the graph. */ diff --git a/src/executor/exec_pass.h b/src/executor/exec_pass.h index 76b02de736e9..0eda71d98214 100644 --- a/src/executor/exec_pass.h +++ b/src/executor/exec_pass.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file exec_pass.h * \brief All the execution related pass and data structures. */ diff --git a/src/executor/graph_executor.cc b/src/executor/graph_executor.cc index a17f44a7cff5..6dc8cf39970e 100644 --- a/src/executor/graph_executor.cc +++ b/src/executor/graph_executor.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file graph_executor.cc * \brief graph executor */ diff --git a/src/executor/graph_executor.h b/src/executor/graph_executor.h index 0efb8ae09f4a..dc50bef002ab 100644 --- a/src/executor/graph_executor.h +++ b/src/executor/graph_executor.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file graph_executor.h * \brief Executor to execute the computation graph. */ diff --git a/src/executor/inplace_addto_detect_pass.cc b/src/executor/inplace_addto_detect_pass.cc index 75a2608313aa..26a91e3f1b5e 100644 --- a/src/executor/inplace_addto_detect_pass.cc +++ b/src/executor/inplace_addto_detect_pass.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file inplace_addto_detect_pass.cc * \brief Detect whether inplace addto operation is possible for certain op. */ diff --git a/src/initialize.cc b/src/initialize.cc index c1e897f01a57..092dacfb26f2 100644 --- a/src/initialize.cc +++ b/src/initialize.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file initialize.cc * \brief initialize mxnet library */ diff --git a/src/io/image_aug_default.cc b/src/io/image_aug_default.cc index f7a79d19f81b..6db14bd583c8 100644 --- a/src/io/image_aug_default.cc +++ b/src/io/image_aug_default.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file image_aug_default.cc * \brief Default augmenter. */ diff --git a/src/io/image_augmenter.h b/src/io/image_augmenter.h index 6c0ad98bee7f..5b6c4e99e502 100644 --- a/src/io/image_augmenter.h +++ b/src/io/image_augmenter.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file image_augmenter.h * \brief Interface of opencv based image augmenter */ diff --git a/src/io/image_det_aug_default.cc b/src/io/image_det_aug_default.cc index cb7966dc7414..7d15facf7843 100644 --- a/src/io/image_det_aug_default.cc +++ b/src/io/image_det_aug_default.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file image_det_aug_default.cc * \brief Default augmenter. */ diff --git a/src/io/image_io.cc b/src/io/image_io.cc index 64fd2dde1908..f9d7f33a5a44 100644 --- a/src/io/image_io.cc +++ b/src/io/image_io.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file optimizer_op-inl.h * \brief Optimizer operators * \author Junyuan Xie diff --git a/src/io/image_iter_common.h b/src/io/image_iter_common.h index 59916c9b9997..f2f72dc928eb 100644 --- a/src/io/image_iter_common.h +++ b/src/io/image_iter_common.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file image_iter_common.h * \brief common types used by image data iterators */ diff --git a/src/io/image_recordio.h b/src/io/image_recordio.h index 10674ec20355..a931539aa296 100644 --- a/src/io/image_recordio.h +++ b/src/io/image_recordio.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file image_recordio.h * \brief image recordio struct */ @@ -24,7 +42,7 @@ struct ImageRecordIO { /*! * \brief label field that returns label of images * when image list was not presented, - * + * * NOTE: user do not need to repack recordio just to * change label field, just supply a list file that * maps image id to new labels @@ -58,9 +76,9 @@ struct ImageRecordIO { return header.image_id[0]; } /*! - * \brief load header from a record content + * \brief load header from a record content * \param buf the head of record - * \param size the size of the entire record + * \param size the size of the entire record */ inline void Load(void *buf, size_t size) { CHECK(size >= sizeof(header)); diff --git a/src/io/inst_vector.h b/src/io/inst_vector.h index d82bd48e2fa1..4bc2a6c758ba 100644 --- a/src/io/inst_vector.h +++ b/src/io/inst_vector.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file inst_vector.h * \brief holder of a sequence of DataInst in CPU * that are not necessarily of same shape diff --git a/src/io/io.cc b/src/io/io.cc index 822f66f47453..e7c92843b44e 100644 --- a/src/io/io.cc +++ b/src/io/io.cc @@ -1,4 +1,22 @@ -// Copyright (c) 2015 by Contributors +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + #include #include diff --git a/src/io/iter_batchloader.h b/src/io/iter_batchloader.h index a51e24503785..c5ec10618080 100644 --- a/src/io/iter_batchloader.h +++ b/src/io/iter_batchloader.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file iter_batchloader.h * \brief define a batch adapter to create tblob batch */ diff --git a/src/io/iter_csv.cc b/src/io/iter_csv.cc index 9dcbcb8a681d..a28b8d4d9d13 100644 --- a/src/io/iter_csv.cc +++ b/src/io/iter_csv.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file iter_csv.cc * \brief define a CSV Reader to read in arrays */ diff --git a/src/io/iter_image_det_recordio.cc b/src/io/iter_image_det_recordio.cc index 25e920d77c13..4e80d5d53172 100644 --- a/src/io/iter_image_det_recordio.cc +++ b/src/io/iter_image_det_recordio.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file iter_image_recordio-inl.hpp * \brief recordio data iterator */ diff --git a/src/io/iter_image_recordio.cc b/src/io/iter_image_recordio.cc index 49694d07f1bb..64f31a65fa51 100644 --- a/src/io/iter_image_recordio.cc +++ b/src/io/iter_image_recordio.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file iter_image_recordio-inl.hpp * \brief recordio data iterator */ diff --git a/src/io/iter_image_recordio_2.cc b/src/io/iter_image_recordio_2.cc index 9d4ebf4b2864..c4d1e8624bcc 100644 --- a/src/io/iter_image_recordio_2.cc +++ b/src/io/iter_image_recordio_2.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file iter_image_recordio_2.cc * \brief new version of recordio data iterator */ diff --git a/src/io/iter_mnist.cc b/src/io/iter_mnist.cc index 09799f2b1991..055af52aaebd 100644 --- a/src/io/iter_mnist.cc +++ b/src/io/iter_mnist.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file iter_mnist.cc * \brief register mnist iterator */ diff --git a/src/io/iter_normalize.h b/src/io/iter_normalize.h index 2cebaaa3a48e..409231b59bc8 100644 --- a/src/io/iter_normalize.h +++ b/src/io/iter_normalize.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file iter_normalize.h * \brief Iterator that subtracts mean and do a few augmentations. */ diff --git a/src/io/iter_prefetcher.h b/src/io/iter_prefetcher.h index 9050ef2d1b38..89960c71a12f 100644 --- a/src/io/iter_prefetcher.h +++ b/src/io/iter_prefetcher.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file iter_prefetcher.h * \brief define a prefetcher using threaditer to keep k batch fetched */ diff --git a/src/kvstore/comm.h b/src/kvstore/comm.h index 07f2d24bd223..ade9c95feda7 100644 --- a/src/kvstore/comm.h +++ b/src/kvstore/comm.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /** - * Copyright (c) 2015 by Contributors */ #ifndef MXNET_KVSTORE_COMM_H_ #define MXNET_KVSTORE_COMM_H_ diff --git a/src/kvstore/kvstore.cc b/src/kvstore/kvstore.cc index 78d4958096cc..a288676102cb 100644 --- a/src/kvstore/kvstore.cc +++ b/src/kvstore/kvstore.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file kvstore.cc * \brief implement kv_store */ diff --git a/src/kvstore/kvstore_dist.h b/src/kvstore/kvstore_dist.h index 5f5a0cc67a64..52c7c132cb5c 100644 --- a/src/kvstore/kvstore_dist.h +++ b/src/kvstore/kvstore_dist.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /** - * Copyright (c) 2015 by Contributors * @file kvstore_dist.h * @brief distributed implementation based on ps-lite */ diff --git a/src/kvstore/kvstore_dist_server.h b/src/kvstore/kvstore_dist_server.h index 02d4a38c2b10..4e9f887173c5 100644 --- a/src/kvstore/kvstore_dist_server.h +++ b/src/kvstore/kvstore_dist_server.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file mxnet_node.h * \brief implement mxnet nodes */ diff --git a/src/kvstore/kvstore_local.h b/src/kvstore/kvstore_local.h index dc5f7b786244..536a89b46e13 100644 --- a/src/kvstore/kvstore_local.h +++ b/src/kvstore/kvstore_local.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /** - * Copyright (c) 2015 by Contributors * @file kvstore_local.h * @brief local implementation */ diff --git a/src/ndarray/autograd.cc b/src/ndarray/autograd.cc index efb6bc9dbf8d..33d0d5d307ed 100644 --- a/src/ndarray/autograd.cc +++ b/src/ndarray/autograd.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file autograd.cc * \brief Implementation of AutogradRuntime module. */ diff --git a/src/ndarray/autograd.h b/src/ndarray/autograd.h index 474864009688..52e461d52c2d 100644 --- a/src/ndarray/autograd.h +++ b/src/ndarray/autograd.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file autograd.h * \brief AutogradRuntime can automatically compute gradients */ diff --git a/src/ndarray/ndarray.cc b/src/ndarray/ndarray.cc index 48499fa2cafd..8e71df729b73 100644 --- a/src/ndarray/ndarray.cc +++ b/src/ndarray/ndarray.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file ndarray.cc * \brief ndarry module of mxnet */ diff --git a/src/ndarray/ndarray_function-inl.h b/src/ndarray/ndarray_function-inl.h index 28524b73d0dd..2be55f50f934 100644 --- a/src/ndarray/ndarray_function-inl.h +++ b/src/ndarray/ndarray_function-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file ndarray_function-inl.h * \brief The real implementation of NDArray functions. */ diff --git a/src/ndarray/ndarray_function.cc b/src/ndarray/ndarray_function.cc index a5ba2660fd34..e4af86d2c824 100644 --- a/src/ndarray/ndarray_function.cc +++ b/src/ndarray/ndarray_function.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file ndarray_function_cpu.cc * \brief CPU Implementation of ndarray function. */ diff --git a/src/ndarray/ndarray_function.cu b/src/ndarray/ndarray_function.cu index 13d36a2c4293..30d532673cff 100644 --- a/src/ndarray/ndarray_function.cu +++ b/src/ndarray/ndarray_function.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file ndarray_function_cpu.cc * \brief GPU Implementation of ndarray function. */ diff --git a/src/ndarray/ndarray_function.h b/src/ndarray/ndarray_function.h index 479f6f99f07a..b1ed58db3e74 100644 --- a/src/ndarray/ndarray_function.h +++ b/src/ndarray/ndarray_function.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file ndarray_op.h * \brief the real execution functions of ndarray operations */ diff --git a/src/operator/activation-inl.h b/src/operator/activation-inl.h index ead79be95865..6e6222bb64dd 100644 --- a/src/operator/activation-inl.h +++ b/src/operator/activation-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file activation-inl.h * \brief Activation operator * \author Bing Xu diff --git a/src/operator/activation.cc b/src/operator/activation.cc index 7ef452f4ec62..a33c11ce546d 100644 --- a/src/operator/activation.cc +++ b/src/operator/activation.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file activation.cc * \brief activation op * \author Bing Xu diff --git a/src/operator/activation.cu b/src/operator/activation.cu index 9a55354de8b0..0ac51ad03109 100644 --- a/src/operator/activation.cu +++ b/src/operator/activation.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file activation.cu * \brief * \author Bing Xu diff --git a/src/operator/batch_norm-inl.h b/src/operator/batch_norm-inl.h index 2d9c96be0cb9..b53acb4d35cb 100644 --- a/src/operator/batch_norm-inl.h +++ b/src/operator/batch_norm-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file batch_norm-inl.h * \brief * \author Bing Xu, Chris Olivier diff --git a/src/operator/batch_norm.cc b/src/operator/batch_norm.cc index e56b30671e3e..86f47dd6163f 100644 --- a/src/operator/batch_norm.cc +++ b/src/operator/batch_norm.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file batch_norm.cc * \brief * \author Bing Xu, Chris Olivier diff --git a/src/operator/batch_norm.cu b/src/operator/batch_norm.cu index 9f7370f00faa..64f7d9373823 100644 --- a/src/operator/batch_norm.cu +++ b/src/operator/batch_norm.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file batch_norm.cu * \brief CUDA Batch Normalization code * \author Chris Olivier, Bing Xu diff --git a/src/operator/batch_norm_v1-inl.h b/src/operator/batch_norm_v1-inl.h index 19215c5400d5..092c4824f9e6 100644 --- a/src/operator/batch_norm_v1-inl.h +++ b/src/operator/batch_norm_v1-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file batch_norm-inl_v1.h * \brief * \author Bing Xu diff --git a/src/operator/batch_norm_v1.cc b/src/operator/batch_norm_v1.cc index 32c5034b0832..1abced8763c5 100644 --- a/src/operator/batch_norm_v1.cc +++ b/src/operator/batch_norm_v1.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file batch_norm_v1.cc * \brief * \author Bing Xu diff --git a/src/operator/batch_norm_v1.cu b/src/operator/batch_norm_v1.cu index 302dc47dbca4..8ed22a4dc6f1 100644 --- a/src/operator/batch_norm_v1.cu +++ b/src/operator/batch_norm_v1.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file batch_norm_v1.cu * \brief * \author Bing Xu diff --git a/src/operator/bilinear_sampler-inl.h b/src/operator/bilinear_sampler-inl.h index b4c9d991865f..2d68d7855b6d 100644 --- a/src/operator/bilinear_sampler-inl.h +++ b/src/operator/bilinear_sampler-inl.h @@ -1,219 +1,237 @@ -/*! - * Copyright (c) 2017 by Contributors - * \file bilinear_Sampler-inl.h - * \brief - * \author Xu Dong -*/ -#ifndef MXNET_OPERATOR_BILINEAR_SAMPLER_INL_H_ -#define MXNET_OPERATOR_BILINEAR_SAMPLER_INL_H_ - -#include -#include -#include -#include -#include -#include -#include -#include "./operator_common.h" - -namespace mxnet { -namespace op { - -namespace bs { -enum BilinearSamplerOpInputs {kData, kGrid}; -enum BilinearSamplerOpOutputs {kOut, kTmp}; -} - -struct BilinearSamplerParam : public dmlc::Parameter { - DMLC_DECLARE_PARAMETER(BilinearSamplerParam) { - } -}; - -template -class BilinearSamplerOp : public Operator { - public: - explicit BilinearSamplerOp(BilinearSamplerParam p) { - this->param_ = p; - } - - virtual void Forward(const OpContext &ctx, - const std::vector &in_data, - const std::vector &req, - const std::vector &out_data, - const std::vector &aux_args) { - using namespace mshadow; - using namespace mshadow::expr; - CHECK_EQ(req[bs::kOut], kWriteTo); - CHECK_EQ(in_data.size(), 2U); - Stream *s = ctx.get_stream(); - - Tensor data = in_data[bs::kData].get(s); - Tensor grid = in_data[bs::kGrid].get(s); - Tensor out = out_data[bs::kOut].get(s); - - BilinearSamplerForward(out, data, grid); - } - - virtual void Backward(const OpContext &ctx, - const std::vector &out_grad, - const std::vector &in_data, - const std::vector &out_data, - const std::vector &req, - const std::vector &in_grad, - const std::vector &aux_args) { - using namespace mshadow; - using namespace mshadow::expr; - CHECK_EQ(in_data.size(), 2U); - CHECK_NE(req[bs::kData], kWriteInplace); - CHECK_NE(req[bs::kGrid], kWriteInplace); - Stream *s = ctx.get_stream(); - - Tensor data = in_data[bs::kData].get(s); - Tensor grid = in_data[bs::kGrid].get(s); - Tensor gdata = in_grad[bs::kData].get(s); - Tensor ggrid = in_grad[bs::kGrid].get(s); - Tensor grad = out_grad[bs::kOut].get(s); - if (req[bs::kData] != kNullOp && req[bs::kGrid] != kNullOp) { - if (req[bs::kData] == kWriteTo) { - gdata = scalar(0.0f); - } - if (req[bs::kGrid] == kWriteTo) { - ggrid = scalar(0.0f); - } - BilinearSamplerBackward(gdata, ggrid, grad, data, grid); - } else if (req[bs::kData] == kNullOp && req[bs::kGrid] == kNullOp) { - return; - } else { - LOG(FATAL) << "Have not implemented the data req combinations! gdata_req=" - << req[bs::kData] << " ggrid_req=" << req[bs::kGrid]; - } - } - - private: - BilinearSamplerParam param_; -}; // class BilinearSamplerOp - -template -Operator* CreateOp(BilinearSamplerParam param, int dtype); - -#if DMLC_USE_CXX11 -class BilinearSamplerProp : public OperatorProperty { - public: - int NumVisibleOutputs() const override { - return 1; - } - - int NumOutputs() const override { - return 2; - } - - std::vector ListArguments() const override { - return {"data", "grid"}; - } - - std::vector ListOutputs() const override { - return {"output", "tmp"}; - } - - void Init(const std::vector >& kwargs) override { - param_.Init(kwargs); - } - - std::map GetParams() const override { - return param_.__DICT__(); - } - - bool InferShape(std::vector *in_shape, - std::vector *out_shape, - std::vector *aux_shape) const override { - using namespace mshadow; - CHECK_EQ(in_shape->size(), 2U) << "Input:[data, grid]"; - const TShape &dshape = (*in_shape)[bs::kData]; - const TShape &lshape = (*in_shape)[bs::kGrid]; - if (dshape.ndim() == 0) return false; - CHECK_EQ(dshape.ndim(), 4U) \ - << "input data should be 4D in batch-num_filter-y-x"; - if (lshape.ndim() == 0) return false; - CHECK_EQ(lshape.ndim(), 4U) \ - << "Sampler grid should be 4D in batch-2-y-x"; - CHECK_EQ(dshape[0], lshape[0]); - CHECK_EQ(lshape[1], 2U) << "incorrect grid shape[1], should be 2"; - // target height - CHECK_GT(lshape[2], 0U) \ - << "incorrect grid_shape: " << lshape[2]; - // target width - CHECK_GT(lshape[3], 0U) \ - << "incorrect grid_shape: " << lshape[3]; - out_shape->clear(); - // output_shape : (data.shape[0], data.shape[1], grid.shape[2], grid.shape[3]) - out_shape->push_back(dshape); - (*out_shape)[bs::kOut][2] = lshape[2]; - (*out_shape)[bs::kOut][3] = lshape[3]; - out_shape->push_back(Shape4(lshape[0], lshape[2], lshape[3], 2)); - return true; - } - - bool InferType(std::vector *in_type, - std::vector *out_type, - std::vector *aux_type) const override { - int dtype = -1; - for (size_t i = 0; i < in_type->size(); ++i) { - if (dtype == -1) { - dtype = in_type->at(i); - } else { - CHECK(in_type->at(i) == dtype || - in_type->at(i) == -1) << - "Non-uniform data type in BilinearSampler"; - } - } - if (dtype == -1) { - LOG(FATAL) << "Not enough information to infer type in BilinearSampler."; - return false; - } - size_t nin = this->ListArguments().size(); - in_type->clear(); - for (size_t i = 0; i < nin; ++i) in_type->push_back(dtype); - size_t naux = this->ListAuxiliaryStates().size(); - aux_type->clear(); - for (size_t i = 0; i < naux; ++i) aux_type->push_back(dtype); - size_t nout = this->ListOutputs().size(); - out_type->clear(); - for (size_t i = 0; i < nout; ++i) out_type->push_back(dtype); - return true; - } - - OperatorProperty* Copy() const override { - auto ptr = new BilinearSamplerProp(); - ptr->param_ = param_; - return ptr; - } - - std::string TypeString() const override { - return "BilinearSampler"; - } - - std::vector DeclareBackwardDependency( - const std::vector &out_grad, - const std::vector &in_data, - const std::vector &out_data) const override { - return {out_grad[bs::kOut], - in_data[bs::kData], - out_data[bs::kTmp], - in_data[bs::kGrid]}; - } - - Operator* CreateOperator(Context ctx) const override { - LOG(FATAL) << "Not Implemented."; - return NULL; - } - - Operator* CreateOperatorEx(Context ctx, std::vector *in_shape, - std::vector *in_type) const override; - - private: - BilinearSamplerParam param_; -}; // class BilinearSamplerProp -#endif // DMLC_USE_CXX11 -} // namespace op -} // namespace mxnet -#endif // MXNET_OPERATOR_BILINEAR_SAMPLER_INL_H_ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/*! + * \file bilinear_Sampler-inl.h + * \brief + * \author Xu Dong +*/ +#ifndef MXNET_OPERATOR_BILINEAR_SAMPLER_INL_H_ +#define MXNET_OPERATOR_BILINEAR_SAMPLER_INL_H_ + +#include +#include +#include +#include +#include +#include +#include +#include "./operator_common.h" + +namespace mxnet { +namespace op { + +namespace bs { +enum BilinearSamplerOpInputs {kData, kGrid}; +enum BilinearSamplerOpOutputs {kOut, kTmp}; +} + +struct BilinearSamplerParam : public dmlc::Parameter { + DMLC_DECLARE_PARAMETER(BilinearSamplerParam) { + } +}; + +template +class BilinearSamplerOp : public Operator { + public: + explicit BilinearSamplerOp(BilinearSamplerParam p) { + this->param_ = p; + } + + virtual void Forward(const OpContext &ctx, + const std::vector &in_data, + const std::vector &req, + const std::vector &out_data, + const std::vector &aux_args) { + using namespace mshadow; + using namespace mshadow::expr; + CHECK_EQ(req[bs::kOut], kWriteTo); + CHECK_EQ(in_data.size(), 2U); + Stream *s = ctx.get_stream(); + + Tensor data = in_data[bs::kData].get(s); + Tensor grid = in_data[bs::kGrid].get(s); + Tensor out = out_data[bs::kOut].get(s); + + BilinearSamplerForward(out, data, grid); + } + + virtual void Backward(const OpContext &ctx, + const std::vector &out_grad, + const std::vector &in_data, + const std::vector &out_data, + const std::vector &req, + const std::vector &in_grad, + const std::vector &aux_args) { + using namespace mshadow; + using namespace mshadow::expr; + CHECK_EQ(in_data.size(), 2U); + CHECK_NE(req[bs::kData], kWriteInplace); + CHECK_NE(req[bs::kGrid], kWriteInplace); + Stream *s = ctx.get_stream(); + + Tensor data = in_data[bs::kData].get(s); + Tensor grid = in_data[bs::kGrid].get(s); + Tensor gdata = in_grad[bs::kData].get(s); + Tensor ggrid = in_grad[bs::kGrid].get(s); + Tensor grad = out_grad[bs::kOut].get(s); + if (req[bs::kData] != kNullOp && req[bs::kGrid] != kNullOp) { + if (req[bs::kData] == kWriteTo) { + gdata = scalar(0.0f); + } + if (req[bs::kGrid] == kWriteTo) { + ggrid = scalar(0.0f); + } + BilinearSamplerBackward(gdata, ggrid, grad, data, grid); + } else if (req[bs::kData] == kNullOp && req[bs::kGrid] == kNullOp) { + return; + } else { + LOG(FATAL) << "Have not implemented the data req combinations! gdata_req=" + << req[bs::kData] << " ggrid_req=" << req[bs::kGrid]; + } + } + + private: + BilinearSamplerParam param_; +}; // class BilinearSamplerOp + +template +Operator* CreateOp(BilinearSamplerParam param, int dtype); + +#if DMLC_USE_CXX11 +class BilinearSamplerProp : public OperatorProperty { + public: + int NumVisibleOutputs() const override { + return 1; + } + + int NumOutputs() const override { + return 2; + } + + std::vector ListArguments() const override { + return {"data", "grid"}; + } + + std::vector ListOutputs() const override { + return {"output", "tmp"}; + } + + void Init(const std::vector >& kwargs) override { + param_.Init(kwargs); + } + + std::map GetParams() const override { + return param_.__DICT__(); + } + + bool InferShape(std::vector *in_shape, + std::vector *out_shape, + std::vector *aux_shape) const override { + using namespace mshadow; + CHECK_EQ(in_shape->size(), 2U) << "Input:[data, grid]"; + const TShape &dshape = (*in_shape)[bs::kData]; + const TShape &lshape = (*in_shape)[bs::kGrid]; + if (dshape.ndim() == 0) return false; + CHECK_EQ(dshape.ndim(), 4U) \ + << "input data should be 4D in batch-num_filter-y-x"; + if (lshape.ndim() == 0) return false; + CHECK_EQ(lshape.ndim(), 4U) \ + << "Sampler grid should be 4D in batch-2-y-x"; + CHECK_EQ(dshape[0], lshape[0]); + CHECK_EQ(lshape[1], 2U) << "incorrect grid shape[1], should be 2"; + // target height + CHECK_GT(lshape[2], 0U) \ + << "incorrect grid_shape: " << lshape[2]; + // target width + CHECK_GT(lshape[3], 0U) \ + << "incorrect grid_shape: " << lshape[3]; + out_shape->clear(); + // output_shape : (data.shape[0], data.shape[1], grid.shape[2], grid.shape[3]) + out_shape->push_back(dshape); + (*out_shape)[bs::kOut][2] = lshape[2]; + (*out_shape)[bs::kOut][3] = lshape[3]; + out_shape->push_back(Shape4(lshape[0], lshape[2], lshape[3], 2)); + return true; + } + + bool InferType(std::vector *in_type, + std::vector *out_type, + std::vector *aux_type) const override { + int dtype = -1; + for (size_t i = 0; i < in_type->size(); ++i) { + if (dtype == -1) { + dtype = in_type->at(i); + } else { + CHECK(in_type->at(i) == dtype || + in_type->at(i) == -1) << + "Non-uniform data type in BilinearSampler"; + } + } + if (dtype == -1) { + LOG(FATAL) << "Not enough information to infer type in BilinearSampler."; + return false; + } + size_t nin = this->ListArguments().size(); + in_type->clear(); + for (size_t i = 0; i < nin; ++i) in_type->push_back(dtype); + size_t naux = this->ListAuxiliaryStates().size(); + aux_type->clear(); + for (size_t i = 0; i < naux; ++i) aux_type->push_back(dtype); + size_t nout = this->ListOutputs().size(); + out_type->clear(); + for (size_t i = 0; i < nout; ++i) out_type->push_back(dtype); + return true; + } + + OperatorProperty* Copy() const override { + auto ptr = new BilinearSamplerProp(); + ptr->param_ = param_; + return ptr; + } + + std::string TypeString() const override { + return "BilinearSampler"; + } + + std::vector DeclareBackwardDependency( + const std::vector &out_grad, + const std::vector &in_data, + const std::vector &out_data) const override { + return {out_grad[bs::kOut], + in_data[bs::kData], + out_data[bs::kTmp], + in_data[bs::kGrid]}; + } + + Operator* CreateOperator(Context ctx) const override { + LOG(FATAL) << "Not Implemented."; + return NULL; + } + + Operator* CreateOperatorEx(Context ctx, std::vector *in_shape, + std::vector *in_type) const override; + + private: + BilinearSamplerParam param_; +}; // class BilinearSamplerProp +#endif // DMLC_USE_CXX11 +} // namespace op +} // namespace mxnet +#endif // MXNET_OPERATOR_BILINEAR_SAMPLER_INL_H_ diff --git a/src/operator/bilinear_sampler.cc b/src/operator/bilinear_sampler.cc index ca83a43343a6..d03f6798fde5 100644 --- a/src/operator/bilinear_sampler.cc +++ b/src/operator/bilinear_sampler.cc @@ -1,228 +1,246 @@ -/*! - * Copyright (c) 2017 by Contributors - * \file bilinear_sampler.cc - * \brief - * \author Xu Dong -*/ - -#include "./bilinear_sampler-inl.h" - -namespace mshadow { -template -bool between(DType value, int lowerBound, int upperBound) { - return (value >= lowerBound && value <= upperBound); -} -template -inline void BilinearSamplerForward(const Tensor &output, - const Tensor &input, - const Tensor &grid_src) { - DType *out = output.dptr_; - const DType *data = input.dptr_; - const DType *grid = grid_src.dptr_; - int o_n = output.size(0), o_c = output.size(1), o_h = output.size(2), o_w = output.size(3); - int i_c = input.size(1), i_h = input.size(2), i_w = input.size(3); - for (index_t n = 0; n < static_cast(o_n); ++n) { - for (index_t c = 0; c < static_cast(o_c); ++c) { - for (index_t h = 0; h < static_cast(o_h); ++h) { - for (index_t w = 0; w < static_cast(o_w); ++w) { - index_t out_index = n * o_c * o_h * o_w + c * o_h * o_w + h * o_w + w; - index_t grid_index = n * o_h * o_w * 2 + h * o_w + w; - DType y_real = (*(grid + grid_index + o_h * o_w) + 1) * (i_h - 1) / 2; - DType x_real = (*(grid + grid_index) + 1) * (i_w - 1) / 2; - int top_left_y = static_cast(floor(y_real)); - int top_left_x = static_cast(floor(x_real)); - DType top_left_y_w = 1.0 - (y_real - top_left_y); - DType top_left_x_w = 1.0 - (x_real - top_left_x); - int data_index = n * i_c * i_h * i_w + c * i_h * i_w + - top_left_y * i_w + top_left_x; - DType top_left_v = 0; - DType top_right_v = 0; - DType bottom_left_v = 0; - DType bottom_right_v = 0; - if (between(top_left_x, 0, i_w-1) && between(top_left_y, 0, i_h-1)) - top_left_v = *(data + data_index); - if (between(top_left_x + 1, 0, i_w-1) && between(top_left_y, 0, i_h-1)) - top_right_v = *(data + data_index + 1); - if (between(top_left_x, 0, i_w-1) && between(top_left_y + 1, 0, i_h-1)) - bottom_left_v = *(data + data_index + i_w); - if (between(top_left_x+1, 0, i_w-1) && between(top_left_y + 1, 0, i_h-1)) - bottom_right_v = *(data + data_index + i_w + 1); - *(out+out_index) = top_left_v * top_left_y_w * top_left_x_w + - top_right_v * top_left_y_w * (1.0 - top_left_x_w) + - bottom_left_v * (1.0 - top_left_y_w) * top_left_x_w + - bottom_right_v * (1.0 - top_left_y_w) * (1.0 - top_left_x_w); - } - } - } - } -} - -template -inline void BilinearSamplerBackward(const Tensor &gdata, - const Tensor &ggrid, - const Tensor &output_grad, - const Tensor &input_data, - const Tensor &grid) { - DType *g_input = gdata.dptr_; - DType *grad_grid = ggrid.dptr_; - const DType *grid_src = grid.dptr_; - const DType *grad = output_grad.dptr_; - const DType *data = input_data.dptr_; - int o_n = output_grad.size(0), o_c = output_grad.size(1), - o_h = output_grad.size(2), o_w = output_grad.size(3); - int i_c = input_data.size(1), i_h = input_data.size(2), i_w = input_data.size(3); - for (index_t n = 0; n < static_cast(o_n); ++n) { - for (index_t h = 0; h < static_cast(o_h); ++h) { - for (index_t w = 0; w < static_cast(o_w); ++w) { - DType top_left_y_gw = 0.0; - DType top_left_x_gw = 0.0; - index_t grid_src_index = n * o_h * o_w * 2 + h * o_w + w; - DType y_real = (*(grid_src + grid_src_index + o_h * o_w) + 1) * (i_h - 1) / 2; - DType x_real = (*(grid_src + grid_src_index) + 1) * (i_w - 1) / 2; - int top_left_y = static_cast(floor(y_real)); - int top_left_x = static_cast(floor(x_real)); - DType top_left_y_w = 1.0 - (y_real - top_left_y); - DType top_left_x_w = 1.0 - (x_real - top_left_x); - for (index_t c = 0; c < static_cast(o_c); ++c) { - index_t grad_index = n * o_c * o_h * o_w + c * o_h * o_w + h * o_w + w; - int data_index = n * i_c * i_h * i_w + c * i_h * i_w + top_left_y * i_w - + top_left_x; - // calc 4 vertex value in input data - DType top_left_v = 0; - DType top_right_v = 0; - DType bottom_left_v = 0; - DType bottom_right_v = 0; - // calc input grad - if (between(top_left_x, 0, i_w-1) && between(top_left_y, 0, i_h-1)) { - *(g_input + data_index) += *(grad + grad_index) * top_left_y_w * top_left_x_w; - top_left_v = *(data + data_index); - } - if (between(top_left_x+1, 0, i_w-1) && between(top_left_y, 0, i_h-1)) { - *(g_input + data_index + 1) += *(grad + grad_index) * top_left_y_w - * (1.0 - top_left_x_w); - top_right_v = *(data + data_index + 1); - } - if (between(top_left_x, 0, i_w-1) && between(top_left_y+1, 0, i_h-1)) { - *(g_input + data_index+ i_w) += *(grad + grad_index) * (1.0 - top_left_y_w) - * top_left_x_w; - bottom_left_v = *(data + data_index + i_w); - } - if (between(top_left_x+1, 0, i_w-1) && between(top_left_y+1, 0, i_h-1)) { - *(g_input + data_index+ i_w + 1) += *(grad + grad_index) * (1.0 - top_left_y_w) - * (1.0 - top_left_x_w); - bottom_right_v = *(data + data_index + i_w + 1); - } - // calc weight grad of top_left_w, then multiple -1 is the grad of grid_src - top_left_y_gw -= *(grad + grad_index) * (top_right_v - bottom_right_v + - (top_left_v - top_right_v - bottom_left_v + bottom_right_v) - * top_left_x_w); - top_left_x_gw -= *(grad + grad_index) * (bottom_left_v - bottom_right_v + - (top_left_v - top_right_v - bottom_left_v + bottom_right_v) - * top_left_y_w); - } - // calc grad of grid - *(grad_grid + grid_src_index + o_h * o_w) += top_left_y_gw * (i_h - 1) / 2; - *(grad_grid + grid_src_index) += top_left_x_gw * (i_w - 1) / 2; - } - } - } - } -} // namespace mshadow - -namespace mxnet { -namespace op { -template<> -Operator* CreateOp(BilinearSamplerParam param, int dtype) { - Operator *op = NULL; - MSHADOW_REAL_TYPE_SWITCH(dtype, DType, { - op = new BilinearSamplerOp(param); - }) - return op; -} - -Operator *BilinearSamplerProp::CreateOperatorEx(Context ctx, std::vector *in_shape, - std::vector *in_type) const { - DO_BIND_DISPATCH(CreateOp, param_, (*in_type)[0]); -} - -DMLC_REGISTER_PARAMETER(BilinearSamplerParam); - -MXNET_REGISTER_OP_PROPERTY(BilinearSampler, BilinearSamplerProp) -.add_argument("data", "NDArray-or-Symbol", "Input data to the BilinearsamplerOp.") -.add_argument("grid", "NDArray-or-Symbol", "Input grid to the BilinearsamplerOp." - "grid has two channels: x_src, y_src") -.add_arguments(BilinearSamplerParam::__FIELDS__()) -.describe(R"code(Applies bilinear sampling to input feature map. - -Bilinear Sampling is the key of [NIPS2015] \"Spatial Transformer Networks\". The usage of the operator is very similar to remap function in OpenCV, -except that the operator has the backward pass. - -Given :math:`data` and :math:`grid`, then the output is computed by - -.. math:: - x_{src} = grid[batch, 0, y_{dst}, x_{dst}] \\ - y_{src} = grid[batch, 1, y_{dst}, x_{dst}] \\ - output[batch, channel, y_{dst}, x_{dst}] = G(data[batch, channel, y_{src}, x_{src}) - -:math:`x_{dst}`, :math:`y_{dst}` enumerate all spatial locations in :math:`output`, and :math:`G()` denotes the bilinear interpolation kernel. -The out-boundary points will be padded with zeros.The shape of the output will be (data.shape[0], data.shape[1], grid.shape[2], grid.shape[3]). - -The operator assumes that :math:`data` has 'NCHW' layout and :math:`grid` has been normalized to [-1, 1]. - -BilinearSampler often cooperates with GridGenerator which generates sampling grids for BilinearSampler. -GridGenerator supports two kinds of transformation: ``affine`` and ``warp``. -If users want to design a CustomOp to manipulate :math:`grid`, please firstly refer to the code of GridGenerator. - -Example 1:: - - ## Zoom out data two times - data = array([[[[1, 4, 3, 6], - [1, 8, 8, 9], - [0, 4, 1, 5], - [1, 0, 1, 3]]]]) - - affine_matrix = array([[2, 0, 0], - [0, 2, 0]]) - - affine_matrix = reshape(affine_matrix, shape=(1, 6)) - - grid = GridGenerator(data=affine_matrix, transform_type='affine', target_shape=(4, 4)) - - out = BilinearSampler(data, grid) - - out - [[[[ 0, 0, 0, 0], - [ 0, 3.5, 6.5, 0], - [ 0, 1.25, 2.5, 0], - [ 0, 0, 0, 0]]] - - -Example 2:: - - ## shift data horizontally by -1 pixel - - data = array([[[[1, 4, 3, 6], - [1, 8, 8, 9], - [0, 4, 1, 5], - [1, 0, 1, 3]]]]) - - warp_maxtrix = array([[[[1, 1, 1, 1], - [1, 1, 1, 1], - [1, 1, 1, 1], - [1, 1, 1, 1]], - [[0, 0, 0, 0], - [0, 0, 0, 0], - [0, 0, 0, 0], - [0, 0, 0, 0]]]]) - - grid = GridGenerator(data=warp_matrix, transform_type='warp') - out = BilinearSampler(data, grid) - - out - [[[[ 4, 3, 6, 0], - [ 8, 8, 9, 0], - [ 4, 1, 5, 0], - [ 0, 1, 3, 0]]] -)code" ADD_FILELINE); -} // namespace op -} // namespace mxnet +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/*! + * \file bilinear_sampler.cc + * \brief + * \author Xu Dong +*/ + +#include "./bilinear_sampler-inl.h" + +namespace mshadow { +template +bool between(DType value, int lowerBound, int upperBound) { + return (value >= lowerBound && value <= upperBound); +} +template +inline void BilinearSamplerForward(const Tensor &output, + const Tensor &input, + const Tensor &grid_src) { + DType *out = output.dptr_; + const DType *data = input.dptr_; + const DType *grid = grid_src.dptr_; + int o_n = output.size(0), o_c = output.size(1), o_h = output.size(2), o_w = output.size(3); + int i_c = input.size(1), i_h = input.size(2), i_w = input.size(3); + for (index_t n = 0; n < static_cast(o_n); ++n) { + for (index_t c = 0; c < static_cast(o_c); ++c) { + for (index_t h = 0; h < static_cast(o_h); ++h) { + for (index_t w = 0; w < static_cast(o_w); ++w) { + index_t out_index = n * o_c * o_h * o_w + c * o_h * o_w + h * o_w + w; + index_t grid_index = n * o_h * o_w * 2 + h * o_w + w; + DType y_real = (*(grid + grid_index + o_h * o_w) + 1) * (i_h - 1) / 2; + DType x_real = (*(grid + grid_index) + 1) * (i_w - 1) / 2; + int top_left_y = static_cast(floor(y_real)); + int top_left_x = static_cast(floor(x_real)); + DType top_left_y_w = 1.0 - (y_real - top_left_y); + DType top_left_x_w = 1.0 - (x_real - top_left_x); + int data_index = n * i_c * i_h * i_w + c * i_h * i_w + + top_left_y * i_w + top_left_x; + DType top_left_v = 0; + DType top_right_v = 0; + DType bottom_left_v = 0; + DType bottom_right_v = 0; + if (between(top_left_x, 0, i_w-1) && between(top_left_y, 0, i_h-1)) + top_left_v = *(data + data_index); + if (between(top_left_x + 1, 0, i_w-1) && between(top_left_y, 0, i_h-1)) + top_right_v = *(data + data_index + 1); + if (between(top_left_x, 0, i_w-1) && between(top_left_y + 1, 0, i_h-1)) + bottom_left_v = *(data + data_index + i_w); + if (between(top_left_x+1, 0, i_w-1) && between(top_left_y + 1, 0, i_h-1)) + bottom_right_v = *(data + data_index + i_w + 1); + *(out+out_index) = top_left_v * top_left_y_w * top_left_x_w + + top_right_v * top_left_y_w * (1.0 - top_left_x_w) + + bottom_left_v * (1.0 - top_left_y_w) * top_left_x_w + + bottom_right_v * (1.0 - top_left_y_w) * (1.0 - top_left_x_w); + } + } + } + } +} + +template +inline void BilinearSamplerBackward(const Tensor &gdata, + const Tensor &ggrid, + const Tensor &output_grad, + const Tensor &input_data, + const Tensor &grid) { + DType *g_input = gdata.dptr_; + DType *grad_grid = ggrid.dptr_; + const DType *grid_src = grid.dptr_; + const DType *grad = output_grad.dptr_; + const DType *data = input_data.dptr_; + int o_n = output_grad.size(0), o_c = output_grad.size(1), + o_h = output_grad.size(2), o_w = output_grad.size(3); + int i_c = input_data.size(1), i_h = input_data.size(2), i_w = input_data.size(3); + for (index_t n = 0; n < static_cast(o_n); ++n) { + for (index_t h = 0; h < static_cast(o_h); ++h) { + for (index_t w = 0; w < static_cast(o_w); ++w) { + DType top_left_y_gw = 0.0; + DType top_left_x_gw = 0.0; + index_t grid_src_index = n * o_h * o_w * 2 + h * o_w + w; + DType y_real = (*(grid_src + grid_src_index + o_h * o_w) + 1) * (i_h - 1) / 2; + DType x_real = (*(grid_src + grid_src_index) + 1) * (i_w - 1) / 2; + int top_left_y = static_cast(floor(y_real)); + int top_left_x = static_cast(floor(x_real)); + DType top_left_y_w = 1.0 - (y_real - top_left_y); + DType top_left_x_w = 1.0 - (x_real - top_left_x); + for (index_t c = 0; c < static_cast(o_c); ++c) { + index_t grad_index = n * o_c * o_h * o_w + c * o_h * o_w + h * o_w + w; + int data_index = n * i_c * i_h * i_w + c * i_h * i_w + top_left_y * i_w + + top_left_x; + // calc 4 vertex value in input data + DType top_left_v = 0; + DType top_right_v = 0; + DType bottom_left_v = 0; + DType bottom_right_v = 0; + // calc input grad + if (between(top_left_x, 0, i_w-1) && between(top_left_y, 0, i_h-1)) { + *(g_input + data_index) += *(grad + grad_index) * top_left_y_w * top_left_x_w; + top_left_v = *(data + data_index); + } + if (between(top_left_x+1, 0, i_w-1) && between(top_left_y, 0, i_h-1)) { + *(g_input + data_index + 1) += *(grad + grad_index) * top_left_y_w + * (1.0 - top_left_x_w); + top_right_v = *(data + data_index + 1); + } + if (between(top_left_x, 0, i_w-1) && between(top_left_y+1, 0, i_h-1)) { + *(g_input + data_index+ i_w) += *(grad + grad_index) * (1.0 - top_left_y_w) + * top_left_x_w; + bottom_left_v = *(data + data_index + i_w); + } + if (between(top_left_x+1, 0, i_w-1) && between(top_left_y+1, 0, i_h-1)) { + *(g_input + data_index+ i_w + 1) += *(grad + grad_index) * (1.0 - top_left_y_w) + * (1.0 - top_left_x_w); + bottom_right_v = *(data + data_index + i_w + 1); + } + // calc weight grad of top_left_w, then multiple -1 is the grad of grid_src + top_left_y_gw -= *(grad + grad_index) * (top_right_v - bottom_right_v + + (top_left_v - top_right_v - bottom_left_v + bottom_right_v) + * top_left_x_w); + top_left_x_gw -= *(grad + grad_index) * (bottom_left_v - bottom_right_v + + (top_left_v - top_right_v - bottom_left_v + bottom_right_v) + * top_left_y_w); + } + // calc grad of grid + *(grad_grid + grid_src_index + o_h * o_w) += top_left_y_gw * (i_h - 1) / 2; + *(grad_grid + grid_src_index) += top_left_x_gw * (i_w - 1) / 2; + } + } + } + } +} // namespace mshadow + +namespace mxnet { +namespace op { +template<> +Operator* CreateOp(BilinearSamplerParam param, int dtype) { + Operator *op = NULL; + MSHADOW_REAL_TYPE_SWITCH(dtype, DType, { + op = new BilinearSamplerOp(param); + }) + return op; +} + +Operator *BilinearSamplerProp::CreateOperatorEx(Context ctx, std::vector *in_shape, + std::vector *in_type) const { + DO_BIND_DISPATCH(CreateOp, param_, (*in_type)[0]); +} + +DMLC_REGISTER_PARAMETER(BilinearSamplerParam); + +MXNET_REGISTER_OP_PROPERTY(BilinearSampler, BilinearSamplerProp) +.add_argument("data", "NDArray-or-Symbol", "Input data to the BilinearsamplerOp.") +.add_argument("grid", "NDArray-or-Symbol", "Input grid to the BilinearsamplerOp." + "grid has two channels: x_src, y_src") +.add_arguments(BilinearSamplerParam::__FIELDS__()) +.describe(R"code(Applies bilinear sampling to input feature map. + +Bilinear Sampling is the key of [NIPS2015] \"Spatial Transformer Networks\". The usage of the operator is very similar to remap function in OpenCV, +except that the operator has the backward pass. + +Given :math:`data` and :math:`grid`, then the output is computed by + +.. math:: + x_{src} = grid[batch, 0, y_{dst}, x_{dst}] \\ + y_{src} = grid[batch, 1, y_{dst}, x_{dst}] \\ + output[batch, channel, y_{dst}, x_{dst}] = G(data[batch, channel, y_{src}, x_{src}) + +:math:`x_{dst}`, :math:`y_{dst}` enumerate all spatial locations in :math:`output`, and :math:`G()` denotes the bilinear interpolation kernel. +The out-boundary points will be padded with zeros.The shape of the output will be (data.shape[0], data.shape[1], grid.shape[2], grid.shape[3]). + +The operator assumes that :math:`data` has 'NCHW' layout and :math:`grid` has been normalized to [-1, 1]. + +BilinearSampler often cooperates with GridGenerator which generates sampling grids for BilinearSampler. +GridGenerator supports two kinds of transformation: ``affine`` and ``warp``. +If users want to design a CustomOp to manipulate :math:`grid`, please firstly refer to the code of GridGenerator. + +Example 1:: + + ## Zoom out data two times + data = array([[[[1, 4, 3, 6], + [1, 8, 8, 9], + [0, 4, 1, 5], + [1, 0, 1, 3]]]]) + + affine_matrix = array([[2, 0, 0], + [0, 2, 0]]) + + affine_matrix = reshape(affine_matrix, shape=(1, 6)) + + grid = GridGenerator(data=affine_matrix, transform_type='affine', target_shape=(4, 4)) + + out = BilinearSampler(data, grid) + + out + [[[[ 0, 0, 0, 0], + [ 0, 3.5, 6.5, 0], + [ 0, 1.25, 2.5, 0], + [ 0, 0, 0, 0]]] + + +Example 2:: + + ## shift data horizontally by -1 pixel + + data = array([[[[1, 4, 3, 6], + [1, 8, 8, 9], + [0, 4, 1, 5], + [1, 0, 1, 3]]]]) + + warp_maxtrix = array([[[[1, 1, 1, 1], + [1, 1, 1, 1], + [1, 1, 1, 1], + [1, 1, 1, 1]], + [[0, 0, 0, 0], + [0, 0, 0, 0], + [0, 0, 0, 0], + [0, 0, 0, 0]]]]) + + grid = GridGenerator(data=warp_matrix, transform_type='warp') + out = BilinearSampler(data, grid) + + out + [[[[ 4, 3, 6, 0], + [ 8, 8, 9, 0], + [ 4, 1, 5, 0], + [ 0, 1, 3, 0]]] +)code" ADD_FILELINE); +} // namespace op +} // namespace mxnet diff --git a/src/operator/bilinear_sampler.cu b/src/operator/bilinear_sampler.cu index dc394f130b0a..14b5cd20a3d7 100644 --- a/src/operator/bilinear_sampler.cu +++ b/src/operator/bilinear_sampler.cu @@ -1,207 +1,225 @@ -/*! - * Copyright (c) 2017 by Contributors - * \file bilinear_sampler.cu - * \brief - * \author Xu Dong -*/ - -#include "./bilinear_sampler-inl.h" -#include -#include "../common/cuda_utils.h" -#if MXNET_USE_CUDNN == 1 && CUDNN_MAJOR >= 5 -#include "./cudnn_bilinear_sampler-inl.h" -#endif // MXNET_USE_CUDNN && CUDNN_MAJOR - -namespace mshadow { -namespace cuda { -template -__device__ bool between(DType value, int lowerBound, int upperBound) { - return (value >= lowerBound && value <= upperBound); -} -template -__global__ void BilinearSamplerForwardKernel(const int i_c, const int i_h, - const int i_w, const DType* data, - const DType* grid, const int o_n, - const int o_c, const int o_h, - const int o_w, DType* out) { - for (int index = (blockIdx.x + blockIdx.y * gridDim.x) * blockDim.x + threadIdx.x; - index < o_n * o_c * o_h * o_w; - index += blockDim.x * gridDim.x * gridDim.y) { - // (n, c, h, w) is the element in out - int w = index % o_w; - int h = (index / o_w) % o_h; - int c = (index / o_w / o_h) % o_c; - int n = index / o_w / o_h / o_c; - index_t out_index = n * o_c * o_h * o_w + c * o_h * o_w + h * o_w + w; - index_t grid_index = n * o_h * o_w * 2 + h * o_w + w; - DType y_real = (*(grid + grid_index + o_h * o_w) + 1) * (i_h - 1) / 2; - DType x_real = (*(grid + grid_index) + 1) * (i_w - 1) / 2; - int top_left_y = static_cast(floor(y_real)); - int top_left_x = static_cast(floor(x_real)); - DType top_left_y_w = 1.0 - (y_real - top_left_y); - DType top_left_x_w = 1.0 - (x_real - top_left_x); - int data_index = n * i_c * i_h * i_w + c * i_h * i_w + top_left_y * i_w + top_left_x; - DType top_left_v = 0; - DType top_right_v = 0; - DType bottom_left_v = 0; - DType bottom_right_v = 0; - if (between(top_left_x, 0, i_w-1) && between(top_left_y, 0, i_h-1)) - top_left_v = *(data + data_index); - if (between(top_left_x + 1, 0, i_w-1) && between(top_left_y, 0, i_h-1)) - top_right_v = *(data + data_index + 1); - if (between(top_left_x, 0, i_w-1) && between(top_left_y + 1, 0, i_h-1)) - bottom_left_v = *(data + data_index + i_w); - if (between(top_left_x+1, 0, i_w-1) && between(top_left_y + 1, 0, i_h-1)) - bottom_right_v = *(data + data_index + i_w + 1); - *(out+out_index) = top_left_v * top_left_y_w * top_left_x_w + - top_right_v * top_left_y_w * (1.0 - top_left_x_w) + - bottom_left_v * (1.0 - top_left_y_w) * top_left_x_w + - bottom_right_v * (1.0 - top_left_y_w) * (1.0 - top_left_x_w); - } -} - -template -__global__ void BilinearSamplerBackwardKernel(const int i_c, const int i_h, - const int i_w, const DType* grad, - const DType* data, const int o_n, - const int o_c, const int o_h, - const int o_w, DType* g_input, - const DType* grid_src, - DType* grad_grid) { - for (int index = (blockIdx.x + blockIdx.y * gridDim.x) * blockDim.x + threadIdx.x; - index < o_n * o_h * o_w; - index += blockDim.x * gridDim.x * gridDim.y) { - // (n, c, h, w) is the element in grad - int w = index % o_w; - int h = (index / o_w) % o_h; - int n = index / o_w / o_h; - DType top_left_y_gw = 0.0; - DType top_left_x_gw = 0.0; - index_t grid_src_index = n * o_h * o_w * 2 + h * o_w + w; - DType y_real = (*(grid_src + grid_src_index + o_h * o_w) + 1) * (i_h - 1) / 2; - DType x_real = (*(grid_src + grid_src_index) + 1) * (i_w - 1) / 2; - - int top_left_y = static_cast(floor(y_real)); - int top_left_x = static_cast(floor(x_real)); - DType top_left_y_w = 1.0 - (y_real - top_left_y); - DType top_left_x_w = 1.0 - (x_real - top_left_x); - for (index_t c = 0; c < o_c; ++c) { - index_t grad_index = n * o_c * o_h * o_w + c * o_h * o_w + h * o_w + w; - int data_index = n * i_c * i_h * i_w + c * i_h * i_w + top_left_y * i_w + top_left_x; - // calc 4 vertex value in input data - DType top_left_v = 0; - DType top_right_v = 0; - DType bottom_left_v = 0; - DType bottom_right_v = 0; - // calc input grad - if (between(top_left_x, 0, i_w-1) && between(top_left_y, 0, i_h-1)) { - atomicAdd(&g_input[data_index], *(grad + grad_index) * top_left_y_w * top_left_x_w); - top_left_v = *(data + data_index); - } - if (between(top_left_x+1, 0, i_w-1) && between(top_left_y, 0, i_h-1)) { - atomicAdd(&g_input[data_index + 1], *(grad + grad_index) * top_left_y_w - * (1.0 - top_left_x_w)); - top_right_v = *(data + data_index + 1); - } - if (between(top_left_x, 0, i_w-1) && between(top_left_y+1, 0, i_h-1)) { - atomicAdd(&g_input[data_index+ i_w], *(grad + grad_index) * (1.0 - top_left_y_w) - * top_left_x_w); - bottom_left_v = *(data + data_index + i_w); - } - if (between(top_left_x+1, 0, i_w-1) && between(top_left_y+1, 0, i_h-1)) { - atomicAdd(&g_input[data_index+ i_w + 1], *(grad + grad_index) * (1.0 - top_left_y_w) - * (1.0 - top_left_x_w)); - bottom_right_v = *(data + data_index + i_w + 1); - } - // calc weight grad of top_left_w, then multiple -1 is the grad of grid_src - top_left_y_gw -= *(grad + grad_index) * (top_right_v - bottom_right_v + - (top_left_v - top_right_v - bottom_left_v + bottom_right_v) - * top_left_x_w); - top_left_x_gw -= *(grad + grad_index) * (bottom_left_v - bottom_right_v + - (top_left_v - top_right_v - bottom_left_v + bottom_right_v) - * top_left_y_w); - } - // calc grad of grid - *(grad_grid + grid_src_index + o_h * o_w) += top_left_y_gw * (i_h - 1) / 2; - *(grad_grid + grid_src_index) += top_left_x_gw * (i_w - 1) / 2; - } -} -} // namespace cuda - -template -inline void BilinearSamplerForward(const Tensor &output, - const Tensor &input, - const Tensor &grid_src) { - DType *out = output.dptr_; - const DType *data = input.dptr_; - const DType *grid = grid_src.dptr_; - int o_n = output.size(0), o_c = output.size(1), o_h = output.size(2), o_w = output.size(3); - int i_c = input.size(1), i_h = input.size(2), i_w = input.size(3); - using namespace cuda; - const int max_block = (output.shape_.Size() + kMaxThreadsPerBlock - 1) / kMaxThreadsPerBlock; - const int grid_dim_x = (max_block > kMaxGridDim) ? kMaxGridDim : max_block; - const int grid_dim_y = - (max_block > kMaxGridDim) ? (max_block + kMaxGridDim - 1) / kMaxGridDim : 1; - dim3 num_blocks(grid_dim_x, grid_dim_y); - dim3 threads_per_block(kMaxThreadsPerBlock); - CheckLaunchParam(num_blocks, threads_per_block, "bilinear sampler forward"); - cudaStream_t stream = Stream::GetStream(output.stream_); - cuda::BilinearSamplerForwardKernel << > >( - i_c, i_h, i_w, data, grid, o_n, o_c, o_h, o_w, out); - // post kernel check - cudaError err = cudaPeekAtLastError(); - CHECK_EQ(err, cudaSuccess) << cudaGetErrorString(err); -} - -template -inline void BilinearSamplerBackward(const Tensor &input_grad, - const Tensor &ggrid, - const Tensor &output_grad, - const Tensor &input_data, - const Tensor &grid) { - DType *g_input = input_grad.dptr_; - DType *grad_grid = ggrid.dptr_; - const DType *grid_src = grid.dptr_; - const DType *grad = output_grad.dptr_; - const DType *data = input_data.dptr_; - int o_n = output_grad.size(0), o_c = output_grad.size(1), - o_h = output_grad.size(2), o_w = output_grad.size(3); - int i_c = input_data.size(1), i_h = input_data.size(2), i_w = input_data.size(3); - using namespace cuda; - const int max_block = (output_grad.shape_.Size() / o_c + kMaxThreadsPerBlock - 1) - / kMaxThreadsPerBlock; - const int grid_dim_x = (max_block > kMaxGridDim) ? kMaxGridDim : max_block; - const int grid_dim_y = - (max_block > kMaxGridDim) ? (max_block + kMaxGridDim - 1) / kMaxGridDim : 1; - dim3 num_blocks(grid_dim_x, grid_dim_y); - dim3 threads_per_block(kMaxThreadsPerBlock); - CheckLaunchParam(num_blocks, threads_per_block, "bilinear sampler backward"); - cudaStream_t stream = Stream::GetStream(input_grad.stream_); - cuda::BilinearSamplerBackwardKernel << > >( - i_c, i_h, i_w, grad, data, o_n, o_c, o_h, o_w, g_input, grid_src, grad_grid); - // post kernel check - cudaError err = cudaPeekAtLastError(); - CHECK_EQ(err, cudaSuccess) << cudaGetErrorString(err); -} - -} // namespace mshadow - -namespace mxnet { -namespace op { -template<> -Operator* CreateOp(BilinearSamplerParam param, int dtype) { - Operator *op = NULL; -#if MXNET_USE_CUDNN == 1 && CUDNN_MAJOR >= 5 - MSHADOW_REAL_TYPE_SWITCH(dtype, DType, { - op = new CuDNNBilinearSamplerOp(param); - }) -#else - MSHADOW_REAL_TYPE_SWITCH(dtype, DType, { - op = new BilinearSamplerOp(param); - }) -#endif // MXNET_USE_CUDNN && CUDNN_MAJOR - return op; -} - -} // namespace op -} // namespace mxnet +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/*! + * \file bilinear_sampler.cu + * \brief + * \author Xu Dong +*/ + +#include "./bilinear_sampler-inl.h" +#include +#include "../common/cuda_utils.h" +#if MXNET_USE_CUDNN == 1 && CUDNN_MAJOR >= 5 +#include "./cudnn_bilinear_sampler-inl.h" +#endif // MXNET_USE_CUDNN && CUDNN_MAJOR + +namespace mshadow { +namespace cuda { +template +__device__ bool between(DType value, int lowerBound, int upperBound) { + return (value >= lowerBound && value <= upperBound); +} +template +__global__ void BilinearSamplerForwardKernel(const int i_c, const int i_h, + const int i_w, const DType* data, + const DType* grid, const int o_n, + const int o_c, const int o_h, + const int o_w, DType* out) { + for (int index = (blockIdx.x + blockIdx.y * gridDim.x) * blockDim.x + threadIdx.x; + index < o_n * o_c * o_h * o_w; + index += blockDim.x * gridDim.x * gridDim.y) { + // (n, c, h, w) is the element in out + int w = index % o_w; + int h = (index / o_w) % o_h; + int c = (index / o_w / o_h) % o_c; + int n = index / o_w / o_h / o_c; + index_t out_index = n * o_c * o_h * o_w + c * o_h * o_w + h * o_w + w; + index_t grid_index = n * o_h * o_w * 2 + h * o_w + w; + DType y_real = (*(grid + grid_index + o_h * o_w) + 1) * (i_h - 1) / 2; + DType x_real = (*(grid + grid_index) + 1) * (i_w - 1) / 2; + int top_left_y = static_cast(floor(y_real)); + int top_left_x = static_cast(floor(x_real)); + DType top_left_y_w = 1.0 - (y_real - top_left_y); + DType top_left_x_w = 1.0 - (x_real - top_left_x); + int data_index = n * i_c * i_h * i_w + c * i_h * i_w + top_left_y * i_w + top_left_x; + DType top_left_v = 0; + DType top_right_v = 0; + DType bottom_left_v = 0; + DType bottom_right_v = 0; + if (between(top_left_x, 0, i_w-1) && between(top_left_y, 0, i_h-1)) + top_left_v = *(data + data_index); + if (between(top_left_x + 1, 0, i_w-1) && between(top_left_y, 0, i_h-1)) + top_right_v = *(data + data_index + 1); + if (between(top_left_x, 0, i_w-1) && between(top_left_y + 1, 0, i_h-1)) + bottom_left_v = *(data + data_index + i_w); + if (between(top_left_x+1, 0, i_w-1) && between(top_left_y + 1, 0, i_h-1)) + bottom_right_v = *(data + data_index + i_w + 1); + *(out+out_index) = top_left_v * top_left_y_w * top_left_x_w + + top_right_v * top_left_y_w * (1.0 - top_left_x_w) + + bottom_left_v * (1.0 - top_left_y_w) * top_left_x_w + + bottom_right_v * (1.0 - top_left_y_w) * (1.0 - top_left_x_w); + } +} + +template +__global__ void BilinearSamplerBackwardKernel(const int i_c, const int i_h, + const int i_w, const DType* grad, + const DType* data, const int o_n, + const int o_c, const int o_h, + const int o_w, DType* g_input, + const DType* grid_src, + DType* grad_grid) { + for (int index = (blockIdx.x + blockIdx.y * gridDim.x) * blockDim.x + threadIdx.x; + index < o_n * o_h * o_w; + index += blockDim.x * gridDim.x * gridDim.y) { + // (n, c, h, w) is the element in grad + int w = index % o_w; + int h = (index / o_w) % o_h; + int n = index / o_w / o_h; + DType top_left_y_gw = 0.0; + DType top_left_x_gw = 0.0; + index_t grid_src_index = n * o_h * o_w * 2 + h * o_w + w; + DType y_real = (*(grid_src + grid_src_index + o_h * o_w) + 1) * (i_h - 1) / 2; + DType x_real = (*(grid_src + grid_src_index) + 1) * (i_w - 1) / 2; + + int top_left_y = static_cast(floor(y_real)); + int top_left_x = static_cast(floor(x_real)); + DType top_left_y_w = 1.0 - (y_real - top_left_y); + DType top_left_x_w = 1.0 - (x_real - top_left_x); + for (index_t c = 0; c < o_c; ++c) { + index_t grad_index = n * o_c * o_h * o_w + c * o_h * o_w + h * o_w + w; + int data_index = n * i_c * i_h * i_w + c * i_h * i_w + top_left_y * i_w + top_left_x; + // calc 4 vertex value in input data + DType top_left_v = 0; + DType top_right_v = 0; + DType bottom_left_v = 0; + DType bottom_right_v = 0; + // calc input grad + if (between(top_left_x, 0, i_w-1) && between(top_left_y, 0, i_h-1)) { + atomicAdd(&g_input[data_index], *(grad + grad_index) * top_left_y_w * top_left_x_w); + top_left_v = *(data + data_index); + } + if (between(top_left_x+1, 0, i_w-1) && between(top_left_y, 0, i_h-1)) { + atomicAdd(&g_input[data_index + 1], *(grad + grad_index) * top_left_y_w + * (1.0 - top_left_x_w)); + top_right_v = *(data + data_index + 1); + } + if (between(top_left_x, 0, i_w-1) && between(top_left_y+1, 0, i_h-1)) { + atomicAdd(&g_input[data_index+ i_w], *(grad + grad_index) * (1.0 - top_left_y_w) + * top_left_x_w); + bottom_left_v = *(data + data_index + i_w); + } + if (between(top_left_x+1, 0, i_w-1) && between(top_left_y+1, 0, i_h-1)) { + atomicAdd(&g_input[data_index+ i_w + 1], *(grad + grad_index) * (1.0 - top_left_y_w) + * (1.0 - top_left_x_w)); + bottom_right_v = *(data + data_index + i_w + 1); + } + // calc weight grad of top_left_w, then multiple -1 is the grad of grid_src + top_left_y_gw -= *(grad + grad_index) * (top_right_v - bottom_right_v + + (top_left_v - top_right_v - bottom_left_v + bottom_right_v) + * top_left_x_w); + top_left_x_gw -= *(grad + grad_index) * (bottom_left_v - bottom_right_v + + (top_left_v - top_right_v - bottom_left_v + bottom_right_v) + * top_left_y_w); + } + // calc grad of grid + *(grad_grid + grid_src_index + o_h * o_w) += top_left_y_gw * (i_h - 1) / 2; + *(grad_grid + grid_src_index) += top_left_x_gw * (i_w - 1) / 2; + } +} +} // namespace cuda + +template +inline void BilinearSamplerForward(const Tensor &output, + const Tensor &input, + const Tensor &grid_src) { + DType *out = output.dptr_; + const DType *data = input.dptr_; + const DType *grid = grid_src.dptr_; + int o_n = output.size(0), o_c = output.size(1), o_h = output.size(2), o_w = output.size(3); + int i_c = input.size(1), i_h = input.size(2), i_w = input.size(3); + using namespace cuda; + const int max_block = (output.shape_.Size() + kMaxThreadsPerBlock - 1) / kMaxThreadsPerBlock; + const int grid_dim_x = (max_block > kMaxGridDim) ? kMaxGridDim : max_block; + const int grid_dim_y = + (max_block > kMaxGridDim) ? (max_block + kMaxGridDim - 1) / kMaxGridDim : 1; + dim3 num_blocks(grid_dim_x, grid_dim_y); + dim3 threads_per_block(kMaxThreadsPerBlock); + CheckLaunchParam(num_blocks, threads_per_block, "bilinear sampler forward"); + cudaStream_t stream = Stream::GetStream(output.stream_); + cuda::BilinearSamplerForwardKernel << > >( + i_c, i_h, i_w, data, grid, o_n, o_c, o_h, o_w, out); + // post kernel check + cudaError err = cudaPeekAtLastError(); + CHECK_EQ(err, cudaSuccess) << cudaGetErrorString(err); +} + +template +inline void BilinearSamplerBackward(const Tensor &input_grad, + const Tensor &ggrid, + const Tensor &output_grad, + const Tensor &input_data, + const Tensor &grid) { + DType *g_input = input_grad.dptr_; + DType *grad_grid = ggrid.dptr_; + const DType *grid_src = grid.dptr_; + const DType *grad = output_grad.dptr_; + const DType *data = input_data.dptr_; + int o_n = output_grad.size(0), o_c = output_grad.size(1), + o_h = output_grad.size(2), o_w = output_grad.size(3); + int i_c = input_data.size(1), i_h = input_data.size(2), i_w = input_data.size(3); + using namespace cuda; + const int max_block = (output_grad.shape_.Size() / o_c + kMaxThreadsPerBlock - 1) + / kMaxThreadsPerBlock; + const int grid_dim_x = (max_block > kMaxGridDim) ? kMaxGridDim : max_block; + const int grid_dim_y = + (max_block > kMaxGridDim) ? (max_block + kMaxGridDim - 1) / kMaxGridDim : 1; + dim3 num_blocks(grid_dim_x, grid_dim_y); + dim3 threads_per_block(kMaxThreadsPerBlock); + CheckLaunchParam(num_blocks, threads_per_block, "bilinear sampler backward"); + cudaStream_t stream = Stream::GetStream(input_grad.stream_); + cuda::BilinearSamplerBackwardKernel << > >( + i_c, i_h, i_w, grad, data, o_n, o_c, o_h, o_w, g_input, grid_src, grad_grid); + // post kernel check + cudaError err = cudaPeekAtLastError(); + CHECK_EQ(err, cudaSuccess) << cudaGetErrorString(err); +} + +} // namespace mshadow + +namespace mxnet { +namespace op { +template<> +Operator* CreateOp(BilinearSamplerParam param, int dtype) { + Operator *op = NULL; +#if MXNET_USE_CUDNN == 1 && CUDNN_MAJOR >= 5 + MSHADOW_REAL_TYPE_SWITCH(dtype, DType, { + op = new CuDNNBilinearSamplerOp(param); + }) +#else + MSHADOW_REAL_TYPE_SWITCH(dtype, DType, { + op = new BilinearSamplerOp(param); + }) +#endif // MXNET_USE_CUDNN && CUDNN_MAJOR + return op; +} + +} // namespace op +} // namespace mxnet diff --git a/src/operator/channel_op_common.h b/src/operator/channel_op_common.h index 9ae6a6602c2e..113da9b35825 100644 --- a/src/operator/channel_op_common.h +++ b/src/operator/channel_op_common.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file channel_op_common.h * \brief common function used for concat and split channel * \author Bing Xu diff --git a/src/operator/concat-inl.h b/src/operator/concat-inl.h index 09b0c4b21e89..ed553c8f99e7 100644 --- a/src/operator/concat-inl.h +++ b/src/operator/concat-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file concat-inl.h * \brief * \author Bing Xu diff --git a/src/operator/concat.cc b/src/operator/concat.cc index 49fa03e7e681..1bee4b45cd21 100644 --- a/src/operator/concat.cc +++ b/src/operator/concat.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file concat.cc * \brief * \author Bing Xu diff --git a/src/operator/concat.cu b/src/operator/concat.cu index a410e199637e..06828fcbcd7d 100644 --- a/src/operator/concat.cu +++ b/src/operator/concat.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file concat.cu * \brief * \author Bing Xu diff --git a/src/operator/contrib/count_sketch-inl.h b/src/operator/contrib/count_sketch-inl.h index 566327e3677c..5df00968e4e5 100644 --- a/src/operator/contrib/count_sketch-inl.h +++ b/src/operator/contrib/count_sketch-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file count_sketch-inl.h * \brief count_sketch operator and symbol * \author Chen Zhu diff --git a/src/operator/contrib/count_sketch.cc b/src/operator/contrib/count_sketch.cc index cf89c97bdc9b..6aba8f44b3ad 100644 --- a/src/operator/contrib/count_sketch.cc +++ b/src/operator/contrib/count_sketch.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file count_sketch.cc * \brief count_sketch op * \author Chen Zhu @@ -30,7 +48,7 @@ MXNET_REGISTER_OP_PROPERTY(_contrib_count_sketch, CountSketchProp) Assume input data has shape (N, d), sign hash table s has shape (N, d), index hash table h has shape (N, d) and mapping dimension out_dim = k, -each element in s is either +1 or -1, each element in h is random integer from 0 to k-1. +each element in s is either +1 or -1, each element in h is random integer from 0 to k-1. Then the operator computs: .. math:: diff --git a/src/operator/contrib/count_sketch.cu b/src/operator/contrib/count_sketch.cu index 7cf13e8a4993..0f3d295ae43f 100644 --- a/src/operator/contrib/count_sketch.cu +++ b/src/operator/contrib/count_sketch.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file count_sketch.cu * \brief count_sketch op * \author Chen Zhu, Yang Shi diff --git a/src/operator/contrib/ctc_loss-inl.h b/src/operator/contrib/ctc_loss-inl.h index 8431f65088f7..0d0c0bf4cd09 100644 --- a/src/operator/contrib/ctc_loss-inl.h +++ b/src/operator/contrib/ctc_loss-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file ctc_loss-inl.h * \brief * \author Sebastian Bodenstien diff --git a/src/operator/contrib/ctc_loss.cc b/src/operator/contrib/ctc_loss.cc index c3f3fe1621b4..3727cee10b1c 100644 --- a/src/operator/contrib/ctc_loss.cc +++ b/src/operator/contrib/ctc_loss.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file ctc_loss.cc * \brief * \author Sebastian Bodenstein @@ -58,24 +76,24 @@ The shapes of the inputs and outputs: - **label**: *(batch_size, label_sequence_length)* - **out**: *(batch_size)*. -``label`` is a tensor of integers between 1 and *alphabet_size*. If a -sequence of labels is shorter than *label_sequence_length*, use the special -padding character 0 at the end of the sequence to conform it to the correct -length. For example, if *label_sequence_length* = 4, and one has two sequences -of labels [2, 1] and [3, 2, 2], the resulting ```label``` tensor should be +``label`` is a tensor of integers between 1 and *alphabet_size*. If a +sequence of labels is shorter than *label_sequence_length*, use the special +padding character 0 at the end of the sequence to conform it to the correct +length. For example, if *label_sequence_length* = 4, and one has two sequences +of labels [2, 1] and [3, 2, 2], the resulting ```label``` tensor should be padded to be:: [[2, 1, 0, 0], [3, 2, 2, 0]] -The ``data`` tensor consists of sequences of activation vectors. The layer -applies a softmax to each vector, which then becomes a vector of probabilities -over the alphabet. Note that the 0th element of this vector is reserved for the +The ``data`` tensor consists of sequences of activation vectors. The layer +applies a softmax to each vector, which then becomes a vector of probabilities +over the alphabet. Note that the 0th element of this vector is reserved for the special blank character. ``out`` is a list of CTC loss values, one per example in the batch. -See *Connectionist Temporal Classification: Labelling Unsegmented -Sequence Data with Recurrent Neural Networks*, A. Graves *et al*. for more +See *Connectionist Temporal Classification: Labelling Unsegmented +Sequence Data with Recurrent Neural Networks*, A. Graves *et al*. for more information. )code" ADD_FILELINE) diff --git a/src/operator/contrib/ctc_loss.cu b/src/operator/contrib/ctc_loss.cu index ed80eb715516..4bdef752812b 100644 --- a/src/operator/contrib/ctc_loss.cu +++ b/src/operator/contrib/ctc_loss.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file ctc_loss.cu * \brief * \author Sebastian Bodenstein diff --git a/src/operator/contrib/deformable_convolution-inl.h b/src/operator/contrib/deformable_convolution-inl.h index d8397cfb715d..a8dc6b8f09ed 100644 --- a/src/operator/contrib/deformable_convolution-inl.h +++ b/src/operator/contrib/deformable_convolution-inl.h @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! * Copyright (c) 2017 Microsoft * Licensed under The Apache-2.0 License [see LICENSE for details] diff --git a/src/operator/contrib/deformable_convolution.cc b/src/operator/contrib/deformable_convolution.cc index 5af91a0aa407..352baa12fbc1 100644 --- a/src/operator/contrib/deformable_convolution.cc +++ b/src/operator/contrib/deformable_convolution.cc @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! * Copyright (c) 2017 Microsoft * Licensed under The Apache-2.0 License [see LICENSE for details] @@ -60,7 +79,7 @@ then we have:: If ``no_bias`` is set to be true, then the ``bias`` term is ignored. The default data ``layout`` is *NCHW*, namely *(batch_size, channle, height, -width)*. +width)*. If ``num_group`` is larger than 1, denoted by *g*, then split the input ``data`` evenly into *g* parts along the channel axis, and also evenly split ``weight`` diff --git a/src/operator/contrib/deformable_convolution.cu b/src/operator/contrib/deformable_convolution.cu index f690cc1ce24c..f2200a9978ca 100644 --- a/src/operator/contrib/deformable_convolution.cu +++ b/src/operator/contrib/deformable_convolution.cu @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! * Copyright (c) 2017 Microsoft * Licensed under The Apache-2.0 License [see LICENSE for details] diff --git a/src/operator/contrib/deformable_psroi_pooling-inl.h b/src/operator/contrib/deformable_psroi_pooling-inl.h index 16a98f76bcff..d391f045a1b5 100644 --- a/src/operator/contrib/deformable_psroi_pooling-inl.h +++ b/src/operator/contrib/deformable_psroi_pooling-inl.h @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! * Copyright (c) 2017 Microsoft * Licensed under The Apache-2.0 License [see LICENSE for details] diff --git a/src/operator/contrib/deformable_psroi_pooling.cc b/src/operator/contrib/deformable_psroi_pooling.cc index 290bad2a76cd..93bb64d2113c 100644 --- a/src/operator/contrib/deformable_psroi_pooling.cc +++ b/src/operator/contrib/deformable_psroi_pooling.cc @@ -1,8 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! * Copyright (c) 2017 Microsoft * Licensed under The Apache-2.0 License [see LICENSE for details] * \file deformable_psroi_pooling.cc - * \brief + * \brief * \author Yi Li, Guodong Zhang, Jifeng Dai */ #include "./deformable_psroi_pooling-inl.h" diff --git a/src/operator/contrib/deformable_psroi_pooling.cu b/src/operator/contrib/deformable_psroi_pooling.cu index f9eb01a26e38..71bbd4cd7f2a 100644 --- a/src/operator/contrib/deformable_psroi_pooling.cu +++ b/src/operator/contrib/deformable_psroi_pooling.cu @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! * Copyright (c) 2017 Microsoft * Licensed under The Apache-2.0 License [see LICENSE for details] diff --git a/src/operator/contrib/dequantize-inl.h b/src/operator/contrib/dequantize-inl.h index ecd0cb42aafc..61940c016b15 100644 --- a/src/operator/contrib/dequantize-inl.h +++ b/src/operator/contrib/dequantize-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file dequantize-inl.h * \brief Implementation of dequantize operation */ diff --git a/src/operator/contrib/dequantize.cc b/src/operator/contrib/dequantize.cc index 46e36fa3c891..422a9557dc1d 100644 --- a/src/operator/contrib/dequantize.cc +++ b/src/operator/contrib/dequantize.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file dequantize.cc * \brief */ diff --git a/src/operator/contrib/dequantize.cu b/src/operator/contrib/dequantize.cu index be09b797b1cd..7081c27c975b 100644 --- a/src/operator/contrib/dequantize.cu +++ b/src/operator/contrib/dequantize.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file dequantize.cu * \brief */ diff --git a/src/operator/contrib/fft-inl.h b/src/operator/contrib/fft-inl.h index 5996322c0cec..5092f586fdf7 100644 --- a/src/operator/contrib/fft-inl.h +++ b/src/operator/contrib/fft-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file fft-inl.h * \brief * \author Chen Zhu diff --git a/src/operator/contrib/fft.cc b/src/operator/contrib/fft.cc index e2094b3bf9a8..11f8425e07b1 100644 --- a/src/operator/contrib/fft.cc +++ b/src/operator/contrib/fft.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file fft-inl.h * \brief * \author Chen Zhu diff --git a/src/operator/contrib/fft.cu b/src/operator/contrib/fft.cu index 5dbd00c779fd..3017ce76756b 100644 --- a/src/operator/contrib/fft.cu +++ b/src/operator/contrib/fft.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file fft-inl.h * \brief * \author Chen Zhu diff --git a/src/operator/contrib/ifft-inl.h b/src/operator/contrib/ifft-inl.h index 98b601eeae0c..abd5bb22a389 100644 --- a/src/operator/contrib/ifft-inl.h +++ b/src/operator/contrib/ifft-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file Ifft-inl.h * \brief * \author Chen Zhu diff --git a/src/operator/contrib/ifft.cc b/src/operator/contrib/ifft.cc index b2afd46cb46d..0ea3a7ec112f 100644 --- a/src/operator/contrib/ifft.cc +++ b/src/operator/contrib/ifft.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file Ifft-inl.h * \brief * \author Chen Zhu diff --git a/src/operator/contrib/ifft.cu b/src/operator/contrib/ifft.cu index 93ec1e636a3b..79795d8561bf 100644 --- a/src/operator/contrib/ifft.cu +++ b/src/operator/contrib/ifft.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file Ifft-inl.h * \brief * \author Chen Zhu diff --git a/src/operator/contrib/krprod.h b/src/operator/contrib/krprod.h index a713f1e093a7..6ce94c648d79 100644 --- a/src/operator/contrib/krprod.h +++ b/src/operator/contrib/krprod.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file krprod.h * \brief Core function for Khatri-Rao product * \author Jencir Lee diff --git a/src/operator/contrib/multi_proposal-inl.h b/src/operator/contrib/multi_proposal-inl.h index 48f3535b5eab..7cd465e0b09e 100644 --- a/src/operator/contrib/multi_proposal-inl.h +++ b/src/operator/contrib/multi_proposal-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * Copyright (c) 2017 Microsoft * Licensed under The Apache-2.0 License [see LICENSE for details] * \file multi_proposal-inl.h diff --git a/src/operator/contrib/multi_proposal.cc b/src/operator/contrib/multi_proposal.cc index c8f75eaec547..cd00e877a11d 100644 --- a/src/operator/contrib/multi_proposal.cc +++ b/src/operator/contrib/multi_proposal.cc @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! * Copyright (c) 2017 Microsoft * Licensed under The Apache-2.0 License [see LICENSE for details] diff --git a/src/operator/contrib/multi_proposal.cu b/src/operator/contrib/multi_proposal.cu index 052d777d5fac..cb9996344e3e 100644 --- a/src/operator/contrib/multi_proposal.cu +++ b/src/operator/contrib/multi_proposal.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * Copyright (c) 2017 Microsoft * Licensed under The Apache-2.0 License [see LICENSE for details] * \file multi_proposal.cu diff --git a/src/operator/contrib/multibox_detection-inl.h b/src/operator/contrib/multibox_detection-inl.h index 3507281eba10..34099a3d6978 100644 --- a/src/operator/contrib/multibox_detection-inl.h +++ b/src/operator/contrib/multibox_detection-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file multibox_detection-inl.h * \brief post-process multibox detection predictions * \author Joshua Zhang diff --git a/src/operator/contrib/multibox_detection.cc b/src/operator/contrib/multibox_detection.cc index 2bf49f34d1ff..0f6982890f4f 100644 --- a/src/operator/contrib/multibox_detection.cc +++ b/src/operator/contrib/multibox_detection.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file multibox_detection.cc * \brief MultiBoxDetection op * \author Joshua Zhang diff --git a/src/operator/contrib/multibox_detection.cu b/src/operator/contrib/multibox_detection.cu index dab11ffbe701..56a1e88dfee0 100644 --- a/src/operator/contrib/multibox_detection.cu +++ b/src/operator/contrib/multibox_detection.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file multibox_detection.cu * \brief MultiBoxDetection op * \author Joshua Zhang diff --git a/src/operator/contrib/multibox_prior-inl.h b/src/operator/contrib/multibox_prior-inl.h index ee83fe462ce4..88ca3dc8de6f 100644 --- a/src/operator/contrib/multibox_prior-inl.h +++ b/src/operator/contrib/multibox_prior-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file multibox_prior-inl.h * \brief generate multibox prior boxes * \author Joshua Zhang diff --git a/src/operator/contrib/multibox_prior.cc b/src/operator/contrib/multibox_prior.cc index a9c747e7c6f5..af77fdaa8015 100644 --- a/src/operator/contrib/multibox_prior.cc +++ b/src/operator/contrib/multibox_prior.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file multibox_prior.cc * \brief generate multibox prior boxes cpu implementation * \author Joshua Zhang diff --git a/src/operator/contrib/multibox_prior.cu b/src/operator/contrib/multibox_prior.cu index a3f2cc22f552..b041b90d1d05 100644 --- a/src/operator/contrib/multibox_prior.cu +++ b/src/operator/contrib/multibox_prior.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file multibox_prior.cu * \brief generate multibox prior boxes cuda kernels * \author Joshua Zhang diff --git a/src/operator/contrib/multibox_target-inl.h b/src/operator/contrib/multibox_target-inl.h index 7185c9a1d2ff..f76df3504a28 100644 --- a/src/operator/contrib/multibox_target-inl.h +++ b/src/operator/contrib/multibox_target-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file multibox_target-inl.h * \brief * \author Joshua Zhang diff --git a/src/operator/contrib/multibox_target.cc b/src/operator/contrib/multibox_target.cc index 56c6ceefdc43..095613d4a938 100644 --- a/src/operator/contrib/multibox_target.cc +++ b/src/operator/contrib/multibox_target.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file multibox_target.cc * \brief MultiBoxTarget op * \author Joshua Zhang diff --git a/src/operator/contrib/multibox_target.cu b/src/operator/contrib/multibox_target.cu index adcfcf249eea..3d0da6ce6f5b 100644 --- a/src/operator/contrib/multibox_target.cu +++ b/src/operator/contrib/multibox_target.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file multibox_target.cu * \brief MultiBoxTarget op * \author Joshua Zhang diff --git a/src/operator/contrib/nn/deformable_im2col.cuh b/src/operator/contrib/nn/deformable_im2col.cuh index d9e7b970ca84..0238921933c5 100644 --- a/src/operator/contrib/nn/deformable_im2col.cuh +++ b/src/operator/contrib/nn/deformable_im2col.cuh @@ -1,34 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! ******************* BEGIN Caffe Copyright Notice and Disclaimer **************** * * COPYRIGHT - * + * * All contributions by the University of California: * Copyright (c) 2014-2017 The Regents of the University of California (Regents) * All rights reserved. - * + * * All other contributions: * Copyright (c) 2014-2017, the respective contributors * All rights reserved. - * + * * Caffe uses a shared copyright model: each contributor holds copyright over * their contributions to Caffe. The project versioning records all such * contribution and copyright details. If a contributor wants to further mark * their specific copyright on a particular contribution, they should indicate * their copyright solely in the commit message of the change when it is * committed. - * + * * LICENSE - * + * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * + * modification, are permitted provided that the following conditions are met: + * * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. + * list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * + * and/or other materials provided with the distribution. + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -39,9 +58,9 @@ * ON ANY THEORY 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. - * + * * CONTRIBUTION AGREEMENT - * + * * By contributing to the BVLC/caffe repository through pull-request, comment, * or otherwise, the contributor releases their content to the * license and copyright terms herein. @@ -75,7 +94,7 @@ namespace mxnet { namespace op { template -__device__ DType deformable_im2col_bilinear(const DType* bottom_data, const int data_width, +__device__ DType deformable_im2col_bilinear(const DType* bottom_data, const int data_width, const int height, const int width, DType h, DType w) { int h_low = floor(h); @@ -114,7 +133,7 @@ __device__ DType deformable_im2col_bilinear(const DType* bottom_data, const int template -__device__ DType get_gradient_weight(DType argmax_h, DType argmax_w, +__device__ DType get_gradient_weight(DType argmax_h, DType argmax_w, const int h, const int w, const int height, const int width) { if (argmax_h < 0 || argmax_h > height || argmax_w < 0 || argmax_w > width) { @@ -282,9 +301,9 @@ __global__ void deformable_im2col_gpu_kernel(const int n, const DType* data_im, */ template inline void deformable_im2col(mshadow::Stream* s, - const DType* data_im, const DType* data_offset, + const DType* data_im, const DType* data_offset, const TShape& im_shape, const TShape& col_shape, const TShape& kernel_shape, - const TShape& pad, const TShape& stride, const TShape& dilation, + const TShape& pad, const TShape& stride, const TShape& dilation, const uint32_t deformable_group, DType* data_col) { // num_axes should be smaller than block size index_t num_spatial_axes = kernel_shape.ndim(); @@ -416,7 +435,7 @@ inline void deformable_col2im(mshadow::Stream* s, * \brief DO NOT call this directly. Use wrapper function deformable_col2im_coord() instead; */ template -__global__ void deformable_col2im_coord_gpu_kernel(const int n, const DType* data_col, +__global__ void deformable_col2im_coord_gpu_kernel(const int n, const DType* data_col, const DType* data_im, const DType* data_offset, const int channels, const int height, const int width, const int kernel_h, const int kernel_w, diff --git a/src/operator/contrib/nn/deformable_im2col.h b/src/operator/contrib/nn/deformable_im2col.h index 9d6180034c71..b477acb4c876 100644 --- a/src/operator/contrib/nn/deformable_im2col.h +++ b/src/operator/contrib/nn/deformable_im2col.h @@ -1,34 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! ******************* BEGIN Caffe Copyright Notice and Disclaimer **************** * * COPYRIGHT - * + * * All contributions by the University of California: * Copyright (c) 2014-2017 The Regents of the University of California (Regents) * All rights reserved. - * + * * All other contributions: * Copyright (c) 2014-2017, the respective contributors * All rights reserved. - * + * * Caffe uses a shared copyright model: each contributor holds copyright over * their contributions to Caffe. The project versioning records all such * contribution and copyright details. If a contributor wants to further mark * their specific copyright on a particular contribution, they should indicate * their copyright solely in the commit message of the change when it is * committed. - * + * * LICENSE - * + * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * + * modification, are permitted provided that the following conditions are met: + * * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. + * list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * + * and/or other materials provided with the distribution. + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -39,9 +58,9 @@ * ON ANY THEORY 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. - * + * * CONTRIBUTION AGREEMENT - * + * * By contributing to the BVLC/caffe repository through pull-request, comment, * or otherwise, the contributor releases their content to the * license and copyright terms herein. @@ -70,7 +89,7 @@ namespace mxnet { namespace op { -/*!\brief +/*!\brief * cpu function of deformable_im2col algorithm * \param s device stream * \param data_im pointer of an image (C, H, W, ...) in the image batch diff --git a/src/operator/contrib/proposal-inl.h b/src/operator/contrib/proposal-inl.h index 686a8a354ff9..3d1851cedbac 100644 --- a/src/operator/contrib/proposal-inl.h +++ b/src/operator/contrib/proposal-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file proposal-inl.h * \brief Proposal Operator * \author Piotr Teterwak, Bing Xu, Jian Guo diff --git a/src/operator/contrib/proposal.cc b/src/operator/contrib/proposal.cc index fe4fe98a9f4b..ec539003b944 100644 --- a/src/operator/contrib/proposal.cc +++ b/src/operator/contrib/proposal.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file proposal.cc * \brief * \author Piotr Teterwak, Bing Xu, Jian Guo diff --git a/src/operator/contrib/proposal.cu b/src/operator/contrib/proposal.cu index ce1e9e5945d0..209ef79a2aaf 100644 --- a/src/operator/contrib/proposal.cu +++ b/src/operator/contrib/proposal.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file proposal.cu * \brief Proposal Operator * \author Shaoqing Ren, Jian Guo diff --git a/src/operator/contrib/psroi_pooling-inl.h b/src/operator/contrib/psroi_pooling-inl.h index 3a3a9c34927c..b4929725279d 100644 --- a/src/operator/contrib/psroi_pooling-inl.h +++ b/src/operator/contrib/psroi_pooling-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * Copyright (c) 2017 Microsoft * Licensed under The Apache-2.0 License [see LICENSE for details] * \file psroi_pooling-inl.h diff --git a/src/operator/contrib/psroi_pooling.cc b/src/operator/contrib/psroi_pooling.cc index ad25aec8eee8..dd3a9e08895d 100644 --- a/src/operator/contrib/psroi_pooling.cc +++ b/src/operator/contrib/psroi_pooling.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * Copyright (c) 2017 Microsoft * Licensed under The Apache-2.0 License [see LICENSE for details] * \file psroi_pooling.cc diff --git a/src/operator/contrib/psroi_pooling.cu b/src/operator/contrib/psroi_pooling.cu index 962c874c6d1a..6df64a1948d6 100644 --- a/src/operator/contrib/psroi_pooling.cu +++ b/src/operator/contrib/psroi_pooling.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * Copyright (c) 2017 Microsoft * Licensed under The Apache-2.0 License [see LICENSE for details] * \file psroi_pooling.cu diff --git a/src/operator/contrib/quantize-inl.h b/src/operator/contrib/quantize-inl.h index e005762cf0eb..1274a7ded58a 100644 --- a/src/operator/contrib/quantize-inl.h +++ b/src/operator/contrib/quantize-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file quantize-inl.h * \brief implementation of quantize operation */ diff --git a/src/operator/contrib/quantize.cc b/src/operator/contrib/quantize.cc index 86f35e117882..dbb8985c72f2 100644 --- a/src/operator/contrib/quantize.cc +++ b/src/operator/contrib/quantize.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file quantize.cc * \brief */ diff --git a/src/operator/contrib/quantize.cu b/src/operator/contrib/quantize.cu index c6d9035c9687..6c9db9aeecf4 100644 --- a/src/operator/contrib/quantize.cu +++ b/src/operator/contrib/quantize.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file quantize.cu * \brief */ diff --git a/src/operator/convolution-inl.h b/src/operator/convolution-inl.h index a97d53b322e8..0a2522cccb65 100644 --- a/src/operator/convolution-inl.h +++ b/src/operator/convolution-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file convolution-inl.h * \brief * \ref: https://github.com/Yangqing/caffe/wiki/Convolution-in-Caffe:-a-memo diff --git a/src/operator/convolution.cc b/src/operator/convolution.cc index fd604d90c546..35ab5f01afa1 100644 --- a/src/operator/convolution.cc +++ b/src/operator/convolution.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file convolution.cc * \brief * \author Bing Xu, Jun Wu diff --git a/src/operator/convolution.cu b/src/operator/convolution.cu index 34ae42f31af8..bf5f3053b2de 100644 --- a/src/operator/convolution.cu +++ b/src/operator/convolution.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file convolution.cu * \brief * \author Bing Xu, Jun Wu diff --git a/src/operator/convolution_v1-inl.h b/src/operator/convolution_v1-inl.h index ee8c8c0462b3..f39d8e0804bc 100644 --- a/src/operator/convolution_v1-inl.h +++ b/src/operator/convolution_v1-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file convolution_v1-inl.h * \brief * \author Bing Xu diff --git a/src/operator/convolution_v1.cc b/src/operator/convolution_v1.cc index a1d115fdae51..cb47ed11b5c9 100644 --- a/src/operator/convolution_v1.cc +++ b/src/operator/convolution_v1.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file convolution_v1.cc * \brief * \author Bing Xu diff --git a/src/operator/convolution_v1.cu b/src/operator/convolution_v1.cu index 83a0f1d0f7df..b20b4b249224 100644 --- a/src/operator/convolution_v1.cu +++ b/src/operator/convolution_v1.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file convolution_v1.cu * \brief * \author Bing Xu diff --git a/src/operator/correlation-inl.h b/src/operator/correlation-inl.h index 6ba209bfb28e..02507cb1d96c 100644 --- a/src/operator/correlation-inl.h +++ b/src/operator/correlation-inl.h @@ -1,236 +1,254 @@ -/*! - * Copyright (c) 2015 by Contributors - * \file correlation-inl.h - * \brief correlation operator and symbol - * \author Xu Dong -*/ -#ifndef MXNET_OPERATOR_CORRELATION_INL_H_ -#define MXNET_OPERATOR_CORRELATION_INL_H_ -#include -#include -#include -#include -#include -#include -#include -#include "./mshadow_op.h" -#include "./operator_common.h" -namespace mxnet { -namespace op { -// Declare enumeration of input order to make code more intuitive. -// These enums are only visible within this header -namespace Correlation { -enum CorrelationOpInputs{kData1, kData2}; -enum CorrelationOpOutputs{kOut, kTemp1, kTemp2}; -} // namespace Correlation -struct CorrelationParam : public dmlc::Parameter { - uint32_t max_displacement; - uint32_t kernel_size; - uint32_t pad_size; - uint32_t stride1; - uint32_t stride2; - bool is_multiply; - DMLC_DECLARE_PARAMETER(CorrelationParam) { - DMLC_DECLARE_FIELD(kernel_size).set_default(1) - .describe("kernel size for Correlation must be an odd number"); - DMLC_DECLARE_FIELD(max_displacement).set_default(1) - .describe("Max displacement of Correlation "); - DMLC_DECLARE_FIELD(stride1).set_default(1) - .describe("stride1 quantize data1 globally"); - DMLC_DECLARE_FIELD(stride2).set_default(1) - .describe("stride2 quantize data2 within the neighborhood centered around data1"); - DMLC_DECLARE_FIELD(pad_size).set_default(0) - .describe("pad for Correlation"); - DMLC_DECLARE_FIELD(is_multiply).set_default(true) - .describe("operation type is either multiplication or subduction"); - } -}; -template -class CorrelationOp : public Operator { - public: - explicit CorrelationOp(CorrelationParam param) { - this->param_ = param; - } - virtual void Forward(const OpContext &ctx, - const std::vector &in_data, - const std::vector &req, - const std::vector &out_data, - const std::vector &aux_args) { - using namespace mshadow; - CHECK_EQ(in_data.size(), 2U); - CHECK_EQ(out_data.size(), 3U); - Stream *s = ctx.get_stream(); - Tensor data1 = in_data[Correlation::kData1].get(s); - Tensor data2 = in_data[Correlation::kData2].get(s); - Tensor out = out_data[Correlation::kOut].get(s); - Tensor tmp1 = out_data[Correlation::kTemp1].get(s); - Tensor tmp2 = out_data[Correlation::kTemp2].get(s); - tmp1 = 0.0f; - tmp2 = 0.0f; - out = 0.0f; - CHECK_EQ(data1.CheckContiguous(), true); - CHECK_EQ(data2.CheckContiguous(), true); - CHECK_EQ(out.CheckContiguous(), true); - CHECK_EQ(tmp1.CheckContiguous(), true); - CHECK_EQ(tmp2.CheckContiguous(), true); - paddedbottomheight = data1.shape_[2] + 2 * param_.pad_size; - paddedbottomwidth = data1.shape_[3] + 2 * param_.pad_size; - kernel_radius_ = (param_.kernel_size - 1) / 2; - border_size_ = param_.max_displacement + kernel_radius_; - stride1 = param_.stride1; - stride2 = param_.stride2; - top_width_ = ceil(static_cast(paddedbottomwidth - border_size_ * 2)\ - / static_cast(stride1)); - top_height_ = ceil(static_cast(paddedbottomheight - border_size_ * 2)\ - / static_cast(stride1)); - neighborhood_grid_radius_ = param_.max_displacement / stride2; - neighborhood_grid_width_ = neighborhood_grid_radius_ * 2 + 1; - top_channels_ = neighborhood_grid_width_ * neighborhood_grid_width_; - num = data1.shape_[0]; - channels = data1.shape_[1]; - height = data1.shape_[2]; - width = data1.shape_[3]; - CorrelationForward(out, data1, data2, tmp1, tmp2, top_channels_, top_height_, top_width_, - param_.pad_size, param_.is_multiply, - param_.max_displacement, param_.kernel_size, - neighborhood_grid_radius_, neighborhood_grid_width_, - kernel_radius_, param_.stride1, param_.stride2); - } - virtual void Backward(const OpContext &ctx, - const std::vector &out_grad, - const std::vector &in_data, - const std::vector &out_data, - const std::vector &req, - const std::vector &in_grad, - const std::vector &aux_args) { - using namespace mshadow; - Stream *s = ctx.get_stream(); - Tensor grad_data1 = in_grad[Correlation::kData1].get(s); - Tensor grad_data2 = in_grad[Correlation::kData2].get(s); - Tensor out_g = out_grad[Correlation::kOut].get(s); - Tensor tmp1 = out_data[Correlation::kTemp1].get(s); - Tensor tmp2 = out_data[Correlation::kTemp2].get(s); - if (req[0] != kAddTo) grad_data1 = 0.0f; - if (req[1] != kAddTo) grad_data2 = 0.0f; - CHECK_EQ(grad_data1.CheckContiguous(), true); - CHECK_EQ(grad_data2.CheckContiguous(), true); - CHECK_EQ(out_g.CheckContiguous(), true); - CHECK_EQ(tmp1.CheckContiguous(), true); - CHECK_EQ(tmp2.CheckContiguous(), true); - CorrelationBackward(out_g, grad_data1, grad_data2, tmp1, tmp2, top_channels_, - top_height_, top_width_, param_.pad_size, param_.is_multiply, - param_.max_displacement, param_.kernel_size, neighborhood_grid_radius_, - neighborhood_grid_width_, kernel_radius_, param_.stride1, param_.stride2, - num, channels, height, width); - } - - private: - CorrelationParam param_; - int paddedbottomheight; - int paddedbottomwidth; - uint32_t kernel_radius_; - uint32_t border_size_; - uint32_t stride1; - uint32_t stride2; - uint32_t top_width_; - uint32_t top_height_; - uint32_t neighborhood_grid_radius_; - uint32_t neighborhood_grid_width_; - uint32_t top_channels_; - int num; - int channels; - int height; - int width; -}; // class CorrelationOp -// Decalre Factory function -template -Operator* CreateOp(CorrelationParam param); -#if DMLC_USE_CXX11 -class CorrelationProp : public OperatorProperty { - public: - std::vector ListArguments() const override { - return {"data1", "data2"}; - } - std::vector ListOutputs() const override { - return {"output", "tmp1", "tmp2"}; - } - int NumOutputs() const override { - return 3; - } - int NumVisibleOutputs() const override { - return 1; - } -void Init(const std::vector >& kwargs) override { - param_.Init(kwargs); - } - std::map GetParams() const override { - return param_.__DICT__(); - } - bool InferShape(std::vector *in_shape, - std::vector *out_shape, - std::vector *aux_shape) const override { - using namespace mshadow; - CHECK_EQ(in_shape->size(), 2U) << "Input:[data1, data2]"; - TShape dshape1 = in_shape->at(Correlation::kData1); - TShape dshape2 = in_shape->at(Correlation::kData2); - CHECK_EQ(dshape1.ndim(), 4U) << "data should be a 4D tensor"; - CHECK_EQ(dshape2.ndim(), 4U) << "data should be a 4D tensor"; - int paddedbottomheight; - int paddedbottomwidth; - uint32_t kernel_radius_; - uint32_t stride1; - uint32_t stride2; - uint32_t top_width_; - uint32_t top_height_; - uint32_t neighborhood_grid_radius_; - uint32_t neighborhood_grid_width_; - uint32_t top_channels_; - uint32_t border_size_; - paddedbottomheight = dshape1[2] + 2*param_.pad_size; - paddedbottomwidth = dshape1[3] + 2*param_.pad_size; - kernel_radius_ = (param_.kernel_size -1)/2; - border_size_ = param_.max_displacement + kernel_radius_; - stride1 = param_.stride1; - stride2 = param_.stride2; - top_width_ = ceil(static_cast(paddedbottomwidth - border_size_ * 2)\ - / static_cast(stride1)); - top_height_ = ceil(static_cast(paddedbottomheight - border_size_ * 2)\ - / static_cast(stride1)); - neighborhood_grid_radius_ = param_.max_displacement / stride2; - neighborhood_grid_width_ = neighborhood_grid_radius_ * 2 + 1; - top_channels_ = neighborhood_grid_width_ * neighborhood_grid_width_; - CHECK_GE(top_width_, 1U) << - "Correlation cannot be done with current settings.Neighborhood and kernel don't fit in blob"; - CHECK_GE(top_height_, 1U) << - "Correlation cannot be done with current settings.Neighborhood and kernel don't fit in blob"; - out_shape->clear(); - out_shape->push_back(Shape4(dshape1[0], top_channels_, top_height_, top_width_)); - out_shape->push_back(Shape4(dshape1[0], paddedbottomheight, paddedbottomwidth, dshape1[1])); - out_shape->push_back(Shape4(dshape1[0], paddedbottomheight, paddedbottomwidth, dshape1[1])); - return true; - } - OperatorProperty* Copy() const override { - CorrelationProp* Correlation_sym = new CorrelationProp(); - Correlation_sym->param_ = this->param_; - return Correlation_sym; - } - std::string TypeString() const override { - return "Correlation"; - } - // decalre dependency and inplace optimization options - std::vector DeclareBackwardDependency( - const std::vector &out_grad, - const std::vector &in_data, - const std::vector &out_data) const override { - return {out_grad[Correlation::kOut], - out_data[Correlation::kTemp1], out_data[Correlation::kTemp2]}; -} - Operator* CreateOperator(Context ctx) const override; - - private: - CorrelationParam param_; -}; // class CorrelationProp -#endif -} // namespace op -} // namespace mxnet -#endif // MXNET_OPERATOR_CORRELATION_INL_H_ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/*! + * \file correlation-inl.h + * \brief correlation operator and symbol + * \author Xu Dong +*/ +#ifndef MXNET_OPERATOR_CORRELATION_INL_H_ +#define MXNET_OPERATOR_CORRELATION_INL_H_ +#include +#include +#include +#include +#include +#include +#include +#include "./mshadow_op.h" +#include "./operator_common.h" +namespace mxnet { +namespace op { +// Declare enumeration of input order to make code more intuitive. +// These enums are only visible within this header +namespace Correlation { +enum CorrelationOpInputs{kData1, kData2}; +enum CorrelationOpOutputs{kOut, kTemp1, kTemp2}; +} // namespace Correlation +struct CorrelationParam : public dmlc::Parameter { + uint32_t max_displacement; + uint32_t kernel_size; + uint32_t pad_size; + uint32_t stride1; + uint32_t stride2; + bool is_multiply; + DMLC_DECLARE_PARAMETER(CorrelationParam) { + DMLC_DECLARE_FIELD(kernel_size).set_default(1) + .describe("kernel size for Correlation must be an odd number"); + DMLC_DECLARE_FIELD(max_displacement).set_default(1) + .describe("Max displacement of Correlation "); + DMLC_DECLARE_FIELD(stride1).set_default(1) + .describe("stride1 quantize data1 globally"); + DMLC_DECLARE_FIELD(stride2).set_default(1) + .describe("stride2 quantize data2 within the neighborhood centered around data1"); + DMLC_DECLARE_FIELD(pad_size).set_default(0) + .describe("pad for Correlation"); + DMLC_DECLARE_FIELD(is_multiply).set_default(true) + .describe("operation type is either multiplication or subduction"); + } +}; +template +class CorrelationOp : public Operator { + public: + explicit CorrelationOp(CorrelationParam param) { + this->param_ = param; + } + virtual void Forward(const OpContext &ctx, + const std::vector &in_data, + const std::vector &req, + const std::vector &out_data, + const std::vector &aux_args) { + using namespace mshadow; + CHECK_EQ(in_data.size(), 2U); + CHECK_EQ(out_data.size(), 3U); + Stream *s = ctx.get_stream(); + Tensor data1 = in_data[Correlation::kData1].get(s); + Tensor data2 = in_data[Correlation::kData2].get(s); + Tensor out = out_data[Correlation::kOut].get(s); + Tensor tmp1 = out_data[Correlation::kTemp1].get(s); + Tensor tmp2 = out_data[Correlation::kTemp2].get(s); + tmp1 = 0.0f; + tmp2 = 0.0f; + out = 0.0f; + CHECK_EQ(data1.CheckContiguous(), true); + CHECK_EQ(data2.CheckContiguous(), true); + CHECK_EQ(out.CheckContiguous(), true); + CHECK_EQ(tmp1.CheckContiguous(), true); + CHECK_EQ(tmp2.CheckContiguous(), true); + paddedbottomheight = data1.shape_[2] + 2 * param_.pad_size; + paddedbottomwidth = data1.shape_[3] + 2 * param_.pad_size; + kernel_radius_ = (param_.kernel_size - 1) / 2; + border_size_ = param_.max_displacement + kernel_radius_; + stride1 = param_.stride1; + stride2 = param_.stride2; + top_width_ = ceil(static_cast(paddedbottomwidth - border_size_ * 2)\ + / static_cast(stride1)); + top_height_ = ceil(static_cast(paddedbottomheight - border_size_ * 2)\ + / static_cast(stride1)); + neighborhood_grid_radius_ = param_.max_displacement / stride2; + neighborhood_grid_width_ = neighborhood_grid_radius_ * 2 + 1; + top_channels_ = neighborhood_grid_width_ * neighborhood_grid_width_; + num = data1.shape_[0]; + channels = data1.shape_[1]; + height = data1.shape_[2]; + width = data1.shape_[3]; + CorrelationForward(out, data1, data2, tmp1, tmp2, top_channels_, top_height_, top_width_, + param_.pad_size, param_.is_multiply, + param_.max_displacement, param_.kernel_size, + neighborhood_grid_radius_, neighborhood_grid_width_, + kernel_radius_, param_.stride1, param_.stride2); + } + virtual void Backward(const OpContext &ctx, + const std::vector &out_grad, + const std::vector &in_data, + const std::vector &out_data, + const std::vector &req, + const std::vector &in_grad, + const std::vector &aux_args) { + using namespace mshadow; + Stream *s = ctx.get_stream(); + Tensor grad_data1 = in_grad[Correlation::kData1].get(s); + Tensor grad_data2 = in_grad[Correlation::kData2].get(s); + Tensor out_g = out_grad[Correlation::kOut].get(s); + Tensor tmp1 = out_data[Correlation::kTemp1].get(s); + Tensor tmp2 = out_data[Correlation::kTemp2].get(s); + if (req[0] != kAddTo) grad_data1 = 0.0f; + if (req[1] != kAddTo) grad_data2 = 0.0f; + CHECK_EQ(grad_data1.CheckContiguous(), true); + CHECK_EQ(grad_data2.CheckContiguous(), true); + CHECK_EQ(out_g.CheckContiguous(), true); + CHECK_EQ(tmp1.CheckContiguous(), true); + CHECK_EQ(tmp2.CheckContiguous(), true); + CorrelationBackward(out_g, grad_data1, grad_data2, tmp1, tmp2, top_channels_, + top_height_, top_width_, param_.pad_size, param_.is_multiply, + param_.max_displacement, param_.kernel_size, neighborhood_grid_radius_, + neighborhood_grid_width_, kernel_radius_, param_.stride1, param_.stride2, + num, channels, height, width); + } + + private: + CorrelationParam param_; + int paddedbottomheight; + int paddedbottomwidth; + uint32_t kernel_radius_; + uint32_t border_size_; + uint32_t stride1; + uint32_t stride2; + uint32_t top_width_; + uint32_t top_height_; + uint32_t neighborhood_grid_radius_; + uint32_t neighborhood_grid_width_; + uint32_t top_channels_; + int num; + int channels; + int height; + int width; +}; // class CorrelationOp +// Decalre Factory function +template +Operator* CreateOp(CorrelationParam param); +#if DMLC_USE_CXX11 +class CorrelationProp : public OperatorProperty { + public: + std::vector ListArguments() const override { + return {"data1", "data2"}; + } + std::vector ListOutputs() const override { + return {"output", "tmp1", "tmp2"}; + } + int NumOutputs() const override { + return 3; + } + int NumVisibleOutputs() const override { + return 1; + } +void Init(const std::vector >& kwargs) override { + param_.Init(kwargs); + } + std::map GetParams() const override { + return param_.__DICT__(); + } + bool InferShape(std::vector *in_shape, + std::vector *out_shape, + std::vector *aux_shape) const override { + using namespace mshadow; + CHECK_EQ(in_shape->size(), 2U) << "Input:[data1, data2]"; + TShape dshape1 = in_shape->at(Correlation::kData1); + TShape dshape2 = in_shape->at(Correlation::kData2); + CHECK_EQ(dshape1.ndim(), 4U) << "data should be a 4D tensor"; + CHECK_EQ(dshape2.ndim(), 4U) << "data should be a 4D tensor"; + int paddedbottomheight; + int paddedbottomwidth; + uint32_t kernel_radius_; + uint32_t stride1; + uint32_t stride2; + uint32_t top_width_; + uint32_t top_height_; + uint32_t neighborhood_grid_radius_; + uint32_t neighborhood_grid_width_; + uint32_t top_channels_; + uint32_t border_size_; + paddedbottomheight = dshape1[2] + 2*param_.pad_size; + paddedbottomwidth = dshape1[3] + 2*param_.pad_size; + kernel_radius_ = (param_.kernel_size -1)/2; + border_size_ = param_.max_displacement + kernel_radius_; + stride1 = param_.stride1; + stride2 = param_.stride2; + top_width_ = ceil(static_cast(paddedbottomwidth - border_size_ * 2)\ + / static_cast(stride1)); + top_height_ = ceil(static_cast(paddedbottomheight - border_size_ * 2)\ + / static_cast(stride1)); + neighborhood_grid_radius_ = param_.max_displacement / stride2; + neighborhood_grid_width_ = neighborhood_grid_radius_ * 2 + 1; + top_channels_ = neighborhood_grid_width_ * neighborhood_grid_width_; + CHECK_GE(top_width_, 1U) << + "Correlation cannot be done with current settings.Neighborhood and kernel don't fit in blob"; + CHECK_GE(top_height_, 1U) << + "Correlation cannot be done with current settings.Neighborhood and kernel don't fit in blob"; + out_shape->clear(); + out_shape->push_back(Shape4(dshape1[0], top_channels_, top_height_, top_width_)); + out_shape->push_back(Shape4(dshape1[0], paddedbottomheight, paddedbottomwidth, dshape1[1])); + out_shape->push_back(Shape4(dshape1[0], paddedbottomheight, paddedbottomwidth, dshape1[1])); + return true; + } + OperatorProperty* Copy() const override { + CorrelationProp* Correlation_sym = new CorrelationProp(); + Correlation_sym->param_ = this->param_; + return Correlation_sym; + } + std::string TypeString() const override { + return "Correlation"; + } + // decalre dependency and inplace optimization options + std::vector DeclareBackwardDependency( + const std::vector &out_grad, + const std::vector &in_data, + const std::vector &out_data) const override { + return {out_grad[Correlation::kOut], + out_data[Correlation::kTemp1], out_data[Correlation::kTemp2]}; +} + Operator* CreateOperator(Context ctx) const override; + + private: + CorrelationParam param_; +}; // class CorrelationProp +#endif +} // namespace op +} // namespace mxnet +#endif // MXNET_OPERATOR_CORRELATION_INL_H_ diff --git a/src/operator/correlation.cc b/src/operator/correlation.cc index 18a3e1cb06b9..2522cd45c414 100644 --- a/src/operator/correlation.cc +++ b/src/operator/correlation.cc @@ -1,175 +1,193 @@ -/*! - * Copyright (c) 2015 by Contributors - * \file correlation.cc - * \brief correlation op - * \author Xu Dong -*/ -#include "./correlation-inl.h" -#include "./mshadow_op.h" - -namespace mshadow { -template -void AddPad(const Tensor &original, - const Tensor &out, - int pad_size) -{ for (index_t nbatch = 0 ; nbatch < original.size(0) ; nbatch++) - for (index_t channel = 0 ; channel < original.size(1) ; channel++) - for (index_t h = 0 ; h < original.size(2) ; h++) - for (index_t w = 0 ; w < original.size(3) ; w++) - out[nbatch][h+pad_size][w+pad_size][channel] = original[nbatch][channel][h][w]; -} -template -inline void CorrelationForward(const Tensor &out, - const Tensor &data1, - const Tensor &data2, - const Tensor &tmp1, - const Tensor &tmp2, - int top_channels_, int top_height_, int top_width_, - int pad_size_, bool is_multiply, - int max_displacement_, int kernel_size_, - int neighborhood_grid_radius_, int neighborhood_grid_width_, - int kernel_radius_, int stride1_, int stride2_) { - const index_t bnum = data1.size(0); - const int bchannels = data1.size(1); - const int sumelems = kernel_size_ * kernel_size_ * bchannels; - AddPad(data1, tmp1, pad_size_); - index_t top_channels_unsigned_ = static_cast(top_channels_); - AddPad(data2, tmp2, pad_size_); - for (index_t i = 0 ; i < static_cast(top_height_) ; i++) - for (index_t j = 0 ; j < static_cast(top_width_); j++) - for (index_t nbatch = 0 ; nbatch < bnum ; nbatch++) { - int x1 = j*stride1_+max_displacement_; - int y1 = i*stride1_+max_displacement_; - for (index_t top_channel = 0 ; top_channel < top_channels_unsigned_ ; top_channel++) { - int s2o = (top_channel % neighborhood_grid_width_ -\ - neighborhood_grid_radius_) * stride2_; - int s2p = (top_channel / neighborhood_grid_width_ -\ - neighborhood_grid_radius_) * stride2_; - int x2 = x1 + s2o; - int y2 = y1 + s2p; - for (index_t h = 0; h < static_cast(kernel_size_); h++) - for (index_t w = 0; w < static_cast(kernel_size_); w++) - for (index_t channel = 0; channel < static_cast(bchannels); channel++) { - if (is_multiply == true) - out[nbatch][top_channel][i][j] += \ - tmp1[nbatch][y1+h][x1+w][channel]*tmp2[nbatch][y2+h][x2+w][channel]; - else - out[nbatch][top_channel][i][j] += \ - fabsf(tmp1[nbatch][y1+h][x1+w][channel]-tmp2[nbatch][y2+h][x2+w][channel]); - } - out[nbatch][top_channel][i][j] /= sumelems; - } - } -} -template -inline void CorrelationBackward(const Tensor &out_grad, - const Tensor &in_grad1, - const Tensor &in_grad2, - const Tensor &tmp1, - const Tensor &tmp2, - int top_channels_, int top_height_, - int top_width_, int pad_size_, - bool is_multiply, int max_displacement_, - int kernel_size_, int neighborhood_grid_radius_, - int neighborhood_grid_width_, - int kernel_radius_, int stride1_, - int stride2_, int num, - int channels, int height, int width - ) { - const float sumelems = kernel_size_ * kernel_size_ * channels; - for (index_t i = 0 ; i < static_cast(top_height_) ; i++) - for (index_t j = 0 ; j < static_cast(top_width_); j++) - for (index_t nbatch = 0 ; nbatch < static_cast(num) ; nbatch++) { - int x1 = j*stride1_+max_displacement_; - int y1 = i*stride1_+max_displacement_; - for (int top_channel = 0 ; top_channel < top_channels_ ; top_channel++) { - int s2o = (top_channel % neighborhood_grid_width_ - \ - neighborhood_grid_radius_) * stride2_; - int s2p = (top_channel / neighborhood_grid_width_ - \ - neighborhood_grid_radius_) * stride2_; - int x2 = x1 + s2o; - int y2 = y1 + s2p; - for (int h = 0; h < kernel_size_; h++) - for (int w = 0; w < kernel_size_; w++) - for (int channel = 0 ; channel < channels; channel++) { - if (is_multiply == true) { - if ((y1 + h - pad_size_ >= 0) && (x1 + w - pad_size_ >= 0) && \ - (y1 + h < height +pad_size_) && (x1 + w < width + pad_size_)) { - in_grad1[nbatch][channel][y1+h-pad_size_][x1+w-pad_size_] += \ - out_grad[nbatch][top_channel][i][j] * \ - tmp2[nbatch][y2+h][x2+w][channel]/sumelems; - } - if ((y2 + h - pad_size_ >= 0) && (x2 + w -pad_size_ >=0) && \ - (y2 + h < height +pad_size_) && (x2 + w < width + pad_size_)) { - in_grad2[nbatch][channel][y2+h-pad_size_][x2+w-pad_size_] += \ - out_grad[nbatch][top_channel][i][j] * \ - tmp1[nbatch][y1+h][x1+w][channel]/sumelems; - } - } else { - if ((y1 + h - pad_size_ >= 0) && (x1 + w -pad_size_ >=0) && \ - (y1 + h < height + pad_size_) && (x1 + w < width + pad_size_)) { - Dtype sign = (tmp1[nbatch][y1+h][x1+w][channel] >= \ - tmp2[nbatch][y2+h][x2+w][channel])? Dtype(1.0) : Dtype(-1.0); - in_grad1[nbatch][channel][y1+h-pad_size_][x1+w-pad_size_] +=\ - out_grad[nbatch][top_channel][i][j]*sign/sumelems; - } - if ((y2 + h - pad_size_ >= 0) && (x2 + w - pad_size_ >=0) && \ - (y2 + h < height + pad_size_) && (x2 + w < width + pad_size_)) { - Dtype sign = (tmp1[nbatch][y1+h][x1+w][channel] >= \ - tmp2[nbatch][y2+h][x2+w][channel])? Dtype(-1.0) : Dtype(1.0); - in_grad2[nbatch][channel][y2+h-pad_size_][x2+w-pad_size_] +=\ - out_grad[nbatch][top_channel][i][j]*sign/sumelems; - } - } - } - } - } -} -} // namespace mshadow -namespace mxnet { -namespace op { -template<> -Operator *CreateOp(CorrelationParam param) { - return new CorrelationOp(param); -} -Operator* CorrelationProp::CreateOperator(Context ctx) const { - DO_BIND_DISPATCH(CreateOp, param_); -} -DMLC_REGISTER_PARAMETER(CorrelationParam); -MXNET_REGISTER_OP_PROPERTY(Correlation, CorrelationProp) -.add_argument("data1", "NDArray-or-Symbol", "Input data1 to the correlation.") -.add_argument("data2", "NDArray-or-Symbol", "Input data2 to the correlation.") -.add_arguments(CorrelationParam::__FIELDS__()) -.describe(R"code(Applies correlation to inputs. - -The correlation layer performs multiplicative patch comparisons between two feature maps. - -Given two multi-channel feature maps :math:`f_{1}, f_{2}`, with :math:`w`, :math:`h`, and :math:`c` being their width, height, and number of channels, -the correlation layer lets the network compare each patch from :math:`f_{1}` with each patch from :math:`f_{2}`. - -For now we consider only a single comparison of two patches. The 'correlation' of two patches centered at :math:`x_{1}` in the first map and -:math:`x_{2}` in the second map is then defined as: - -.. math:: - c(x_{1}, x_{2}) = \sum_{o \in [-k,k] \times [-k,k]} - -for a square patch of size :math:`K:=2k+1`. - -Note that the equation above is identical to one step of a convolution in neural networks, but instead of convolving data with a filter, it convolves data with other -data. For this reason, it has no training weights. - -Computing :math:`c(x_{1}, x_{2})` involves :math:`c * K^{2}` multiplications. Comparing all patch combinations involves :math:`w^{2}*h^{2}` such computations. - -Given a maximum displacement :math:`d`, for each location :math:`x_{1}` it computes correlations :math:`c(x_{1}, x_{2})` only in a neighborhood of size :math:`D:=2d+1`, -by limiting the range of :math:`x_{2}`. We use strides :math:`s_{1}, s_{2}`, to quantize :math:`x_{1}` globally and to quantize :math:`x_{2}` within the neighborhood -centered around :math:`x_{1}`. - -The final output is defined by the following expression: - -.. math:: - out[n, q, i, j] = c(x_{i, j}, x_{q}) - -where :math:`i` and :math:`j` enumerate spatial locations in :math:`f_{1}`, and :math:`q` denotes the :math:`q^{th}` neighborhood of :math:`x_{i,j}`. -)code" ADD_FILELINE); -} // namespace op -} // namespace mxnet +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/*! + * \file correlation.cc + * \brief correlation op + * \author Xu Dong +*/ +#include "./correlation-inl.h" +#include "./mshadow_op.h" + +namespace mshadow { +template +void AddPad(const Tensor &original, + const Tensor &out, + int pad_size) +{ for (index_t nbatch = 0 ; nbatch < original.size(0) ; nbatch++) + for (index_t channel = 0 ; channel < original.size(1) ; channel++) + for (index_t h = 0 ; h < original.size(2) ; h++) + for (index_t w = 0 ; w < original.size(3) ; w++) + out[nbatch][h+pad_size][w+pad_size][channel] = original[nbatch][channel][h][w]; +} +template +inline void CorrelationForward(const Tensor &out, + const Tensor &data1, + const Tensor &data2, + const Tensor &tmp1, + const Tensor &tmp2, + int top_channels_, int top_height_, int top_width_, + int pad_size_, bool is_multiply, + int max_displacement_, int kernel_size_, + int neighborhood_grid_radius_, int neighborhood_grid_width_, + int kernel_radius_, int stride1_, int stride2_) { + const index_t bnum = data1.size(0); + const int bchannels = data1.size(1); + const int sumelems = kernel_size_ * kernel_size_ * bchannels; + AddPad(data1, tmp1, pad_size_); + index_t top_channels_unsigned_ = static_cast(top_channels_); + AddPad(data2, tmp2, pad_size_); + for (index_t i = 0 ; i < static_cast(top_height_) ; i++) + for (index_t j = 0 ; j < static_cast(top_width_); j++) + for (index_t nbatch = 0 ; nbatch < bnum ; nbatch++) { + int x1 = j*stride1_+max_displacement_; + int y1 = i*stride1_+max_displacement_; + for (index_t top_channel = 0 ; top_channel < top_channels_unsigned_ ; top_channel++) { + int s2o = (top_channel % neighborhood_grid_width_ -\ + neighborhood_grid_radius_) * stride2_; + int s2p = (top_channel / neighborhood_grid_width_ -\ + neighborhood_grid_radius_) * stride2_; + int x2 = x1 + s2o; + int y2 = y1 + s2p; + for (index_t h = 0; h < static_cast(kernel_size_); h++) + for (index_t w = 0; w < static_cast(kernel_size_); w++) + for (index_t channel = 0; channel < static_cast(bchannels); channel++) { + if (is_multiply == true) + out[nbatch][top_channel][i][j] += \ + tmp1[nbatch][y1+h][x1+w][channel]*tmp2[nbatch][y2+h][x2+w][channel]; + else + out[nbatch][top_channel][i][j] += \ + fabsf(tmp1[nbatch][y1+h][x1+w][channel]-tmp2[nbatch][y2+h][x2+w][channel]); + } + out[nbatch][top_channel][i][j] /= sumelems; + } + } +} +template +inline void CorrelationBackward(const Tensor &out_grad, + const Tensor &in_grad1, + const Tensor &in_grad2, + const Tensor &tmp1, + const Tensor &tmp2, + int top_channels_, int top_height_, + int top_width_, int pad_size_, + bool is_multiply, int max_displacement_, + int kernel_size_, int neighborhood_grid_radius_, + int neighborhood_grid_width_, + int kernel_radius_, int stride1_, + int stride2_, int num, + int channels, int height, int width + ) { + const float sumelems = kernel_size_ * kernel_size_ * channels; + for (index_t i = 0 ; i < static_cast(top_height_) ; i++) + for (index_t j = 0 ; j < static_cast(top_width_); j++) + for (index_t nbatch = 0 ; nbatch < static_cast(num) ; nbatch++) { + int x1 = j*stride1_+max_displacement_; + int y1 = i*stride1_+max_displacement_; + for (int top_channel = 0 ; top_channel < top_channels_ ; top_channel++) { + int s2o = (top_channel % neighborhood_grid_width_ - \ + neighborhood_grid_radius_) * stride2_; + int s2p = (top_channel / neighborhood_grid_width_ - \ + neighborhood_grid_radius_) * stride2_; + int x2 = x1 + s2o; + int y2 = y1 + s2p; + for (int h = 0; h < kernel_size_; h++) + for (int w = 0; w < kernel_size_; w++) + for (int channel = 0 ; channel < channels; channel++) { + if (is_multiply == true) { + if ((y1 + h - pad_size_ >= 0) && (x1 + w - pad_size_ >= 0) && \ + (y1 + h < height +pad_size_) && (x1 + w < width + pad_size_)) { + in_grad1[nbatch][channel][y1+h-pad_size_][x1+w-pad_size_] += \ + out_grad[nbatch][top_channel][i][j] * \ + tmp2[nbatch][y2+h][x2+w][channel]/sumelems; + } + if ((y2 + h - pad_size_ >= 0) && (x2 + w -pad_size_ >=0) && \ + (y2 + h < height +pad_size_) && (x2 + w < width + pad_size_)) { + in_grad2[nbatch][channel][y2+h-pad_size_][x2+w-pad_size_] += \ + out_grad[nbatch][top_channel][i][j] * \ + tmp1[nbatch][y1+h][x1+w][channel]/sumelems; + } + } else { + if ((y1 + h - pad_size_ >= 0) && (x1 + w -pad_size_ >=0) && \ + (y1 + h < height + pad_size_) && (x1 + w < width + pad_size_)) { + Dtype sign = (tmp1[nbatch][y1+h][x1+w][channel] >= \ + tmp2[nbatch][y2+h][x2+w][channel])? Dtype(1.0) : Dtype(-1.0); + in_grad1[nbatch][channel][y1+h-pad_size_][x1+w-pad_size_] +=\ + out_grad[nbatch][top_channel][i][j]*sign/sumelems; + } + if ((y2 + h - pad_size_ >= 0) && (x2 + w - pad_size_ >=0) && \ + (y2 + h < height + pad_size_) && (x2 + w < width + pad_size_)) { + Dtype sign = (tmp1[nbatch][y1+h][x1+w][channel] >= \ + tmp2[nbatch][y2+h][x2+w][channel])? Dtype(-1.0) : Dtype(1.0); + in_grad2[nbatch][channel][y2+h-pad_size_][x2+w-pad_size_] +=\ + out_grad[nbatch][top_channel][i][j]*sign/sumelems; + } + } + } + } + } +} +} // namespace mshadow +namespace mxnet { +namespace op { +template<> +Operator *CreateOp(CorrelationParam param) { + return new CorrelationOp(param); +} +Operator* CorrelationProp::CreateOperator(Context ctx) const { + DO_BIND_DISPATCH(CreateOp, param_); +} +DMLC_REGISTER_PARAMETER(CorrelationParam); +MXNET_REGISTER_OP_PROPERTY(Correlation, CorrelationProp) +.add_argument("data1", "NDArray-or-Symbol", "Input data1 to the correlation.") +.add_argument("data2", "NDArray-or-Symbol", "Input data2 to the correlation.") +.add_arguments(CorrelationParam::__FIELDS__()) +.describe(R"code(Applies correlation to inputs. + +The correlation layer performs multiplicative patch comparisons between two feature maps. + +Given two multi-channel feature maps :math:`f_{1}, f_{2}`, with :math:`w`, :math:`h`, and :math:`c` being their width, height, and number of channels, +the correlation layer lets the network compare each patch from :math:`f_{1}` with each patch from :math:`f_{2}`. + +For now we consider only a single comparison of two patches. The 'correlation' of two patches centered at :math:`x_{1}` in the first map and +:math:`x_{2}` in the second map is then defined as: + +.. math:: + c(x_{1}, x_{2}) = \sum_{o \in [-k,k] \times [-k,k]} + +for a square patch of size :math:`K:=2k+1`. + +Note that the equation above is identical to one step of a convolution in neural networks, but instead of convolving data with a filter, it convolves data with other +data. For this reason, it has no training weights. + +Computing :math:`c(x_{1}, x_{2})` involves :math:`c * K^{2}` multiplications. Comparing all patch combinations involves :math:`w^{2}*h^{2}` such computations. + +Given a maximum displacement :math:`d`, for each location :math:`x_{1}` it computes correlations :math:`c(x_{1}, x_{2})` only in a neighborhood of size :math:`D:=2d+1`, +by limiting the range of :math:`x_{2}`. We use strides :math:`s_{1}, s_{2}`, to quantize :math:`x_{1}` globally and to quantize :math:`x_{2}` within the neighborhood +centered around :math:`x_{1}`. + +The final output is defined by the following expression: + +.. math:: + out[n, q, i, j] = c(x_{i, j}, x_{q}) + +where :math:`i` and :math:`j` enumerate spatial locations in :math:`f_{1}`, and :math:`q` denotes the :math:`q^{th}` neighborhood of :math:`x_{i,j}`. +)code" ADD_FILELINE); +} // namespace op +} // namespace mxnet diff --git a/src/operator/correlation.cu b/src/operator/correlation.cu index b26ae04f2d0b..149d73f2e83a 100644 --- a/src/operator/correlation.cu +++ b/src/operator/correlation.cu @@ -1,609 +1,628 @@ -/*! - * Copyright [2016] - * \file Correation.cu - * \brief Correlation operator - * \author Xu Dong -*/ -#include "./correlation-inl.h" -#include -#include -#include -#include - -#define ROUND_OFF 50000 -#define WARPS_PER_BLOCK 1 -#define THREADS_PER_WARP 32 -#define CORRELATION_CUDA_CHECK(condition) \ - /* Code block avoids redefinition of cudaError_t error */ \ - do { \ - cudaError_t error = condition; \ - CHECK_EQ(error, cudaSuccess) << " " << cudaGetErrorString(error); \ - } while (0) -#define CUDA_KERNEL_LOOP(i, n) \ -for (int i = blockIdx.x * blockDim.x + threadIdx.x; \ - i < (n); \ - i += blockDim.x * gridDim.x) -namespace mshadow { -namespace cuda { -// == Correlation Kernel -template -__global__ void CorrelateData(const int nthreads, int num, int topwidth, - int topheight, int topchannels, int topcount, - int max_displacement, int neighborhood_grid_radius, - int neighborhood_grid_width, int kernel_radius, int kernel_size, int stride1, int stride2, - int bottomwidth, int bottomheight, int bottomchannels, - const Dtype *bottom0, const Dtype *bottom1, Dtype *top) { - extern __shared__ char patch_data_char[]; - Dtype *patch_data = reinterpret_cast(patch_data_char); - // First (upper left) position of kernel upper-left corner - // in current center position of neighborhood in image 1 - int x1 = blockIdx.x * stride1 + max_displacement; - int y1 = blockIdx.y * stride1 + max_displacement; - int item = blockIdx.z; - int ch_off = threadIdx.x; - // Load 3D patch into shared shared memory - for (int j = 0; j < kernel_size; j++) { // HEIGHT - for (int i = 0; i < kernel_size; i++) { // WIDTH - int ji_off = ((j * kernel_size) + i) * bottomchannels; - for (int ch = ch_off; ch < bottomchannels; ch += (THREADS_PER_WARP * WARPS_PER_BLOCK)) { - // CHANNELS - int idx1 = ((item * bottomheight + y1+j) * bottomwidth + x1+i) * bottomchannels + ch; - int idxPatchData = ji_off + ch; - patch_data[idxPatchData] = bottom0[idx1]; - } - } - } - __syncthreads(); - __shared__ Dtype sum[THREADS_PER_WARP * WARPS_PER_BLOCK]; - // Compute correlation - for (int top_channel = 0; top_channel < topchannels; top_channel++) { - sum[ch_off] = 0; - int s2o = (top_channel % neighborhood_grid_width - neighborhood_grid_radius) * stride2; - int s2p = (top_channel / neighborhood_grid_width - neighborhood_grid_radius) * stride2; - for (int j = 0; j < kernel_size; j++) { // HEIGHT - for (int i = 0; i < kernel_size; i++) { // WIDTH - int ji_off = ((j * kernel_size) + i) * bottomchannels; - for (int ch = ch_off; ch < bottomchannels; ch += (THREADS_PER_WARP * WARPS_PER_BLOCK)) { - // CHANNELS - int x2 = x1 + s2o; - int y2 = y1 + s2p; - int idxPatchData = ji_off + ch; - int idx2 = ((item * bottomheight + y2 + j) * bottomwidth + x2 + i) * bottomchannels + ch; - sum[ch_off] += patch_data[idxPatchData] * bottom1[idx2]; - } - } - } - __syncthreads(); - if (ch_off == 0) { - Dtype total_sum = 0; - for (int idx = 0; idx < THREADS_PER_WARP * WARPS_PER_BLOCK; idx++) { - total_sum += sum[idx]; - } - const int sumelems = kernel_size * kernel_size * bottomchannels; - const int index = ((top_channel * topheight + blockIdx.y) * topwidth) + blockIdx.x; - top[index + item*topcount] = total_sum / static_cast(sumelems); - } // Aggregate result of different threads - } -} -// == Correlation Backward Pass Kernel (For data1) -template -__global__ void CorrelateDataBackward0(const int nthreads, int num, int item, - int topwidth, int topheight, int topchannels, - int max_displacement, int neighborhood_grid_radius, - int neighborhood_grid_width, int kernel_radius, int stride1, int stride2, - int bottomwidth, int bottomheight, int pbottomwidth, int pbottomheight, - int bottomchannels, int bottomcount, int pad_size, - Dtype *bottom0diff, const Dtype *bottom1, const Dtype *topdiff) { - CUDA_KERNEL_LOOP(index, nthreads) { - int n = index % bottomchannels; // channels - int l = (index / bottomchannels) % bottomwidth + pad_size; // w-pos - int m = (index / bottomchannels / bottomwidth) % bottomheight + pad_size; // h-pos - // Get X,Y ranges and clamp - // round_off is a trick to enable integer division with ceil, even for negative numbers - // We use a large offset, for the inner part not to become negative. - const int round_off = ROUND_OFF; - const int round_off_s1 = stride1 * round_off; - // We add round_off before_s1 the int division and subtract round_off after it, - // to ensure the formula matches ceil behavior: - int xmin = (l - 2*kernel_radius - max_displacement + round_off_s1 - 1)\ - / stride1 + 1 - round_off; // ceil (l - 2*kernel_radius - max_displacement) / stride1 - int ymin = (m - 2*kernel_radius - max_displacement + round_off_s1 - 1)\ - / stride1 + 1 - round_off; // ceil (l - 2*kernel_radius - max_displacement) / stride1 - // Same here: - int xmax = (l - max_displacement + round_off_s1) / stride1 - round_off; - // floor (l - max_displacement) / stride1 - int ymax = (m - max_displacement + round_off_s1) / stride1 - round_off; - // floor (m - max_displacement) / stride1 - Dtype sum = 0; - if (xmax >= 0 && ymax >= 0 && (xmin <= topwidth-1) && (ymin <= topheight-1)) { - xmin = max(0, xmin); - xmax = min(topwidth-1, xmax); - ymin = max(0, ymin); - ymax = min(topheight-1, ymax); - for (int p = -neighborhood_grid_radius; p <= neighborhood_grid_radius; p++) { - for (int o = -neighborhood_grid_radius; o <= neighborhood_grid_radius; o++) { - // Get bottom1 data: - int s2o = stride2 * o; - int s2p = stride2 * p; - int idxbot1 = ((item * pbottomheight + (m + s2p)) * pbottomwidth + (l + s2o))\ - * bottomchannels + n; - Dtype bot1tmp = bottom1[idxbot1]; // bottom1[l+s2o,m+s2p,n] - // Index offset for topdiff in following loops: - int op = (p+neighborhood_grid_radius) * neighborhood_grid_width\ - + (o + neighborhood_grid_radius); // index [o,p] - int idxopoffset = (item * topchannels + op); - for (int y = ymin; y <= ymax; y++) { - for (int x = xmin; x <= xmax; x++) { - int idxtopdiff = (idxopoffset * topheight + y) * topwidth + x; // topdiff[x,y,o,p] - sum += topdiff[idxtopdiff] * bot1tmp; - } - } - } - } - } - const int sumelems = (kernel_radius * 2 + 1) * (kernel_radius * 2+1) * bottomchannels; - const int bot0index = ((n * bottomheight) + (m-pad_size)) * bottomwidth + (l-pad_size); - bottom0diff[bot0index + item * bottomcount] = sum / static_cast(sumelems); - } -} -// == Correlation Backward Pass Kernel (For Blob 1) -template -__global__ void CorrelateDataBackward1(const int nthreads, - int num, int item, int topwidth, int topheight, int topchannels, - int max_displacement, int neighborhood_grid_radius, - int neighborhood_grid_width, int kernel_radius, int stride1, int stride2, - int bottomwidth, int bottomheight, int pbottomwidth, int pbottomheight, - int bottomchannels, int bottomcount, int pad_size, - const Dtype *bottom0, Dtype *bottom1diff, const Dtype *topdiff) { - CUDA_KERNEL_LOOP(index, nthreads) { - // int l = index % bottomwidth + pad_size; //w-pos - // int m = (index / bottomwidth) % bottomheight + pad_size; // h-pos - // int n = (index / bottomwidth / bottomheight) % bottomchannels; // channels - int n = index % bottomchannels; // channels - int l = (index / bottomchannels) % bottomwidth + pad_size; // w-pos - int m = (index / bottomchannels / bottomwidth) % bottomheight + pad_size; // h-pos - // round_off is a trick to enable integer division with ceil, even for negative numbers - // We use a large offset, for the inner part not to become negative. - const int round_off = ROUND_OFF; - const int round_off_s1 = stride1 * round_off; - Dtype sum = 0; - for (int p = -neighborhood_grid_radius; p <= neighborhood_grid_radius; p++) { - for (int o = -neighborhood_grid_radius; o <= neighborhood_grid_radius; o++) { - int s2o = stride2 * o; - int s2p = stride2 * p; - // Get X,Y ranges and clamp - // We add round_off before_s1 the int division and subtract round_off after it, - // to ensure the formula matches ceil behavior: - int xmin = (l - 2*kernel_radius - max_displacement - s2o + round_off_s1 - 1)\ - / stride1 + 1 - round_off; - // ceil (l - 2*kernel_radius - max_displacement - s2o) / stride1 - int ymin = (m - 2*kernel_radius - max_displacement - s2p + round_off_s1 - 1)\ - / stride1 + 1 - round_off; - // ceil (l - 2*kernel_radius - max_displacement - s2o) / stride1 - // Same here: - int xmax = (l - max_displacement - s2o + round_off_s1) / stride1 - round_off; - // floor (l - max_displacement - s2o) / stride1 - int ymax = (m - max_displacement - s2p + round_off_s1) / stride1 - round_off; - // floor (m - max_displacement - s2p) / stride1 - if (xmax >= 0 && ymax >= 0 && (xmin <= topwidth - 1) && (ymin <= topheight - 1)) { - xmin = max(0, xmin); - xmax = min(topwidth-1, xmax); - ymin = max(0, ymin); - ymax = min(topheight-1, ymax); - // Get bottom0 data: - int idxbot0 = ((item * pbottomheight + (m - s2p)) \ - * pbottomwidth + (l - s2o)) * bottomchannels + n; - Dtype bot0tmp = bottom0[idxbot0]; // bottom1[l+s2o,m+s2p,n] - // Index offset for topdiff in following loops: - int op = (p+neighborhood_grid_radius) * \ - neighborhood_grid_width + (o+neighborhood_grid_radius); // index [o,p] - int idxOpOffset = (item * topchannels + op); - for (int y = ymin; y <= ymax; y++) { - for (int x = xmin; x <= xmax; x++) { - int idxtopdiff = (idxOpOffset * topheight + y)\ - * topwidth + x; // topdiff[x,y,o,p] - sum += topdiff[idxtopdiff] * bot0tmp; - } - } - } - } - } - const int sumelems = (kernel_radius*2+1)*(kernel_radius*2+1)*bottomchannels; - const int bot1index = ((n * bottomheight) + (m - pad_size)) * bottomwidth + (l - pad_size); - bottom1diff[bot1index + item * bottomcount] = sum / static_cast(sumelems); - } -} -// == Correlation Kernel Subtraction -template -__global__ void CorrelateDataSubtract(const int nthreads, int num, int item, - int topwidth, int topheight, int topchannels, int topcount, - int max_displacement, int neighborhood_grid_radius, - int neighborhood_grid_width, int kernel_radius, int stride1, int stride2, - int bottomwidth, int bottomheight, int bottomchannels, - const Dtype *bottom0, const Dtype *bottom1, Dtype *top) { - CUDA_KERNEL_LOOP(index, nthreads) { - int x = index % topwidth; // w-pos - int y = (index / topwidth) % topheight; // h-pos - int c = (index / topwidth / topheight) % topchannels; // channels - // Offset of patch in image 2 - int s2o = (c % neighborhood_grid_width - neighborhood_grid_radius) * stride2; - int s2p = (c / neighborhood_grid_width - neighborhood_grid_radius) * stride2; - // First (upper left) position of kernel center in current neighborhood in image 1 - int x1 = x*stride1 + kernel_radius + max_displacement; - int y1 = y*stride1 + kernel_radius + max_displacement; - // Iterate through 3D patch - Dtype sum = 0; - for (int j = -kernel_radius; j <= kernel_radius; j++) { // HEIGHT - for (int i = -kernel_radius; i <= kernel_radius; i++) { // WIDTH - for (int l = 0; l < bottomchannels; l++) { // CHANNELS - // Calculate position in image 2 - int x2 = x1 + s2o; - int y2 = y1 + s2p; - // Indices in bottom data: (CH=l,W=x2,H=y2,N) - int idx1 = ((item * bottomheight + y1 + j) * bottomwidth + x1 + i) \ - * bottomchannels + l; - int idx2 = ((item * bottomheight + y2 + j) * bottomwidth + x2 + i) \ - * bottomchannels + l; - // Do the correlation: - sum += fabsf(bottom0[idx1] - bottom1[idx2]); - } - } - } - const int sumelems = (kernel_radius * 2 + 1) * (kernel_radius * 2 + 1) * bottomchannels; - top[index + item * topcount] = sum / static_cast(sumelems); - } -} -// == Correlation Backward Pass Kernel (For Blob 0) -template -__global__ void CorrelateDataBackward0Subtract(const int nthreads, int num, - int item, int topwidth, int topheight, int topchannels, - int max_displacement, int neighborhood_grid_radius, - int neighborhood_grid_width, int kernel_radius, - int stride1, int stride2, int bottomwidth, int bottomheight, - int pbottomwidth, int pbottomheight, - int bottomchannels, int bottomcount, int pad_size, - Dtype *bottom0diff, const Dtype *bottom0, const Dtype *bottom1, const Dtype *topdiff) { - CUDA_KERNEL_LOOP(index, nthreads) { - int n = index % bottomchannels; // channels - int l = (index / bottomchannels) % bottomwidth + pad_size; // w-pos - int m = (index / bottomchannels / bottomwidth) % bottomheight + pad_size; // h-pos - // Get X,Y ranges and clamp - // round_off is a trick to enable integer division with ceil, even for negative numbers - // We use a large offset, for the inner part not to become negative. - const int round_off = ROUND_OFF; - const int round_off_s1 = stride1 * round_off; - int idxbot0 = ((item * pbottomheight + m) * pbottomwidth + l)\ - * bottomchannels + n; - // We add round_off before_s1 the int division and subtract round_off after it, - // to ensure the formula matches ceil behavior: - int xmin = (l - 2*kernel_radius - max_displacement + round_off_s1 - 1)\ - / stride1 + 1 - round_off; // ceil (l - 2*kernel_radius - max_displacement) / stride1 - int ymin = (m - 2*kernel_radius - max_displacement + round_off_s1 - 1)\ - / stride1 + 1 - round_off; // ceil (l - 2*kernel_radius - max_displacement) / stride1 - // Same here: - int xmax = (l - max_displacement + round_off_s1) / stride1 - round_off; - // floor (l - max_displacement) / stride1 - int ymax = (m - max_displacement + round_off_s1) / stride1 - round_off; - // floor (m - max_displacement) / stride1 - Dtype sum = 0; - if (xmax >= 0 && ymax >= 0 && (xmin <= topwidth-1) && (ymin <= topheight-1)) { - xmin = max(0, xmin); - xmax = min(topwidth-1, xmax); - ymin = max(0, ymin); - ymax = min(topheight-1, ymax); - for (int p = -neighborhood_grid_radius; p <= neighborhood_grid_radius; p++) { - for (int o = -neighborhood_grid_radius; o <= neighborhood_grid_radius; o++) { - // Get bottom1 data: - int s2o = stride2 * o; - int s2p = stride2 * p; - int idxbot1 = ((item * pbottomheight + (m+s2p)) * pbottomwidth\ - + (l+s2o)) * bottomchannels + n; - Dtype bot0tmp = bottom0[idxbot0]; - Dtype bot1tmp = bottom1[idxbot1]; - Dtype sign = (bot0tmp >= bot1tmp) ? Dtype(1.0) : Dtype(-1.0); - // Index offset for topdiff in following loops: - int op = (p+neighborhood_grid_radius) * neighborhood_grid_width\ - + (o + neighborhood_grid_radius); // index [o,p] - int idxopoffset = (item * topchannels + op); - for (int y = ymin; y <= ymax; y++) { - for (int x = xmin; x <= xmax; x++) { - int idxtopdiff = (idxopoffset * topheight + y) * topwidth + x; // topdiff[x,y,o,p] - sum += topdiff[idxtopdiff] * sign; - } - } - } - } - } - const int sumelems = (kernel_radius * 2 + 1) * (kernel_radius * 2+1) * bottomchannels; - const int bot0index = ((n * bottomheight) + (m-pad_size)) * bottomwidth + (l-pad_size); - bottom0diff[bot0index + item * bottomcount] = sum / static_cast(sumelems); - } -} -// == Correlation Backward Pass Kernel (For Blob 1) -template -__global__ void CorrelateDataBackward1Subtract(const int nthreads, int num, - int item, int topwidth, int topheight, int topchannels, - int max_displacement, int neighborhood_grid_radius, - int neighborhood_grid_width, int kernel_radius, - int stride1, int stride2, int bottomwidth, int bottomheight, - int pbottomwidth, int pbottomheight, int bottomchannels, - int bottomcount, int pad_size, const Dtype *bottom0, - const Dtype *bottom1, Dtype *bottom1diff, const Dtype *topdiff) { - CUDA_KERNEL_LOOP(index, nthreads) { - // int l = index % bottomwidth + pad_size; //w-pos - // int m = (index / bottomwidth) % bottomheight + pad_size; // h-pos - // int n = (index / bottomwidth / bottomheight) % bottomchannels; // channels - int n = index % bottomchannels; // channels - int l = (index / bottomchannels) % bottomwidth + pad_size; // w-pos - int m = (index / bottomchannels / bottomwidth) % bottomheight + pad_size; // h-pos - // round_off is a trick to enable integer division with ceil, even for negative numbers - // We use a large offset, for the inner part not to become negative. - const int round_off = ROUND_OFF; - const int round_off_s1 = stride1 * round_off; - Dtype sum = 0; - int idxbot1 = ((item * pbottomheight + m) * pbottomwidth + l)\ - * bottomchannels + n; - for (int p = -neighborhood_grid_radius; p <= neighborhood_grid_radius; p++) { - for (int o = -neighborhood_grid_radius; o <= neighborhood_grid_radius; o++) { - int s2o = stride2 * o; - int s2p = stride2 * p; - // Get X,Y ranges and clamp - // We add round_off before_s1 the int division and subtract round_off after it, - // to ensure the formula matches ceil behavior: - int xmin = (l - 2*kernel_radius - max_displacement - s2o + round_off_s1 - 1)\ - / stride1 + 1 - round_off; - // ceil (l - 2*kernel_radius - max_displacement - s2o) / stride1 - int ymin = (m - 2*kernel_radius - max_displacement - s2p + round_off_s1 - 1)\ - / stride1 + 1 - round_off; - // ceil (l - 2*kernel_radius - max_displacement - s2o) / stride1 - // Same here: - int xmax = (l - max_displacement - s2o + round_off_s1) / stride1 - round_off; - // floor (l - max_displacement - s2o) / stride1 - int ymax = (m - max_displacement - s2p + round_off_s1) / stride1 - round_off; - // floor (m - max_displacement - s2p) / stride1 - if (xmax >= 0 && ymax >= 0 && (xmin <= topwidth - 1) && (ymin <= topheight - 1)) { - xmin = max(0, xmin); - xmax = min(topwidth-1, xmax); - ymin = max(0, ymin); - ymax = min(topheight-1, ymax); - // Get bottom0 data: - int idxbot0 = ((item * pbottomheight + (m - s2p)) * pbottomwidth + (l - s2o))\ - * bottomchannels + n; - // bottom0[l+s2o,m+s2p,n] - Dtype bot0tmp = bottom0[idxbot0]; - Dtype bot1tmp = bottom1[idxbot1]; - Dtype sign = (bot0tmp >= bot1tmp) ? Dtype(-1.0) : Dtype(1.0); - // Index offset for topdiff in following loops: - int op = (p+neighborhood_grid_radius) * \ - neighborhood_grid_width + (o+neighborhood_grid_radius); // index [o,p] - int idxOpOffset = (item * topchannels + op); - for (int y = ymin; y <= ymax; y++) { - for (int x = xmin; x <= xmax; x++) { - int idxtopdiff = (idxOpOffset * topheight + y)\ - * topwidth + x; // topdiff[x,y,o,p] - sum += topdiff[idxtopdiff] * sign; - } - } - } - } - } - const int sumelems = (kernel_radius*2+1)*(kernel_radius*2+1)*bottomchannels; - const int bot1index = ((n * bottomheight) + (m - pad_size)) * bottomwidth + (l - pad_size); - bottom1diff[bot1index + item * bottomcount] = sum / static_cast(sumelems); - } -} -// == Forward -// == Dimension rearrangement Kernel -template -__global__ void blob_rearrange_kernel2(const Dtype* in, Dtype* out, int num, -int channels, int width, int height, int widthheight, int padding, int pwidthheight) { - // change shape from [batchsize,channel,y,x] to [batchsize,y,x,channel] - int xy = blockIdx.x * blockDim.x + threadIdx.x; - if (xy >= widthheight ) - return; - int ch = blockIdx.y; - int n = blockIdx.z; - Dtype value = in[(n * channels + ch) * widthheight + xy]; - __syncthreads(); - int xpad = (xy % width + padding); - int ypad = (xy / width + padding); - int xypad = ypad * (width + 2 * padding) + xpad; - out[(n * pwidthheight + xypad) * channels + ch] = value; -} -template -void Forward_gpu( - const Tensor &out, - const Tensor &data1, - const Tensor &data2, - const Tensor &tmp1, - const Tensor &tmp2, - int top_channels_, int top_height_, int top_width_, int pad_size_, - bool is_multiply, int max_displacement_, int kernel_size_, - int neighborhood_grid_radius_, int neighborhood_grid_width_, - int kernel_radius_, int stride1_, int stride2_, cudaStream_t stream, - cudaStream_t stream_tmp1, cudaStream_t stream_tmp2) { - const Dtype *bottom_data1 = data1.dptr_; - const Dtype *bottom_data2 = data2.dptr_; - Dtype *rbot1 = tmp1.dptr_; - Dtype *rbot2 = tmp2.dptr_; - Dtype *top = out.dptr_; - const int bnum = data1.size(0); - const int bchannels = data1.size(1); - const int bheight = data1.size(2); - const int bwidth = data1.size(3); - const int bwidthheight = bwidth * bheight; - const int topcount = top_width_ * top_height_ * top_channels_; - dim3 threadsPerBlock(THREADS_PER_WARP * WARPS_PER_BLOCK); - int threads_per_block = 16; - dim3 totalBlocksRearr((bwidthheight - 1) / threads_per_block + 1, bchannels, bnum); - const int pwidthheight = (bwidth + 2 * pad_size_) * (bheight + 2 * pad_size_); - blob_rearrange_kernel2<<>> - (bottom_data1, rbot1, bnum, bchannels, bwidth, bheight, bwidthheight, pad_size_, pwidthheight); - blob_rearrange_kernel2<<>> - (bottom_data2, rbot2, bnum, bchannels, bwidth, bheight, bwidthheight, pad_size_, pwidthheight); - const int num = bnum; - const int channels = bchannels; - const int height = bheight + 2 * pad_size_; - const int width = bwidth + 2 * pad_size_; - const int shared_memory_per_block = (kernel_size_ * kernel_size_) * bchannels; - if (is_multiply == true) { - // CorrelationLayer - int topThreadCount = topcount; - dim3 totalBlocksCorr(top_width_, top_height_, num); - CorrelateData<<>>( - topThreadCount, - num, top_width_, top_height_, top_channels_, topcount, - max_displacement_, neighborhood_grid_radius_, - neighborhood_grid_width_, kernel_radius_, kernel_size_, - stride1_, stride2_, - width, height, channels, - rbot1, rbot2, top); - CORRELATION_CUDA_CHECK(cudaPeekAtLastError()); - } else { - // CorrelationLayer - for (int n = 0; n < num; n++) { - int topThreadCount = topcount; - const int gridSize = (topThreadCount + kMaxThreadsPerBlock - 1)\ - / kMaxThreadsPerBlock; - CorrelateDataSubtract<<>>( - topThreadCount, - num, n, top_width_, top_height_, top_channels_, topcount, - max_displacement_, neighborhood_grid_radius_, - neighborhood_grid_width_, kernel_radius_, - stride1_, stride2_, width, height, channels, rbot1, rbot2, top); - CORRELATION_CUDA_CHECK(cudaPeekAtLastError()); - } - } -} -template -void Backward_gpu( - const Tensor &out_grad, - const Tensor &in_grad1, - const Tensor &in_grad2, - const Tensor &tmp1, - const Tensor &tmp2, - int top_channels_, int top_height_, - int top_width_, int pad_size_, bool is_multiply, - int max_displacement_, int kernel_size_, - int neighborhood_grid_radius_, int neighborhood_grid_width_, - int kernel_radius_, int stride1_, int stride2_, - cudaStream_t stream0, cudaStream_t stream1, - int num, int channels, int height, int width) { - // Get top diff, compute bottom diff - const Dtype* top_diff = out_grad.dptr_; - Dtype* bottom0_diff = in_grad1.dptr_; - Dtype* bottom1_diff = in_grad2.dptr_; - const Dtype* rbot1 = tmp1.dptr_; - const Dtype* rbot2 = tmp2.dptr_; - const int paddedheight = height + 2 * pad_size_; - const int paddedwidth = width + 2 * pad_size_; - const int bottomcount = channels * height * width; - int botThreadCount = bottomcount; - const int gridSize = (botThreadCount + kMaxThreadsPerBlock - 1) / kMaxThreadsPerBlock; - // CorrelationLayerBackward - if (is_multiply == true) { - // == Run kernel Backward 0 - dim3 totalBlocksBackward0(width, height, channels * num); // First dim is fastest - const int buffer_size_backw0 = \ - (static_cast(ceil(static_cast(2 * kernel_radius_)\ - / static_cast(stride1_))) + 1) * top_channels_; - // == Run kernel Backward 0 - for (int n = 0; n < num; n++) { - CorrelateDataBackward0<<>>( - botThreadCount, - num, n, top_width_, top_height_, top_channels_, - max_displacement_, neighborhood_grid_radius_, neighborhood_grid_width_, kernel_radius_, - stride1_, stride2_, - width, height, paddedwidth, paddedheight, channels, bottomcount, pad_size_, - bottom0_diff, rbot2, top_diff); - CORRELATION_CUDA_CHECK(cudaPeekAtLastError()); - } - // == Run kernel Backward 1 - for (int n = 0; n < num; n++) { - CorrelateDataBackward1<<>>( - botThreadCount, - num, n, top_width_, top_height_, top_channels_, - max_displacement_, neighborhood_grid_radius_, neighborhood_grid_width_, kernel_radius_, - stride1_, stride2_, - width, height, paddedwidth, paddedheight, channels, bottomcount, pad_size_, - rbot1, bottom1_diff, top_diff); - CORRELATION_CUDA_CHECK(cudaPeekAtLastError()); - } - } else { - for (int n = 0; n < num; n++) { - // Bottom0: - CorrelateDataBackward0Subtract<<>>( - botThreadCount, - num, n, top_width_, top_height_, top_channels_, - max_displacement_, neighborhood_grid_radius_, neighborhood_grid_width_, kernel_radius_, - stride1_, stride2_, - width, height, paddedwidth, paddedheight, channels, bottomcount, pad_size_, - bottom0_diff, rbot1, rbot2, top_diff); - CORRELATION_CUDA_CHECK(cudaPeekAtLastError()); - } - for (int n = 0; n < num; n++) { - // Bottom1: - CorrelateDataBackward1Subtract<<>>( - botThreadCount, - num, n, top_width_, top_height_, top_channels_, - max_displacement_, neighborhood_grid_radius_, neighborhood_grid_width_, kernel_radius_, - stride1_, stride2_, - width, height, paddedwidth, paddedheight, channels, bottomcount, pad_size_, - rbot1, rbot2, bottom1_diff, top_diff); - CORRELATION_CUDA_CHECK(cudaPeekAtLastError()); - } - } -} -} // namespace cuda -template -inline void CorrelationForward(const Tensor &out, - const Tensor &data1, - const Tensor &data2, - const Tensor &tmp1, - const Tensor &tmp2, - int top_channels_, int top_height_, - int top_width_, int pad_size_, bool is_multiply, - int max_displacement_, int kernel_size_, - int neighborhood_grid_radius_, int neighborhood_grid_width_, - int kernel_radius_, int stride1_, int stride2_ - ) { - cudaStream_t stream = Stream::GetStream(out.stream_); - cudaStream_t stream_tmp1 = Stream::GetStream(tmp1.stream_); - cudaStream_t stream_tmp2 = Stream::GetStream(tmp2.stream_); - cuda::Forward_gpu(out, data1, data2, tmp1, tmp2, top_channels_, top_height_, - top_width_, pad_size_, is_multiply, max_displacement_, kernel_size_, - neighborhood_grid_radius_, neighborhood_grid_width_, kernel_radius_, - stride1_, stride2_, stream, stream_tmp1, stream_tmp2); -} - -template -inline void CorrelationBackward(const Tensor &out_grad, - const Tensor &in_grad1, - const Tensor &in_grad2, - const Tensor &tmp1, - const Tensor &tmp2, - int top_channels_, int top_height_, - int top_width_, int pad_size_, bool is_multiply, - int max_displacement_, int kernel_size_, - int neighborhood_grid_radius_, int neighborhood_grid_width_, - int kernel_radius_, int stride1_, - int stride2_, int num, int channels, int height, int width - ) { - cudaStream_t stream0 = Stream::GetStream(in_grad1.stream_); - cudaStream_t stream1 = Stream::GetStream(in_grad2.stream_); - cuda::Backward_gpu(out_grad, in_grad1, in_grad2, tmp1, tmp2, top_channels_, - top_height_, top_width_, pad_size_, is_multiply, - max_displacement_, kernel_size_, neighborhood_grid_radius_, - neighborhood_grid_width_, kernel_radius_, stride1_, stride2_, - stream0, stream1, num, channels, height, width); -} -} // namespace mshadow -namespace mxnet { -namespace op { -template<> -Operator* CreateOp(CorrelationParam param) { - return new CorrelationOp(param); -} -} // namespace op -} // namespace mxnet +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/*! + * Copyright [2016] + * \file Correation.cu + * \brief Correlation operator + * \author Xu Dong +*/ +#include "./correlation-inl.h" +#include +#include +#include +#include + +#define ROUND_OFF 50000 +#define WARPS_PER_BLOCK 1 +#define THREADS_PER_WARP 32 +#define CORRELATION_CUDA_CHECK(condition) \ + /* Code block avoids redefinition of cudaError_t error */ \ + do { \ + cudaError_t error = condition; \ + CHECK_EQ(error, cudaSuccess) << " " << cudaGetErrorString(error); \ + } while (0) +#define CUDA_KERNEL_LOOP(i, n) \ +for (int i = blockIdx.x * blockDim.x + threadIdx.x; \ + i < (n); \ + i += blockDim.x * gridDim.x) +namespace mshadow { +namespace cuda { +// == Correlation Kernel +template +__global__ void CorrelateData(const int nthreads, int num, int topwidth, + int topheight, int topchannels, int topcount, + int max_displacement, int neighborhood_grid_radius, + int neighborhood_grid_width, int kernel_radius, int kernel_size, int stride1, int stride2, + int bottomwidth, int bottomheight, int bottomchannels, + const Dtype *bottom0, const Dtype *bottom1, Dtype *top) { + extern __shared__ char patch_data_char[]; + Dtype *patch_data = reinterpret_cast(patch_data_char); + // First (upper left) position of kernel upper-left corner + // in current center position of neighborhood in image 1 + int x1 = blockIdx.x * stride1 + max_displacement; + int y1 = blockIdx.y * stride1 + max_displacement; + int item = blockIdx.z; + int ch_off = threadIdx.x; + // Load 3D patch into shared shared memory + for (int j = 0; j < kernel_size; j++) { // HEIGHT + for (int i = 0; i < kernel_size; i++) { // WIDTH + int ji_off = ((j * kernel_size) + i) * bottomchannels; + for (int ch = ch_off; ch < bottomchannels; ch += (THREADS_PER_WARP * WARPS_PER_BLOCK)) { + // CHANNELS + int idx1 = ((item * bottomheight + y1+j) * bottomwidth + x1+i) * bottomchannels + ch; + int idxPatchData = ji_off + ch; + patch_data[idxPatchData] = bottom0[idx1]; + } + } + } + __syncthreads(); + __shared__ Dtype sum[THREADS_PER_WARP * WARPS_PER_BLOCK]; + // Compute correlation + for (int top_channel = 0; top_channel < topchannels; top_channel++) { + sum[ch_off] = 0; + int s2o = (top_channel % neighborhood_grid_width - neighborhood_grid_radius) * stride2; + int s2p = (top_channel / neighborhood_grid_width - neighborhood_grid_radius) * stride2; + for (int j = 0; j < kernel_size; j++) { // HEIGHT + for (int i = 0; i < kernel_size; i++) { // WIDTH + int ji_off = ((j * kernel_size) + i) * bottomchannels; + for (int ch = ch_off; ch < bottomchannels; ch += (THREADS_PER_WARP * WARPS_PER_BLOCK)) { + // CHANNELS + int x2 = x1 + s2o; + int y2 = y1 + s2p; + int idxPatchData = ji_off + ch; + int idx2 = ((item * bottomheight + y2 + j) * bottomwidth + x2 + i) * bottomchannels + ch; + sum[ch_off] += patch_data[idxPatchData] * bottom1[idx2]; + } + } + } + __syncthreads(); + if (ch_off == 0) { + Dtype total_sum = 0; + for (int idx = 0; idx < THREADS_PER_WARP * WARPS_PER_BLOCK; idx++) { + total_sum += sum[idx]; + } + const int sumelems = kernel_size * kernel_size * bottomchannels; + const int index = ((top_channel * topheight + blockIdx.y) * topwidth) + blockIdx.x; + top[index + item*topcount] = total_sum / static_cast(sumelems); + } // Aggregate result of different threads + } +} +// == Correlation Backward Pass Kernel (For data1) +template +__global__ void CorrelateDataBackward0(const int nthreads, int num, int item, + int topwidth, int topheight, int topchannels, + int max_displacement, int neighborhood_grid_radius, + int neighborhood_grid_width, int kernel_radius, int stride1, int stride2, + int bottomwidth, int bottomheight, int pbottomwidth, int pbottomheight, + int bottomchannels, int bottomcount, int pad_size, + Dtype *bottom0diff, const Dtype *bottom1, const Dtype *topdiff) { + CUDA_KERNEL_LOOP(index, nthreads) { + int n = index % bottomchannels; // channels + int l = (index / bottomchannels) % bottomwidth + pad_size; // w-pos + int m = (index / bottomchannels / bottomwidth) % bottomheight + pad_size; // h-pos + // Get X,Y ranges and clamp + // round_off is a trick to enable integer division with ceil, even for negative numbers + // We use a large offset, for the inner part not to become negative. + const int round_off = ROUND_OFF; + const int round_off_s1 = stride1 * round_off; + // We add round_off before_s1 the int division and subtract round_off after it, + // to ensure the formula matches ceil behavior: + int xmin = (l - 2*kernel_radius - max_displacement + round_off_s1 - 1)\ + / stride1 + 1 - round_off; // ceil (l - 2*kernel_radius - max_displacement) / stride1 + int ymin = (m - 2*kernel_radius - max_displacement + round_off_s1 - 1)\ + / stride1 + 1 - round_off; // ceil (l - 2*kernel_radius - max_displacement) / stride1 + // Same here: + int xmax = (l - max_displacement + round_off_s1) / stride1 - round_off; + // floor (l - max_displacement) / stride1 + int ymax = (m - max_displacement + round_off_s1) / stride1 - round_off; + // floor (m - max_displacement) / stride1 + Dtype sum = 0; + if (xmax >= 0 && ymax >= 0 && (xmin <= topwidth-1) && (ymin <= topheight-1)) { + xmin = max(0, xmin); + xmax = min(topwidth-1, xmax); + ymin = max(0, ymin); + ymax = min(topheight-1, ymax); + for (int p = -neighborhood_grid_radius; p <= neighborhood_grid_radius; p++) { + for (int o = -neighborhood_grid_radius; o <= neighborhood_grid_radius; o++) { + // Get bottom1 data: + int s2o = stride2 * o; + int s2p = stride2 * p; + int idxbot1 = ((item * pbottomheight + (m + s2p)) * pbottomwidth + (l + s2o))\ + * bottomchannels + n; + Dtype bot1tmp = bottom1[idxbot1]; // bottom1[l+s2o,m+s2p,n] + // Index offset for topdiff in following loops: + int op = (p+neighborhood_grid_radius) * neighborhood_grid_width\ + + (o + neighborhood_grid_radius); // index [o,p] + int idxopoffset = (item * topchannels + op); + for (int y = ymin; y <= ymax; y++) { + for (int x = xmin; x <= xmax; x++) { + int idxtopdiff = (idxopoffset * topheight + y) * topwidth + x; // topdiff[x,y,o,p] + sum += topdiff[idxtopdiff] * bot1tmp; + } + } + } + } + } + const int sumelems = (kernel_radius * 2 + 1) * (kernel_radius * 2+1) * bottomchannels; + const int bot0index = ((n * bottomheight) + (m-pad_size)) * bottomwidth + (l-pad_size); + bottom0diff[bot0index + item * bottomcount] = sum / static_cast(sumelems); + } +} +// == Correlation Backward Pass Kernel (For Blob 1) +template +__global__ void CorrelateDataBackward1(const int nthreads, + int num, int item, int topwidth, int topheight, int topchannels, + int max_displacement, int neighborhood_grid_radius, + int neighborhood_grid_width, int kernel_radius, int stride1, int stride2, + int bottomwidth, int bottomheight, int pbottomwidth, int pbottomheight, + int bottomchannels, int bottomcount, int pad_size, + const Dtype *bottom0, Dtype *bottom1diff, const Dtype *topdiff) { + CUDA_KERNEL_LOOP(index, nthreads) { + // int l = index % bottomwidth + pad_size; //w-pos + // int m = (index / bottomwidth) % bottomheight + pad_size; // h-pos + // int n = (index / bottomwidth / bottomheight) % bottomchannels; // channels + int n = index % bottomchannels; // channels + int l = (index / bottomchannels) % bottomwidth + pad_size; // w-pos + int m = (index / bottomchannels / bottomwidth) % bottomheight + pad_size; // h-pos + // round_off is a trick to enable integer division with ceil, even for negative numbers + // We use a large offset, for the inner part not to become negative. + const int round_off = ROUND_OFF; + const int round_off_s1 = stride1 * round_off; + Dtype sum = 0; + for (int p = -neighborhood_grid_radius; p <= neighborhood_grid_radius; p++) { + for (int o = -neighborhood_grid_radius; o <= neighborhood_grid_radius; o++) { + int s2o = stride2 * o; + int s2p = stride2 * p; + // Get X,Y ranges and clamp + // We add round_off before_s1 the int division and subtract round_off after it, + // to ensure the formula matches ceil behavior: + int xmin = (l - 2*kernel_radius - max_displacement - s2o + round_off_s1 - 1)\ + / stride1 + 1 - round_off; + // ceil (l - 2*kernel_radius - max_displacement - s2o) / stride1 + int ymin = (m - 2*kernel_radius - max_displacement - s2p + round_off_s1 - 1)\ + / stride1 + 1 - round_off; + // ceil (l - 2*kernel_radius - max_displacement - s2o) / stride1 + // Same here: + int xmax = (l - max_displacement - s2o + round_off_s1) / stride1 - round_off; + // floor (l - max_displacement - s2o) / stride1 + int ymax = (m - max_displacement - s2p + round_off_s1) / stride1 - round_off; + // floor (m - max_displacement - s2p) / stride1 + if (xmax >= 0 && ymax >= 0 && (xmin <= topwidth - 1) && (ymin <= topheight - 1)) { + xmin = max(0, xmin); + xmax = min(topwidth-1, xmax); + ymin = max(0, ymin); + ymax = min(topheight-1, ymax); + // Get bottom0 data: + int idxbot0 = ((item * pbottomheight + (m - s2p)) \ + * pbottomwidth + (l - s2o)) * bottomchannels + n; + Dtype bot0tmp = bottom0[idxbot0]; // bottom1[l+s2o,m+s2p,n] + // Index offset for topdiff in following loops: + int op = (p+neighborhood_grid_radius) * \ + neighborhood_grid_width + (o+neighborhood_grid_radius); // index [o,p] + int idxOpOffset = (item * topchannels + op); + for (int y = ymin; y <= ymax; y++) { + for (int x = xmin; x <= xmax; x++) { + int idxtopdiff = (idxOpOffset * topheight + y)\ + * topwidth + x; // topdiff[x,y,o,p] + sum += topdiff[idxtopdiff] * bot0tmp; + } + } + } + } + } + const int sumelems = (kernel_radius*2+1)*(kernel_radius*2+1)*bottomchannels; + const int bot1index = ((n * bottomheight) + (m - pad_size)) * bottomwidth + (l - pad_size); + bottom1diff[bot1index + item * bottomcount] = sum / static_cast(sumelems); + } +} +// == Correlation Kernel Subtraction +template +__global__ void CorrelateDataSubtract(const int nthreads, int num, int item, + int topwidth, int topheight, int topchannels, int topcount, + int max_displacement, int neighborhood_grid_radius, + int neighborhood_grid_width, int kernel_radius, int stride1, int stride2, + int bottomwidth, int bottomheight, int bottomchannels, + const Dtype *bottom0, const Dtype *bottom1, Dtype *top) { + CUDA_KERNEL_LOOP(index, nthreads) { + int x = index % topwidth; // w-pos + int y = (index / topwidth) % topheight; // h-pos + int c = (index / topwidth / topheight) % topchannels; // channels + // Offset of patch in image 2 + int s2o = (c % neighborhood_grid_width - neighborhood_grid_radius) * stride2; + int s2p = (c / neighborhood_grid_width - neighborhood_grid_radius) * stride2; + // First (upper left) position of kernel center in current neighborhood in image 1 + int x1 = x*stride1 + kernel_radius + max_displacement; + int y1 = y*stride1 + kernel_radius + max_displacement; + // Iterate through 3D patch + Dtype sum = 0; + for (int j = -kernel_radius; j <= kernel_radius; j++) { // HEIGHT + for (int i = -kernel_radius; i <= kernel_radius; i++) { // WIDTH + for (int l = 0; l < bottomchannels; l++) { // CHANNELS + // Calculate position in image 2 + int x2 = x1 + s2o; + int y2 = y1 + s2p; + // Indices in bottom data: (CH=l,W=x2,H=y2,N) + int idx1 = ((item * bottomheight + y1 + j) * bottomwidth + x1 + i) \ + * bottomchannels + l; + int idx2 = ((item * bottomheight + y2 + j) * bottomwidth + x2 + i) \ + * bottomchannels + l; + // Do the correlation: + sum += fabsf(bottom0[idx1] - bottom1[idx2]); + } + } + } + const int sumelems = (kernel_radius * 2 + 1) * (kernel_radius * 2 + 1) * bottomchannels; + top[index + item * topcount] = sum / static_cast(sumelems); + } +} +// == Correlation Backward Pass Kernel (For Blob 0) +template +__global__ void CorrelateDataBackward0Subtract(const int nthreads, int num, + int item, int topwidth, int topheight, int topchannels, + int max_displacement, int neighborhood_grid_radius, + int neighborhood_grid_width, int kernel_radius, + int stride1, int stride2, int bottomwidth, int bottomheight, + int pbottomwidth, int pbottomheight, + int bottomchannels, int bottomcount, int pad_size, + Dtype *bottom0diff, const Dtype *bottom0, const Dtype *bottom1, const Dtype *topdiff) { + CUDA_KERNEL_LOOP(index, nthreads) { + int n = index % bottomchannels; // channels + int l = (index / bottomchannels) % bottomwidth + pad_size; // w-pos + int m = (index / bottomchannels / bottomwidth) % bottomheight + pad_size; // h-pos + // Get X,Y ranges and clamp + // round_off is a trick to enable integer division with ceil, even for negative numbers + // We use a large offset, for the inner part not to become negative. + const int round_off = ROUND_OFF; + const int round_off_s1 = stride1 * round_off; + int idxbot0 = ((item * pbottomheight + m) * pbottomwidth + l)\ + * bottomchannels + n; + // We add round_off before_s1 the int division and subtract round_off after it, + // to ensure the formula matches ceil behavior: + int xmin = (l - 2*kernel_radius - max_displacement + round_off_s1 - 1)\ + / stride1 + 1 - round_off; // ceil (l - 2*kernel_radius - max_displacement) / stride1 + int ymin = (m - 2*kernel_radius - max_displacement + round_off_s1 - 1)\ + / stride1 + 1 - round_off; // ceil (l - 2*kernel_radius - max_displacement) / stride1 + // Same here: + int xmax = (l - max_displacement + round_off_s1) / stride1 - round_off; + // floor (l - max_displacement) / stride1 + int ymax = (m - max_displacement + round_off_s1) / stride1 - round_off; + // floor (m - max_displacement) / stride1 + Dtype sum = 0; + if (xmax >= 0 && ymax >= 0 && (xmin <= topwidth-1) && (ymin <= topheight-1)) { + xmin = max(0, xmin); + xmax = min(topwidth-1, xmax); + ymin = max(0, ymin); + ymax = min(topheight-1, ymax); + for (int p = -neighborhood_grid_radius; p <= neighborhood_grid_radius; p++) { + for (int o = -neighborhood_grid_radius; o <= neighborhood_grid_radius; o++) { + // Get bottom1 data: + int s2o = stride2 * o; + int s2p = stride2 * p; + int idxbot1 = ((item * pbottomheight + (m+s2p)) * pbottomwidth\ + + (l+s2o)) * bottomchannels + n; + Dtype bot0tmp = bottom0[idxbot0]; + Dtype bot1tmp = bottom1[idxbot1]; + Dtype sign = (bot0tmp >= bot1tmp) ? Dtype(1.0) : Dtype(-1.0); + // Index offset for topdiff in following loops: + int op = (p+neighborhood_grid_radius) * neighborhood_grid_width\ + + (o + neighborhood_grid_radius); // index [o,p] + int idxopoffset = (item * topchannels + op); + for (int y = ymin; y <= ymax; y++) { + for (int x = xmin; x <= xmax; x++) { + int idxtopdiff = (idxopoffset * topheight + y) * topwidth + x; // topdiff[x,y,o,p] + sum += topdiff[idxtopdiff] * sign; + } + } + } + } + } + const int sumelems = (kernel_radius * 2 + 1) * (kernel_radius * 2+1) * bottomchannels; + const int bot0index = ((n * bottomheight) + (m-pad_size)) * bottomwidth + (l-pad_size); + bottom0diff[bot0index + item * bottomcount] = sum / static_cast(sumelems); + } +} +// == Correlation Backward Pass Kernel (For Blob 1) +template +__global__ void CorrelateDataBackward1Subtract(const int nthreads, int num, + int item, int topwidth, int topheight, int topchannels, + int max_displacement, int neighborhood_grid_radius, + int neighborhood_grid_width, int kernel_radius, + int stride1, int stride2, int bottomwidth, int bottomheight, + int pbottomwidth, int pbottomheight, int bottomchannels, + int bottomcount, int pad_size, const Dtype *bottom0, + const Dtype *bottom1, Dtype *bottom1diff, const Dtype *topdiff) { + CUDA_KERNEL_LOOP(index, nthreads) { + // int l = index % bottomwidth + pad_size; //w-pos + // int m = (index / bottomwidth) % bottomheight + pad_size; // h-pos + // int n = (index / bottomwidth / bottomheight) % bottomchannels; // channels + int n = index % bottomchannels; // channels + int l = (index / bottomchannels) % bottomwidth + pad_size; // w-pos + int m = (index / bottomchannels / bottomwidth) % bottomheight + pad_size; // h-pos + // round_off is a trick to enable integer division with ceil, even for negative numbers + // We use a large offset, for the inner part not to become negative. + const int round_off = ROUND_OFF; + const int round_off_s1 = stride1 * round_off; + Dtype sum = 0; + int idxbot1 = ((item * pbottomheight + m) * pbottomwidth + l)\ + * bottomchannels + n; + for (int p = -neighborhood_grid_radius; p <= neighborhood_grid_radius; p++) { + for (int o = -neighborhood_grid_radius; o <= neighborhood_grid_radius; o++) { + int s2o = stride2 * o; + int s2p = stride2 * p; + // Get X,Y ranges and clamp + // We add round_off before_s1 the int division and subtract round_off after it, + // to ensure the formula matches ceil behavior: + int xmin = (l - 2*kernel_radius - max_displacement - s2o + round_off_s1 - 1)\ + / stride1 + 1 - round_off; + // ceil (l - 2*kernel_radius - max_displacement - s2o) / stride1 + int ymin = (m - 2*kernel_radius - max_displacement - s2p + round_off_s1 - 1)\ + / stride1 + 1 - round_off; + // ceil (l - 2*kernel_radius - max_displacement - s2o) / stride1 + // Same here: + int xmax = (l - max_displacement - s2o + round_off_s1) / stride1 - round_off; + // floor (l - max_displacement - s2o) / stride1 + int ymax = (m - max_displacement - s2p + round_off_s1) / stride1 - round_off; + // floor (m - max_displacement - s2p) / stride1 + if (xmax >= 0 && ymax >= 0 && (xmin <= topwidth - 1) && (ymin <= topheight - 1)) { + xmin = max(0, xmin); + xmax = min(topwidth-1, xmax); + ymin = max(0, ymin); + ymax = min(topheight-1, ymax); + // Get bottom0 data: + int idxbot0 = ((item * pbottomheight + (m - s2p)) * pbottomwidth + (l - s2o))\ + * bottomchannels + n; + // bottom0[l+s2o,m+s2p,n] + Dtype bot0tmp = bottom0[idxbot0]; + Dtype bot1tmp = bottom1[idxbot1]; + Dtype sign = (bot0tmp >= bot1tmp) ? Dtype(-1.0) : Dtype(1.0); + // Index offset for topdiff in following loops: + int op = (p+neighborhood_grid_radius) * \ + neighborhood_grid_width + (o+neighborhood_grid_radius); // index [o,p] + int idxOpOffset = (item * topchannels + op); + for (int y = ymin; y <= ymax; y++) { + for (int x = xmin; x <= xmax; x++) { + int idxtopdiff = (idxOpOffset * topheight + y)\ + * topwidth + x; // topdiff[x,y,o,p] + sum += topdiff[idxtopdiff] * sign; + } + } + } + } + } + const int sumelems = (kernel_radius*2+1)*(kernel_radius*2+1)*bottomchannels; + const int bot1index = ((n * bottomheight) + (m - pad_size)) * bottomwidth + (l - pad_size); + bottom1diff[bot1index + item * bottomcount] = sum / static_cast(sumelems); + } +} +// == Forward +// == Dimension rearrangement Kernel +template +__global__ void blob_rearrange_kernel2(const Dtype* in, Dtype* out, int num, +int channels, int width, int height, int widthheight, int padding, int pwidthheight) { + // change shape from [batchsize,channel,y,x] to [batchsize,y,x,channel] + int xy = blockIdx.x * blockDim.x + threadIdx.x; + if (xy >= widthheight ) + return; + int ch = blockIdx.y; + int n = blockIdx.z; + Dtype value = in[(n * channels + ch) * widthheight + xy]; + __syncthreads(); + int xpad = (xy % width + padding); + int ypad = (xy / width + padding); + int xypad = ypad * (width + 2 * padding) + xpad; + out[(n * pwidthheight + xypad) * channels + ch] = value; +} +template +void Forward_gpu( + const Tensor &out, + const Tensor &data1, + const Tensor &data2, + const Tensor &tmp1, + const Tensor &tmp2, + int top_channels_, int top_height_, int top_width_, int pad_size_, + bool is_multiply, int max_displacement_, int kernel_size_, + int neighborhood_grid_radius_, int neighborhood_grid_width_, + int kernel_radius_, int stride1_, int stride2_, cudaStream_t stream, + cudaStream_t stream_tmp1, cudaStream_t stream_tmp2) { + const Dtype *bottom_data1 = data1.dptr_; + const Dtype *bottom_data2 = data2.dptr_; + Dtype *rbot1 = tmp1.dptr_; + Dtype *rbot2 = tmp2.dptr_; + Dtype *top = out.dptr_; + const int bnum = data1.size(0); + const int bchannels = data1.size(1); + const int bheight = data1.size(2); + const int bwidth = data1.size(3); + const int bwidthheight = bwidth * bheight; + const int topcount = top_width_ * top_height_ * top_channels_; + dim3 threadsPerBlock(THREADS_PER_WARP * WARPS_PER_BLOCK); + int threads_per_block = 16; + dim3 totalBlocksRearr((bwidthheight - 1) / threads_per_block + 1, bchannels, bnum); + const int pwidthheight = (bwidth + 2 * pad_size_) * (bheight + 2 * pad_size_); + blob_rearrange_kernel2<<>> + (bottom_data1, rbot1, bnum, bchannels, bwidth, bheight, bwidthheight, pad_size_, pwidthheight); + blob_rearrange_kernel2<<>> + (bottom_data2, rbot2, bnum, bchannels, bwidth, bheight, bwidthheight, pad_size_, pwidthheight); + const int num = bnum; + const int channels = bchannels; + const int height = bheight + 2 * pad_size_; + const int width = bwidth + 2 * pad_size_; + const int shared_memory_per_block = (kernel_size_ * kernel_size_) * bchannels; + if (is_multiply == true) { + // CorrelationLayer + int topThreadCount = topcount; + dim3 totalBlocksCorr(top_width_, top_height_, num); + CorrelateData<<>>( + topThreadCount, + num, top_width_, top_height_, top_channels_, topcount, + max_displacement_, neighborhood_grid_radius_, + neighborhood_grid_width_, kernel_radius_, kernel_size_, + stride1_, stride2_, + width, height, channels, + rbot1, rbot2, top); + CORRELATION_CUDA_CHECK(cudaPeekAtLastError()); + } else { + // CorrelationLayer + for (int n = 0; n < num; n++) { + int topThreadCount = topcount; + const int gridSize = (topThreadCount + kMaxThreadsPerBlock - 1)\ + / kMaxThreadsPerBlock; + CorrelateDataSubtract<<>>( + topThreadCount, + num, n, top_width_, top_height_, top_channels_, topcount, + max_displacement_, neighborhood_grid_radius_, + neighborhood_grid_width_, kernel_radius_, + stride1_, stride2_, width, height, channels, rbot1, rbot2, top); + CORRELATION_CUDA_CHECK(cudaPeekAtLastError()); + } + } +} +template +void Backward_gpu( + const Tensor &out_grad, + const Tensor &in_grad1, + const Tensor &in_grad2, + const Tensor &tmp1, + const Tensor &tmp2, + int top_channels_, int top_height_, + int top_width_, int pad_size_, bool is_multiply, + int max_displacement_, int kernel_size_, + int neighborhood_grid_radius_, int neighborhood_grid_width_, + int kernel_radius_, int stride1_, int stride2_, + cudaStream_t stream0, cudaStream_t stream1, + int num, int channels, int height, int width) { + // Get top diff, compute bottom diff + const Dtype* top_diff = out_grad.dptr_; + Dtype* bottom0_diff = in_grad1.dptr_; + Dtype* bottom1_diff = in_grad2.dptr_; + const Dtype* rbot1 = tmp1.dptr_; + const Dtype* rbot2 = tmp2.dptr_; + const int paddedheight = height + 2 * pad_size_; + const int paddedwidth = width + 2 * pad_size_; + const int bottomcount = channels * height * width; + int botThreadCount = bottomcount; + const int gridSize = (botThreadCount + kMaxThreadsPerBlock - 1) / kMaxThreadsPerBlock; + // CorrelationLayerBackward + if (is_multiply == true) { + // == Run kernel Backward 0 + dim3 totalBlocksBackward0(width, height, channels * num); // First dim is fastest + const int buffer_size_backw0 = \ + (static_cast(ceil(static_cast(2 * kernel_radius_)\ + / static_cast(stride1_))) + 1) * top_channels_; + // == Run kernel Backward 0 + for (int n = 0; n < num; n++) { + CorrelateDataBackward0<<>>( + botThreadCount, + num, n, top_width_, top_height_, top_channels_, + max_displacement_, neighborhood_grid_radius_, neighborhood_grid_width_, kernel_radius_, + stride1_, stride2_, + width, height, paddedwidth, paddedheight, channels, bottomcount, pad_size_, + bottom0_diff, rbot2, top_diff); + CORRELATION_CUDA_CHECK(cudaPeekAtLastError()); + } + // == Run kernel Backward 1 + for (int n = 0; n < num; n++) { + CorrelateDataBackward1<<>>( + botThreadCount, + num, n, top_width_, top_height_, top_channels_, + max_displacement_, neighborhood_grid_radius_, neighborhood_grid_width_, kernel_radius_, + stride1_, stride2_, + width, height, paddedwidth, paddedheight, channels, bottomcount, pad_size_, + rbot1, bottom1_diff, top_diff); + CORRELATION_CUDA_CHECK(cudaPeekAtLastError()); + } + } else { + for (int n = 0; n < num; n++) { + // Bottom0: + CorrelateDataBackward0Subtract<<>>( + botThreadCount, + num, n, top_width_, top_height_, top_channels_, + max_displacement_, neighborhood_grid_radius_, neighborhood_grid_width_, kernel_radius_, + stride1_, stride2_, + width, height, paddedwidth, paddedheight, channels, bottomcount, pad_size_, + bottom0_diff, rbot1, rbot2, top_diff); + CORRELATION_CUDA_CHECK(cudaPeekAtLastError()); + } + for (int n = 0; n < num; n++) { + // Bottom1: + CorrelateDataBackward1Subtract<<>>( + botThreadCount, + num, n, top_width_, top_height_, top_channels_, + max_displacement_, neighborhood_grid_radius_, neighborhood_grid_width_, kernel_radius_, + stride1_, stride2_, + width, height, paddedwidth, paddedheight, channels, bottomcount, pad_size_, + rbot1, rbot2, bottom1_diff, top_diff); + CORRELATION_CUDA_CHECK(cudaPeekAtLastError()); + } + } +} +} // namespace cuda +template +inline void CorrelationForward(const Tensor &out, + const Tensor &data1, + const Tensor &data2, + const Tensor &tmp1, + const Tensor &tmp2, + int top_channels_, int top_height_, + int top_width_, int pad_size_, bool is_multiply, + int max_displacement_, int kernel_size_, + int neighborhood_grid_radius_, int neighborhood_grid_width_, + int kernel_radius_, int stride1_, int stride2_ + ) { + cudaStream_t stream = Stream::GetStream(out.stream_); + cudaStream_t stream_tmp1 = Stream::GetStream(tmp1.stream_); + cudaStream_t stream_tmp2 = Stream::GetStream(tmp2.stream_); + cuda::Forward_gpu(out, data1, data2, tmp1, tmp2, top_channels_, top_height_, + top_width_, pad_size_, is_multiply, max_displacement_, kernel_size_, + neighborhood_grid_radius_, neighborhood_grid_width_, kernel_radius_, + stride1_, stride2_, stream, stream_tmp1, stream_tmp2); +} + +template +inline void CorrelationBackward(const Tensor &out_grad, + const Tensor &in_grad1, + const Tensor &in_grad2, + const Tensor &tmp1, + const Tensor &tmp2, + int top_channels_, int top_height_, + int top_width_, int pad_size_, bool is_multiply, + int max_displacement_, int kernel_size_, + int neighborhood_grid_radius_, int neighborhood_grid_width_, + int kernel_radius_, int stride1_, + int stride2_, int num, int channels, int height, int width + ) { + cudaStream_t stream0 = Stream::GetStream(in_grad1.stream_); + cudaStream_t stream1 = Stream::GetStream(in_grad2.stream_); + cuda::Backward_gpu(out_grad, in_grad1, in_grad2, tmp1, tmp2, top_channels_, + top_height_, top_width_, pad_size_, is_multiply, + max_displacement_, kernel_size_, neighborhood_grid_radius_, + neighborhood_grid_width_, kernel_radius_, stride1_, stride2_, + stream0, stream1, num, channels, height, width); +} +} // namespace mshadow +namespace mxnet { +namespace op { +template<> +Operator* CreateOp(CorrelationParam param) { + return new CorrelationOp(param); +} +} // namespace op +} // namespace mxnet diff --git a/src/operator/crop-inl.h b/src/operator/crop-inl.h index 5b5adbf15874..5a8709633f21 100644 --- a/src/operator/crop-inl.h +++ b/src/operator/crop-inl.h @@ -1,214 +1,232 @@ -/*! - * Copyright (c) 2015 by Contributors - * \file crop-inl.h - * \brief - * \author Wei Wu -*/ -#ifndef MXNET_OPERATOR_CROP_INL_H_ -#define MXNET_OPERATOR_CROP_INL_H_ -#include -#include -#include -#include -#include -#include -#include -#include -#include "./operator_common.h" - -namespace mxnet { -namespace op { - -namespace crop_enum { -enum CropOpInputs {kData, kCropLike}; -enum CropOpOutputs {kOut}; -} // namespace crop_enum - -struct CropParam : public dmlc::Parameter { - int num_args; - TShape offset; - TShape h_w; - bool center_crop; - DMLC_DECLARE_PARAMETER(CropParam) { - DMLC_DECLARE_FIELD(num_args).set_range(1, 3) - .describe("Number of inputs for crop, if equals one, then we will use the h_w" - "for crop height and width, else if equals two, then we will use the height" - "and width of the second input symbol, we name crop_like here"); - int shape[] = {0, 0}; - DMLC_DECLARE_FIELD(offset).set_default(TShape(shape, shape + 2)) - .describe("crop offset coordinate: (y, x)"); - DMLC_DECLARE_FIELD(h_w).set_default(TShape(shape, shape + 2)) - .describe("crop height and width: (h, w)"); - DMLC_DECLARE_FIELD(center_crop).set_default(false) - .describe("If set to true, then it will use be the center_crop," - "or it will crop using the shape of crop_like"); - } -}; // struct CropParam - -template -class CropOp : public Operator { - public: - explicit CropOp(CropParam param) { - this->param_ = param; - } - - virtual void Forward(const OpContext &ctx, - const std::vector &in_data, - const std::vector &req, - const std::vector &out_data, - const std::vector &aux_args) { - using namespace mshadow; - using namespace mshadow::expr; - CHECK_EQ(static_cast(in_data.size()), param_.num_args); - CHECK_EQ(out_data.size(), 1U); - CHECK_EQ(req[crop_enum::kOut], kWriteTo); - Stream *s = ctx.get_stream(); - Tensor data = in_data[crop_enum::kData].get(s); - Tensor out = out_data[crop_enum::kOut].get(s); - offset_hw_ = InferCropOfferset(data.shape_, out.shape_); - out = crop(data, Shape2(out.size(2), out.size(3)), offset_hw_[0], offset_hw_[1]); - } - - // because the crop_like input is only used with it's shape, so we should be - // careful setting its backwrd grad value to zeros, so that it will not hurt - // the connection of crop_like. - virtual void Backward(const OpContext &ctx, - const std::vector &out_grad, - const std::vector &in_data, - const std::vector &out_data, - const std::vector &req, - const std::vector &in_grad, - const std::vector &aux_states) { - using namespace mshadow; - using namespace mshadow::expr; - CHECK_EQ(in_grad.size(), static_cast(param_.num_args)) << in_grad.size(); - CHECK_EQ(out_grad.size(), 1U) << out_grad.size(); - Stream *s = ctx.get_stream(); - Tensor grad = out_grad[crop_enum::kOut].get(s); - Tensor gdata = in_grad[crop_enum::kData].get(s); - if (param_.num_args > 1) { - // here backward grad is set to zero for crop_like - // however, this should only be done when num_args > 1, i.e., crop_like exists - Tensor gcrop_like = in_grad[crop_enum::kCropLike].get(s); - gcrop_like = (real_t)0.0f; - } - offset_hw_ = InferCropOfferset(gdata.shape_, grad.shape_); - gdata = (real_t)0.0f; - slice<3>(slice<2>(gdata, offset_hw_[0], offset_hw_[0]+grad.size(2)), - offset_hw_[1], offset_hw_[1]+grad.size(3)) = grad; - } - - private: - CropParam param_; - std::vector offset_hw_; - std::vector InferCropOfferset(const mshadow::Shape<4> &data_shape, - const mshadow::Shape<4> &out_shape) { - std::vector offset_hw; - CHECK_GE(data_shape[2], out_shape[2]) << - "data_shape'height should be larger than that of out_shape"; - CHECK_GE(data_shape[3], out_shape[3]) << - "data_shape'weight should be larger than that of out_shape"; - if (param_.center_crop) { - offset_hw.push_back(static_cast((data_shape[2]-out_shape[2])/2)); - offset_hw.push_back(static_cast((data_shape[3]-out_shape[3])/2)); - } else { - CHECK_GE(static_cast(param_.offset[0]), 0) << - "offset[0] should be larger than 0"; - CHECK_LE(param_.offset[0], data_shape[2]-out_shape[2]) << - "offset[0] should be less than the residual space of height"; - CHECK_GE(static_cast(param_.offset[1]), 0) << - "offset[1] should be larger than 0"; - CHECK_LE(param_.offset[1], data_shape[3]-out_shape[3]) << - "offset[1] should be less than the residual space of width"; - offset_hw.push_back(static_cast(param_.offset[0])); - offset_hw.push_back(static_cast(param_.offset[1])); - } - return offset_hw; - } -}; // class CropOp - -template -Operator *CreateOp(CropParam param); - -#if DMLC_USE_CXX11 -class CropProp : public OperatorProperty { - public: - void Init(const std::vector >& kwargs) override { - param_.Init(kwargs); - } - - std::map GetParams() const override { - return param_.__DICT__(); - } - - std::vector ListArguments() const override { - // return {"data", "crop_like"}; - std::vector ret; - for (int i = 0; i < param_.num_args; ++i) { - ret.push_back(std::string("arg") + std::to_string(i)); - } - return ret; - } - - bool InferShape(std::vector *in_shape, - std::vector *out_shape, - std::vector *aux_shape) const override { - using namespace mshadow; - CHECK_EQ(in_shape->size(), static_cast(param_.num_args)); - TShape data_shape = in_shape->at(crop_enum::kData); - if (data_shape.ndim() == 0) return false; - CHECK_EQ(data_shape.ndim(), 4U) << \ - "Input data should be 4D in batch-num_filter-y-x"; - std::vector crop_shape; - if (param_.num_args == 1) { - CHECK_GE(static_cast(param_.h_w[0]), 1) << - "the crop height(h_w[0]) should be larger than 1"; - CHECK_LE(static_cast(param_.h_w[0]), static_cast(data_shape[2])) << - "the crop height(h_w[0]) should be less than the input data's height"; - CHECK_GE(static_cast(param_.h_w[1]), 1) << - "the crop width(h_w[1]) should be larger than 1"; - CHECK_LE(static_cast(param_.h_w[1]), static_cast(data_shape[3])) << - "the crop width(h_w[1]) should be less than the input data's width"; - crop_shape.push_back(param_.h_w[0]); - crop_shape.push_back(param_.h_w[1]); - } else if (param_.num_args == 2) { - TShape crop_like_shape = in_shape->at(crop_enum::kCropLike); - crop_shape.push_back(crop_like_shape[2]); - crop_shape.push_back(crop_like_shape[3]); - } - if (crop_shape.size() == 0) return false; - CHECK_EQ(crop_shape.size(), 2U) << \ - "Input crop_like should be 2D in height-width"; - out_shape->clear(); - data_shape[2] = crop_shape[0]; - data_shape[3] = crop_shape[1]; - out_shape->push_back(data_shape); - return true; - } - - OperatorProperty* Copy() const override { - auto ptr = new CropProp(); - ptr->param_ = param_; - return ptr; - } - - std::string TypeString() const override { - return "Crop"; - } - - std::vector DeclareBackwardDependency( - const std::vector &out_grad, - const std::vector &in_data, - const std::vector &out_data) const override { - return out_grad; - } - - Operator* CreateOperator(Context ctx) const override; - - private: - CropParam param_; -}; // class CropProp -#endif // DMLC_USE_CXX11 -} // namespace op -} // namespace mxnet -#endif // MXNET_OPERATOR_CROP_INL_H_ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/*! + * \file crop-inl.h + * \brief + * \author Wei Wu +*/ +#ifndef MXNET_OPERATOR_CROP_INL_H_ +#define MXNET_OPERATOR_CROP_INL_H_ +#include +#include +#include +#include +#include +#include +#include +#include +#include "./operator_common.h" + +namespace mxnet { +namespace op { + +namespace crop_enum { +enum CropOpInputs {kData, kCropLike}; +enum CropOpOutputs {kOut}; +} // namespace crop_enum + +struct CropParam : public dmlc::Parameter { + int num_args; + TShape offset; + TShape h_w; + bool center_crop; + DMLC_DECLARE_PARAMETER(CropParam) { + DMLC_DECLARE_FIELD(num_args).set_range(1, 3) + .describe("Number of inputs for crop, if equals one, then we will use the h_w" + "for crop height and width, else if equals two, then we will use the height" + "and width of the second input symbol, we name crop_like here"); + int shape[] = {0, 0}; + DMLC_DECLARE_FIELD(offset).set_default(TShape(shape, shape + 2)) + .describe("crop offset coordinate: (y, x)"); + DMLC_DECLARE_FIELD(h_w).set_default(TShape(shape, shape + 2)) + .describe("crop height and width: (h, w)"); + DMLC_DECLARE_FIELD(center_crop).set_default(false) + .describe("If set to true, then it will use be the center_crop," + "or it will crop using the shape of crop_like"); + } +}; // struct CropParam + +template +class CropOp : public Operator { + public: + explicit CropOp(CropParam param) { + this->param_ = param; + } + + virtual void Forward(const OpContext &ctx, + const std::vector &in_data, + const std::vector &req, + const std::vector &out_data, + const std::vector &aux_args) { + using namespace mshadow; + using namespace mshadow::expr; + CHECK_EQ(static_cast(in_data.size()), param_.num_args); + CHECK_EQ(out_data.size(), 1U); + CHECK_EQ(req[crop_enum::kOut], kWriteTo); + Stream *s = ctx.get_stream(); + Tensor data = in_data[crop_enum::kData].get(s); + Tensor out = out_data[crop_enum::kOut].get(s); + offset_hw_ = InferCropOfferset(data.shape_, out.shape_); + out = crop(data, Shape2(out.size(2), out.size(3)), offset_hw_[0], offset_hw_[1]); + } + + // because the crop_like input is only used with it's shape, so we should be + // careful setting its backwrd grad value to zeros, so that it will not hurt + // the connection of crop_like. + virtual void Backward(const OpContext &ctx, + const std::vector &out_grad, + const std::vector &in_data, + const std::vector &out_data, + const std::vector &req, + const std::vector &in_grad, + const std::vector &aux_states) { + using namespace mshadow; + using namespace mshadow::expr; + CHECK_EQ(in_grad.size(), static_cast(param_.num_args)) << in_grad.size(); + CHECK_EQ(out_grad.size(), 1U) << out_grad.size(); + Stream *s = ctx.get_stream(); + Tensor grad = out_grad[crop_enum::kOut].get(s); + Tensor gdata = in_grad[crop_enum::kData].get(s); + if (param_.num_args > 1) { + // here backward grad is set to zero for crop_like + // however, this should only be done when num_args > 1, i.e., crop_like exists + Tensor gcrop_like = in_grad[crop_enum::kCropLike].get(s); + gcrop_like = (real_t)0.0f; + } + offset_hw_ = InferCropOfferset(gdata.shape_, grad.shape_); + gdata = (real_t)0.0f; + slice<3>(slice<2>(gdata, offset_hw_[0], offset_hw_[0]+grad.size(2)), + offset_hw_[1], offset_hw_[1]+grad.size(3)) = grad; + } + + private: + CropParam param_; + std::vector offset_hw_; + std::vector InferCropOfferset(const mshadow::Shape<4> &data_shape, + const mshadow::Shape<4> &out_shape) { + std::vector offset_hw; + CHECK_GE(data_shape[2], out_shape[2]) << + "data_shape'height should be larger than that of out_shape"; + CHECK_GE(data_shape[3], out_shape[3]) << + "data_shape'weight should be larger than that of out_shape"; + if (param_.center_crop) { + offset_hw.push_back(static_cast((data_shape[2]-out_shape[2])/2)); + offset_hw.push_back(static_cast((data_shape[3]-out_shape[3])/2)); + } else { + CHECK_GE(static_cast(param_.offset[0]), 0) << + "offset[0] should be larger than 0"; + CHECK_LE(param_.offset[0], data_shape[2]-out_shape[2]) << + "offset[0] should be less than the residual space of height"; + CHECK_GE(static_cast(param_.offset[1]), 0) << + "offset[1] should be larger than 0"; + CHECK_LE(param_.offset[1], data_shape[3]-out_shape[3]) << + "offset[1] should be less than the residual space of width"; + offset_hw.push_back(static_cast(param_.offset[0])); + offset_hw.push_back(static_cast(param_.offset[1])); + } + return offset_hw; + } +}; // class CropOp + +template +Operator *CreateOp(CropParam param); + +#if DMLC_USE_CXX11 +class CropProp : public OperatorProperty { + public: + void Init(const std::vector >& kwargs) override { + param_.Init(kwargs); + } + + std::map GetParams() const override { + return param_.__DICT__(); + } + + std::vector ListArguments() const override { + // return {"data", "crop_like"}; + std::vector ret; + for (int i = 0; i < param_.num_args; ++i) { + ret.push_back(std::string("arg") + std::to_string(i)); + } + return ret; + } + + bool InferShape(std::vector *in_shape, + std::vector *out_shape, + std::vector *aux_shape) const override { + using namespace mshadow; + CHECK_EQ(in_shape->size(), static_cast(param_.num_args)); + TShape data_shape = in_shape->at(crop_enum::kData); + if (data_shape.ndim() == 0) return false; + CHECK_EQ(data_shape.ndim(), 4U) << \ + "Input data should be 4D in batch-num_filter-y-x"; + std::vector crop_shape; + if (param_.num_args == 1) { + CHECK_GE(static_cast(param_.h_w[0]), 1) << + "the crop height(h_w[0]) should be larger than 1"; + CHECK_LE(static_cast(param_.h_w[0]), static_cast(data_shape[2])) << + "the crop height(h_w[0]) should be less than the input data's height"; + CHECK_GE(static_cast(param_.h_w[1]), 1) << + "the crop width(h_w[1]) should be larger than 1"; + CHECK_LE(static_cast(param_.h_w[1]), static_cast(data_shape[3])) << + "the crop width(h_w[1]) should be less than the input data's width"; + crop_shape.push_back(param_.h_w[0]); + crop_shape.push_back(param_.h_w[1]); + } else if (param_.num_args == 2) { + TShape crop_like_shape = in_shape->at(crop_enum::kCropLike); + crop_shape.push_back(crop_like_shape[2]); + crop_shape.push_back(crop_like_shape[3]); + } + if (crop_shape.size() == 0) return false; + CHECK_EQ(crop_shape.size(), 2U) << \ + "Input crop_like should be 2D in height-width"; + out_shape->clear(); + data_shape[2] = crop_shape[0]; + data_shape[3] = crop_shape[1]; + out_shape->push_back(data_shape); + return true; + } + + OperatorProperty* Copy() const override { + auto ptr = new CropProp(); + ptr->param_ = param_; + return ptr; + } + + std::string TypeString() const override { + return "Crop"; + } + + std::vector DeclareBackwardDependency( + const std::vector &out_grad, + const std::vector &in_data, + const std::vector &out_data) const override { + return out_grad; + } + + Operator* CreateOperator(Context ctx) const override; + + private: + CropParam param_; +}; // class CropProp +#endif // DMLC_USE_CXX11 +} // namespace op +} // namespace mxnet +#endif // MXNET_OPERATOR_CROP_INL_H_ diff --git a/src/operator/crop.cc b/src/operator/crop.cc index f1233ba8a135..8465819903ce 100644 --- a/src/operator/crop.cc +++ b/src/operator/crop.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file crop.cc * \brief * \author Wei Wu diff --git a/src/operator/crop.cu b/src/operator/crop.cu index 64f8cb219f30..0b51b1449581 100644 --- a/src/operator/crop.cu +++ b/src/operator/crop.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file concat.cu * \brief * \author Wei Wu diff --git a/src/operator/cross_device_copy.cc b/src/operator/cross_device_copy.cc index a9a5f475f0bc..b32a68d3038c 100644 --- a/src/operator/cross_device_copy.cc +++ b/src/operator/cross_device_copy.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file cross_device_copy.cc * \brief Special operator that copys NDArray */ diff --git a/src/operator/cudnn_activation-inl.h b/src/operator/cudnn_activation-inl.h index 68f68b6225be..317ef47c126a 100644 --- a/src/operator/cudnn_activation-inl.h +++ b/src/operator/cudnn_activation-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file cudnn_activation-inl.h * \brief * \author Bing Xu diff --git a/src/operator/cudnn_algoreg-inl.h b/src/operator/cudnn_algoreg-inl.h index 0d1c3948186c..1078d658597e 100644 --- a/src/operator/cudnn_algoreg-inl.h +++ b/src/operator/cudnn_algoreg-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file cudnn_algoreg-inl.h * \brief * \author Bing Xu diff --git a/src/operator/cudnn_algoreg.cc b/src/operator/cudnn_algoreg.cc index 103c4819d951..5aa8688c8148 100644 --- a/src/operator/cudnn_algoreg.cc +++ b/src/operator/cudnn_algoreg.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file cudnn_algoreg.cc * \brief * \author Junyuan Xie diff --git a/src/operator/cudnn_batch_norm-inl.h b/src/operator/cudnn_batch_norm-inl.h index 6005b0f58b12..b0c5f43157d0 100644 --- a/src/operator/cudnn_batch_norm-inl.h +++ b/src/operator/cudnn_batch_norm-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file cudnn_batch_norm-inl.h * \brief * \author Junyuan Xie diff --git a/src/operator/cudnn_batch_norm.cc b/src/operator/cudnn_batch_norm.cc index 424299d93260..28c592b78ccf 100644 --- a/src/operator/cudnn_batch_norm.cc +++ b/src/operator/cudnn_batch_norm.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file cudnn_batch_norm.cc * \brief * \author Junyuan Xie diff --git a/src/operator/cudnn_batch_norm.cu b/src/operator/cudnn_batch_norm.cu index 3ab43cabd6cd..c16fc0cac25b 100644 --- a/src/operator/cudnn_batch_norm.cu +++ b/src/operator/cudnn_batch_norm.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file cudnn_batch_norm.cu * \brief * \author Junyuan Xie diff --git a/src/operator/cudnn_bilinear_sampler-inl.h b/src/operator/cudnn_bilinear_sampler-inl.h index 8b012b71723b..57592dabd891 100644 --- a/src/operator/cudnn_bilinear_sampler-inl.h +++ b/src/operator/cudnn_bilinear_sampler-inl.h @@ -1,167 +1,185 @@ -/*! - * Copyright (c) 2016 by Contributors - * \file cudnn_bilinear_sampler-inl.h - * \brief - * \author Xu Dong -*/ -#ifndef MXNET_OPERATOR_CUDNN_BILINEAR_SAMPLER_INL_H_ -#define MXNET_OPERATOR_CUDNN_BILINEAR_SAMPLER_INL_H_ - -#include -#include -#include "./bilinear_sampler-inl.h" -namespace mxnet { -namespace op { -#if defined(__CUDACC__) && MXNET_USE_CUDNN == 1 && CUDNN_MAJOR >= 5 -template -class CuDNNBilinearSamplerOp : public Operator { - public: - explicit CuDNNBilinearSamplerOp(BilinearSamplerParam param) { - this->param_ = param; - init_cudnn_ = false; - dtype_ = mshadow::DataType::kCudnnFlag; - sampler_ = CUDNN_SAMPLER_BILINEAR; - } - - ~CuDNNBilinearSamplerOp() { - if (init_cudnn_) { - CUDNN_CALL(cudnnDestroySpatialTransformerDescriptor(st_desc_)); - CUDNN_CALL(cudnnDestroyTensorDescriptor(in_desc_)); - CUDNN_CALL(cudnnDestroyTensorDescriptor(out_desc_)); - } - } - - virtual void Forward(const OpContext &ctx, - const std::vector &in_data, - const std::vector &req, - const std::vector &out_data, - const std::vector &aux_args) { - using namespace mshadow; - CHECK_EQ(req[bs::kOut], kWriteTo); - CHECK_EQ(in_data.size(), 2U); - CHECK_EQ(out_data.size(), 2U); - Stream *s = ctx.get_stream(); - - Tensor data = in_data[bs::kData].get(s); - Tensor grid = in_data[bs::kGrid].get(s); - Tensor grid_tmp = out_data[bs::kTmp].get(s); - Tensor out = out_data[bs::kOut].get(s); - // grid_tmp : (batch, h, w, 2) - grid_tmp = transpose(grid, Shape4(0, 2, 3, 1)); - if (!init_cudnn_) { - Init(s, in_data, out_data); - } - CHECK_EQ(data.CheckContiguous(), true); - CHECK_EQ(out.CheckContiguous(), true); - CHECK_EQ(grid_tmp.CheckContiguous(), true); - typename DataType::ScaleType alpha = 1.0f; - typename DataType::ScaleType beta = 0.0f; - CUDNN_CALL(cudnnSpatialTfSamplerForward(s->dnn_handle_, - st_desc_, - &alpha, - in_desc_, - data.dptr_, - grid_tmp.dptr_, - &beta, - out_desc_, - out.dptr_)); - } - - virtual void Backward(const OpContext &ctx, - const std::vector &out_grad, - const std::vector &in_data, - const std::vector &out_data, - const std::vector &req, - const std::vector &in_grad, - const std::vector &aux_args) { - using namespace mshadow; - CHECK_NE(req[bs::kData], kWriteInplace); - CHECK_NE(req[bs::kGrid], kWriteInplace); - CHECK_EQ(in_data.size(), 2U); - CHECK_EQ(out_data.size(), 2U); - CHECK_EQ(out_grad.size(), 1U); - Stream *s = ctx.get_stream(); - Tensor data = in_data[bs::kData].get(s); - Tensor grid_tmp = out_data[bs::kTmp].get(s); - Tensor gdata = in_grad[bs::kData].get(s); - Tensor ggrid = in_grad[bs::kGrid].get(s); - Tensor grad = out_grad[bs::kOut].get(s); - - typename DataType::ScaleType alpha = (req[bs::kData] == kNullOp) ? 0.0f : 1.0f; - typename DataType::ScaleType beta = (req[bs::kData] == kAddTo) ? 1.0f : 0.0f; - typename DataType::ScaleType alpha_dgrid = 1.0f; - typename DataType::ScaleType beta_dgrid = 0.0f; - CUDNN_CALL(cudnnSpatialTfSamplerBackward(s->dnn_handle_, - st_desc_, - &alpha, - in_desc_, - data.dptr_, - &beta, - in_desc_/*reuse in_desc_*/, - gdata.dptr_/*output*/, - &alpha_dgrid, - out_desc_/*reuse out_desc_*/, - grad.dptr_, - grid_tmp.dptr_, - &beta_dgrid, - grid_tmp.dptr_)); - Assign(ggrid, req[bs::kGrid], transpose(grid_tmp, Shape4(0, 3, 1, 2))); - } - - private: - inline void Init(mshadow::Stream *s, - const std::vector &in_data, - const std::vector &out_data) { - using namespace mshadow; - #if CUDNN_MAJOR >= 5 - format_ = CUDNN_TENSOR_NCHW; - #endif - CHECK_EQ(in_data.size(), 2U); - CHECK_EQ(out_data.size(), 2U); - if (!init_cudnn_) { - init_cudnn_ = true; - Tensor data = in_data[bs::kData].get(s); - Tensor out = out_data[bs::kOut].get(s); - CUDNN_CALL(cudnnCreateSpatialTransformerDescriptor(&st_desc_)); - CUDNN_CALL(cudnnCreateTensorDescriptor(&in_desc_)); - CUDNN_CALL(cudnnCreateTensorDescriptor(&out_desc_)); - CUDNN_CALL(cudnnSetTensor4dDescriptor(in_desc_, - format_, - dtype_, - data.size(0), - data.size(1), - data.size(2), - data.size(3))); - CUDNN_CALL(cudnnSetTensor4dDescriptor(out_desc_, - format_, - dtype_, - out.size(0), - out.size(1), - out.size(2), - out.size(3))); - int dim[] = {static_cast(out.size(0)), static_cast(out.size(1)), - static_cast(out.size(2)), static_cast(out.size(3))}; - CUDNN_CALL(cudnnSetSpatialTransformerNdDescriptor(st_desc_, - sampler_, - dtype_, - 4, - dim)); - } - } - - bool init_cudnn_; - cudnnDataType_t dtype_; - cudnnSpatialTransformerDescriptor_t st_desc_; - cudnnTensorDescriptor_t in_desc_; - cudnnTensorDescriptor_t out_desc_; - cudnnSamplerType_t sampler_; - #if CUDNN_MAJOR >= 5 - cudnnTensorFormat_t format_; - #endif - BilinearSamplerParam param_; -}; -#endif // __CUDACC__ && CUDNN -} // namespace op -} // namespace mxnet - -#endif // MXNET_OPERATOR_CUDNN_BILINEAR_SAMPLER_INL_H_ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/*! + * \file cudnn_bilinear_sampler-inl.h + * \brief + * \author Xu Dong +*/ +#ifndef MXNET_OPERATOR_CUDNN_BILINEAR_SAMPLER_INL_H_ +#define MXNET_OPERATOR_CUDNN_BILINEAR_SAMPLER_INL_H_ + +#include +#include +#include "./bilinear_sampler-inl.h" +namespace mxnet { +namespace op { +#if defined(__CUDACC__) && MXNET_USE_CUDNN == 1 && CUDNN_MAJOR >= 5 +template +class CuDNNBilinearSamplerOp : public Operator { + public: + explicit CuDNNBilinearSamplerOp(BilinearSamplerParam param) { + this->param_ = param; + init_cudnn_ = false; + dtype_ = mshadow::DataType::kCudnnFlag; + sampler_ = CUDNN_SAMPLER_BILINEAR; + } + + ~CuDNNBilinearSamplerOp() { + if (init_cudnn_) { + CUDNN_CALL(cudnnDestroySpatialTransformerDescriptor(st_desc_)); + CUDNN_CALL(cudnnDestroyTensorDescriptor(in_desc_)); + CUDNN_CALL(cudnnDestroyTensorDescriptor(out_desc_)); + } + } + + virtual void Forward(const OpContext &ctx, + const std::vector &in_data, + const std::vector &req, + const std::vector &out_data, + const std::vector &aux_args) { + using namespace mshadow; + CHECK_EQ(req[bs::kOut], kWriteTo); + CHECK_EQ(in_data.size(), 2U); + CHECK_EQ(out_data.size(), 2U); + Stream *s = ctx.get_stream(); + + Tensor data = in_data[bs::kData].get(s); + Tensor grid = in_data[bs::kGrid].get(s); + Tensor grid_tmp = out_data[bs::kTmp].get(s); + Tensor out = out_data[bs::kOut].get(s); + // grid_tmp : (batch, h, w, 2) + grid_tmp = transpose(grid, Shape4(0, 2, 3, 1)); + if (!init_cudnn_) { + Init(s, in_data, out_data); + } + CHECK_EQ(data.CheckContiguous(), true); + CHECK_EQ(out.CheckContiguous(), true); + CHECK_EQ(grid_tmp.CheckContiguous(), true); + typename DataType::ScaleType alpha = 1.0f; + typename DataType::ScaleType beta = 0.0f; + CUDNN_CALL(cudnnSpatialTfSamplerForward(s->dnn_handle_, + st_desc_, + &alpha, + in_desc_, + data.dptr_, + grid_tmp.dptr_, + &beta, + out_desc_, + out.dptr_)); + } + + virtual void Backward(const OpContext &ctx, + const std::vector &out_grad, + const std::vector &in_data, + const std::vector &out_data, + const std::vector &req, + const std::vector &in_grad, + const std::vector &aux_args) { + using namespace mshadow; + CHECK_NE(req[bs::kData], kWriteInplace); + CHECK_NE(req[bs::kGrid], kWriteInplace); + CHECK_EQ(in_data.size(), 2U); + CHECK_EQ(out_data.size(), 2U); + CHECK_EQ(out_grad.size(), 1U); + Stream *s = ctx.get_stream(); + Tensor data = in_data[bs::kData].get(s); + Tensor grid_tmp = out_data[bs::kTmp].get(s); + Tensor gdata = in_grad[bs::kData].get(s); + Tensor ggrid = in_grad[bs::kGrid].get(s); + Tensor grad = out_grad[bs::kOut].get(s); + + typename DataType::ScaleType alpha = (req[bs::kData] == kNullOp) ? 0.0f : 1.0f; + typename DataType::ScaleType beta = (req[bs::kData] == kAddTo) ? 1.0f : 0.0f; + typename DataType::ScaleType alpha_dgrid = 1.0f; + typename DataType::ScaleType beta_dgrid = 0.0f; + CUDNN_CALL(cudnnSpatialTfSamplerBackward(s->dnn_handle_, + st_desc_, + &alpha, + in_desc_, + data.dptr_, + &beta, + in_desc_/*reuse in_desc_*/, + gdata.dptr_/*output*/, + &alpha_dgrid, + out_desc_/*reuse out_desc_*/, + grad.dptr_, + grid_tmp.dptr_, + &beta_dgrid, + grid_tmp.dptr_)); + Assign(ggrid, req[bs::kGrid], transpose(grid_tmp, Shape4(0, 3, 1, 2))); + } + + private: + inline void Init(mshadow::Stream *s, + const std::vector &in_data, + const std::vector &out_data) { + using namespace mshadow; + #if CUDNN_MAJOR >= 5 + format_ = CUDNN_TENSOR_NCHW; + #endif + CHECK_EQ(in_data.size(), 2U); + CHECK_EQ(out_data.size(), 2U); + if (!init_cudnn_) { + init_cudnn_ = true; + Tensor data = in_data[bs::kData].get(s); + Tensor out = out_data[bs::kOut].get(s); + CUDNN_CALL(cudnnCreateSpatialTransformerDescriptor(&st_desc_)); + CUDNN_CALL(cudnnCreateTensorDescriptor(&in_desc_)); + CUDNN_CALL(cudnnCreateTensorDescriptor(&out_desc_)); + CUDNN_CALL(cudnnSetTensor4dDescriptor(in_desc_, + format_, + dtype_, + data.size(0), + data.size(1), + data.size(2), + data.size(3))); + CUDNN_CALL(cudnnSetTensor4dDescriptor(out_desc_, + format_, + dtype_, + out.size(0), + out.size(1), + out.size(2), + out.size(3))); + int dim[] = {static_cast(out.size(0)), static_cast(out.size(1)), + static_cast(out.size(2)), static_cast(out.size(3))}; + CUDNN_CALL(cudnnSetSpatialTransformerNdDescriptor(st_desc_, + sampler_, + dtype_, + 4, + dim)); + } + } + + bool init_cudnn_; + cudnnDataType_t dtype_; + cudnnSpatialTransformerDescriptor_t st_desc_; + cudnnTensorDescriptor_t in_desc_; + cudnnTensorDescriptor_t out_desc_; + cudnnSamplerType_t sampler_; + #if CUDNN_MAJOR >= 5 + cudnnTensorFormat_t format_; + #endif + BilinearSamplerParam param_; +}; +#endif // __CUDACC__ && CUDNN +} // namespace op +} // namespace mxnet + +#endif // MXNET_OPERATOR_CUDNN_BILINEAR_SAMPLER_INL_H_ diff --git a/src/operator/cudnn_convolution-inl.h b/src/operator/cudnn_convolution-inl.h index 06887a94aa70..e966b56d2a20 100644 --- a/src/operator/cudnn_convolution-inl.h +++ b/src/operator/cudnn_convolution-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file cudnn_convolution-inl.h * \brief * \author Bing Xu diff --git a/src/operator/cudnn_deconvolution-inl.h b/src/operator/cudnn_deconvolution-inl.h index 2e2ae3a8cb8f..8c8f0551dde3 100644 --- a/src/operator/cudnn_deconvolution-inl.h +++ b/src/operator/cudnn_deconvolution-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file cudnn_deconvolution-inl.h * \brief * \author Wei Wu, Leonard Lausen diff --git a/src/operator/cudnn_lrn-inl.h b/src/operator/cudnn_lrn-inl.h index d65a678bc07d..241ec704a904 100644 --- a/src/operator/cudnn_lrn-inl.h +++ b/src/operator/cudnn_lrn-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file cudnn_lrn-inl.h * \brief * \author Bing Xu diff --git a/src/operator/cudnn_pooling-inl.h b/src/operator/cudnn_pooling-inl.h index 3c9344ec5aeb..5b03fe5ee6f3 100644 --- a/src/operator/cudnn_pooling-inl.h +++ b/src/operator/cudnn_pooling-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file cudnn_pooling-inl.h * \brief * \author Bing Xu diff --git a/src/operator/cudnn_rnn-inl.h b/src/operator/cudnn_rnn-inl.h index 17acf4a5b35f..1122aff033f2 100644 --- a/src/operator/cudnn_rnn-inl.h +++ b/src/operator/cudnn_rnn-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file cudnn_rnn-inl.h * \brief * \author Sebastian Bodenstein diff --git a/src/operator/cudnn_softmax_activation-inl.h b/src/operator/cudnn_softmax_activation-inl.h index 86c27317f923..c604a8f3f4c1 100644 --- a/src/operator/cudnn_softmax_activation-inl.h +++ b/src/operator/cudnn_softmax_activation-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file cudnn_activation-inl.h * \brief * \author Bing Xu diff --git a/src/operator/cudnn_spatial_transformer-inl.h b/src/operator/cudnn_spatial_transformer-inl.h index b25e8cebc077..fc767841447b 100644 --- a/src/operator/cudnn_spatial_transformer-inl.h +++ b/src/operator/cudnn_spatial_transformer-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file cudnn_spatial_transformer-inl.h * \brief * \author Wei Wu diff --git a/src/operator/custom/custom-inl.h b/src/operator/custom/custom-inl.h index 3c688feb05a1..4b2d620be1d6 100644 --- a/src/operator/custom/custom-inl.h +++ b/src/operator/custom/custom-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file native_op-inl.h * \brief * \author Junyuan Xie diff --git a/src/operator/custom/custom.cc b/src/operator/custom/custom.cc index 5a40be92b68e..7b257ba843c3 100644 --- a/src/operator/custom/custom.cc +++ b/src/operator/custom/custom.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file custom.cc * \brief * \author Junyuan Xie diff --git a/src/operator/custom/native_op-inl.h b/src/operator/custom/native_op-inl.h index 780b0ae41f67..ebce18611b56 100644 --- a/src/operator/custom/native_op-inl.h +++ b/src/operator/custom/native_op-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file native_op-inl.h * \brief * \author Junyuan Xie diff --git a/src/operator/custom/native_op.cc b/src/operator/custom/native_op.cc index 2ccd286e8cd3..5dd35049d5bd 100644 --- a/src/operator/custom/native_op.cc +++ b/src/operator/custom/native_op.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file native_op.cc * \brief * \author Junyuan Xie diff --git a/src/operator/custom/native_op.cu b/src/operator/custom/native_op.cu index 807592626e8b..ad8d65e3c2eb 100644 --- a/src/operator/custom/native_op.cu +++ b/src/operator/custom/native_op.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file native_op.cu * \brief * \author Junyuan Xie diff --git a/src/operator/custom/ndarray_op-inl.h b/src/operator/custom/ndarray_op-inl.h index fa4208f1da89..b3a4662b669e 100644 --- a/src/operator/custom/ndarray_op-inl.h +++ b/src/operator/custom/ndarray_op-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file native_op-inl.h * \brief * \author Junyuan Xie diff --git a/src/operator/custom/ndarray_op.cc b/src/operator/custom/ndarray_op.cc index 9815f888a98b..48426baea866 100644 --- a/src/operator/custom/ndarray_op.cc +++ b/src/operator/custom/ndarray_op.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file ndarray_op.cc * \brief * \author Junyuan Xie diff --git a/src/operator/deconvolution-inl.h b/src/operator/deconvolution-inl.h index 909a6fd5fed6..43530138b8ea 100644 --- a/src/operator/deconvolution-inl.h +++ b/src/operator/deconvolution-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file deconvolution-inl.h * \brief * \author Wei Wu diff --git a/src/operator/deconvolution.cc b/src/operator/deconvolution.cc index 397bd0065f80..6a59ff6588ff 100644 --- a/src/operator/deconvolution.cc +++ b/src/operator/deconvolution.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file deconvolution.cc * \brief * \author Wei Wu diff --git a/src/operator/deconvolution.cu b/src/operator/deconvolution.cu index 60cf0ad5a21a..b9dd1c156187 100644 --- a/src/operator/deconvolution.cu +++ b/src/operator/deconvolution.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file deconvolution.cu * \brief * \author Wei Wu diff --git a/src/operator/dropout-inl.h b/src/operator/dropout-inl.h index 57d78146a68d..b2fb7823bedc 100644 --- a/src/operator/dropout-inl.h +++ b/src/operator/dropout-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file dropout-inl.h * \brief * \author Bing Xu diff --git a/src/operator/dropout.cc b/src/operator/dropout.cc index e206214e9b64..af65578ec6f8 100644 --- a/src/operator/dropout.cc +++ b/src/operator/dropout.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file dropout.cc * \brief * \author Bing Xu diff --git a/src/operator/dropout.cu b/src/operator/dropout.cu index ea9eb7dfa200..5265d8013ff7 100644 --- a/src/operator/dropout.cu +++ b/src/operator/dropout.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file dropout.cc * \brief * \author Bing Xu diff --git a/src/operator/elemwise_op_common.h b/src/operator/elemwise_op_common.h index 228303c85a82..9b398f947e30 100644 --- a/src/operator/elemwise_op_common.h +++ b/src/operator/elemwise_op_common.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! -* Copyright (c) 2016 by Contributors * \file elemwise_op_common.h * \brief common function used for broadcasting and reducing * \author Xingjian Shi diff --git a/src/operator/fully_connected-inl.h b/src/operator/fully_connected-inl.h index 94616bc2e7d7..e2fab9f1f7dd 100644 --- a/src/operator/fully_connected-inl.h +++ b/src/operator/fully_connected-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file fully_connect_op-inl.h * \brief fully connect operator and symbol */ diff --git a/src/operator/fully_connected.cc b/src/operator/fully_connected.cc index 56cf4f6dbdde..5dbaf8c82005 100644 --- a/src/operator/fully_connected.cc +++ b/src/operator/fully_connected.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file fully_connected.cc * \brief fully connect operator */ diff --git a/src/operator/fully_connected.cu b/src/operator/fully_connected.cu index 7b834a3b08ef..28a0307b70bd 100644 --- a/src/operator/fully_connected.cu +++ b/src/operator/fully_connected.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file fully_connected.cu * \brief fully connect operator */ diff --git a/src/operator/grid_generator-inl.h b/src/operator/grid_generator-inl.h index 04fe7ec1c5fd..65fb8ccf2e07 100644 --- a/src/operator/grid_generator-inl.h +++ b/src/operator/grid_generator-inl.h @@ -1,318 +1,336 @@ -/*! - * Copyright (c) 2017 by Contributors - * \file grid_generator-inl.h - * \brief - * The operator generate sampling grid - * \author Xu Dong -*/ -#ifndef MXNET_OPERATOR_GRID_GENERATOR_INL_H_ -#define MXNET_OPERATOR_GRID_GENERATOR_INL_H_ - -#include -#include -#include -#include -#include -#include -#include -#include "./mshadow_op.h" -#include "./operator_common.h" - -namespace mxnet { -namespace op { - -namespace grid { -enum GridGeneratorOpInputs {kData}; -enum GridGeneratorOpOutputs {kOut, kGridDst}; -enum GridGeneratorOpResource {kTempSpace}; -enum GridGeneratorTransformType {kAffine, kWarp}; -} - -struct GridGeneratorParam : public dmlc::Parameter { - int transform_type; - TShape target_shape; - DMLC_DECLARE_PARAMETER(GridGeneratorParam) { - int shape[] = {0, 0}; - DMLC_DECLARE_FIELD(transform_type) - .add_enum("affine", grid::kAffine) - .add_enum("warp", grid::kWarp) - .describe("The type of transformation. For `affine`, input data should be an affine matrix " - "of size (batch, 6). For `warp`, input data should be an optical flow of size " - "(batch, 2, h, w)."); - DMLC_DECLARE_FIELD(target_shape).set_default(TShape(shape, shape + 2)) - .describe("Specifies the output shape (H, W). This is required if transformation type is " - "`affine`. If transformation type is `warp`, this parameter is ignored."); - } -}; - -template -class GridGeneratorOp : public Operator { - public: - explicit GridGeneratorOp(GridGeneratorParam p) { - this->param_ = p; - } - - virtual void Forward(const OpContext &ctx, - const std::vector &in_data, - const std::vector &req, - const std::vector &out_data, - const std::vector &aux_args) { - using namespace mshadow; - using namespace mshadow::expr; - CHECK_EQ(req[grid::kOut], kWriteTo); - CHECK_EQ(in_data.size(), 1U); - CHECK_EQ(out_data.size(), 2U); - Stream *s = ctx.get_stream(); - switch (param_.transform_type) { - case grid::kAffine: { - // if transform_type is affine, data is affine matrix, input shape : (batch, 2, 3) - Tensor out = out_data[grid::kOut]. - get_with_shape(Shape2(out_data[grid::kOut].shape_[0] * 2, - out_data[grid::kOut].shape_[2] * out_data[grid::kOut].shape_[3]), s); - Tensor grid_dst = out_data[grid::kGridDst].get(s); - Shape<2> data_shape = Shape2(out_data[grid::kOut].shape_[0] * 2, 3); - Tensor data = in_data[grid::kData] - .get_with_shape(data_shape, s); - // x, y, 1 - grid_dst[0] = range(0, grid_dst.shape_[1]); - grid_dst[0] = grid_dst[0] - tcast(tcast(grid_dst[0] / - scalar(param_.target_shape[1]))) * scalar(param_.target_shape[1]); - grid_dst[0] = scalar(-1.0) + grid_dst[0] * - scalar(2.0 / (param_.target_shape[1] - 1)); - grid_dst[1] = range(0, grid_dst.shape_[1]); - grid_dst[1] = scalar(-1.0) + tcast(tcast(grid_dst[1] / - scalar(param_.target_shape[1]))) * scalar(2.0/(param_.target_shape[0] - 1)); - grid_dst[2] = scalar(1.0); - Assign(out, req[grid::kOut], dot(data, grid_dst)); - break; - } - // Warping transformation - case grid::kWarp: { - // if transform_type is warp, data is optical flow, input shape : (batch, 2, height, width) - // grid_src = grid_dst + optical flow - Tensor data = in_data[grid::kData].get(s); - Tensor out = out_data[grid::kOut].get(s); - // grid_dst : (2, H, W) - Tensor grid_dst = out_data[grid::kGridDst].get(s); - Tensor workspace = ctx.requested[grid::kTempSpace] - .get_space_typed(Shape2(2, 1), s); - grid_dst[0] = repmat(range(0, data.size(3)), data.size(2)); - grid_dst[1] = reshape(range(0, data.size(2), 1, data.size(3)), - Shape2(data.size(2), data.size(3))); - workspace[0] = scalar((DType(data.size(3)) - 1.0) / 2.0); - workspace[1] = scalar((DType(data.size(2)) - 1.0) / 2.0); - Assign(out, req[grid::kOut], - (data + broadcast_with_axis(grid_dst, -1, data.shape_[0])) / - broadcast_to(reshape(workspace, Shape4(1, 2, 1, 1)), - TShape(data.shape_)) - scalar(1)); - break; - } - } - } - - virtual void Backward(const OpContext &ctx, - const std::vector &out_grad, - const std::vector &in_data, - const std::vector &out_data, - const std::vector &req, - const std::vector &in_grad, - const std::vector &aux_args) { - using namespace mshadow; - using namespace mshadow::expr; - CHECK_EQ(in_data.size(), 1U); - CHECK_EQ(out_data.size(), 2U); - Stream *s = ctx.get_stream(); - switch (param_.transform_type) { - case grid::kAffine: { - Tensor grid_dst = out_data[grid::kGridDst].get(s); - Shape<2> data_shape = Shape2(in_grad[grid::kData].shape_[0] * 2, 3); - Tensor gdata = in_grad[grid::kData] - .get_with_shape(data_shape, s); - Shape<2> grad_shape = Shape2(out_grad[grid::kOut].shape_[0] * 2, - param_.target_shape[0] * param_.target_shape[1]); - Tensor grad = out_grad[grid::kOut] - .get_with_shape(grad_shape, s); - // grad : (batch * 2, H * W) grid_dst.T : (H * W, 3) - Assign(gdata, req[grid::kData] , dot(grad, grid_dst.T())); - break; - } - case grid::kWarp: { - Tensor grad = out_grad[grid::kOut].get(s); - Tensor gdata = in_grad[grid::kData].get(s); - Tensor workspace = ctx.requested[grid::kTempSpace] - .get_space_typed(Shape2(2, 1), s); - workspace[0] = scalar((DType(gdata.size(3)) - 1.0) / 2.0); - workspace[1] = scalar((DType(gdata.size(2)) - 1.0) / 2.0); - Assign(gdata, req[grid::kData], - grad / broadcast_to(reshape(workspace, Shape4(1, 2, 1, 1)), - TShape(gdata.shape_))); - break; - } - } - } - - private: - GridGeneratorParam param_; -}; // class GridGeneratorOp - -template -Operator* CreateOp(GridGeneratorParam param, int dtype); - -#if DMLC_USE_CXX11 -class GridGeneratorProp : public OperatorProperty { - public: - int NumVisibleOutputs() const override { - return 1; - } - - int NumOutputs() const override { - return 2; - } - - std::vector ListArguments() const override { - return {"data"}; - } - - std::vector ListOutputs() const override { - return {"output", "grid_dst"}; - } - - void Init(const std::vector >& kwargs) override { - param_.Init(kwargs); - } - - std::map GetParams() const override { - return param_.__DICT__(); - } - - bool InferShape(std::vector *in_shape, - std::vector *out_shape, - std::vector *aux_shape) const override { - using namespace mshadow; - CHECK_EQ(in_shape->size(), 1U) << "Input:[data]"; - const TShape &lshape = (*in_shape)[grid::kData]; - if (lshape.ndim() == 0) return false; - out_shape->clear(); - switch (param_.transform_type) { - case grid::kAffine: { - CHECK_EQ(lshape.ndim(), 2U) \ - << "if transform_type is affine, data is affine matrix" - "affine matrix should be 2D in batch-num_hidden"; - CHECK_EQ(lshape[1], 6U) << "incorrect data shape[1], should be 6"; - CHECK_GT(param_.target_shape[0], 0U) \ - << "incorrect target_shape: " << param_.target_shape[0]; - CHECK_GT(param_.target_shape[1], 0U) \ - << "incorrect target_shape: " << param_.target_shape[1]; - out_shape->push_back(Shape4(lshape[0], 2, param_.target_shape[0], param_.target_shape[1])); - out_shape->push_back(Shape2(3, param_.target_shape[0] * param_.target_shape[1])); - break; - } - case grid::kWarp: { - CHECK_EQ(lshape.ndim(), 4U) \ - << "if transform_type is warp, data is optical flow" - "optical flow should be 4D in batch-num_hidden-y-x"; - CHECK_EQ(lshape[1], 2U) << "incorrect data shape[1], should be 2"; - out_shape->push_back(lshape); - out_shape->push_back(Shape3(2, lshape[2], lshape[3])); - break; - } - } - return true; - } - - bool InferType(std::vector *in_type, - std::vector *out_type, - std::vector *aux_type) const override { - int dtype = -1; - for (size_t i = 0; i < in_type->size(); ++i) { - if (dtype == -1) { - dtype = in_type->at(i); - } else { - CHECK(in_type->at(i) == dtype || - in_type->at(i) == -1) << - "Non-uniform data type in GridGenerator"; - } - } - if (dtype == -1) { - LOG(FATAL) << "Not enough information to infer type in GridGenerator."; - return false; - } - size_t nin = this->ListArguments().size(); - in_type->clear(); - for (size_t i = 0; i < nin; ++i) in_type->push_back(dtype); - size_t naux = this->ListAuxiliaryStates().size(); - aux_type->clear(); - for (size_t i = 0; i < naux; ++i) aux_type->push_back(dtype); - size_t nout = this->ListOutputs().size(); - out_type->clear(); - for (size_t i = 0; i < nout; ++i) out_type->push_back(dtype); - return true; - } - - OperatorProperty* Copy() const override { - auto ptr = new GridGeneratorProp(); - ptr->param_ = param_; - return ptr; - } - - std::string TypeString() const override { - return "GridGenerator"; - } - - std::vector DeclareBackwardDependency( - const std::vector &out_grad, - const std::vector &in_data, - const std::vector &out_data) const override { - switch (param_.transform_type) { - case grid::kAffine: { - return {out_grad[grid::kOut], - out_data[grid::kGridDst]}; - } - case grid::kWarp: { - return {out_grad[grid::kOut]}; - } - } - return {}; - } - - std::vector ForwardResource( - const std::vector &in_shape) const override { - switch (param_.transform_type) { - case grid::kAffine: { - return{}; - } - case grid::kWarp: { - return{ ResourceRequest::kTempSpace }; - } - } - return{}; - } - - std::vector BackwardResource( - const std::vector &in_shape) const override { - switch (param_.transform_type) { - case grid::kAffine: { - return {}; - } - case grid::kWarp: { - return {ResourceRequest::kTempSpace}; - } - } - return {}; - } - - Operator* CreateOperator(Context ctx) const override { - LOG(FATAL) << "Not Implemented."; - return NULL; - } - - Operator* CreateOperatorEx(Context ctx, std::vector *in_shape, - std::vector *in_type) const override; - - private: - GridGeneratorParam param_; -}; // class GridGeneratorProp -#endif // DMLC_USE_CXX11 -} // namespace op -} // namespace mxnet -#endif // MXNET_OPERATOR_GRID_GENERATOR_INL_H_ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/*! + * \file grid_generator-inl.h + * \brief + * The operator generate sampling grid + * \author Xu Dong +*/ +#ifndef MXNET_OPERATOR_GRID_GENERATOR_INL_H_ +#define MXNET_OPERATOR_GRID_GENERATOR_INL_H_ + +#include +#include +#include +#include +#include +#include +#include +#include "./mshadow_op.h" +#include "./operator_common.h" + +namespace mxnet { +namespace op { + +namespace grid { +enum GridGeneratorOpInputs {kData}; +enum GridGeneratorOpOutputs {kOut, kGridDst}; +enum GridGeneratorOpResource {kTempSpace}; +enum GridGeneratorTransformType {kAffine, kWarp}; +} + +struct GridGeneratorParam : public dmlc::Parameter { + int transform_type; + TShape target_shape; + DMLC_DECLARE_PARAMETER(GridGeneratorParam) { + int shape[] = {0, 0}; + DMLC_DECLARE_FIELD(transform_type) + .add_enum("affine", grid::kAffine) + .add_enum("warp", grid::kWarp) + .describe("The type of transformation. For `affine`, input data should be an affine matrix " + "of size (batch, 6). For `warp`, input data should be an optical flow of size " + "(batch, 2, h, w)."); + DMLC_DECLARE_FIELD(target_shape).set_default(TShape(shape, shape + 2)) + .describe("Specifies the output shape (H, W). This is required if transformation type is " + "`affine`. If transformation type is `warp`, this parameter is ignored."); + } +}; + +template +class GridGeneratorOp : public Operator { + public: + explicit GridGeneratorOp(GridGeneratorParam p) { + this->param_ = p; + } + + virtual void Forward(const OpContext &ctx, + const std::vector &in_data, + const std::vector &req, + const std::vector &out_data, + const std::vector &aux_args) { + using namespace mshadow; + using namespace mshadow::expr; + CHECK_EQ(req[grid::kOut], kWriteTo); + CHECK_EQ(in_data.size(), 1U); + CHECK_EQ(out_data.size(), 2U); + Stream *s = ctx.get_stream(); + switch (param_.transform_type) { + case grid::kAffine: { + // if transform_type is affine, data is affine matrix, input shape : (batch, 2, 3) + Tensor out = out_data[grid::kOut]. + get_with_shape(Shape2(out_data[grid::kOut].shape_[0] * 2, + out_data[grid::kOut].shape_[2] * out_data[grid::kOut].shape_[3]), s); + Tensor grid_dst = out_data[grid::kGridDst].get(s); + Shape<2> data_shape = Shape2(out_data[grid::kOut].shape_[0] * 2, 3); + Tensor data = in_data[grid::kData] + .get_with_shape(data_shape, s); + // x, y, 1 + grid_dst[0] = range(0, grid_dst.shape_[1]); + grid_dst[0] = grid_dst[0] - tcast(tcast(grid_dst[0] / + scalar(param_.target_shape[1]))) * scalar(param_.target_shape[1]); + grid_dst[0] = scalar(-1.0) + grid_dst[0] * + scalar(2.0 / (param_.target_shape[1] - 1)); + grid_dst[1] = range(0, grid_dst.shape_[1]); + grid_dst[1] = scalar(-1.0) + tcast(tcast(grid_dst[1] / + scalar(param_.target_shape[1]))) * scalar(2.0/(param_.target_shape[0] - 1)); + grid_dst[2] = scalar(1.0); + Assign(out, req[grid::kOut], dot(data, grid_dst)); + break; + } + // Warping transformation + case grid::kWarp: { + // if transform_type is warp, data is optical flow, input shape : (batch, 2, height, width) + // grid_src = grid_dst + optical flow + Tensor data = in_data[grid::kData].get(s); + Tensor out = out_data[grid::kOut].get(s); + // grid_dst : (2, H, W) + Tensor grid_dst = out_data[grid::kGridDst].get(s); + Tensor workspace = ctx.requested[grid::kTempSpace] + .get_space_typed(Shape2(2, 1), s); + grid_dst[0] = repmat(range(0, data.size(3)), data.size(2)); + grid_dst[1] = reshape(range(0, data.size(2), 1, data.size(3)), + Shape2(data.size(2), data.size(3))); + workspace[0] = scalar((DType(data.size(3)) - 1.0) / 2.0); + workspace[1] = scalar((DType(data.size(2)) - 1.0) / 2.0); + Assign(out, req[grid::kOut], + (data + broadcast_with_axis(grid_dst, -1, data.shape_[0])) / + broadcast_to(reshape(workspace, Shape4(1, 2, 1, 1)), + TShape(data.shape_)) - scalar(1)); + break; + } + } + } + + virtual void Backward(const OpContext &ctx, + const std::vector &out_grad, + const std::vector &in_data, + const std::vector &out_data, + const std::vector &req, + const std::vector &in_grad, + const std::vector &aux_args) { + using namespace mshadow; + using namespace mshadow::expr; + CHECK_EQ(in_data.size(), 1U); + CHECK_EQ(out_data.size(), 2U); + Stream *s = ctx.get_stream(); + switch (param_.transform_type) { + case grid::kAffine: { + Tensor grid_dst = out_data[grid::kGridDst].get(s); + Shape<2> data_shape = Shape2(in_grad[grid::kData].shape_[0] * 2, 3); + Tensor gdata = in_grad[grid::kData] + .get_with_shape(data_shape, s); + Shape<2> grad_shape = Shape2(out_grad[grid::kOut].shape_[0] * 2, + param_.target_shape[0] * param_.target_shape[1]); + Tensor grad = out_grad[grid::kOut] + .get_with_shape(grad_shape, s); + // grad : (batch * 2, H * W) grid_dst.T : (H * W, 3) + Assign(gdata, req[grid::kData] , dot(grad, grid_dst.T())); + break; + } + case grid::kWarp: { + Tensor grad = out_grad[grid::kOut].get(s); + Tensor gdata = in_grad[grid::kData].get(s); + Tensor workspace = ctx.requested[grid::kTempSpace] + .get_space_typed(Shape2(2, 1), s); + workspace[0] = scalar((DType(gdata.size(3)) - 1.0) / 2.0); + workspace[1] = scalar((DType(gdata.size(2)) - 1.0) / 2.0); + Assign(gdata, req[grid::kData], + grad / broadcast_to(reshape(workspace, Shape4(1, 2, 1, 1)), + TShape(gdata.shape_))); + break; + } + } + } + + private: + GridGeneratorParam param_; +}; // class GridGeneratorOp + +template +Operator* CreateOp(GridGeneratorParam param, int dtype); + +#if DMLC_USE_CXX11 +class GridGeneratorProp : public OperatorProperty { + public: + int NumVisibleOutputs() const override { + return 1; + } + + int NumOutputs() const override { + return 2; + } + + std::vector ListArguments() const override { + return {"data"}; + } + + std::vector ListOutputs() const override { + return {"output", "grid_dst"}; + } + + void Init(const std::vector >& kwargs) override { + param_.Init(kwargs); + } + + std::map GetParams() const override { + return param_.__DICT__(); + } + + bool InferShape(std::vector *in_shape, + std::vector *out_shape, + std::vector *aux_shape) const override { + using namespace mshadow; + CHECK_EQ(in_shape->size(), 1U) << "Input:[data]"; + const TShape &lshape = (*in_shape)[grid::kData]; + if (lshape.ndim() == 0) return false; + out_shape->clear(); + switch (param_.transform_type) { + case grid::kAffine: { + CHECK_EQ(lshape.ndim(), 2U) \ + << "if transform_type is affine, data is affine matrix" + "affine matrix should be 2D in batch-num_hidden"; + CHECK_EQ(lshape[1], 6U) << "incorrect data shape[1], should be 6"; + CHECK_GT(param_.target_shape[0], 0U) \ + << "incorrect target_shape: " << param_.target_shape[0]; + CHECK_GT(param_.target_shape[1], 0U) \ + << "incorrect target_shape: " << param_.target_shape[1]; + out_shape->push_back(Shape4(lshape[0], 2, param_.target_shape[0], param_.target_shape[1])); + out_shape->push_back(Shape2(3, param_.target_shape[0] * param_.target_shape[1])); + break; + } + case grid::kWarp: { + CHECK_EQ(lshape.ndim(), 4U) \ + << "if transform_type is warp, data is optical flow" + "optical flow should be 4D in batch-num_hidden-y-x"; + CHECK_EQ(lshape[1], 2U) << "incorrect data shape[1], should be 2"; + out_shape->push_back(lshape); + out_shape->push_back(Shape3(2, lshape[2], lshape[3])); + break; + } + } + return true; + } + + bool InferType(std::vector *in_type, + std::vector *out_type, + std::vector *aux_type) const override { + int dtype = -1; + for (size_t i = 0; i < in_type->size(); ++i) { + if (dtype == -1) { + dtype = in_type->at(i); + } else { + CHECK(in_type->at(i) == dtype || + in_type->at(i) == -1) << + "Non-uniform data type in GridGenerator"; + } + } + if (dtype == -1) { + LOG(FATAL) << "Not enough information to infer type in GridGenerator."; + return false; + } + size_t nin = this->ListArguments().size(); + in_type->clear(); + for (size_t i = 0; i < nin; ++i) in_type->push_back(dtype); + size_t naux = this->ListAuxiliaryStates().size(); + aux_type->clear(); + for (size_t i = 0; i < naux; ++i) aux_type->push_back(dtype); + size_t nout = this->ListOutputs().size(); + out_type->clear(); + for (size_t i = 0; i < nout; ++i) out_type->push_back(dtype); + return true; + } + + OperatorProperty* Copy() const override { + auto ptr = new GridGeneratorProp(); + ptr->param_ = param_; + return ptr; + } + + std::string TypeString() const override { + return "GridGenerator"; + } + + std::vector DeclareBackwardDependency( + const std::vector &out_grad, + const std::vector &in_data, + const std::vector &out_data) const override { + switch (param_.transform_type) { + case grid::kAffine: { + return {out_grad[grid::kOut], + out_data[grid::kGridDst]}; + } + case grid::kWarp: { + return {out_grad[grid::kOut]}; + } + } + return {}; + } + + std::vector ForwardResource( + const std::vector &in_shape) const override { + switch (param_.transform_type) { + case grid::kAffine: { + return{}; + } + case grid::kWarp: { + return{ ResourceRequest::kTempSpace }; + } + } + return{}; + } + + std::vector BackwardResource( + const std::vector &in_shape) const override { + switch (param_.transform_type) { + case grid::kAffine: { + return {}; + } + case grid::kWarp: { + return {ResourceRequest::kTempSpace}; + } + } + return {}; + } + + Operator* CreateOperator(Context ctx) const override { + LOG(FATAL) << "Not Implemented."; + return NULL; + } + + Operator* CreateOperatorEx(Context ctx, std::vector *in_shape, + std::vector *in_type) const override; + + private: + GridGeneratorParam param_; +}; // class GridGeneratorProp +#endif // DMLC_USE_CXX11 +} // namespace op +} // namespace mxnet +#endif // MXNET_OPERATOR_GRID_GENERATOR_INL_H_ diff --git a/src/operator/grid_generator.cc b/src/operator/grid_generator.cc index 62ff75a88359..411f856be08b 100644 --- a/src/operator/grid_generator.cc +++ b/src/operator/grid_generator.cc @@ -1,36 +1,54 @@ -/*! - * Copyright (c) 2017 by Contributors - * \file grid_generator.cc - * \brief - * \author Xu Dong -*/ - -#include "./grid_generator-inl.h" - -namespace mxnet { -namespace op { -template<> -Operator* CreateOp(GridGeneratorParam param, int dtype) { - Operator *op = NULL; - if (dtype == mshadow::kFloat32) { - op = new GridGeneratorOp(param); - } else { - LOG(FATAL) << "Other DTypes are not supported!"; - } - return op; -} - -Operator *GridGeneratorProp::CreateOperatorEx(Context ctx, std::vector *in_shape, - std::vector *in_type) const { - DO_BIND_DISPATCH(CreateOp, param_, (*in_type)[0]); -} - -DMLC_REGISTER_PARAMETER(GridGeneratorParam); - -MXNET_REGISTER_OP_PROPERTY(GridGenerator, GridGeneratorProp) -.add_argument("data", "NDArray-or-Symbol", "Input data to the function.") -.add_arguments(GridGeneratorParam::__FIELDS__()) -.describe("Generates 2D sampling grid for bilinear sampling."); - -} // namespace op -} // namespace mxnet +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/*! + * \file grid_generator.cc + * \brief + * \author Xu Dong +*/ + +#include "./grid_generator-inl.h" + +namespace mxnet { +namespace op { +template<> +Operator* CreateOp(GridGeneratorParam param, int dtype) { + Operator *op = NULL; + if (dtype == mshadow::kFloat32) { + op = new GridGeneratorOp(param); + } else { + LOG(FATAL) << "Other DTypes are not supported!"; + } + return op; +} + +Operator *GridGeneratorProp::CreateOperatorEx(Context ctx, std::vector *in_shape, + std::vector *in_type) const { + DO_BIND_DISPATCH(CreateOp, param_, (*in_type)[0]); +} + +DMLC_REGISTER_PARAMETER(GridGeneratorParam); + +MXNET_REGISTER_OP_PROPERTY(GridGenerator, GridGeneratorProp) +.add_argument("data", "NDArray-or-Symbol", "Input data to the function.") +.add_arguments(GridGeneratorParam::__FIELDS__()) +.describe("Generates 2D sampling grid for bilinear sampling."); + +} // namespace op +} // namespace mxnet diff --git a/src/operator/grid_generator.cu b/src/operator/grid_generator.cu index 991948cd1581..7c0a80258d36 100644 --- a/src/operator/grid_generator.cu +++ b/src/operator/grid_generator.cu @@ -1,21 +1,39 @@ -/*! - * Copyright (c) 2017 by Contributors - * \file grid_generator.cu - * \brief - * \author Xu Dong -*/ - -#include "./grid_generator-inl.h" - -namespace mxnet { -namespace op { -template<> -Operator* CreateOp(GridGeneratorParam param, int dtype) { - Operator *op = NULL; - MSHADOW_REAL_TYPE_SWITCH(dtype, DType, { - op = new GridGeneratorOp(param); - }) - return op; -} -} // namespace op -} // namespace mxnet +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/*! + * \file grid_generator.cu + * \brief + * \author Xu Dong +*/ + +#include "./grid_generator-inl.h" + +namespace mxnet { +namespace op { +template<> +Operator* CreateOp(GridGeneratorParam param, int dtype) { + Operator *op = NULL; + MSHADOW_REAL_TYPE_SWITCH(dtype, DType, { + op = new GridGeneratorOp(param); + }) + return op; +} +} // namespace op +} // namespace mxnet diff --git a/src/operator/identity_attach_KL_sparse_reg-inl.h b/src/operator/identity_attach_KL_sparse_reg-inl.h index 413bac90c0ac..2307914f62a5 100644 --- a/src/operator/identity_attach_KL_sparse_reg-inl.h +++ b/src/operator/identity_attach_KL_sparse_reg-inl.h @@ -1,177 +1,195 @@ -/*! - * Copyright (c) 2015 by Contributors - * \file sparse_reg-inl.h - * \brief -*/ -#ifndef MXNET_OPERATOR_IDENTITY_ATTACH_KL_SPARSE_REG_INL_H_ -#define MXNET_OPERATOR_IDENTITY_ATTACH_KL_SPARSE_REG_INL_H_ -#include -#include -#include -#include -#include -#include -#include -#include "./mshadow_op.h" -#include "./operator_common.h" - -namespace mxnet { -namespace op { - -namespace sparsereg { -enum IdentityAttachKLSparseRegOpInputs {kData}; -enum IdentityAttachKLSparseRegOpOutputs {kOut}; -enum IdentityAttachKLSparseRegOpAuxiliary {kMovingAvg}; -enum IdentityAttachKLSparseRegBackResource {kTempSpace}; -} // namespace sparsereg - -struct IdentityAttachKLSparseRegParam : public dmlc::Parameter { - float penalty; - float sparseness_target; - float momentum; - DMLC_DECLARE_PARAMETER(IdentityAttachKLSparseRegParam) { - DMLC_DECLARE_FIELD(sparseness_target).set_default(0.1) - .set_range(0, 1) - .describe("The sparseness target"); - DMLC_DECLARE_FIELD(penalty).set_default(0.001) - .describe("The tradeoff parameter for the sparseness penalty"); - DMLC_DECLARE_FIELD(momentum).set_default(0.9) - .set_range(0, 1) - .describe("The momentum for running average"); - } -}; // struct IdentityAttachKLSparseRegParam - -// This op regularizes the output of a sigmoid activation function. -// In forward, it simply copies the input. -// In backward, it attaches sparseness penalty to the gradient. -// The regularization is based on the KL divergence of mean activation and target. -// More details: P11 of https://www.cs.toronto.edu/~hinton/absps/guideTR.pdf -// Please make sure that it is only paired with sigmoid activation, otherwise NaN may occur. -template -class IdentityAttachKLSparseRegOp : public Operator { - public: - explicit IdentityAttachKLSparseRegOp(IdentityAttachKLSparseRegParam param) { - this->param_ = param; - } - virtual void Forward(const OpContext &ctx, - const std::vector &in_data, - const std::vector &req, - const std::vector &out_data, - const std::vector &aux_args) { - using namespace mshadow; - using namespace mshadow::expr; - CHECK_EQ(in_data.size(), 1U); - CHECK_EQ(out_data.size(), 1U); - Stream *s = ctx.get_stream(); - Tensor data = in_data[sparsereg::kData].FlatTo2D(s); - Tensor out = out_data[sparsereg::kOut].FlatTo2D(s); - Assign(out, req[sparsereg::kData], F(data)); - } - - virtual void Backward(const OpContext &ctx, - const std::vector &out_grad, - const std::vector &in_data, - const std::vector &out_data, - const std::vector &req, - const std::vector &in_grad, - const std::vector &aux_args) { - using namespace mshadow; - using namespace mshadow::expr; - Stream *s = ctx.get_stream(); - Tensor grad_in = in_grad[sparsereg::kData].FlatTo2D(s); - Tensor data_in = in_data[sparsereg::kData].FlatTo2D(s); - Tensor grad_out = out_grad[sparsereg::kOut].FlatTo2D(s); - Tensor moving_avg = aux_args[sparsereg::kMovingAvg].get(s); - Tensor avg = ctx.requested[sparsereg::kTempSpace].get_space( - mshadow::Shape1(moving_avg.shape_[0]), s); - avg = sumall_except_dim<1>(data_in); - avg /= data_in.shape_[0]; - moving_avg = param_.momentum * moving_avg + (1 - param_.momentum) * avg; - Assign(grad_in, req[sparsereg::kData], grad_out + param_.penalty * - (-param_.sparseness_target / broadcast<1>(moving_avg, data_in.shape_) + - ((1 - param_.sparseness_target) / (1 - broadcast<1>(moving_avg, data_in.shape_))))); - } - - private: - IdentityAttachKLSparseRegParam param_; -}; // class IdentityAttachKLSparseRegOp - -template -Operator *CreateOp(IdentityAttachKLSparseRegParam param); - -#if DMLC_USE_CXX11 -class IdentityAttachKLSparseRegProp : public OperatorProperty { - public: - void Init(const std::vector >& kwargs) override { - param_.Init(kwargs); - } - - std::map GetParams() const override { - return param_.__DICT__(); - } - - bool InferShape(std::vector *in_shape, - std::vector *out_shape, - std::vector *aux_shape) const override { - using namespace mshadow; - CHECK_EQ(in_shape->size(), 1U); - const TShape &dshape = in_shape->at(sparsereg::kData); - if (dshape.ndim() == 0) return false; - out_shape->clear(); - out_shape->push_back(dshape); - aux_shape->clear(); - aux_shape->push_back(Shape1(dshape[1])); - return true; - } - - OperatorProperty* Copy() const override { - auto ptr = new IdentityAttachKLSparseRegProp(); - ptr->param_ = param_; - return ptr; - } - - std::string TypeString() const override { - return "IdentityAttachKLSparseReg"; - } - - std::vector DeclareBackwardDependency( - const std::vector &out_grad, - const std::vector &in_data, - const std::vector &out_data) const override { - return {out_grad[sparsereg::kOut], in_data[sparsereg::kData]}; - } - - std::vector > ForwardInplaceOption( - const std::vector &in_data, - const std::vector &out_data) const override { - return {{in_data[sparsereg::kData], out_data[sparsereg::kOut]}}; - } - - std::vector > BackwardInplaceOption( - const std::vector &out_grad, - const std::vector &in_data, - const std::vector &out_data, - const std::vector &in_grad) const override { - return { {out_grad[sparsereg::kOut], in_grad[sparsereg::kData]} }; - } - - std::vector ListAuxiliaryStates() const override { - return {"moving_avg"}; - } - - std::vector BackwardResource( - const std::vector &in_shape) const override { - return {ResourceRequest::kTempSpace}; - } - - Operator* CreateOperator(Context ctx) const override; - - private: - IdentityAttachKLSparseRegParam param_; -}; // class IdentityAttachKLSparseRegProperty - -#endif // DMLC_USE_CXX11 -} // namespace op -} // namespace mxnet - -#endif // MXNET_OPERATOR_IDENTITY_ATTACH_KL_SPARSE_REG_INL_H_ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/*! + * \file sparse_reg-inl.h + * \brief +*/ +#ifndef MXNET_OPERATOR_IDENTITY_ATTACH_KL_SPARSE_REG_INL_H_ +#define MXNET_OPERATOR_IDENTITY_ATTACH_KL_SPARSE_REG_INL_H_ +#include +#include +#include +#include +#include +#include +#include +#include "./mshadow_op.h" +#include "./operator_common.h" + +namespace mxnet { +namespace op { + +namespace sparsereg { +enum IdentityAttachKLSparseRegOpInputs {kData}; +enum IdentityAttachKLSparseRegOpOutputs {kOut}; +enum IdentityAttachKLSparseRegOpAuxiliary {kMovingAvg}; +enum IdentityAttachKLSparseRegBackResource {kTempSpace}; +} // namespace sparsereg + +struct IdentityAttachKLSparseRegParam : public dmlc::Parameter { + float penalty; + float sparseness_target; + float momentum; + DMLC_DECLARE_PARAMETER(IdentityAttachKLSparseRegParam) { + DMLC_DECLARE_FIELD(sparseness_target).set_default(0.1) + .set_range(0, 1) + .describe("The sparseness target"); + DMLC_DECLARE_FIELD(penalty).set_default(0.001) + .describe("The tradeoff parameter for the sparseness penalty"); + DMLC_DECLARE_FIELD(momentum).set_default(0.9) + .set_range(0, 1) + .describe("The momentum for running average"); + } +}; // struct IdentityAttachKLSparseRegParam + +// This op regularizes the output of a sigmoid activation function. +// In forward, it simply copies the input. +// In backward, it attaches sparseness penalty to the gradient. +// The regularization is based on the KL divergence of mean activation and target. +// More details: P11 of https://www.cs.toronto.edu/~hinton/absps/guideTR.pdf +// Please make sure that it is only paired with sigmoid activation, otherwise NaN may occur. +template +class IdentityAttachKLSparseRegOp : public Operator { + public: + explicit IdentityAttachKLSparseRegOp(IdentityAttachKLSparseRegParam param) { + this->param_ = param; + } + virtual void Forward(const OpContext &ctx, + const std::vector &in_data, + const std::vector &req, + const std::vector &out_data, + const std::vector &aux_args) { + using namespace mshadow; + using namespace mshadow::expr; + CHECK_EQ(in_data.size(), 1U); + CHECK_EQ(out_data.size(), 1U); + Stream *s = ctx.get_stream(); + Tensor data = in_data[sparsereg::kData].FlatTo2D(s); + Tensor out = out_data[sparsereg::kOut].FlatTo2D(s); + Assign(out, req[sparsereg::kData], F(data)); + } + + virtual void Backward(const OpContext &ctx, + const std::vector &out_grad, + const std::vector &in_data, + const std::vector &out_data, + const std::vector &req, + const std::vector &in_grad, + const std::vector &aux_args) { + using namespace mshadow; + using namespace mshadow::expr; + Stream *s = ctx.get_stream(); + Tensor grad_in = in_grad[sparsereg::kData].FlatTo2D(s); + Tensor data_in = in_data[sparsereg::kData].FlatTo2D(s); + Tensor grad_out = out_grad[sparsereg::kOut].FlatTo2D(s); + Tensor moving_avg = aux_args[sparsereg::kMovingAvg].get(s); + Tensor avg = ctx.requested[sparsereg::kTempSpace].get_space( + mshadow::Shape1(moving_avg.shape_[0]), s); + avg = sumall_except_dim<1>(data_in); + avg /= data_in.shape_[0]; + moving_avg = param_.momentum * moving_avg + (1 - param_.momentum) * avg; + Assign(grad_in, req[sparsereg::kData], grad_out + param_.penalty * + (-param_.sparseness_target / broadcast<1>(moving_avg, data_in.shape_) + + ((1 - param_.sparseness_target) / (1 - broadcast<1>(moving_avg, data_in.shape_))))); + } + + private: + IdentityAttachKLSparseRegParam param_; +}; // class IdentityAttachKLSparseRegOp + +template +Operator *CreateOp(IdentityAttachKLSparseRegParam param); + +#if DMLC_USE_CXX11 +class IdentityAttachKLSparseRegProp : public OperatorProperty { + public: + void Init(const std::vector >& kwargs) override { + param_.Init(kwargs); + } + + std::map GetParams() const override { + return param_.__DICT__(); + } + + bool InferShape(std::vector *in_shape, + std::vector *out_shape, + std::vector *aux_shape) const override { + using namespace mshadow; + CHECK_EQ(in_shape->size(), 1U); + const TShape &dshape = in_shape->at(sparsereg::kData); + if (dshape.ndim() == 0) return false; + out_shape->clear(); + out_shape->push_back(dshape); + aux_shape->clear(); + aux_shape->push_back(Shape1(dshape[1])); + return true; + } + + OperatorProperty* Copy() const override { + auto ptr = new IdentityAttachKLSparseRegProp(); + ptr->param_ = param_; + return ptr; + } + + std::string TypeString() const override { + return "IdentityAttachKLSparseReg"; + } + + std::vector DeclareBackwardDependency( + const std::vector &out_grad, + const std::vector &in_data, + const std::vector &out_data) const override { + return {out_grad[sparsereg::kOut], in_data[sparsereg::kData]}; + } + + std::vector > ForwardInplaceOption( + const std::vector &in_data, + const std::vector &out_data) const override { + return {{in_data[sparsereg::kData], out_data[sparsereg::kOut]}}; + } + + std::vector > BackwardInplaceOption( + const std::vector &out_grad, + const std::vector &in_data, + const std::vector &out_data, + const std::vector &in_grad) const override { + return { {out_grad[sparsereg::kOut], in_grad[sparsereg::kData]} }; + } + + std::vector ListAuxiliaryStates() const override { + return {"moving_avg"}; + } + + std::vector BackwardResource( + const std::vector &in_shape) const override { + return {ResourceRequest::kTempSpace}; + } + + Operator* CreateOperator(Context ctx) const override; + + private: + IdentityAttachKLSparseRegParam param_; +}; // class IdentityAttachKLSparseRegProperty + +#endif // DMLC_USE_CXX11 +} // namespace op +} // namespace mxnet + +#endif // MXNET_OPERATOR_IDENTITY_ATTACH_KL_SPARSE_REG_INL_H_ diff --git a/src/operator/identity_attach_KL_sparse_reg.cc b/src/operator/identity_attach_KL_sparse_reg.cc index 51e67721032c..5e776774e00b 100644 --- a/src/operator/identity_attach_KL_sparse_reg.cc +++ b/src/operator/identity_attach_KL_sparse_reg.cc @@ -1,37 +1,55 @@ -/*! - * Copyright (c) 2015 by Contributors - * \file identity_attach_KL_sparse_reg.cc - * \brief\ -*/ -#include "./identity_attach_KL_sparse_reg-inl.h" -#include - -namespace mxnet { -namespace op { -template<> -Operator *CreateOp(IdentityAttachKLSparseRegParam param) { - return new IdentityAttachKLSparseRegOp(param); -} - -Operator *IdentityAttachKLSparseRegProp::CreateOperator(Context ctx) const { - DO_BIND_DISPATCH(CreateOp, param_); -} - -DMLC_REGISTER_PARAMETER(IdentityAttachKLSparseRegParam); - -MXNET_REGISTER_OP_PROPERTY(IdentityAttachKLSparseReg, IdentityAttachKLSparseRegProp) -.describe("Apply a sparse regularization to the output a sigmoid activation function.") -.add_argument("data", "NDArray-or-Symbol", "Input data.") -.add_arguments(IdentityAttachKLSparseRegParam::__FIELDS__()); - -NNVM_REGISTER_OP(IdentityAttachKLSparseReg) -.set_attr("FSetInputVarAttrOnCompose", - [](const nnvm::NodeAttrs& attrs, nnvm::NodePtr var, const int index) { - if (var->attrs.dict.find("__init__") != var->attrs.dict.end()) return; - if (index == 1) { - var->attrs.dict["__init__"] = "[\"zero\", {}]"; - } - }); -} // namespace op -} // namespace mxnet - +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/*! + * \file identity_attach_KL_sparse_reg.cc + * \brief\ +*/ +#include "./identity_attach_KL_sparse_reg-inl.h" +#include + +namespace mxnet { +namespace op { +template<> +Operator *CreateOp(IdentityAttachKLSparseRegParam param) { + return new IdentityAttachKLSparseRegOp(param); +} + +Operator *IdentityAttachKLSparseRegProp::CreateOperator(Context ctx) const { + DO_BIND_DISPATCH(CreateOp, param_); +} + +DMLC_REGISTER_PARAMETER(IdentityAttachKLSparseRegParam); + +MXNET_REGISTER_OP_PROPERTY(IdentityAttachKLSparseReg, IdentityAttachKLSparseRegProp) +.describe("Apply a sparse regularization to the output a sigmoid activation function.") +.add_argument("data", "NDArray-or-Symbol", "Input data.") +.add_arguments(IdentityAttachKLSparseRegParam::__FIELDS__()); + +NNVM_REGISTER_OP(IdentityAttachKLSparseReg) +.set_attr("FSetInputVarAttrOnCompose", + [](const nnvm::NodeAttrs& attrs, nnvm::NodePtr var, const int index) { + if (var->attrs.dict.find("__init__") != var->attrs.dict.end()) return; + if (index == 1) { + var->attrs.dict["__init__"] = "[\"zero\", {}]"; + } + }); +} // namespace op +} // namespace mxnet + diff --git a/src/operator/identity_attach_KL_sparse_reg.cu b/src/operator/identity_attach_KL_sparse_reg.cu index 6188fb9d954f..0a11fb167399 100644 --- a/src/operator/identity_attach_KL_sparse_reg.cu +++ b/src/operator/identity_attach_KL_sparse_reg.cu @@ -1,16 +1,34 @@ -/*! - * Copyright (c) 2015 by Contributors - * \file identity_attach_KL_sparse_reg.cu - * \brief -*/ -#include "./identity_attach_KL_sparse_reg-inl.h" - -namespace mxnet { -namespace op { -template<> -Operator *CreateOp(IdentityAttachKLSparseRegParam param) { - return new IdentityAttachKLSparseRegOp(param); -} - -} // namespace op -} // namespace mxnet +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/*! + * \file identity_attach_KL_sparse_reg.cu + * \brief +*/ +#include "./identity_attach_KL_sparse_reg-inl.h" + +namespace mxnet { +namespace op { +template<> +Operator *CreateOp(IdentityAttachKLSparseRegParam param) { + return new IdentityAttachKLSparseRegOp(param); +} + +} // namespace op +} // namespace mxnet diff --git a/src/operator/instance_norm-inl.h b/src/operator/instance_norm-inl.h index 4a4f515ed601..6e78f7628a11 100644 --- a/src/operator/instance_norm-inl.h +++ b/src/operator/instance_norm-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file instance_norm-inl.h * \brief Reproducing paper Instance Normalization: The Missing Ingredient for * Fast Stylization, D. Ulyanov, A. Vedaldi, V. Lempitsky, 2016 diff --git a/src/operator/instance_norm.cc b/src/operator/instance_norm.cc index cc2bd6b93e8b..0666b4bd0303 100644 --- a/src/operator/instance_norm.cc +++ b/src/operator/instance_norm.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file instance_norm.cc * \brief * \author Sebastian Bodenstein diff --git a/src/operator/instance_norm.cu b/src/operator/instance_norm.cu index 096008463c4a..9f8cbea797ed 100644 --- a/src/operator/instance_norm.cu +++ b/src/operator/instance_norm.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file instance_norm.cu * \brief * \author Sebastian Bodenstein diff --git a/src/operator/l2_normalization-inl.h b/src/operator/l2_normalization-inl.h index a49c8362645d..c1f17acbbce1 100644 --- a/src/operator/l2_normalization-inl.h +++ b/src/operator/l2_normalization-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file l2_normalization_op-inl.h * \brief instance l2 Normalization op */ diff --git a/src/operator/l2_normalization.cc b/src/operator/l2_normalization.cc index 8a4112d8db35..6995a0d1e440 100644 --- a/src/operator/l2_normalization.cc +++ b/src/operator/l2_normalization.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file l2_normalization.cc * \brief l2 normalization operator */ diff --git a/src/operator/l2_normalization.cu b/src/operator/l2_normalization.cu index d7bab3586a27..ae76278559a8 100644 --- a/src/operator/l2_normalization.cu +++ b/src/operator/l2_normalization.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file l2_normalization.cu * \brief l2 normalization operator */ diff --git a/src/operator/leaky_relu-inl.h b/src/operator/leaky_relu-inl.h index b0a5c0e53300..828930a0e405 100644 --- a/src/operator/leaky_relu-inl.h +++ b/src/operator/leaky_relu-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file leaky_relu-inl.h * \brief leaky relu family operator * \author Bing Xu diff --git a/src/operator/leaky_relu.cc b/src/operator/leaky_relu.cc index 25fe17edb5ee..da58bd94bd57 100644 --- a/src/operator/leaky_relu.cc +++ b/src/operator/leaky_relu.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file leaky_relu.cc * \brief * \author Bing Xu @@ -24,7 +42,7 @@ DMLC_REGISTER_PARAMETER(LeakyReLUParam); MXNET_REGISTER_OP_PROPERTY(LeakyReLU, LeakyReLUProp) .describe(R"code(Applies Leaky rectified linear unit activation element-wise to the input. -Leaky ReLUs attempt to fix the "dying ReLU" problem by allowing a small `slope` +Leaky ReLUs attempt to fix the "dying ReLU" problem by allowing a small `slope` when the input is negative and has a slope of one when input is positive. The following modified ReLU Activation functions are supported: diff --git a/src/operator/leaky_relu.cu b/src/operator/leaky_relu.cu index c9af119a96ed..b9b3a7b73f9c 100644 --- a/src/operator/leaky_relu.cu +++ b/src/operator/leaky_relu.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file leaky_relu.cc * \brief * \author Bing Xu diff --git a/src/operator/loss_binary_op-inl.h b/src/operator/loss_binary_op-inl.h index a61cee7e3d3c..8add82725292 100644 --- a/src/operator/loss_binary_op-inl.h +++ b/src/operator/loss_binary_op-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file loss_binary_op-inl.h * \brief Loss functions */ diff --git a/src/operator/loss_binary_op.cc b/src/operator/loss_binary_op.cc index 43bf6943e0c5..d0a77946ffba 100644 --- a/src/operator/loss_binary_op.cc +++ b/src/operator/loss_binary_op.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file loss_binary_op.cc * \brief loss function that takes a data and label */ diff --git a/src/operator/loss_binary_op.cu b/src/operator/loss_binary_op.cu index 66700e7918b8..8694b9f2844f 100644 --- a/src/operator/loss_binary_op.cu +++ b/src/operator/loss_binary_op.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file loss_binary_op.cu * \brief loss function that takes a data and label */ diff --git a/src/operator/lrn-inl.h b/src/operator/lrn-inl.h index 66be9ac7f4ed..a320a26bed30 100644 --- a/src/operator/lrn-inl.h +++ b/src/operator/lrn-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file lrn-inl.h * \brief * \author Bing Xu diff --git a/src/operator/lrn.cc b/src/operator/lrn.cc index ac4a309cbe05..46f4fca486b5 100644 --- a/src/operator/lrn.cc +++ b/src/operator/lrn.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file lrn.cc * \brief * \author Bing Xu diff --git a/src/operator/lrn.cu b/src/operator/lrn.cu index 681de80508c7..702f4b2fa92a 100644 --- a/src/operator/lrn.cu +++ b/src/operator/lrn.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file lrn.cu * \brief * \author Bing Xu diff --git a/src/operator/make_loss-inl.h b/src/operator/make_loss-inl.h index 65af62732373..3f4a99373ca3 100644 --- a/src/operator/make_loss-inl.h +++ b/src/operator/make_loss-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file make_loss-inl.h * \brief special layer for propagating loss */ diff --git a/src/operator/make_loss.cc b/src/operator/make_loss.cc index 1be93def5e87..748357d243f5 100644 --- a/src/operator/make_loss.cc +++ b/src/operator/make_loss.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file make_loss.cc * \brief special layer for propagating loss */ diff --git a/src/operator/make_loss.cu b/src/operator/make_loss.cu index 5f5fad6955fe..7f508500f58e 100644 --- a/src/operator/make_loss.cu +++ b/src/operator/make_loss.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file make_loss.cu * \brief special layer for propagating loss */ diff --git a/src/operator/mshadow_op.h b/src/operator/mshadow_op.h index 8d867043dccd..f7815d2f8d4c 100644 --- a/src/operator/mshadow_op.h +++ b/src/operator/mshadow_op.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file mshadow_op.h * \brief * \author Bing Xu diff --git a/src/operator/mxnet_op.h b/src/operator/mxnet_op.h index 9b5dcfe3d3b1..0af7d026d9d5 100644 --- a/src/operator/mxnet_op.h +++ b/src/operator/mxnet_op.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file mxnet_op.h * \brief * \author Junyuan Xie diff --git a/src/operator/nn/im2col.cuh b/src/operator/nn/im2col.cuh index 786fd22f8c9b..edd5b0dcfb2f 100644 --- a/src/operator/nn/im2col.cuh +++ b/src/operator/nn/im2col.cuh @@ -1,34 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! ******************* BEGIN Caffe Copyright Notice and Disclaimer **************** * * COPYRIGHT - * + * * All contributions by the University of California: * Copyright (c) 2014-2017 The Regents of the University of California (Regents) * All rights reserved. - * + * * All other contributions: * Copyright (c) 2014-2017, the respective contributors * All rights reserved. - * + * * Caffe uses a shared copyright model: each contributor holds copyright over * their contributions to Caffe. The project versioning records all such * contribution and copyright details. If a contributor wants to further mark * their specific copyright on a particular contribution, they should indicate * their copyright solely in the commit message of the change when it is * committed. - * + * * LICENSE - * + * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * + * modification, are permitted provided that the following conditions are met: + * * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. + * list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * + * and/or other materials provided with the distribution. + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -39,9 +58,9 @@ * ON ANY THEORY 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. - * + * * CONTRIBUTION AGREEMENT - * + * * By contributing to the BVLC/caffe repository through pull-request, comment, * or otherwise, the contributor releases their content to the * license and copyright terms herein. @@ -304,7 +323,7 @@ inline void im2col(mshadow::Stream* s, <<::GetStream(s)>>>( num_kernels, data_im, im_shape[2], im_shape[3], kernel_shape[0], kernel_shape[1], - pad[0], pad[1], stride[0], stride[1], dilation[0], dilation[1], + pad[0], pad[1], stride[0], stride[1], dilation[0], dilation[1], col_shape[1], col_shape[2], data_col); break; case 3: diff --git a/src/operator/nn/im2col.h b/src/operator/nn/im2col.h index ce4d9e31db9c..621b2451a19e 100644 --- a/src/operator/nn/im2col.h +++ b/src/operator/nn/im2col.h @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! ******************* BEGIN Caffe Copyright Notice and Disclaimer **************** * @@ -48,7 +67,6 @@ * ***************** END Caffe Copyright Notice and Disclaimer ******************** * - * Copyright (c) 2017 by Contributors * \file im2col.h * \brief Function definitions of converting an image to * column matrix based on kernel, padding, and dilation. diff --git a/src/operator/nn/pool.cuh b/src/operator/nn/pool.cuh index 54fd3461d80f..0e9cff0c51e4 100644 --- a/src/operator/nn/pool.cuh +++ b/src/operator/nn/pool.cuh @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! ******************* BEGIN Caffe Copyright Notice and Disclaimer **************** * diff --git a/src/operator/nn/pool.h b/src/operator/nn/pool.h index 79accb5d521f..3bac86560407 100644 --- a/src/operator/nn/pool.h +++ b/src/operator/nn/pool.h @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! ******************* BEGIN Caffe Copyright Notice and Disclaimer **************** * @@ -48,7 +67,6 @@ * ***************** END Caffe Copyright Notice and Disclaimer ******************** * - * Copyright (c) 2017 by Contributors * \file pool.h * \brief Function definitions of pooling 1/2/3-D images. * We adopted looping 2-D image pixels from Caffe and extended it to 1-D and 3-D cases. diff --git a/src/operator/nn/softmax-inl.h b/src/operator/nn/softmax-inl.h index 749ad7374b96..e1150b14f69d 100644 --- a/src/operator/nn/softmax-inl.h +++ b/src/operator/nn/softmax-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file softmax-inl.h * \brief */ diff --git a/src/operator/nn/softmax.cc b/src/operator/nn/softmax.cc index f1f2078ddce1..58c1a051248e 100644 --- a/src/operator/nn/softmax.cc +++ b/src/operator/nn/softmax.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file softmax.cc * \brief CPU Implementation of softmax */ diff --git a/src/operator/nn/softmax.cu b/src/operator/nn/softmax.cu index 570f5bf15c88..d5a843ddc07b 100644 --- a/src/operator/nn/softmax.cu +++ b/src/operator/nn/softmax.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file softmax.cc * \brief CPU Implementation of softmax */ diff --git a/src/operator/nnpack/nnpack_convolution-inl.h b/src/operator/nnpack/nnpack_convolution-inl.h index 03f4a0bcfdb4..4a1342688969 100644 --- a/src/operator/nnpack/nnpack_convolution-inl.h +++ b/src/operator/nnpack/nnpack_convolution-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file nnpack_convolution-inl.h * \brief * \author Carwin diff --git a/src/operator/nnpack/nnpack_fully_connected-inl.h b/src/operator/nnpack/nnpack_fully_connected-inl.h index 2d87db1e1aec..f85ddd89c702 100644 --- a/src/operator/nnpack/nnpack_fully_connected-inl.h +++ b/src/operator/nnpack/nnpack_fully_connected-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file nnpack_fully_connected-inl.h * \brief * \author Wei Wu diff --git a/src/operator/nnpack/nnpack_pooling-inl.h b/src/operator/nnpack/nnpack_pooling-inl.h index 0df070de812c..968ead16204d 100644 --- a/src/operator/nnpack/nnpack_pooling-inl.h +++ b/src/operator/nnpack/nnpack_pooling-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file nnpack_pooling-inl.h * \brief * \author Wei Wu diff --git a/src/operator/nnpack/nnpack_util.cc b/src/operator/nnpack/nnpack_util.cc index 8004bb1063dc..b873b591fa57 100644 --- a/src/operator/nnpack/nnpack_util.cc +++ b/src/operator/nnpack/nnpack_util.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file nnpack_util.cc * \brief * \author Wei Wu diff --git a/src/operator/nnpack/nnpack_util.h b/src/operator/nnpack/nnpack_util.h index 280c6ffce875..cde1880257a3 100644 --- a/src/operator/nnpack/nnpack_util.h +++ b/src/operator/nnpack/nnpack_util.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file nnpack_util.h * \brief * \author Carwin diff --git a/src/operator/operator.cc b/src/operator/operator.cc index e476c583e668..9117c1c1288a 100644 --- a/src/operator/operator.cc +++ b/src/operator/operator.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file operator.cc * \brief operator module of mxnet */ diff --git a/src/operator/operator_common.h b/src/operator/operator_common.h index a43d092bceb6..2d46bd3230ce 100644 --- a/src/operator/operator_common.h +++ b/src/operator/operator_common.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file operator_common.h * \brief common internal header of most operators * this header includes utility functions operator can use diff --git a/src/operator/operator_util.cc b/src/operator/operator_util.cc index 84a19d6b4b15..25fa209a026c 100644 --- a/src/operator/operator_util.cc +++ b/src/operator/operator_util.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file operator_util.cc * Implementation of operator util. */ diff --git a/src/operator/optimizer_op-inl.h b/src/operator/optimizer_op-inl.h index 9f4959350362..70759b15251a 100644 --- a/src/operator/optimizer_op-inl.h +++ b/src/operator/optimizer_op-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file optimizer_op-inl.h * \brief Optimizer operators * \author Junyuan Xie diff --git a/src/operator/optimizer_op.cc b/src/operator/optimizer_op.cc index 3fdb9c2498fb..b26c333edaef 100644 --- a/src/operator/optimizer_op.cc +++ b/src/operator/optimizer_op.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file optimizer_op.cc * \brief Optimizer operators * \author Junyuan Xie diff --git a/src/operator/optimizer_op.cu b/src/operator/optimizer_op.cu index a30584dd183f..0e74e303dbc9 100644 --- a/src/operator/optimizer_op.cu +++ b/src/operator/optimizer_op.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file optimizer_op.cu * \brief Optimizer operators * \author Junyuan Xie diff --git a/src/operator/pad-inl.h b/src/operator/pad-inl.h index e6e6b7b30327..80f9e0bf92ac 100644 --- a/src/operator/pad-inl.h +++ b/src/operator/pad-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file pad-inl.h * \brief * \author Sebastian Bodenstien diff --git a/src/operator/pad.cc b/src/operator/pad.cc index 77177b5758ec..468629a43672 100644 --- a/src/operator/pad.cc +++ b/src/operator/pad.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file pad.cc * \brief * \author Sebastian Bodenstein diff --git a/src/operator/pad.cu b/src/operator/pad.cu index bf7265cfa342..98220b6c39ef 100644 --- a/src/operator/pad.cu +++ b/src/operator/pad.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file pad.cu * \brief * \author Sebastian Bodenstein diff --git a/src/operator/pooling-inl.h b/src/operator/pooling-inl.h index 8156c3796539..fbc6981a7591 100644 --- a/src/operator/pooling-inl.h +++ b/src/operator/pooling-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file pooling-inl.h * \brief * \author Bing Xu, Jun Wu diff --git a/src/operator/pooling.cc b/src/operator/pooling.cc index 72b17038af9f..51dce873cd04 100644 --- a/src/operator/pooling.cc +++ b/src/operator/pooling.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file pooling.cc * \brief * \author Bing Xu, Jun Wu diff --git a/src/operator/pooling.cu b/src/operator/pooling.cu index bc7716b946af..950f09956258 100644 --- a/src/operator/pooling.cu +++ b/src/operator/pooling.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file pooling.cu * \brief * \author Bing Xu, Jun Wu diff --git a/src/operator/pooling_v1-inl.h b/src/operator/pooling_v1-inl.h index 0b9f7adce62f..e541298ed2ab 100644 --- a/src/operator/pooling_v1-inl.h +++ b/src/operator/pooling_v1-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file pooling_v1-inl.h * \brief * \author Bing Xu diff --git a/src/operator/pooling_v1.cc b/src/operator/pooling_v1.cc index 20acff76a5fb..40de7457520f 100644 --- a/src/operator/pooling_v1.cc +++ b/src/operator/pooling_v1.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file pooling_v1.cc * \brief * \author Bing Xu diff --git a/src/operator/pooling_v1.cu b/src/operator/pooling_v1.cu index 99aebbc6446c..4db22c18420d 100644 --- a/src/operator/pooling_v1.cu +++ b/src/operator/pooling_v1.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file pooling_v1.cu * \brief * \author Bing Xu diff --git a/src/operator/random/multisample_op.cc b/src/operator/random/multisample_op.cc index 303d1d2f0086..f1264e5dc3cc 100644 --- a/src/operator/random/multisample_op.cc +++ b/src/operator/random/multisample_op.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file multisample_op.cc * \brief CPU-implementation of multi-sampling operators */ diff --git a/src/operator/random/multisample_op.h b/src/operator/random/multisample_op.h index 0b5b4cee6217..748b3ba0ccad 100644 --- a/src/operator/random/multisample_op.h +++ b/src/operator/random/multisample_op.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file sampling_op.h * \brief Function definitions of operators for sampling from multiple distributions */ diff --git a/src/operator/random/sample_multinomial_op.cc b/src/operator/random/sample_multinomial_op.cc index 9e6dbe99c045..b358b3b2b4f2 100644 --- a/src/operator/random/sample_multinomial_op.cc +++ b/src/operator/random/sample_multinomial_op.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file sample_multinomial_op.h * \brief Operator for sampling from multinomial distributions */ diff --git a/src/operator/random/sample_multinomial_op.cu b/src/operator/random/sample_multinomial_op.cu index 434202d5e09b..c2bc99b7323e 100644 --- a/src/operator/random/sample_multinomial_op.cu +++ b/src/operator/random/sample_multinomial_op.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file sample_multinomial_op.h * \brief Operator for sampling from multinomial distributions */ diff --git a/src/operator/random/sample_multinomial_op.h b/src/operator/random/sample_multinomial_op.h index ab73ebf0543e..2b016329f390 100644 --- a/src/operator/random/sample_multinomial_op.h +++ b/src/operator/random/sample_multinomial_op.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file sample_multinomial_op.h * \brief Operator for sampling from multinomial distributions */ diff --git a/src/operator/random/sample_op.cc b/src/operator/random/sample_op.cc index 1b3c293548e1..8d87d2b99d14 100644 --- a/src/operator/random/sample_op.cc +++ b/src/operator/random/sample_op.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file sample_op.cc * \brief CPU Implementation of sample op */ @@ -106,7 +124,7 @@ MXNET_OPERATOR_REGISTER_SAMPLE(random_negative_binomial, SampleNegBinomialParam) .add_alias("_sample_negbinomial") .describe(R"code(Draw random samples from a negative binomial distribution. -Samples are distributed according to a negative binomial distribution parametrized by +Samples are distributed according to a negative binomial distribution parametrized by *k* (limit of unsuccessful experiments) and *p* (failure probability in each experiment). Samples will always be returned as a floating point data type. @@ -121,8 +139,8 @@ MXNET_OPERATOR_REGISTER_SAMPLE(random_generalized_negative_binomial, SampleGenNe .add_alias("_sample_gennegbinomial") .describe(R"code(Draw random samples from a generalized negative binomial distribution. -Samples are distributed according to a generalized negative binomial distribution parametrized by -*mu* (mean) and *alpha* (dispersion). *alpha* is defined as *1/k* where *k* is the failure limit of the +Samples are distributed according to a generalized negative binomial distribution parametrized by +*mu* (mean) and *alpha* (dispersion). *alpha* is defined as *1/k* where *k* is the failure limit of the number of unsuccessful experiments (generalized to real numbers). Samples will always be returned as a floating point data type. diff --git a/src/operator/random/sample_op.cu b/src/operator/random/sample_op.cu index 62c8a73249cb..0d4b2e5a8270 100644 --- a/src/operator/random/sample_op.cu +++ b/src/operator/random/sample_op.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file sample_op.cu * \brief GPU Implementation of sample op */ diff --git a/src/operator/random/sample_op.h b/src/operator/random/sample_op.h index 79655b3a3ba1..a1a6a2345b1b 100644 --- a/src/operator/random/sample_op.h +++ b/src/operator/random/sample_op.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file sample_op.h * \brief Elementary sampling operators */ diff --git a/src/operator/regression_output-inl.h b/src/operator/regression_output-inl.h index 7f8b2948ebfa..0de312cff8d6 100644 --- a/src/operator/regression_output-inl.h +++ b/src/operator/regression_output-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file regression_ouput-inl.h * \brief Regression output operator. */ diff --git a/src/operator/regression_output.cc b/src/operator/regression_output.cc index fc71a993d43a..d19f336d2aa2 100644 --- a/src/operator/regression_output.cc +++ b/src/operator/regression_output.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file regression_output.cc * \brief regression output operator */ diff --git a/src/operator/regression_output.cu b/src/operator/regression_output.cu index 18e7a1f4184c..64dcef3df6f0 100644 --- a/src/operator/regression_output.cu +++ b/src/operator/regression_output.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file regression_output.cu * \brief regression output operator */ diff --git a/src/operator/rnn-inl.h b/src/operator/rnn-inl.h index bc5f3d7da6ee..4f09ebe9c3ea 100644 --- a/src/operator/rnn-inl.h +++ b/src/operator/rnn-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file rnn-inl.h * \brief * \author Sebastian Bodenstein diff --git a/src/operator/rnn.cc b/src/operator/rnn.cc index f19c3bbad04b..4c7954f3e5a6 100644 --- a/src/operator/rnn.cc +++ b/src/operator/rnn.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file rnn.cc * \brief * \author Sebastian Bodenstein diff --git a/src/operator/rnn.cu b/src/operator/rnn.cu index 4e3998eac269..0daee32abe5b 100644 --- a/src/operator/rnn.cu +++ b/src/operator/rnn.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file rnn.cu * \brief * \author Sebastian Bodenstein diff --git a/src/operator/roi_pooling-inl.h b/src/operator/roi_pooling-inl.h index 7eb14b7219c7..05a0ae41ab94 100644 --- a/src/operator/roi_pooling-inl.h +++ b/src/operator/roi_pooling-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file roi_pooling-inl.h * \brief roi pooling operator and symbol * \author Kye-Hyeon Kim, Jian Guo diff --git a/src/operator/roi_pooling.cc b/src/operator/roi_pooling.cc index 0faca1e463bc..9af00bb450d4 100644 --- a/src/operator/roi_pooling.cc +++ b/src/operator/roi_pooling.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file roi_pooling.cc * \brief roi pooling operator * \author Ross Girshick, Kye-Hyeon Kim, Jian Guo diff --git a/src/operator/roi_pooling.cu b/src/operator/roi_pooling.cu index 3d744680d009..80d38e476f80 100644 --- a/src/operator/roi_pooling.cu +++ b/src/operator/roi_pooling.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file roi_pooling.cu * \brief roi pooling operator * \author Ross Girshick, Kye-Hyeon Kim, Jian Guo diff --git a/src/operator/sequence_last-inl.h b/src/operator/sequence_last-inl.h index c2acbf164197..0551ee933f0a 100644 --- a/src/operator/sequence_last-inl.h +++ b/src/operator/sequence_last-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file sequence_last-inl.h * \brief * \author Sebastian Bodenstien diff --git a/src/operator/sequence_last.cc b/src/operator/sequence_last.cc index 8a50ff73ec64..6c04bdd34d86 100644 --- a/src/operator/sequence_last.cc +++ b/src/operator/sequence_last.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file sequence_last.cc * \brief * \author Sebastian Bodenstein diff --git a/src/operator/sequence_last.cu b/src/operator/sequence_last.cu index 329c2c77f6b4..9215b2478c1d 100644 --- a/src/operator/sequence_last.cu +++ b/src/operator/sequence_last.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file sequence_last.cu * \brief * \author Sebastian Bodenstein diff --git a/src/operator/sequence_mask-inl.h b/src/operator/sequence_mask-inl.h index 69c98746553b..dec1f2a2b7ed 100644 --- a/src/operator/sequence_mask-inl.h +++ b/src/operator/sequence_mask-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file wl_sequence_mask-inl.h * \brief * \author Sebastian Bodenstien diff --git a/src/operator/sequence_mask.cc b/src/operator/sequence_mask.cc index 0ac782e51c3c..ed90f3ee4a4f 100644 --- a/src/operator/sequence_mask.cc +++ b/src/operator/sequence_mask.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file sequence_mask.cc * \brief * \author Sebastian Bodenstein diff --git a/src/operator/sequence_mask.cu b/src/operator/sequence_mask.cu index 41c08942cdff..d370ff3d13ec 100644 --- a/src/operator/sequence_mask.cu +++ b/src/operator/sequence_mask.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file sequence_mask.cu * \brief * \author Sebastian Bodenstein diff --git a/src/operator/sequence_op_common.h b/src/operator/sequence_op_common.h index a2924921218f..9e5843161087 100644 --- a/src/operator/sequence_op_common.h +++ b/src/operator/sequence_op_common.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file sequence_op_common.h * \brief common function used for sequence layers * \author Sebastian Bodenstein diff --git a/src/operator/sequence_reverse-inl.h b/src/operator/sequence_reverse-inl.h index 0ead25ceba72..0a43138a085c 100644 --- a/src/operator/sequence_reverse-inl.h +++ b/src/operator/sequence_reverse-inl.h @@ -1,5 +1,23 @@ /* - * Copyright (c) 2016 by Contributors + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* * \file sequence_reverse-inl.h * \brief * \author Sebastian Bodenstien diff --git a/src/operator/sequence_reverse.cc b/src/operator/sequence_reverse.cc index 01dcb6810e62..61821d3945f7 100644 --- a/src/operator/sequence_reverse.cc +++ b/src/operator/sequence_reverse.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file sequence_reverse.cc * \brief * \author Sebastian Bodenstein diff --git a/src/operator/sequence_reverse.cu b/src/operator/sequence_reverse.cu index cdd8f348950c..c6cc3f66d0fe 100644 --- a/src/operator/sequence_reverse.cu +++ b/src/operator/sequence_reverse.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file sequence_reverse.cu * \brief * \author Sebastian Bodenstein diff --git a/src/operator/slice_channel-inl.h b/src/operator/slice_channel-inl.h index 69d1f2ad5449..a48c52f0b70e 100644 --- a/src/operator/slice_channel-inl.h +++ b/src/operator/slice_channel-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file slice_channel-inl.h * \brief * \author Bing Xu diff --git a/src/operator/slice_channel.cc b/src/operator/slice_channel.cc index 689f0109214f..7293ba6afcf3 100644 --- a/src/operator/slice_channel.cc +++ b/src/operator/slice_channel.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file slice_channel.cc * \brief * \author Bing Xu @@ -31,7 +49,7 @@ MXNET_REGISTER_OP_PROPERTY(SliceChannel, SliceChannelProp) .. note:: ``SliceChannel`` is deprecated. Use ``split`` instead. -**Note** that `num_outputs` should evenly divide the length of the axis +**Note** that `num_outputs` should evenly divide the length of the axis along which to split the array. Example:: diff --git a/src/operator/slice_channel.cu b/src/operator/slice_channel.cu index 6afd45003ed3..eb1c9c8b6e93 100644 --- a/src/operator/slice_channel.cu +++ b/src/operator/slice_channel.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file slice_channel.cc * \brief * \author Bing Xu diff --git a/src/operator/softmax_activation-inl.h b/src/operator/softmax_activation-inl.h index 0f4bf5f290af..b1b76930b483 100644 --- a/src/operator/softmax_activation-inl.h +++ b/src/operator/softmax_activation-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file softmax_activation-inl.h * \brief SoftmaxActivation operator * \author Junyuan Xie diff --git a/src/operator/softmax_activation.cc b/src/operator/softmax_activation.cc index 827ea03a4fd4..115b0a730cde 100644 --- a/src/operator/softmax_activation.cc +++ b/src/operator/softmax_activation.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file activation.cc * \brief softmax_activation op * \author Junyuan Xie diff --git a/src/operator/softmax_activation.cu b/src/operator/softmax_activation.cu index b2d903a98ae6..5bebed2846b8 100644 --- a/src/operator/softmax_activation.cu +++ b/src/operator/softmax_activation.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file softmax_activation.cu * \brief * \author Junyuan Xie diff --git a/src/operator/softmax_output-inl.h b/src/operator/softmax_output-inl.h index 3bed9387c1db..d14193bdc9fc 100644 --- a/src/operator/softmax_output-inl.h +++ b/src/operator/softmax_output-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file softmax_output-inl.h * \brief * \author Bing Xu diff --git a/src/operator/softmax_output.cc b/src/operator/softmax_output.cc index 08580e9328cd..52bb2a400755 100644 --- a/src/operator/softmax_output.cc +++ b/src/operator/softmax_output.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file softmax_output.cc * \brief * \author Bing Xu diff --git a/src/operator/softmax_output.cu b/src/operator/softmax_output.cu index 7d9324bd2632..8de5df6655f7 100644 --- a/src/operator/softmax_output.cu +++ b/src/operator/softmax_output.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file softmax_output.cu * \brief * \author Bing Xu diff --git a/src/operator/spatial_transformer-inl.h b/src/operator/spatial_transformer-inl.h index 8c02d35ebc44..77967579340f 100644 --- a/src/operator/spatial_transformer-inl.h +++ b/src/operator/spatial_transformer-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file spatial_transformer-inl.h * \brief * Reproducing paper: aderberg M, Simonyan K, Zisserman A. "Spatial transformer networks" diff --git a/src/operator/spatial_transformer.cc b/src/operator/spatial_transformer.cc index 409339b3c445..0d8ee2917637 100644 --- a/src/operator/spatial_transformer.cc +++ b/src/operator/spatial_transformer.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file spatial_transformer.cc * \brief * \author Wei Wu diff --git a/src/operator/spatial_transformer.cu b/src/operator/spatial_transformer.cu index 4942f6573dac..b3d635c5e8ab 100644 --- a/src/operator/spatial_transformer.cu +++ b/src/operator/spatial_transformer.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file spatial_transformer.cu * \brief * \author Wei Wu diff --git a/src/operator/special_functions-inl.h b/src/operator/special_functions-inl.h index 743391e0fce0..b9460a3e7f0f 100644 --- a/src/operator/special_functions-inl.h +++ b/src/operator/special_functions-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file special_functions-inl.h * \brief * \author Valentin Flunkert diff --git a/src/operator/svm_output-inl.h b/src/operator/svm_output-inl.h index 7f460ace8967..f02546144107 100644 --- a/src/operator/svm_output-inl.h +++ b/src/operator/svm_output-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file svm_output-inl.h * \brief * \author Jonas Amaro diff --git a/src/operator/svm_output.cc b/src/operator/svm_output.cc index 5f1f77ad9fc1..766968dfaf0f 100644 --- a/src/operator/svm_output.cc +++ b/src/operator/svm_output.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file svm_output.cc * \brief * \author Jonas Amaro diff --git a/src/operator/svm_output.cu b/src/operator/svm_output.cu index d4b959683287..250df9147f87 100644 --- a/src/operator/svm_output.cu +++ b/src/operator/svm_output.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file svm_output.cu * \brief * \author Jonas Amaro diff --git a/src/operator/swapaxis-inl.h b/src/operator/swapaxis-inl.h index 9595f6e93884..89c724556b8b 100644 --- a/src/operator/swapaxis-inl.h +++ b/src/operator/swapaxis-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file swapaxis-inl.h * \brief * \author Ming Zhang diff --git a/src/operator/swapaxis.cc b/src/operator/swapaxis.cc index 097f9837025f..a6c3e8bff0c7 100644 --- a/src/operator/swapaxis.cc +++ b/src/operator/swapaxis.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file swapaxis.cc * \brief * \author Ming Zhang diff --git a/src/operator/swapaxis.cu b/src/operator/swapaxis.cu index 93f78c2e733d..e9b105d71ea4 100644 --- a/src/operator/swapaxis.cu +++ b/src/operator/swapaxis.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file swapaxis.cu * \brief * \author Ming Zhang diff --git a/src/operator/tensor/broadcast_reduce-inl.cuh b/src/operator/tensor/broadcast_reduce-inl.cuh index 2ba0eb5cec17..b1a259f9b791 100644 --- a/src/operator/tensor/broadcast_reduce-inl.cuh +++ b/src/operator/tensor/broadcast_reduce-inl.cuh @@ -1,605 +1,624 @@ -/*! - * Copyright (c) 2015-2017 by Contributors - * \file broadcast_reduce-inl.cuh - * \brief CUDA implementations for binary broadcast and reduce - * \author Antti-Pekka Hynninen -*/ -#ifndef MXNET_OPERATOR_TENSOR_BROADCAST_REDUCE_INL_CUH_ -#define MXNET_OPERATOR_TENSOR_BROADCAST_REDUCE_INL_CUH_ - -using namespace mshadow::cuda; - -template -__launch_bounds__(kMaxThreadsPerBlock) -__global__ void binary_broadcast_kernel(const int N, const bool addto, - const DType* __restrict lhs, - const DType* __restrict rhs, DType *out, - const Shape lstride, const Shape rstride, - const Shape oshape) { - for (int idx = blockIdx.x * blockDim.x * unroll + threadIdx.x; idx < N; - idx += blockDim.x * gridDim.x * unroll) - { - int j[unroll]; - int k[unroll]; - DType val[unroll]; - #pragma unroll - for (int i=0;i < unroll;i++) { - unravel_dot(idx + i*blockDim.x, oshape, lstride, rstride, &j[i], &k[i]); - val[i] = OP::Map(lhs[j[i]], rhs[k[i]]); - } - #pragma unroll - for (int i=0;i < unroll;i++) { - if (idx + i*blockDim.x < N) assign(&out[idx + i*blockDim.x], addto, val[i]); - } - - } -} - -template -void BinaryBroadcastComputeImpl(Stream *s, const OpReqType req, - const TBlob& lhs, const TBlob& rhs, const TBlob& out) { - if (req == kNullOp) return; - cudaStream_t stream = Stream::GetStream(s); - int N = out.shape_.Size(); - const int warpSize = 32; - const int unroll = 2; - int nthread = std::min(kMaxThreadsPerBlock, ((N + warpSize - 1)/warpSize)*warpSize ); - int ngrid = std::min(kBaseGridNum, (N + nthread*unroll - 1) / (nthread*unroll)); - Shape lstride = calc_stride(lhs.shape_.get()); - Shape rstride = calc_stride(rhs.shape_.get()); - binary_broadcast_kernel<<>>( - N, req == kAddTo, lhs.dptr(), rhs.dptr(), out.dptr(), lstride, rstride, - out.shape_.get()); -} - -const int nthread_reduce = kMaxThreadsPerBlock; -template -__launch_bounds__(nthread_reduce) -__global__ void reduce_kernel(const int N, const int M, const bool addto, - const DType* __restrict big, DType *small, - const Shape big_shape0, const Shape small_shape, - const Shape big_shape, const Shape big_stride, - const int Mnext, const bool do_transpose) { - extern __shared__ char shTileChar[]; - DType* shTile = (DType*)(shTileChar); - const int tid = threadIdx.x + threadIdx.y*blockDim.x; - const int bx = (do_transpose) ? blockDim.y : blockDim.x; - const int by = (do_transpose) ? blockDim.x : blockDim.y; - const int tidx = (do_transpose) ? tid / by : threadIdx.x; - const int tidy = (do_transpose) ? tid % by : threadIdx.y; - for (int m0 = blockIdx.y; m0 < Mnext; m0 += gridDim.y) { - // This TB handles M range [Mstart, ...., Mend - 1] - const int Mstart = (int)((uint64_t)M*(uint64_t)m0/(uint64_t)Mnext); - const int Mend = (int)((uint64_t)M*(uint64_t)(m0 + 1)/(uint64_t)Mnext); - for (int idx0 = blockIdx.x*bx; idx0 < N; idx0 += bx*gridDim.x) { - int idx = idx0 + tidx; - Shape coord = unravel(idx, small_shape); - int idx_big0 = ravel(coord, big_shape0); - - DType val; - Reducer::SetInitValue(val); - if (idx < N) { - for (int k = tidy + Mstart; k < Mend; k += by*unroll) { - int idx_big[unroll]; - #pragma unroll - for (int u=0;u < unroll;u++) { - idx_big[u] = idx_big0 + unravel_dot(k + u*by, big_shape, big_stride); - } - DType tmp[unroll]; - #pragma unroll - for (int u=0;u < unroll;u++) { - if (k + u*by < Mend) { - tmp[u] = OP::Map(big[idx_big[u]]); - } - } - #pragma unroll - for (int u=0;u < unroll;u++) { - if (k + u*by < Mend) Reducer::Reduce(val, tmp[u]); - } - } - } - - // Shared memory block bx * by. Reduction is along by. Final result is in tidy=0 - if (by > 1) { - // Fix bx to avoid bank conflicts. Assumes warpSize number of banks - const int fbx = (do_transpose && ((bx & (warpSize - 1)) == 0)) ? (bx + 1) : bx; - const int it0 = tidx + tidy*fbx; - shTile[it0] = val; - __syncthreads(); - for (int t=1;t < by;t <<= 1) { - DType tmp; - Reducer::SetInitValue(tmp); - if (tidy + t < by) tmp = shTile[it0 + t*fbx]; - __syncthreads(); - Reducer::Reduce(shTile[it0], tmp); - __syncthreads(); - } - if (idx < N && tidy == 0) { - assign(&small[idx + m0*N], addto, shTile[tidx]); - } - } else { - if (idx < N) { - assign(&small[idx + m0*N], addto, val); - } - } - } - } - -} - -template -__launch_bounds__(nthread_reduce) -__global__ void reduce_kernel(const int N, const int M, const bool addto, - const DType* __restrict big, const DType* __restrict lhs, - const DType* __restrict rhs, DType *small, - const Shape big_shape0, const Shape lhs_shape0, - const Shape rhs_shape0, const Shape small_shape, - const Shape big_shape, const Shape lhs_shape, - const Shape rhs_shape, const Shape big_stride, - const Shape lhs_stride, const Shape rhs_stride, - const int Mnext, const bool do_transpose) { - extern __shared__ char shTileChar[]; - DType* shTile = (DType*)(shTileChar); - const int tid = threadIdx.x + threadIdx.y*blockDim.x; - const int bx = (do_transpose) ? blockDim.y : blockDim.x; - const int by = (do_transpose) ? blockDim.x : blockDim.y; - const int tidx = (do_transpose) ? tid / by : threadIdx.x; - const int tidy = (do_transpose) ? tid % by : threadIdx.y; - for (int m0 = blockIdx.y; m0 < Mnext; m0 += gridDim.y) { - // This TB handles M range [Mstart, ...., Mend - 1] - const int Mstart = (int)((uint64_t)M*(uint64_t)m0/(uint64_t)Mnext); - const int Mend = (int)((uint64_t)M*(uint64_t)(m0 + 1)/(uint64_t)Mnext); - for (int idx0 = blockIdx.x*bx; idx0 < N; idx0 += bx*gridDim.x) { - int idx = idx0 + tidx; - Shape coord = unravel(idx, small_shape); - int idx_big0 = ravel(coord, big_shape0); - int idx_lhs0 = ravel(coord, lhs_shape0); - int idx_rhs0 = ravel(coord, rhs_shape0); - - DType val; - Reducer::SetInitValue(val); - if (idx < N) { - for (int k = tidy + Mstart; k < Mend; k += by*unroll) { - int idx_big[unroll]; - int idx_lhs[unroll]; - int idx_rhs[unroll]; - #pragma unroll - for (int u=0;u < unroll;u++) { - idx_big[u] = idx_big0 + unravel_dot(k + u*by, big_shape, big_stride); - idx_lhs[u] = idx_lhs0 + unravel_dot(k + u*by, lhs_shape, lhs_stride); - idx_rhs[u] = idx_rhs0 + unravel_dot(k + u*by, rhs_shape, rhs_stride); - } - DType tmp[unroll]; - #pragma unroll - for (int u=0;u < unroll;u++) { - if (k + u*by < Mend) { - tmp[u] = OP1::Map(big[idx_big[u]], OP2::Map(lhs[idx_lhs[u]], rhs[idx_rhs[u]])); - } - } - #pragma unroll - for (int u=0;u < unroll;u++) { - if (k + u*by < Mend) Reducer::Reduce(val, tmp[u]); - } - } - } - - // Shared memory block bx * by. Reduction is along by. Final result is in tidy=0 - if (by > 1) { - // Fix bx to avoid bank conflicts. Assumes warpSize number of banks - const int fbx = (do_transpose && ((bx & (warpSize - 1)) == 0)) ? (bx + 1) : bx; - const int it0 = tidx + tidy*fbx; - shTile[it0] = val; - __syncthreads(); - for (int t=1;t < by;t <<= 1) { - DType tmp; - Reducer::SetInitValue(tmp); - if (tidy + t < by) tmp = shTile[it0 + t*fbx]; - __syncthreads(); - Reducer::Reduce(shTile[it0], tmp); - __syncthreads(); - } - if (idx < N && tidy == 0) { - assign(&small[idx + m0*N], addto, shTile[tidx]); - } - } else { - if (idx < N) { - assign(&small[idx + m0*N], addto, val); - } - } - } - } - -} - -// Simple reduction of lines when M is small -template -__launch_bounds__(kMaxThreadsPerBlock) -__global__ void reduce_lines_kernel(const int N, const int M, const bool addto, - const int small_in_stride, const DType* __restrict small_in, DType *small_out) { - for (int idx = threadIdx.x + blockIdx.x*blockDim.x; idx < N; idx += blockDim.x*gridDim.x) { - - DType val; - Reducer::SetInitValue(val); - for (int k = 0; k < M; k++) { - Reducer::Reduce(val, small_in[idx + k*small_in_stride]); - } - - if (idx < N) { - assign(&small_out[idx], addto, val); - } - - } -} - -template -__global__ void reduce_kernel_M1(const int N, const bool addto, - const DType* __restrict big, DType *small, const Shape bshape, - const Shape sshape) { - for (int idx = threadIdx.x + blockIdx.x*blockDim.x; idx < N; idx += blockDim.x*gridDim.x) { - Shape coord = unravel(idx, sshape); - int j = ravel(coord, bshape); - assign(&small[idx], addto, OP::Map(big[j])); - } -} - -template -__global__ void reduce_kernel_M1(const int N, const bool addto, - const DType* __restrict big, - const DType* __restrict lhs, - const DType* __restrict rhs, - DType *small, - const Shape big_shape, - const Shape lhs_shape, - const Shape rhs_shape, - const Shape small_shape) { - for (int idx = threadIdx.x + blockIdx.x*blockDim.x; idx < N; idx += blockDim.x*gridDim.x) { - Shape coord = unravel(idx, small_shape); - int idx_big = ravel(coord, big_shape); - int idx_lhs = ravel(coord, lhs_shape); - int idx_rhs = ravel(coord, rhs_shape); - DType val = OP1::Map(big[idx_big], OP2::Map(lhs[idx_lhs], rhs[idx_rhs])); - assign(&small[idx], addto, val); - } -} - -// Returns the stride with which the fastest dimension is moving. -// Used to detect memory access scatter. -template -MSHADOW_XINLINE int fastest_stride(const Shape& small, const Shape& big, - const Shape& big_stride) { - for (int i = ndim-1; i >= 0; --i) { - if (big[i] != 1) { - return (small[i] == big[i]) ? 1 : big_stride[i]; - } - } - return 1; -} - -// Returns a/b integer division rounded up -template -Type ceil_idiv(const Type a, const Type b) { - return (a + b - 1)/b; -} - -// Configuration for ReduceImpl() -template -struct ReduceImplConfig { - static const int warpSize = 32; - static const int unroll_reduce = 2; - static const int maxLoopPerTB = 64; - int N; - int M; - int Mnext; - struct { - dim3 blockDim; - dim3 gridDim; - int shMemSize; - bool do_transpose; - } kernel_1; - struct { - int blockSize; - int gridSize; - } kernel_2; - size_t workspace_size; - - Shape rshape, rstride; - Shape lhs_shape, lhs_stride; - Shape rhs_shape, rhs_stride; -}; - -static inline uint64_t calc_num_load(const int X, const int Y, const int* strides) { - const int warpSize = ReduceImplConfig<1>::warpSize; - // Number of full warps - uint64_t num_full_warp = X / warpSize; - // Length of the partial warp i.e. number of threads that are performing loads - uint64_t len_part_warp = X % warpSize; - - uint64_t num_load_full = (std::min(warpSize, strides[0]) + - std::min(warpSize, strides[1]) + - std::min(warpSize, strides[2]))*num_full_warp; - - uint64_t num_load_part = - (std::min(len_part_warp, ceil_idiv(len_part_warp*strides[0], warpSize)) + - std::min(len_part_warp, ceil_idiv(len_part_warp*strides[1], warpSize)) + - std::min(len_part_warp, ceil_idiv(len_part_warp*strides[2], warpSize)))* - (len_part_warp != 0); - - uint64_t num_load = (num_load_full + num_load_part)*(uint64_t)Y; - return num_load; -} - -template -ReduceImplConfig ConfigureReduceImpl(const TBlob& small, const TBlob& big, const TBlob* lhs, - const TBlob* rhs) { - - ReduceImplConfig config; - - diff(small.shape_.get(), big.shape_.get(), &config.rshape, &config.rstride); - config.N = small.shape_.Size(); - config.M = config.rshape.Size(); - - bool multiOp = false; - if (lhs != NULL) { - CHECK_NOTNULL(rhs); - diff(small.shape_.get(), lhs->shape_.get(), &config.lhs_shape, - &config.lhs_stride); - diff(small.shape_.get(), rhs->shape_.get(), &config.rhs_shape, - &config.rhs_stride); - multiOp = true; - } - - config.workspace_size = 0; - - if (config.M == 1) { - config.kernel_1.blockDim.x = kMaxThreadsPerBlock; - config.kernel_1.gridDim.x = std::min((unsigned int)kBaseGridNum, - (config.N + config.kernel_1.blockDim.x - 1)/config.kernel_1.blockDim.x); - } else { - - int reduce_strides[3]; - reduce_strides[0] = fastest_stride(small.shape_.get(), big.shape_.get(), - big.shape_.get()); - reduce_strides[1] = (multiOp) ? fastest_stride(small.shape_.get(), - lhs->shape_.get(), lhs->shape_.get()) : 1; - reduce_strides[2] = (multiOp) ? fastest_stride(small.shape_.get(), - rhs->shape_.get(), rhs->shape_.get()) : 1; - - int reduce_strides_transp[3]; - reduce_strides_transp[0] = fastest_stride(small.shape_.get(), config.rshape, - config.rstride); - reduce_strides_transp[1] = (multiOp) ? - fastest_stride(small.shape_.get(), config.lhs_shape, config.lhs_stride) : 1; - reduce_strides_transp[2] = (multiOp) ? - fastest_stride(small.shape_.get(), config.rhs_shape, config.rhs_stride) : 1; - - uint64_t num_load = calc_num_load(config.N, config.M, reduce_strides); - uint64_t num_load_transp = calc_num_load(config.M, config.N, reduce_strides_transp); - - config.Mnext = 1; - config.kernel_1.do_transpose = (num_load > num_load_transp); - - config.kernel_1.blockDim.x = 0; - config.kernel_1.blockDim.y = 0; - - if (config.kernel_1.do_transpose) { - // Fastest thread ID goes through M - // Loop over N has step size config.kernel_1.blockDim.y - if (config.N < 8) { - config.kernel_1.blockDim.y = 1; - } else if (config.N < 256) { - config.kernel_1.blockDim.y = 4; - } else { - if (config.M < 8) { - config.kernel_1.blockDim.x = 1; - } else if (config.M < 256) { - config.kernel_1.blockDim.x = 4; - } else { - config.kernel_1.blockDim.x = config.warpSize; - } - } - } else { - // Fastest thread ID goes through N - // Loop over M has step size config.kernel_1.blockDim.y - if (config.M < 8) { - config.kernel_1.blockDim.y = 1; - } else if (config.M < 256) { - config.kernel_1.blockDim.y = 4; - } else { - if (config.N < 8) { - config.kernel_1.blockDim.x = 1; - } else if (config.N < 256) { - config.kernel_1.blockDim.x = 4; - } else { - config.kernel_1.blockDim.x = config.warpSize; - } - } - } - - if (config.kernel_1.blockDim.x == 0 && config.kernel_1.blockDim.y == 0) { - LOG(FATAL) << "Unable to set blockDim"; - } else if (config.kernel_1.blockDim.x == 0) { - config.kernel_1.blockDim.x = nthread_reduce / config.kernel_1.blockDim.y; - } else if (config.kernel_1.blockDim.y == 0) { - config.kernel_1.blockDim.y = nthread_reduce / config.kernel_1.blockDim.x; - } - - if (config.kernel_1.do_transpose) { - // Fastest thread ID goes through M - config.kernel_1.gridDim.x = std::min((unsigned int)kBaseGridNum, - ceil_idiv(config.N, config.kernel_1.blockDim.y)); - config.kernel_1.gridDim.y = std::min(kBaseGridNum, config.Mnext); - int by = config.kernel_1.blockDim.y; - if (config.kernel_1.blockDim.y % config.warpSize == 0) { - // Fix shared memory bank conflict - by++; - } - config.kernel_1.shMemSize = (config.kernel_1.blockDim.x > 1) ? - config.kernel_1.blockDim.x*by*sizeof(DType) : 0; - // Maximum number of times we want TB to loop in M - // Max size of M-block each TB can handle - int maxMblock = config.kernel_1.blockDim.x*config.maxLoopPerTB; - config.Mnext = (config.M + maxMblock - 1) / maxMblock; - } else { - // Fastest thread ID goes through N - config.kernel_1.gridDim.x = std::min((unsigned int)kBaseGridNum, - ceil_idiv(config.N, config.kernel_1.blockDim.x)); - config.kernel_1.gridDim.y = std::min(kBaseGridNum, config.Mnext); - config.kernel_1.shMemSize = (config.kernel_1.blockDim.y > 1) ? - config.kernel_1.blockDim.x*config.kernel_1.blockDim.y*sizeof(DType) : 0; - // Maximum number of times we want TB to loop in M - // Max size of M-block each TB can handle - int maxMblock = config.kernel_1.blockDim.y*config.maxLoopPerTB; - config.Mnext = (config.M + maxMblock - 1) / maxMblock; - } - - if (config.Mnext > 1) { - // small_dptr[] is N*Mnext*sizeof(DType) bytes - config.workspace_size += config.N*config.Mnext*sizeof(DType); - // Set gridDim.y to Mnext - config.kernel_1.gridDim.y = std::min(kBaseGridNum, config.Mnext); - } - - if (config.Mnext > 1) { - config.kernel_2.blockSize = kMaxThreadsPerBlock; - config.kernel_2.gridSize = std::min((int)kBaseGridNum, - (config.N + config.kernel_2.blockSize - 1)/config.kernel_2.blockSize ); - } - - } - - return config; -} - -#define KERNEL_UNROLL_SWITCH(do_unroll, unrollAmount, unrollVar, ...) \ - if (do_unroll) { \ - const int unrollVar = unrollAmount; \ - {__VA_ARGS__} \ - } else { \ - const int unrollVar = 1; \ - {__VA_ARGS__} \ - } - -template -void ReduceImpl(cudaStream_t stream, const TBlob& small, const OpReqType req, - const TBlob& big, const Tensor& workspace, - const ReduceImplConfig& config) { - if (config.M == 1) { - reduce_kernel_M1 - <<< config.kernel_1.gridDim, config.kernel_1.blockDim, 0, stream >>>( - config.N, req == kAddTo, big.dptr(), small.dptr(), big.shape_.get(), - small.shape_.get()); - } else { - - DType* small_dptr = small.dptr(); - bool addto = (req == kAddTo); - if (config.Mnext > 1) { - // small_dptr[] is N*Mnext*sizeof(DType) bytes - small_dptr = reinterpret_cast(workspace.dptr_); - addto = false; - // Check that the workspace is contigiuous - CHECK_EQ(workspace.CheckContiguous(), true); - // Check that we have enough storage - CHECK_GE(workspace.size(0), config.workspace_size); - } - - const int by = (config.kernel_1.do_transpose) ? - config.kernel_1.blockDim.x : config.kernel_1.blockDim.y; - const bool do_unroll = ( config.M / (by*config.Mnext) >= config.unroll_reduce ); - KERNEL_UNROLL_SWITCH(do_unroll, ReduceImplConfig::unroll_reduce, UNROLL, { - reduce_kernel - <<< config.kernel_1.gridDim, config.kernel_1.blockDim, config.kernel_1.shMemSize, stream>>>( - config.N, config.M, addto, big.dptr(), small_dptr, big.shape_.get(), - small.shape_.get(), config.rshape, config.rstride, config.Mnext, - config.kernel_1.do_transpose); - }); - - if (config.Mnext > 1) { - reduce_lines_kernel - <<< config.kernel_2.gridSize, config.kernel_2.blockSize, 0, stream >>> - (config.N, config.Mnext, req == kAddTo, config.N, small_dptr, small.dptr()); - } - } -} - -template -void ReduceImpl(cudaStream_t stream, const TBlob& small, const TBlob& lhs, const TBlob& rhs, - const OpReqType req, const TBlob& big, const Tensor& workspace, - const ReduceImplConfig& config) { - if (config.M == 1) { - reduce_kernel_M1 - <<< config.kernel_1.gridDim, config.kernel_1.blockDim, 0, stream >>>( - config.N, req == kAddTo, big.dptr(), lhs.dptr(), rhs.dptr(), - small.dptr(), big.shape_.get(), lhs.shape_.get(), - rhs.shape_.get(), small.shape_.get()); - } else { - DType* small_dptr = small.dptr(); - bool addto = (req == kAddTo); - if (config.Mnext > 1) { - // small_dptr[] is N*Mnext*sizeof(DType) bytes - small_dptr = reinterpret_cast(workspace.dptr_); - addto = false; - // Check that the workspace is contigiuous - CHECK_EQ(workspace.CheckContiguous(), true); - // Check that we have enough storage - CHECK_GE(workspace.size(0), config.workspace_size); - } - - const int by = (config.kernel_1.do_transpose) ? - config.kernel_1.blockDim.x : config.kernel_1.blockDim.y; - const bool do_unroll = ( config.M / (by*config.Mnext) >= config.unroll_reduce ); - KERNEL_UNROLL_SWITCH(do_unroll, ReduceImplConfig::unroll_reduce, UNROLL, { - reduce_kernel - <<< config.kernel_1.gridDim, config.kernel_1.blockDim, config.kernel_1.shMemSize, stream>>>( - config.N, config.M, addto, big.dptr(), lhs.dptr(), rhs.dptr(), - small_dptr, big.shape_.get(), lhs.shape_.get(), - rhs.shape_.get(), small.shape_.get(), config.rshape, config.lhs_shape, - config.rhs_shape, config.rstride, config.lhs_stride, config.rhs_stride, config.Mnext, - config.kernel_1.do_transpose); - }); - - if (config.Mnext > 1) { - reduce_lines_kernel - <<< config.kernel_2.gridSize, config.kernel_2.blockSize, 0, stream >>> - (config.N, config.Mnext, req == kAddTo, config.N, small_dptr, small.dptr()); - } - } -} - -#undef KERNEL_UNROLL_SWITCH - -template -void Reduce(Stream *s, const TBlob& small, const OpReqType req, - const Tensor& workspace, const TBlob& big) { - if (req == kNullOp) return; - cudaStream_t stream = Stream::GetStream(s); - ReduceImplConfig config = ConfigureReduceImpl(small, big, NULL, NULL); - ReduceImpl(stream, small, req, big, workspace, config); -} - -template -void Reduce(Stream *s, const TBlob& small, const OpReqType req, - const Tensor& workspace, const TBlob& big, - const TBlob& lhs, const TBlob& rhs) { - if (req == kNullOp) return; - cudaStream_t stream = Stream::GetStream(s); - ReduceImplConfig config = ConfigureReduceImpl(small, big, &lhs, &rhs); - ReduceImpl(stream, small, lhs, rhs, req, big, workspace, config); -} - -template -size_t ReduceWorkspaceSize(Stream *s, const TBlob& small, const OpReqType req, - const TBlob& big) { - if (req == kNullOp) return 0; - ReduceImplConfig config = ConfigureReduceImpl(small, big, NULL, NULL); - return config.workspace_size; -} - -template -size_t ReduceWorkspaceSize(Stream *s, const TBlob& small, const OpReqType req, - const TBlob& big, const TBlob& lhs, const TBlob& rhs) { - if (req == kNullOp) return 0; - ReduceImplConfig config = ConfigureReduceImpl(small, big, &lhs, &rhs); - return config.workspace_size; -} - -#endif //MXNET_OPERATOR_TENSOR_BROADCAST_REDUCE_INL_CUH_ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/*! + * Copyright (c) 2015-2017 by Contributors + * \file broadcast_reduce-inl.cuh + * \brief CUDA implementations for binary broadcast and reduce + * \author Antti-Pekka Hynninen +*/ +#ifndef MXNET_OPERATOR_TENSOR_BROADCAST_REDUCE_INL_CUH_ +#define MXNET_OPERATOR_TENSOR_BROADCAST_REDUCE_INL_CUH_ + +using namespace mshadow::cuda; + +template +__launch_bounds__(kMaxThreadsPerBlock) +__global__ void binary_broadcast_kernel(const int N, const bool addto, + const DType* __restrict lhs, + const DType* __restrict rhs, DType *out, + const Shape lstride, const Shape rstride, + const Shape oshape) { + for (int idx = blockIdx.x * blockDim.x * unroll + threadIdx.x; idx < N; + idx += blockDim.x * gridDim.x * unroll) + { + int j[unroll]; + int k[unroll]; + DType val[unroll]; + #pragma unroll + for (int i=0;i < unroll;i++) { + unravel_dot(idx + i*blockDim.x, oshape, lstride, rstride, &j[i], &k[i]); + val[i] = OP::Map(lhs[j[i]], rhs[k[i]]); + } + #pragma unroll + for (int i=0;i < unroll;i++) { + if (idx + i*blockDim.x < N) assign(&out[idx + i*blockDim.x], addto, val[i]); + } + + } +} + +template +void BinaryBroadcastComputeImpl(Stream *s, const OpReqType req, + const TBlob& lhs, const TBlob& rhs, const TBlob& out) { + if (req == kNullOp) return; + cudaStream_t stream = Stream::GetStream(s); + int N = out.shape_.Size(); + const int warpSize = 32; + const int unroll = 2; + int nthread = std::min(kMaxThreadsPerBlock, ((N + warpSize - 1)/warpSize)*warpSize ); + int ngrid = std::min(kBaseGridNum, (N + nthread*unroll - 1) / (nthread*unroll)); + Shape lstride = calc_stride(lhs.shape_.get()); + Shape rstride = calc_stride(rhs.shape_.get()); + binary_broadcast_kernel<<>>( + N, req == kAddTo, lhs.dptr(), rhs.dptr(), out.dptr(), lstride, rstride, + out.shape_.get()); +} + +const int nthread_reduce = kMaxThreadsPerBlock; +template +__launch_bounds__(nthread_reduce) +__global__ void reduce_kernel(const int N, const int M, const bool addto, + const DType* __restrict big, DType *small, + const Shape big_shape0, const Shape small_shape, + const Shape big_shape, const Shape big_stride, + const int Mnext, const bool do_transpose) { + extern __shared__ char shTileChar[]; + DType* shTile = (DType*)(shTileChar); + const int tid = threadIdx.x + threadIdx.y*blockDim.x; + const int bx = (do_transpose) ? blockDim.y : blockDim.x; + const int by = (do_transpose) ? blockDim.x : blockDim.y; + const int tidx = (do_transpose) ? tid / by : threadIdx.x; + const int tidy = (do_transpose) ? tid % by : threadIdx.y; + for (int m0 = blockIdx.y; m0 < Mnext; m0 += gridDim.y) { + // This TB handles M range [Mstart, ...., Mend - 1] + const int Mstart = (int)((uint64_t)M*(uint64_t)m0/(uint64_t)Mnext); + const int Mend = (int)((uint64_t)M*(uint64_t)(m0 + 1)/(uint64_t)Mnext); + for (int idx0 = blockIdx.x*bx; idx0 < N; idx0 += bx*gridDim.x) { + int idx = idx0 + tidx; + Shape coord = unravel(idx, small_shape); + int idx_big0 = ravel(coord, big_shape0); + + DType val; + Reducer::SetInitValue(val); + if (idx < N) { + for (int k = tidy + Mstart; k < Mend; k += by*unroll) { + int idx_big[unroll]; + #pragma unroll + for (int u=0;u < unroll;u++) { + idx_big[u] = idx_big0 + unravel_dot(k + u*by, big_shape, big_stride); + } + DType tmp[unroll]; + #pragma unroll + for (int u=0;u < unroll;u++) { + if (k + u*by < Mend) { + tmp[u] = OP::Map(big[idx_big[u]]); + } + } + #pragma unroll + for (int u=0;u < unroll;u++) { + if (k + u*by < Mend) Reducer::Reduce(val, tmp[u]); + } + } + } + + // Shared memory block bx * by. Reduction is along by. Final result is in tidy=0 + if (by > 1) { + // Fix bx to avoid bank conflicts. Assumes warpSize number of banks + const int fbx = (do_transpose && ((bx & (warpSize - 1)) == 0)) ? (bx + 1) : bx; + const int it0 = tidx + tidy*fbx; + shTile[it0] = val; + __syncthreads(); + for (int t=1;t < by;t <<= 1) { + DType tmp; + Reducer::SetInitValue(tmp); + if (tidy + t < by) tmp = shTile[it0 + t*fbx]; + __syncthreads(); + Reducer::Reduce(shTile[it0], tmp); + __syncthreads(); + } + if (idx < N && tidy == 0) { + assign(&small[idx + m0*N], addto, shTile[tidx]); + } + } else { + if (idx < N) { + assign(&small[idx + m0*N], addto, val); + } + } + } + } + +} + +template +__launch_bounds__(nthread_reduce) +__global__ void reduce_kernel(const int N, const int M, const bool addto, + const DType* __restrict big, const DType* __restrict lhs, + const DType* __restrict rhs, DType *small, + const Shape big_shape0, const Shape lhs_shape0, + const Shape rhs_shape0, const Shape small_shape, + const Shape big_shape, const Shape lhs_shape, + const Shape rhs_shape, const Shape big_stride, + const Shape lhs_stride, const Shape rhs_stride, + const int Mnext, const bool do_transpose) { + extern __shared__ char shTileChar[]; + DType* shTile = (DType*)(shTileChar); + const int tid = threadIdx.x + threadIdx.y*blockDim.x; + const int bx = (do_transpose) ? blockDim.y : blockDim.x; + const int by = (do_transpose) ? blockDim.x : blockDim.y; + const int tidx = (do_transpose) ? tid / by : threadIdx.x; + const int tidy = (do_transpose) ? tid % by : threadIdx.y; + for (int m0 = blockIdx.y; m0 < Mnext; m0 += gridDim.y) { + // This TB handles M range [Mstart, ...., Mend - 1] + const int Mstart = (int)((uint64_t)M*(uint64_t)m0/(uint64_t)Mnext); + const int Mend = (int)((uint64_t)M*(uint64_t)(m0 + 1)/(uint64_t)Mnext); + for (int idx0 = blockIdx.x*bx; idx0 < N; idx0 += bx*gridDim.x) { + int idx = idx0 + tidx; + Shape coord = unravel(idx, small_shape); + int idx_big0 = ravel(coord, big_shape0); + int idx_lhs0 = ravel(coord, lhs_shape0); + int idx_rhs0 = ravel(coord, rhs_shape0); + + DType val; + Reducer::SetInitValue(val); + if (idx < N) { + for (int k = tidy + Mstart; k < Mend; k += by*unroll) { + int idx_big[unroll]; + int idx_lhs[unroll]; + int idx_rhs[unroll]; + #pragma unroll + for (int u=0;u < unroll;u++) { + idx_big[u] = idx_big0 + unravel_dot(k + u*by, big_shape, big_stride); + idx_lhs[u] = idx_lhs0 + unravel_dot(k + u*by, lhs_shape, lhs_stride); + idx_rhs[u] = idx_rhs0 + unravel_dot(k + u*by, rhs_shape, rhs_stride); + } + DType tmp[unroll]; + #pragma unroll + for (int u=0;u < unroll;u++) { + if (k + u*by < Mend) { + tmp[u] = OP1::Map(big[idx_big[u]], OP2::Map(lhs[idx_lhs[u]], rhs[idx_rhs[u]])); + } + } + #pragma unroll + for (int u=0;u < unroll;u++) { + if (k + u*by < Mend) Reducer::Reduce(val, tmp[u]); + } + } + } + + // Shared memory block bx * by. Reduction is along by. Final result is in tidy=0 + if (by > 1) { + // Fix bx to avoid bank conflicts. Assumes warpSize number of banks + const int fbx = (do_transpose && ((bx & (warpSize - 1)) == 0)) ? (bx + 1) : bx; + const int it0 = tidx + tidy*fbx; + shTile[it0] = val; + __syncthreads(); + for (int t=1;t < by;t <<= 1) { + DType tmp; + Reducer::SetInitValue(tmp); + if (tidy + t < by) tmp = shTile[it0 + t*fbx]; + __syncthreads(); + Reducer::Reduce(shTile[it0], tmp); + __syncthreads(); + } + if (idx < N && tidy == 0) { + assign(&small[idx + m0*N], addto, shTile[tidx]); + } + } else { + if (idx < N) { + assign(&small[idx + m0*N], addto, val); + } + } + } + } + +} + +// Simple reduction of lines when M is small +template +__launch_bounds__(kMaxThreadsPerBlock) +__global__ void reduce_lines_kernel(const int N, const int M, const bool addto, + const int small_in_stride, const DType* __restrict small_in, DType *small_out) { + for (int idx = threadIdx.x + blockIdx.x*blockDim.x; idx < N; idx += blockDim.x*gridDim.x) { + + DType val; + Reducer::SetInitValue(val); + for (int k = 0; k < M; k++) { + Reducer::Reduce(val, small_in[idx + k*small_in_stride]); + } + + if (idx < N) { + assign(&small_out[idx], addto, val); + } + + } +} + +template +__global__ void reduce_kernel_M1(const int N, const bool addto, + const DType* __restrict big, DType *small, const Shape bshape, + const Shape sshape) { + for (int idx = threadIdx.x + blockIdx.x*blockDim.x; idx < N; idx += blockDim.x*gridDim.x) { + Shape coord = unravel(idx, sshape); + int j = ravel(coord, bshape); + assign(&small[idx], addto, OP::Map(big[j])); + } +} + +template +__global__ void reduce_kernel_M1(const int N, const bool addto, + const DType* __restrict big, + const DType* __restrict lhs, + const DType* __restrict rhs, + DType *small, + const Shape big_shape, + const Shape lhs_shape, + const Shape rhs_shape, + const Shape small_shape) { + for (int idx = threadIdx.x + blockIdx.x*blockDim.x; idx < N; idx += blockDim.x*gridDim.x) { + Shape coord = unravel(idx, small_shape); + int idx_big = ravel(coord, big_shape); + int idx_lhs = ravel(coord, lhs_shape); + int idx_rhs = ravel(coord, rhs_shape); + DType val = OP1::Map(big[idx_big], OP2::Map(lhs[idx_lhs], rhs[idx_rhs])); + assign(&small[idx], addto, val); + } +} + +// Returns the stride with which the fastest dimension is moving. +// Used to detect memory access scatter. +template +MSHADOW_XINLINE int fastest_stride(const Shape& small, const Shape& big, + const Shape& big_stride) { + for (int i = ndim-1; i >= 0; --i) { + if (big[i] != 1) { + return (small[i] == big[i]) ? 1 : big_stride[i]; + } + } + return 1; +} + +// Returns a/b integer division rounded up +template +Type ceil_idiv(const Type a, const Type b) { + return (a + b - 1)/b; +} + +// Configuration for ReduceImpl() +template +struct ReduceImplConfig { + static const int warpSize = 32; + static const int unroll_reduce = 2; + static const int maxLoopPerTB = 64; + int N; + int M; + int Mnext; + struct { + dim3 blockDim; + dim3 gridDim; + int shMemSize; + bool do_transpose; + } kernel_1; + struct { + int blockSize; + int gridSize; + } kernel_2; + size_t workspace_size; + + Shape rshape, rstride; + Shape lhs_shape, lhs_stride; + Shape rhs_shape, rhs_stride; +}; + +static inline uint64_t calc_num_load(const int X, const int Y, const int* strides) { + const int warpSize = ReduceImplConfig<1>::warpSize; + // Number of full warps + uint64_t num_full_warp = X / warpSize; + // Length of the partial warp i.e. number of threads that are performing loads + uint64_t len_part_warp = X % warpSize; + + uint64_t num_load_full = (std::min(warpSize, strides[0]) + + std::min(warpSize, strides[1]) + + std::min(warpSize, strides[2]))*num_full_warp; + + uint64_t num_load_part = + (std::min(len_part_warp, ceil_idiv(len_part_warp*strides[0], warpSize)) + + std::min(len_part_warp, ceil_idiv(len_part_warp*strides[1], warpSize)) + + std::min(len_part_warp, ceil_idiv(len_part_warp*strides[2], warpSize)))* + (len_part_warp != 0); + + uint64_t num_load = (num_load_full + num_load_part)*(uint64_t)Y; + return num_load; +} + +template +ReduceImplConfig ConfigureReduceImpl(const TBlob& small, const TBlob& big, const TBlob* lhs, + const TBlob* rhs) { + + ReduceImplConfig config; + + diff(small.shape_.get(), big.shape_.get(), &config.rshape, &config.rstride); + config.N = small.shape_.Size(); + config.M = config.rshape.Size(); + + bool multiOp = false; + if (lhs != NULL) { + CHECK_NOTNULL(rhs); + diff(small.shape_.get(), lhs->shape_.get(), &config.lhs_shape, + &config.lhs_stride); + diff(small.shape_.get(), rhs->shape_.get(), &config.rhs_shape, + &config.rhs_stride); + multiOp = true; + } + + config.workspace_size = 0; + + if (config.M == 1) { + config.kernel_1.blockDim.x = kMaxThreadsPerBlock; + config.kernel_1.gridDim.x = std::min((unsigned int)kBaseGridNum, + (config.N + config.kernel_1.blockDim.x - 1)/config.kernel_1.blockDim.x); + } else { + + int reduce_strides[3]; + reduce_strides[0] = fastest_stride(small.shape_.get(), big.shape_.get(), + big.shape_.get()); + reduce_strides[1] = (multiOp) ? fastest_stride(small.shape_.get(), + lhs->shape_.get(), lhs->shape_.get()) : 1; + reduce_strides[2] = (multiOp) ? fastest_stride(small.shape_.get(), + rhs->shape_.get(), rhs->shape_.get()) : 1; + + int reduce_strides_transp[3]; + reduce_strides_transp[0] = fastest_stride(small.shape_.get(), config.rshape, + config.rstride); + reduce_strides_transp[1] = (multiOp) ? + fastest_stride(small.shape_.get(), config.lhs_shape, config.lhs_stride) : 1; + reduce_strides_transp[2] = (multiOp) ? + fastest_stride(small.shape_.get(), config.rhs_shape, config.rhs_stride) : 1; + + uint64_t num_load = calc_num_load(config.N, config.M, reduce_strides); + uint64_t num_load_transp = calc_num_load(config.M, config.N, reduce_strides_transp); + + config.Mnext = 1; + config.kernel_1.do_transpose = (num_load > num_load_transp); + + config.kernel_1.blockDim.x = 0; + config.kernel_1.blockDim.y = 0; + + if (config.kernel_1.do_transpose) { + // Fastest thread ID goes through M + // Loop over N has step size config.kernel_1.blockDim.y + if (config.N < 8) { + config.kernel_1.blockDim.y = 1; + } else if (config.N < 256) { + config.kernel_1.blockDim.y = 4; + } else { + if (config.M < 8) { + config.kernel_1.blockDim.x = 1; + } else if (config.M < 256) { + config.kernel_1.blockDim.x = 4; + } else { + config.kernel_1.blockDim.x = config.warpSize; + } + } + } else { + // Fastest thread ID goes through N + // Loop over M has step size config.kernel_1.blockDim.y + if (config.M < 8) { + config.kernel_1.blockDim.y = 1; + } else if (config.M < 256) { + config.kernel_1.blockDim.y = 4; + } else { + if (config.N < 8) { + config.kernel_1.blockDim.x = 1; + } else if (config.N < 256) { + config.kernel_1.blockDim.x = 4; + } else { + config.kernel_1.blockDim.x = config.warpSize; + } + } + } + + if (config.kernel_1.blockDim.x == 0 && config.kernel_1.blockDim.y == 0) { + LOG(FATAL) << "Unable to set blockDim"; + } else if (config.kernel_1.blockDim.x == 0) { + config.kernel_1.blockDim.x = nthread_reduce / config.kernel_1.blockDim.y; + } else if (config.kernel_1.blockDim.y == 0) { + config.kernel_1.blockDim.y = nthread_reduce / config.kernel_1.blockDim.x; + } + + if (config.kernel_1.do_transpose) { + // Fastest thread ID goes through M + config.kernel_1.gridDim.x = std::min((unsigned int)kBaseGridNum, + ceil_idiv(config.N, config.kernel_1.blockDim.y)); + config.kernel_1.gridDim.y = std::min(kBaseGridNum, config.Mnext); + int by = config.kernel_1.blockDim.y; + if (config.kernel_1.blockDim.y % config.warpSize == 0) { + // Fix shared memory bank conflict + by++; + } + config.kernel_1.shMemSize = (config.kernel_1.blockDim.x > 1) ? + config.kernel_1.blockDim.x*by*sizeof(DType) : 0; + // Maximum number of times we want TB to loop in M + // Max size of M-block each TB can handle + int maxMblock = config.kernel_1.blockDim.x*config.maxLoopPerTB; + config.Mnext = (config.M + maxMblock - 1) / maxMblock; + } else { + // Fastest thread ID goes through N + config.kernel_1.gridDim.x = std::min((unsigned int)kBaseGridNum, + ceil_idiv(config.N, config.kernel_1.blockDim.x)); + config.kernel_1.gridDim.y = std::min(kBaseGridNum, config.Mnext); + config.kernel_1.shMemSize = (config.kernel_1.blockDim.y > 1) ? + config.kernel_1.blockDim.x*config.kernel_1.blockDim.y*sizeof(DType) : 0; + // Maximum number of times we want TB to loop in M + // Max size of M-block each TB can handle + int maxMblock = config.kernel_1.blockDim.y*config.maxLoopPerTB; + config.Mnext = (config.M + maxMblock - 1) / maxMblock; + } + + if (config.Mnext > 1) { + // small_dptr[] is N*Mnext*sizeof(DType) bytes + config.workspace_size += config.N*config.Mnext*sizeof(DType); + // Set gridDim.y to Mnext + config.kernel_1.gridDim.y = std::min(kBaseGridNum, config.Mnext); + } + + if (config.Mnext > 1) { + config.kernel_2.blockSize = kMaxThreadsPerBlock; + config.kernel_2.gridSize = std::min((int)kBaseGridNum, + (config.N + config.kernel_2.blockSize - 1)/config.kernel_2.blockSize ); + } + + } + + return config; +} + +#define KERNEL_UNROLL_SWITCH(do_unroll, unrollAmount, unrollVar, ...) \ + if (do_unroll) { \ + const int unrollVar = unrollAmount; \ + {__VA_ARGS__} \ + } else { \ + const int unrollVar = 1; \ + {__VA_ARGS__} \ + } + +template +void ReduceImpl(cudaStream_t stream, const TBlob& small, const OpReqType req, + const TBlob& big, const Tensor& workspace, + const ReduceImplConfig& config) { + if (config.M == 1) { + reduce_kernel_M1 + <<< config.kernel_1.gridDim, config.kernel_1.blockDim, 0, stream >>>( + config.N, req == kAddTo, big.dptr(), small.dptr(), big.shape_.get(), + small.shape_.get()); + } else { + + DType* small_dptr = small.dptr(); + bool addto = (req == kAddTo); + if (config.Mnext > 1) { + // small_dptr[] is N*Mnext*sizeof(DType) bytes + small_dptr = reinterpret_cast(workspace.dptr_); + addto = false; + // Check that the workspace is contigiuous + CHECK_EQ(workspace.CheckContiguous(), true); + // Check that we have enough storage + CHECK_GE(workspace.size(0), config.workspace_size); + } + + const int by = (config.kernel_1.do_transpose) ? + config.kernel_1.blockDim.x : config.kernel_1.blockDim.y; + const bool do_unroll = ( config.M / (by*config.Mnext) >= config.unroll_reduce ); + KERNEL_UNROLL_SWITCH(do_unroll, ReduceImplConfig::unroll_reduce, UNROLL, { + reduce_kernel + <<< config.kernel_1.gridDim, config.kernel_1.blockDim, config.kernel_1.shMemSize, stream>>>( + config.N, config.M, addto, big.dptr(), small_dptr, big.shape_.get(), + small.shape_.get(), config.rshape, config.rstride, config.Mnext, + config.kernel_1.do_transpose); + }); + + if (config.Mnext > 1) { + reduce_lines_kernel + <<< config.kernel_2.gridSize, config.kernel_2.blockSize, 0, stream >>> + (config.N, config.Mnext, req == kAddTo, config.N, small_dptr, small.dptr()); + } + } +} + +template +void ReduceImpl(cudaStream_t stream, const TBlob& small, const TBlob& lhs, const TBlob& rhs, + const OpReqType req, const TBlob& big, const Tensor& workspace, + const ReduceImplConfig& config) { + if (config.M == 1) { + reduce_kernel_M1 + <<< config.kernel_1.gridDim, config.kernel_1.blockDim, 0, stream >>>( + config.N, req == kAddTo, big.dptr(), lhs.dptr(), rhs.dptr(), + small.dptr(), big.shape_.get(), lhs.shape_.get(), + rhs.shape_.get(), small.shape_.get()); + } else { + DType* small_dptr = small.dptr(); + bool addto = (req == kAddTo); + if (config.Mnext > 1) { + // small_dptr[] is N*Mnext*sizeof(DType) bytes + small_dptr = reinterpret_cast(workspace.dptr_); + addto = false; + // Check that the workspace is contigiuous + CHECK_EQ(workspace.CheckContiguous(), true); + // Check that we have enough storage + CHECK_GE(workspace.size(0), config.workspace_size); + } + + const int by = (config.kernel_1.do_transpose) ? + config.kernel_1.blockDim.x : config.kernel_1.blockDim.y; + const bool do_unroll = ( config.M / (by*config.Mnext) >= config.unroll_reduce ); + KERNEL_UNROLL_SWITCH(do_unroll, ReduceImplConfig::unroll_reduce, UNROLL, { + reduce_kernel + <<< config.kernel_1.gridDim, config.kernel_1.blockDim, config.kernel_1.shMemSize, stream>>>( + config.N, config.M, addto, big.dptr(), lhs.dptr(), rhs.dptr(), + small_dptr, big.shape_.get(), lhs.shape_.get(), + rhs.shape_.get(), small.shape_.get(), config.rshape, config.lhs_shape, + config.rhs_shape, config.rstride, config.lhs_stride, config.rhs_stride, config.Mnext, + config.kernel_1.do_transpose); + }); + + if (config.Mnext > 1) { + reduce_lines_kernel + <<< config.kernel_2.gridSize, config.kernel_2.blockSize, 0, stream >>> + (config.N, config.Mnext, req == kAddTo, config.N, small_dptr, small.dptr()); + } + } +} + +#undef KERNEL_UNROLL_SWITCH + +template +void Reduce(Stream *s, const TBlob& small, const OpReqType req, + const Tensor& workspace, const TBlob& big) { + if (req == kNullOp) return; + cudaStream_t stream = Stream::GetStream(s); + ReduceImplConfig config = ConfigureReduceImpl(small, big, NULL, NULL); + ReduceImpl(stream, small, req, big, workspace, config); +} + +template +void Reduce(Stream *s, const TBlob& small, const OpReqType req, + const Tensor& workspace, const TBlob& big, + const TBlob& lhs, const TBlob& rhs) { + if (req == kNullOp) return; + cudaStream_t stream = Stream::GetStream(s); + ReduceImplConfig config = ConfigureReduceImpl(small, big, &lhs, &rhs); + ReduceImpl(stream, small, lhs, rhs, req, big, workspace, config); +} + +template +size_t ReduceWorkspaceSize(Stream *s, const TBlob& small, const OpReqType req, + const TBlob& big) { + if (req == kNullOp) return 0; + ReduceImplConfig config = ConfigureReduceImpl(small, big, NULL, NULL); + return config.workspace_size; +} + +template +size_t ReduceWorkspaceSize(Stream *s, const TBlob& small, const OpReqType req, + const TBlob& big, const TBlob& lhs, const TBlob& rhs) { + if (req == kNullOp) return 0; + ReduceImplConfig config = ConfigureReduceImpl(small, big, &lhs, &rhs); + return config.workspace_size; +} + +#endif //MXNET_OPERATOR_TENSOR_BROADCAST_REDUCE_INL_CUH_ diff --git a/src/operator/tensor/broadcast_reduce-inl.h b/src/operator/tensor/broadcast_reduce-inl.h index 118b50578385..744308d9a486 100644 --- a/src/operator/tensor/broadcast_reduce-inl.h +++ b/src/operator/tensor/broadcast_reduce-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015-2017 by Contributors * \file broadcast_reduce_kernel.h * \brief Function definition of elementwise unary operators */ diff --git a/src/operator/tensor/broadcast_reduce_op.h b/src/operator/tensor/broadcast_reduce_op.h index 1de33bc86f89..aa678fd7dd82 100644 --- a/src/operator/tensor/broadcast_reduce_op.h +++ b/src/operator/tensor/broadcast_reduce_op.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file elementwise_unary_op-inl.h * \brief Function definition of elementwise unary operators */ diff --git a/src/operator/tensor/broadcast_reduce_op_index.cc b/src/operator/tensor/broadcast_reduce_op_index.cc index 5944e2374ea3..6887955880bc 100644 --- a/src/operator/tensor/broadcast_reduce_op_index.cc +++ b/src/operator/tensor/broadcast_reduce_op_index.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file broadcast_reduce_op.cc * \brief CPU Implementation of broadcast and reduce functions. */ diff --git a/src/operator/tensor/broadcast_reduce_op_index.cu b/src/operator/tensor/broadcast_reduce_op_index.cu index e07b3a2b66d7..defa35ea6227 100644 --- a/src/operator/tensor/broadcast_reduce_op_index.cu +++ b/src/operator/tensor/broadcast_reduce_op_index.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file broadcast_reduce_op.cu * \brief GPU Implementation of broadcast and reduce functions. */ diff --git a/src/operator/tensor/broadcast_reduce_op_value.cc b/src/operator/tensor/broadcast_reduce_op_value.cc index fdbaf7610e9b..551ee8be89d5 100644 --- a/src/operator/tensor/broadcast_reduce_op_value.cc +++ b/src/operator/tensor/broadcast_reduce_op_value.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file broadcast_reduce_op.cc * \brief CPU Implementation of broadcast and reduce functions. */ diff --git a/src/operator/tensor/broadcast_reduce_op_value.cu b/src/operator/tensor/broadcast_reduce_op_value.cu index e4b90d580043..2c216e78982d 100644 --- a/src/operator/tensor/broadcast_reduce_op_value.cu +++ b/src/operator/tensor/broadcast_reduce_op_value.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file broadcast_reduce_op.cu * \brief GPU Implementation of broadcast and reduce functions. */ diff --git a/src/operator/tensor/control_flow_op.cc b/src/operator/tensor/control_flow_op.cc index 5dd525ea391e..bf08fe7e9d94 100644 --- a/src/operator/tensor/control_flow_op.cc +++ b/src/operator/tensor/control_flow_op.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file control_flow_op.cc * \brief CPU Implementation of flow control */ diff --git a/src/operator/tensor/control_flow_op.cu b/src/operator/tensor/control_flow_op.cu index dbea01c43d3d..da2c47247f28 100644 --- a/src/operator/tensor/control_flow_op.cu +++ b/src/operator/tensor/control_flow_op.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file control_flow_op.cu * \brief */ diff --git a/src/operator/tensor/control_flow_op.h b/src/operator/tensor/control_flow_op.h index c7fcda0f0c01..c240247202e8 100644 --- a/src/operator/tensor/control_flow_op.h +++ b/src/operator/tensor/control_flow_op.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file control_flow.h * \brief Function definitions of operators for controlling flow */ diff --git a/src/operator/tensor/elemwise_binary_broadcast_op.h b/src/operator/tensor/elemwise_binary_broadcast_op.h index be0d27d1e334..851a1c5cdf2f 100644 --- a/src/operator/tensor/elemwise_binary_broadcast_op.h +++ b/src/operator/tensor/elemwise_binary_broadcast_op.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file elementwise_binary_broadcast_op.h * \brief Function definition of elementwise unary operators */ diff --git a/src/operator/tensor/elemwise_binary_broadcast_op_basic.cc b/src/operator/tensor/elemwise_binary_broadcast_op_basic.cc index 27a4b5f25c82..c80d46a883ea 100644 --- a/src/operator/tensor/elemwise_binary_broadcast_op_basic.cc +++ b/src/operator/tensor/elemwise_binary_broadcast_op_basic.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file elemwise_binary_scalar_op.cc * \brief CPU Implementation of unary function. */ diff --git a/src/operator/tensor/elemwise_binary_broadcast_op_basic.cu b/src/operator/tensor/elemwise_binary_broadcast_op_basic.cu index ef0e679d6166..bf69132cff14 100644 --- a/src/operator/tensor/elemwise_binary_broadcast_op_basic.cu +++ b/src/operator/tensor/elemwise_binary_broadcast_op_basic.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file elemwise_binary_scalar_op.cu * \brief GPU Implementation of unary function. */ diff --git a/src/operator/tensor/elemwise_binary_broadcast_op_extended.cc b/src/operator/tensor/elemwise_binary_broadcast_op_extended.cc index 127d8c0ec1c5..42da19155ef5 100644 --- a/src/operator/tensor/elemwise_binary_broadcast_op_extended.cc +++ b/src/operator/tensor/elemwise_binary_broadcast_op_extended.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file elemwise_binary_scalar_op.cc * \brief CPU Implementation of unary function. */ diff --git a/src/operator/tensor/elemwise_binary_broadcast_op_extended.cu b/src/operator/tensor/elemwise_binary_broadcast_op_extended.cu index 649e19ba092a..2b7cc70b59a7 100644 --- a/src/operator/tensor/elemwise_binary_broadcast_op_extended.cu +++ b/src/operator/tensor/elemwise_binary_broadcast_op_extended.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file elemwise_binary_scalar_op.cu * \brief GPU Implementation of unary function. */ diff --git a/src/operator/tensor/elemwise_binary_broadcast_op_logic.cc b/src/operator/tensor/elemwise_binary_broadcast_op_logic.cc index 900f376fe421..957b00b5e774 100644 --- a/src/operator/tensor/elemwise_binary_broadcast_op_logic.cc +++ b/src/operator/tensor/elemwise_binary_broadcast_op_logic.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file elemwise_binary_scalar_op.cc * \brief CPU Implementation of unary function. */ diff --git a/src/operator/tensor/elemwise_binary_broadcast_op_logic.cu b/src/operator/tensor/elemwise_binary_broadcast_op_logic.cu index 167b5d34f00a..8673b4f1f1ed 100644 --- a/src/operator/tensor/elemwise_binary_broadcast_op_logic.cu +++ b/src/operator/tensor/elemwise_binary_broadcast_op_logic.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file elemwise_binary_scalar_op.cu * \brief GPU Implementation of unary function. */ diff --git a/src/operator/tensor/elemwise_binary_op.h b/src/operator/tensor/elemwise_binary_op.h index 6062febe2d9e..87b0d46a63c9 100644 --- a/src/operator/tensor/elemwise_binary_op.h +++ b/src/operator/tensor/elemwise_binary_op.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file elemwise_binary_op.h * \brief Function definition of elementwise binary operators */ diff --git a/src/operator/tensor/elemwise_binary_op_basic.cc b/src/operator/tensor/elemwise_binary_op_basic.cc index 635f2a8692aa..65d4ca9aadd6 100644 --- a/src/operator/tensor/elemwise_binary_op_basic.cc +++ b/src/operator/tensor/elemwise_binary_op_basic.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file elemwise_binary_scalar_op.cc * \brief CPU Implementation of unary function. */ diff --git a/src/operator/tensor/elemwise_binary_op_basic.cu b/src/operator/tensor/elemwise_binary_op_basic.cu index 6355c4e5cf01..429140a63bc5 100644 --- a/src/operator/tensor/elemwise_binary_op_basic.cu +++ b/src/operator/tensor/elemwise_binary_op_basic.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file elemwise_binary_scalar_op.cu * \brief GPU Implementation of unary function. */ diff --git a/src/operator/tensor/elemwise_binary_op_extended.cc b/src/operator/tensor/elemwise_binary_op_extended.cc index c1669c6daf6e..31d977c9fd48 100644 --- a/src/operator/tensor/elemwise_binary_op_extended.cc +++ b/src/operator/tensor/elemwise_binary_op_extended.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file elemwise_binary_scalar_op.cc * \brief CPU Implementation of unary function. */ diff --git a/src/operator/tensor/elemwise_binary_op_extended.cu b/src/operator/tensor/elemwise_binary_op_extended.cu index 7325ebfff819..9a10b05cf901 100644 --- a/src/operator/tensor/elemwise_binary_op_extended.cu +++ b/src/operator/tensor/elemwise_binary_op_extended.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file elemwise_binary_scalar_op.cu * \brief GPU Implementation of unary function. */ diff --git a/src/operator/tensor/elemwise_binary_op_logic.cc b/src/operator/tensor/elemwise_binary_op_logic.cc index 0903b503e1c8..85f2bf11539d 100644 --- a/src/operator/tensor/elemwise_binary_op_logic.cc +++ b/src/operator/tensor/elemwise_binary_op_logic.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file elemwise_binary_scalar_op.cc * \brief CPU Implementation of unary function. */ diff --git a/src/operator/tensor/elemwise_binary_op_logic.cu b/src/operator/tensor/elemwise_binary_op_logic.cu index 9fab912227b1..1a703ed90ed0 100644 --- a/src/operator/tensor/elemwise_binary_op_logic.cu +++ b/src/operator/tensor/elemwise_binary_op_logic.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file elemwise_binary_scalar_op.cu * \brief GPU Implementation of unary function. */ diff --git a/src/operator/tensor/elemwise_binary_scalar_op.h b/src/operator/tensor/elemwise_binary_scalar_op.h index 5e577c6e3d4f..f27df274e5b2 100644 --- a/src/operator/tensor/elemwise_binary_scalar_op.h +++ b/src/operator/tensor/elemwise_binary_scalar_op.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file elemwise_binary_scalar_op.h * \brief Function definition of elementwise binary scalar operators */ diff --git a/src/operator/tensor/elemwise_binary_scalar_op_basic.cc b/src/operator/tensor/elemwise_binary_scalar_op_basic.cc index bd0b5335e3ae..3249bcbaa7ca 100644 --- a/src/operator/tensor/elemwise_binary_scalar_op_basic.cc +++ b/src/operator/tensor/elemwise_binary_scalar_op_basic.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file elemwise_binary_scalar_op.cc * \brief CPU Implementation of unary function. */ diff --git a/src/operator/tensor/elemwise_binary_scalar_op_basic.cu b/src/operator/tensor/elemwise_binary_scalar_op_basic.cu index ae19aa8a72f6..a843f67c2723 100644 --- a/src/operator/tensor/elemwise_binary_scalar_op_basic.cu +++ b/src/operator/tensor/elemwise_binary_scalar_op_basic.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file elemwise_binary_scalar_op.cu * \brief GPU Implementation of unary function. */ diff --git a/src/operator/tensor/elemwise_binary_scalar_op_extended.cc b/src/operator/tensor/elemwise_binary_scalar_op_extended.cc index 6b712fce2dcb..785fce2dcbb6 100644 --- a/src/operator/tensor/elemwise_binary_scalar_op_extended.cc +++ b/src/operator/tensor/elemwise_binary_scalar_op_extended.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file elemwise_binary_scalar_op.cc * \brief CPU Implementation of unary function. */ diff --git a/src/operator/tensor/elemwise_binary_scalar_op_extended.cu b/src/operator/tensor/elemwise_binary_scalar_op_extended.cu index 4623b0572938..74e6b7de478b 100644 --- a/src/operator/tensor/elemwise_binary_scalar_op_extended.cu +++ b/src/operator/tensor/elemwise_binary_scalar_op_extended.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file elemwise_binary_scalar_op.cu * \brief GPU Implementation of unary function. */ diff --git a/src/operator/tensor/elemwise_binary_scalar_op_logic.cc b/src/operator/tensor/elemwise_binary_scalar_op_logic.cc index a0f5c2355f39..6771fff21387 100644 --- a/src/operator/tensor/elemwise_binary_scalar_op_logic.cc +++ b/src/operator/tensor/elemwise_binary_scalar_op_logic.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file elemwise_binary_scalar_op.cc * \brief CPU Implementation of unary function. */ diff --git a/src/operator/tensor/elemwise_binary_scalar_op_logic.cu b/src/operator/tensor/elemwise_binary_scalar_op_logic.cu index e400b3baa8d8..9fee4e9e4c87 100644 --- a/src/operator/tensor/elemwise_binary_scalar_op_logic.cu +++ b/src/operator/tensor/elemwise_binary_scalar_op_logic.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file elemwise_binary_scalar_op.cu * \brief GPU Implementation of unary function. */ diff --git a/src/operator/tensor/elemwise_sum.cc b/src/operator/tensor/elemwise_sum.cc index 7ae7ae97acea..652be72f3fab 100644 --- a/src/operator/tensor/elemwise_sum.cc +++ b/src/operator/tensor/elemwise_sum.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file elemwise_sum.cc * \brief elementwise sum operator */ diff --git a/src/operator/tensor/elemwise_sum.cu b/src/operator/tensor/elemwise_sum.cu index 63c3a96acb6a..ce734ad90c8a 100644 --- a/src/operator/tensor/elemwise_sum.cu +++ b/src/operator/tensor/elemwise_sum.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file elemwise_sum.cu * \brief elementwise sum operator */ diff --git a/src/operator/tensor/elemwise_sum.h b/src/operator/tensor/elemwise_sum.h index 2dd6a133b407..3d6d72511156 100644 --- a/src/operator/tensor/elemwise_sum.h +++ b/src/operator/tensor/elemwise_sum.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file elemwise_sum.h * \brief elementwise sum * \author Bing Xu diff --git a/src/operator/tensor/elemwise_unary_op.cc b/src/operator/tensor/elemwise_unary_op.cc index ff03846ab5b3..defe72d3738c 100644 --- a/src/operator/tensor/elemwise_unary_op.cc +++ b/src/operator/tensor/elemwise_unary_op.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file elemwise_unary_op.cc * \brief CPU Implementation of unary function. */ diff --git a/src/operator/tensor/elemwise_unary_op.cu b/src/operator/tensor/elemwise_unary_op.cu index 67ceb1ce5093..4211ea305b4e 100644 --- a/src/operator/tensor/elemwise_unary_op.cu +++ b/src/operator/tensor/elemwise_unary_op.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file elemwise_unary_op.cu * \brief GPU Implementation of unary function. */ diff --git a/src/operator/tensor/elemwise_unary_op.h b/src/operator/tensor/elemwise_unary_op.h index 97a7e36535f0..b6994844e0fe 100644 --- a/src/operator/tensor/elemwise_unary_op.h +++ b/src/operator/tensor/elemwise_unary_op.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file elementwise_unary_op-inl.h * \brief Function definition of elementwise unary operators */ diff --git a/src/operator/tensor/indexing_op-inl.cuh b/src/operator/tensor/indexing_op-inl.cuh index 2f366c2c3e48..4458151f1782 100644 --- a/src/operator/tensor/indexing_op-inl.cuh +++ b/src/operator/tensor/indexing_op-inl.cuh @@ -1,293 +1,312 @@ -/*! - * Copyright (c) 2017 by Contributors - * \file indexing_op-inl.cuh - * \brief CUDA implementations for indexing_op.h - * \author Antti-Pekka Hynninen -*/ -#ifndef MXNET_OPERATOR_TENSOR_INDEXING_OP_CUH_ -#define MXNET_OPERATOR_TENSOR_INDEXING_OP_CUH_ -#include -#include - -#if CUDA_VERSION >= 9000 -#define FULLMASK 0xFFFFFFFF -#define __ballot(x) __ballot_sync(FULLMASK, (x)) -#define __all(x) __all_sync(FULLMASK, (x)) -#endif - -namespace mxnet { -namespace op { -const int kWarpSize = 32; - -template -__global__ void AddTakeGradLargeBatchKernel(DType* dst, - // If idx_start == NULL, then in-kernel edge - // detection is used - const IdxType *idx_start, - // idx_start_size_ptr ignored if idx_start == NULL - const int* idx_start_size_ptr, - const IdxType *sorted, const IdxType *index, - const DType *src, - int ymax, int xmax) { - // Size of the shared memory is [blockDim.x*SZ*blockDim.y]*sizeof(DType) - extern __shared__ char sh_grad_weight_char[]; - DType* sh_grad_weight = (DType*)sh_grad_weight_char; - - int iidx_end = (idx_start == NULL) ? ymax : *idx_start_size_ptr; - - for (int iidx = blockIdx.y;iidx < iidx_end;iidx += gridDim.y) { - - // Thread block sums up elements in the range [idx_begin, idx_end-1] - int idx_begin, idx_end; - int sorted_value; - if (idx_start == NULL) { - idx_begin = iidx; - sorted_value = static_cast(sorted[idx_begin]); - if (idx_begin > 0 && sorted_value == static_cast(sorted[idx_begin - 1])) continue; - // Algorithm is explained using an example: - // blockDim.x = 32 - // blockDim.y = 4 - // sorted[idx_begin:] = [4 4 4 9] - // (3,4) denotes threadIdx.x=3, threadIdx.y=4, ":" is used for ranges - // (0:31,0:3) sorted_value = 4 - idx_end = idx_begin + 1; - unsigned int* sh_ballot = (unsigned int*)sh_grad_weight_char; - int no_edge = 0; - do { - int idx = idx_end + threadIdx.x + threadIdx.y*blockDim.x; - // Example: - // (0:1,0) sorted_idx = 4 - // (rest) sorted_idx = -1 - int sorted_idx = (idx < ymax) ? static_cast(sorted[idx]) : -1; - // Example: - // (0:31,0) sh_ballot[0] = 0b100 - // (rest) sh_ballot[1...3] = 0 - // sh_ballot[] tells us which thread within the warp found the edge - sh_ballot[threadIdx.y] = __ballot(sorted_value != sorted_idx); - __syncthreads(); - // No edge if sh_ballot[threadIdx.x] == 0 - // NOTE: All warps have the same value for no_edge - // Example: - // (0,:) no_edge = 0 - // (rest) no_edge = 1 - no_edge = (threadIdx.x < blockDim.y) ? (sh_ballot[threadIdx.x] == 0) : 1; - idx_end += blockDim.x*blockDim.y; - // Example: - // __all(no_edge) = 0 since no_edge = 0 for threadIdx.x = 0, hence we leave the loop - } while (__all(no_edge)); - idx_end -= blockDim.x*blockDim.y; - // Find the first edge - // Example: - // (0,:) val = 1 - // (rest) val = 0 - unsigned int val = (threadIdx.x < blockDim.y && sh_ballot[threadIdx.x] != 0) ? - 1 : 0; - // NOTE: Set nth bit if thread n in the warp has val = 1 - // Example: - // (all) val = 1 - val = __ballot( val ); - // __ffs() returns the position of first set bit, 1...32. __ffs(1) = 1 - // j will be the warp index where edge was found - // Example: - // (all) j = 1 - 1 = 0 - int j = __ffs(val) - 1; - // j = warp index where the edge was found - // __ffs(sh_ballot[j]) - 1 = warp lane where the edge was found - // idx_end points to the one over the last value. - // Example: - // idx_end += 0*blockDim.x + _ffs(0b100) - 1 = 0 + 3 - 1 = 2 - // sorted[idx_end] = 9 - idx_end += j*blockDim.x + __ffs(sh_ballot[j]) - 1; - __syncthreads(); - } else { - idx_begin = idx_start[iidx]; - idx_end = ((iidx + 1) < iidx_end) ? idx_start[iidx + 1] : ymax; - sorted_value = static_cast(sorted[idx_begin]); - } - - const int start_feature = threadIdx.x + blockIdx.x * blockDim.x * SZ; - const int dst_row = sorted_value * xmax; - - int num_idx = idx_end - idx_begin; - int idx0 = idx_begin + threadIdx.y*num_idx/blockDim.y; - int idx1 = idx_begin + (threadIdx.y + 1)*num_idx/blockDim.y; - - // Read and sum data into grad_weight[] - DType grad_weight[SZ]; - #pragma unroll - for (int ii = 0; ii < SZ; ii++) { - grad_weight[ii] = (DType)0; - } - for (int idx=idx0; idx < idx1;idx++) { - const int src_row = static_cast(index[idx]) * xmax; - #pragma unroll - for (int ii = 0; ii < SZ; ii++) - { - int feature_dim = start_feature + ii * blockDim.x; - if (feature_dim < xmax) - { - grad_weight[ii] += src[src_row + feature_dim]; - } - } - } - #pragma unroll - for (int ii = 0; ii < SZ; ii++) { - sh_grad_weight[threadIdx.x + ii*blockDim.x + threadIdx.y*blockDim.x*SZ] = grad_weight[ii]; - } - __syncthreads(); - // We now have grad_weight[] values, reduce within thread block - for (int t=1;t < blockDim.y;t <<= 1) { - DType tmp[SZ]; - #pragma unroll - for (int ii = 0; ii < SZ; ii++) { - tmp[ii] = (threadIdx.y + t < blockDim.y) ? - sh_grad_weight[threadIdx.x + ii*blockDim.x + (threadIdx.y + t)*blockDim.x*SZ] : (DType)0; - } - __syncthreads(); - #pragma unroll - for (int ii = 0; ii < SZ; ii++) { - sh_grad_weight[threadIdx.x + ii*blockDim.x + threadIdx.y*blockDim.x*SZ] += tmp[ii]; - } - __syncthreads(); - } - // Result is in sh_grad_weight[threadIdx.x + ii*blockDim.x] - if (threadIdx.y == 0) { - #pragma unroll - for (int ii = 0; ii < SZ; ii++) { - int feature_dim = start_feature + ii * blockDim.x; - if (feature_dim < xmax) { - dst[dst_row + feature_dim] += sh_grad_weight[threadIdx.x + ii*blockDim.x]; - } - } - } - - } -} - -template -inline typename std::enable_if::value, size_t>::type -AddTakeGradLargeBatchWorkspaceSize(size_t num_keys) { - size_t encode_bytes = 0; - cub::DeviceRunLengthEncode::Encode - (NULL, encode_bytes, NULL, NULL, NULL, NULL, num_keys); - size_t exclusivesum_bytes = 0; - cub::DeviceScan::ExclusiveSum(NULL, exclusivesum_bytes, - NULL, NULL, num_keys); - size_t temporary_bytes = std::max(encode_bytes, exclusivesum_bytes); - size_t unique_bytes = num_keys*sizeof(IndexType); - size_t counts_bytes = num_keys*sizeof(IndexType); - size_t num_runs_bytes = 1*sizeof(int); - return (unique_bytes + counts_bytes + num_runs_bytes + temporary_bytes); -} - -template -inline void AddTakeGradLargeBatch(mshadow::Tensor dst, - const mshadow::Tensor& sorted, - const mshadow::Tensor& index, - const mshadow::Tensor &src, - mshadow::Tensor* workspace) { - CHECK_EQ(dst.CheckContiguous(), true); - CHECK_EQ(sorted.CheckContiguous(), true); - CHECK_EQ(index.CheckContiguous(), true); - CHECK_EQ(src.CheckContiguous(), true); - // const int kWarpBits = kMemUnitBits; - cudaStream_t stream = mshadow::Stream::GetStream(dst.stream_); - IndexType* sum_counts_ptr = NULL; - int* num_runs_ptr = NULL; - if (dst.size(0)*4 < src.size(0) && workspace != NULL) { - // Workspace given and potentially loops at least 4 times, use CUB to create sum_counts - CHECK_EQ(workspace->CheckContiguous(), true); - // workspace = [unique_out, counts_out, temporary_storage] - size_t unique_bytes = sorted.size(0)*sizeof(IndexType); - size_t counts_bytes = sorted.size(0)*sizeof(IndexType); - size_t num_runs_bytes = 1*sizeof(int); - - size_t encode_bytes = 0; - cub::DeviceRunLengthEncode::Encode - (NULL, encode_bytes, NULL, NULL, NULL, NULL, sorted.size(0), stream); - size_t exclusivesum_bytes = 0; - cub::DeviceScan::ExclusiveSum - (NULL, exclusivesum_bytes, NULL, NULL, sorted.size(0), stream); - size_t temporary_bytes = std::max(encode_bytes, exclusivesum_bytes); - - // Check that we have enough storage - CHECK_GE(workspace->size(0), unique_bytes + counts_bytes + - num_runs_bytes + temporary_bytes); - - IndexType* unique_out_ptr = reinterpret_cast(workspace->dptr_); - IndexType* counts_out_ptr = reinterpret_cast(workspace->dptr_ + unique_bytes); - num_runs_ptr = reinterpret_cast(workspace->dptr_ + unique_bytes + - counts_bytes); - void* temporary_storage = reinterpret_cast(workspace->dptr_ + unique_bytes + - counts_bytes + num_runs_bytes); - - cub::DeviceRunLengthEncode::Encode - (temporary_storage, temporary_bytes, sorted.dptr_, unique_out_ptr, counts_out_ptr, - num_runs_ptr, sorted.size(0), stream); - - sum_counts_ptr = unique_out_ptr; - cub::DeviceScan::ExclusiveSum - (temporary_storage, temporary_bytes, counts_out_ptr, sum_counts_ptr, - sorted.size(0), stream); - } - - const int num_unique_est = min(dst.size(0), src.size(0)); - const int max_nthread = 128; - const int num_y = max(src.size(0)/num_unique_est, 1); - const int block_dim_x = kWarpSize; - const int block_dim_y = min(num_y, max_nthread/block_dim_x); - const int SZ = min((src.size(1) + block_dim_x - 1) / block_dim_x, 4); - const int grid_dim_x = (src.size(1) + block_dim_x * SZ - 1) / (block_dim_x * SZ); - const int grid_dim_y = min(num_unique_est, mshadow::cuda::kBaseGridNum); - dim3 dimBlock(block_dim_x, block_dim_y); - dim3 dimGrid(grid_dim_x, grid_dim_y); - // Maximum shared memory usage: 128*4*sizeof(DType), which is 4K for 64bit DType elements - int shmem_size = dimBlock.x*SZ*dimBlock.y*sizeof(DType); - - CHECK_EQ(dst.size(1), src.size(1)) << "AddTakeGradLargeBatch: shape mismatch"; - CHECK_EQ(index.size(0), src.size(0)) << "AddTakeGradLargeBatch: shape mismatch"; - mshadow::cuda::CheckLaunchParam(dimGrid, dimBlock, "AddTakeGradLargeBatch"); - - switch (SZ) { - case 1: - AddTakeGradLargeBatchKernel<1, DType> - <<>> - (dst.dptr_, sum_counts_ptr, num_runs_ptr, - sorted.dptr_, index.dptr_, src.dptr_, - static_cast(src.size(0)), - static_cast(src.size(1))); - break; - case 2: - AddTakeGradLargeBatchKernel<2, DType> - <<>> - (dst.dptr_, sum_counts_ptr, num_runs_ptr, - sorted.dptr_, index.dptr_, src.dptr_, - static_cast(src.size(0)), - static_cast(src.size(1))); - break; - case 3: - AddTakeGradLargeBatchKernel<3, DType> - <<>> - (dst.dptr_, sum_counts_ptr, num_runs_ptr, - sorted.dptr_, index.dptr_, src.dptr_, - static_cast(src.size(0)), - static_cast(src.size(1))); - break; - case 4: - AddTakeGradLargeBatchKernel<4, DType> - <<>> - (dst.dptr_, sum_counts_ptr, num_runs_ptr, - sorted.dptr_, index.dptr_, src.dptr_, - static_cast(src.size(0)), - static_cast(src.size(1))); - break; - default: - LOG(FATAL) << "AddTakeGradLargeBatch, incorrect value SZ " << SZ; - break; - } - MSHADOW_CUDA_POST_KERNEL_CHECK(AddTakeGradLargeBatchKernel); -} - -} // namespace op -} // namespace mxnet -#endif // MXNET_OPERATOR_TENSOR_INDEXING_OP_CUH_ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/*! + * Copyright (c) 2017 by Contributors + * \file indexing_op-inl.cuh + * \brief CUDA implementations for indexing_op.h + * \author Antti-Pekka Hynninen +*/ +#ifndef MXNET_OPERATOR_TENSOR_INDEXING_OP_CUH_ +#define MXNET_OPERATOR_TENSOR_INDEXING_OP_CUH_ +#include +#include + +#if CUDA_VERSION >= 9000 +#define FULLMASK 0xFFFFFFFF +#define __ballot(x) __ballot_sync(FULLMASK, (x)) +#define __all(x) __all_sync(FULLMASK, (x)) +#endif + +namespace mxnet { +namespace op { +const int kWarpSize = 32; + +template +__global__ void AddTakeGradLargeBatchKernel(DType* dst, + // If idx_start == NULL, then in-kernel edge + // detection is used + const IdxType *idx_start, + // idx_start_size_ptr ignored if idx_start == NULL + const int* idx_start_size_ptr, + const IdxType *sorted, const IdxType *index, + const DType *src, + int ymax, int xmax) { + // Size of the shared memory is [blockDim.x*SZ*blockDim.y]*sizeof(DType) + extern __shared__ char sh_grad_weight_char[]; + DType* sh_grad_weight = (DType*)sh_grad_weight_char; + + int iidx_end = (idx_start == NULL) ? ymax : *idx_start_size_ptr; + + for (int iidx = blockIdx.y;iidx < iidx_end;iidx += gridDim.y) { + + // Thread block sums up elements in the range [idx_begin, idx_end-1] + int idx_begin, idx_end; + int sorted_value; + if (idx_start == NULL) { + idx_begin = iidx; + sorted_value = static_cast(sorted[idx_begin]); + if (idx_begin > 0 && sorted_value == static_cast(sorted[idx_begin - 1])) continue; + // Algorithm is explained using an example: + // blockDim.x = 32 + // blockDim.y = 4 + // sorted[idx_begin:] = [4 4 4 9] + // (3,4) denotes threadIdx.x=3, threadIdx.y=4, ":" is used for ranges + // (0:31,0:3) sorted_value = 4 + idx_end = idx_begin + 1; + unsigned int* sh_ballot = (unsigned int*)sh_grad_weight_char; + int no_edge = 0; + do { + int idx = idx_end + threadIdx.x + threadIdx.y*blockDim.x; + // Example: + // (0:1,0) sorted_idx = 4 + // (rest) sorted_idx = -1 + int sorted_idx = (idx < ymax) ? static_cast(sorted[idx]) : -1; + // Example: + // (0:31,0) sh_ballot[0] = 0b100 + // (rest) sh_ballot[1...3] = 0 + // sh_ballot[] tells us which thread within the warp found the edge + sh_ballot[threadIdx.y] = __ballot(sorted_value != sorted_idx); + __syncthreads(); + // No edge if sh_ballot[threadIdx.x] == 0 + // NOTE: All warps have the same value for no_edge + // Example: + // (0,:) no_edge = 0 + // (rest) no_edge = 1 + no_edge = (threadIdx.x < blockDim.y) ? (sh_ballot[threadIdx.x] == 0) : 1; + idx_end += blockDim.x*blockDim.y; + // Example: + // __all(no_edge) = 0 since no_edge = 0 for threadIdx.x = 0, hence we leave the loop + } while (__all(no_edge)); + idx_end -= blockDim.x*blockDim.y; + // Find the first edge + // Example: + // (0,:) val = 1 + // (rest) val = 0 + unsigned int val = (threadIdx.x < blockDim.y && sh_ballot[threadIdx.x] != 0) ? + 1 : 0; + // NOTE: Set nth bit if thread n in the warp has val = 1 + // Example: + // (all) val = 1 + val = __ballot( val ); + // __ffs() returns the position of first set bit, 1...32. __ffs(1) = 1 + // j will be the warp index where edge was found + // Example: + // (all) j = 1 - 1 = 0 + int j = __ffs(val) - 1; + // j = warp index where the edge was found + // __ffs(sh_ballot[j]) - 1 = warp lane where the edge was found + // idx_end points to the one over the last value. + // Example: + // idx_end += 0*blockDim.x + _ffs(0b100) - 1 = 0 + 3 - 1 = 2 + // sorted[idx_end] = 9 + idx_end += j*blockDim.x + __ffs(sh_ballot[j]) - 1; + __syncthreads(); + } else { + idx_begin = idx_start[iidx]; + idx_end = ((iidx + 1) < iidx_end) ? idx_start[iidx + 1] : ymax; + sorted_value = static_cast(sorted[idx_begin]); + } + + const int start_feature = threadIdx.x + blockIdx.x * blockDim.x * SZ; + const int dst_row = sorted_value * xmax; + + int num_idx = idx_end - idx_begin; + int idx0 = idx_begin + threadIdx.y*num_idx/blockDim.y; + int idx1 = idx_begin + (threadIdx.y + 1)*num_idx/blockDim.y; + + // Read and sum data into grad_weight[] + DType grad_weight[SZ]; + #pragma unroll + for (int ii = 0; ii < SZ; ii++) { + grad_weight[ii] = (DType)0; + } + for (int idx=idx0; idx < idx1;idx++) { + const int src_row = static_cast(index[idx]) * xmax; + #pragma unroll + for (int ii = 0; ii < SZ; ii++) + { + int feature_dim = start_feature + ii * blockDim.x; + if (feature_dim < xmax) + { + grad_weight[ii] += src[src_row + feature_dim]; + } + } + } + #pragma unroll + for (int ii = 0; ii < SZ; ii++) { + sh_grad_weight[threadIdx.x + ii*blockDim.x + threadIdx.y*blockDim.x*SZ] = grad_weight[ii]; + } + __syncthreads(); + // We now have grad_weight[] values, reduce within thread block + for (int t=1;t < blockDim.y;t <<= 1) { + DType tmp[SZ]; + #pragma unroll + for (int ii = 0; ii < SZ; ii++) { + tmp[ii] = (threadIdx.y + t < blockDim.y) ? + sh_grad_weight[threadIdx.x + ii*blockDim.x + (threadIdx.y + t)*blockDim.x*SZ] : (DType)0; + } + __syncthreads(); + #pragma unroll + for (int ii = 0; ii < SZ; ii++) { + sh_grad_weight[threadIdx.x + ii*blockDim.x + threadIdx.y*blockDim.x*SZ] += tmp[ii]; + } + __syncthreads(); + } + // Result is in sh_grad_weight[threadIdx.x + ii*blockDim.x] + if (threadIdx.y == 0) { + #pragma unroll + for (int ii = 0; ii < SZ; ii++) { + int feature_dim = start_feature + ii * blockDim.x; + if (feature_dim < xmax) { + dst[dst_row + feature_dim] += sh_grad_weight[threadIdx.x + ii*blockDim.x]; + } + } + } + + } +} + +template +inline typename std::enable_if::value, size_t>::type +AddTakeGradLargeBatchWorkspaceSize(size_t num_keys) { + size_t encode_bytes = 0; + cub::DeviceRunLengthEncode::Encode + (NULL, encode_bytes, NULL, NULL, NULL, NULL, num_keys); + size_t exclusivesum_bytes = 0; + cub::DeviceScan::ExclusiveSum(NULL, exclusivesum_bytes, + NULL, NULL, num_keys); + size_t temporary_bytes = std::max(encode_bytes, exclusivesum_bytes); + size_t unique_bytes = num_keys*sizeof(IndexType); + size_t counts_bytes = num_keys*sizeof(IndexType); + size_t num_runs_bytes = 1*sizeof(int); + return (unique_bytes + counts_bytes + num_runs_bytes + temporary_bytes); +} + +template +inline void AddTakeGradLargeBatch(mshadow::Tensor dst, + const mshadow::Tensor& sorted, + const mshadow::Tensor& index, + const mshadow::Tensor &src, + mshadow::Tensor* workspace) { + CHECK_EQ(dst.CheckContiguous(), true); + CHECK_EQ(sorted.CheckContiguous(), true); + CHECK_EQ(index.CheckContiguous(), true); + CHECK_EQ(src.CheckContiguous(), true); + // const int kWarpBits = kMemUnitBits; + cudaStream_t stream = mshadow::Stream::GetStream(dst.stream_); + IndexType* sum_counts_ptr = NULL; + int* num_runs_ptr = NULL; + if (dst.size(0)*4 < src.size(0) && workspace != NULL) { + // Workspace given and potentially loops at least 4 times, use CUB to create sum_counts + CHECK_EQ(workspace->CheckContiguous(), true); + // workspace = [unique_out, counts_out, temporary_storage] + size_t unique_bytes = sorted.size(0)*sizeof(IndexType); + size_t counts_bytes = sorted.size(0)*sizeof(IndexType); + size_t num_runs_bytes = 1*sizeof(int); + + size_t encode_bytes = 0; + cub::DeviceRunLengthEncode::Encode + (NULL, encode_bytes, NULL, NULL, NULL, NULL, sorted.size(0), stream); + size_t exclusivesum_bytes = 0; + cub::DeviceScan::ExclusiveSum + (NULL, exclusivesum_bytes, NULL, NULL, sorted.size(0), stream); + size_t temporary_bytes = std::max(encode_bytes, exclusivesum_bytes); + + // Check that we have enough storage + CHECK_GE(workspace->size(0), unique_bytes + counts_bytes + + num_runs_bytes + temporary_bytes); + + IndexType* unique_out_ptr = reinterpret_cast(workspace->dptr_); + IndexType* counts_out_ptr = reinterpret_cast(workspace->dptr_ + unique_bytes); + num_runs_ptr = reinterpret_cast(workspace->dptr_ + unique_bytes + + counts_bytes); + void* temporary_storage = reinterpret_cast(workspace->dptr_ + unique_bytes + + counts_bytes + num_runs_bytes); + + cub::DeviceRunLengthEncode::Encode + (temporary_storage, temporary_bytes, sorted.dptr_, unique_out_ptr, counts_out_ptr, + num_runs_ptr, sorted.size(0), stream); + + sum_counts_ptr = unique_out_ptr; + cub::DeviceScan::ExclusiveSum + (temporary_storage, temporary_bytes, counts_out_ptr, sum_counts_ptr, + sorted.size(0), stream); + } + + const int num_unique_est = min(dst.size(0), src.size(0)); + const int max_nthread = 128; + const int num_y = max(src.size(0)/num_unique_est, 1); + const int block_dim_x = kWarpSize; + const int block_dim_y = min(num_y, max_nthread/block_dim_x); + const int SZ = min((src.size(1) + block_dim_x - 1) / block_dim_x, 4); + const int grid_dim_x = (src.size(1) + block_dim_x * SZ - 1) / (block_dim_x * SZ); + const int grid_dim_y = min(num_unique_est, mshadow::cuda::kBaseGridNum); + dim3 dimBlock(block_dim_x, block_dim_y); + dim3 dimGrid(grid_dim_x, grid_dim_y); + // Maximum shared memory usage: 128*4*sizeof(DType), which is 4K for 64bit DType elements + int shmem_size = dimBlock.x*SZ*dimBlock.y*sizeof(DType); + + CHECK_EQ(dst.size(1), src.size(1)) << "AddTakeGradLargeBatch: shape mismatch"; + CHECK_EQ(index.size(0), src.size(0)) << "AddTakeGradLargeBatch: shape mismatch"; + mshadow::cuda::CheckLaunchParam(dimGrid, dimBlock, "AddTakeGradLargeBatch"); + + switch (SZ) { + case 1: + AddTakeGradLargeBatchKernel<1, DType> + <<>> + (dst.dptr_, sum_counts_ptr, num_runs_ptr, + sorted.dptr_, index.dptr_, src.dptr_, + static_cast(src.size(0)), + static_cast(src.size(1))); + break; + case 2: + AddTakeGradLargeBatchKernel<2, DType> + <<>> + (dst.dptr_, sum_counts_ptr, num_runs_ptr, + sorted.dptr_, index.dptr_, src.dptr_, + static_cast(src.size(0)), + static_cast(src.size(1))); + break; + case 3: + AddTakeGradLargeBatchKernel<3, DType> + <<>> + (dst.dptr_, sum_counts_ptr, num_runs_ptr, + sorted.dptr_, index.dptr_, src.dptr_, + static_cast(src.size(0)), + static_cast(src.size(1))); + break; + case 4: + AddTakeGradLargeBatchKernel<4, DType> + <<>> + (dst.dptr_, sum_counts_ptr, num_runs_ptr, + sorted.dptr_, index.dptr_, src.dptr_, + static_cast(src.size(0)), + static_cast(src.size(1))); + break; + default: + LOG(FATAL) << "AddTakeGradLargeBatch, incorrect value SZ " << SZ; + break; + } + MSHADOW_CUDA_POST_KERNEL_CHECK(AddTakeGradLargeBatchKernel); +} + +} // namespace op +} // namespace mxnet +#endif // MXNET_OPERATOR_TENSOR_INDEXING_OP_CUH_ diff --git a/src/operator/tensor/indexing_op.cc b/src/operator/tensor/indexing_op.cc index 5f010fdfc62c..e5cb41088e22 100644 --- a/src/operator/tensor/indexing_op.cc +++ b/src/operator/tensor/indexing_op.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file indexing_op.cc * \brief * \author Siyi Li, Chi Zhang diff --git a/src/operator/tensor/indexing_op.cu b/src/operator/tensor/indexing_op.cu index 287ec25d70be..d57628a4389c 100644 --- a/src/operator/tensor/indexing_op.cu +++ b/src/operator/tensor/indexing_op.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file indexing_op.cu * \brief * \author Siyi Li, Chi Zhang diff --git a/src/operator/tensor/indexing_op.h b/src/operator/tensor/indexing_op.h index 5fd6e81d0b2f..ef42b01fb5b6 100644 --- a/src/operator/tensor/indexing_op.h +++ b/src/operator/tensor/indexing_op.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file indexing_op.h * \brief * \author Bing Xu, Siyi Li, Chi Zhang diff --git a/src/operator/tensor/init_op.cc b/src/operator/tensor/init_op.cc index 16f71fc7e4e3..8dac22a64966 100644 --- a/src/operator/tensor/init_op.cc +++ b/src/operator/tensor/init_op.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file init_op.cc * \brief CPU Implementation of init op */ diff --git a/src/operator/tensor/init_op.cu b/src/operator/tensor/init_op.cu index a798f26db60d..6e2b65cc8519 100644 --- a/src/operator/tensor/init_op.cu +++ b/src/operator/tensor/init_op.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file init_op.cu * \brief GPU Implementation of init op */ diff --git a/src/operator/tensor/init_op.h b/src/operator/tensor/init_op.h index 5ce132d4bebf..bdc74d332491 100644 --- a/src/operator/tensor/init_op.h +++ b/src/operator/tensor/init_op.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file init_op.h * \brief Function definition of initialization op */ diff --git a/src/operator/tensor/la_op.cc b/src/operator/tensor/la_op.cc index 859e761c7409..1b726ced906b 100644 --- a/src/operator/tensor/la_op.cc +++ b/src/operator/tensor/la_op.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file la_op.cc * \brief CPU-Operators for advanced linear algebra. */ @@ -293,7 +311,7 @@ NNVM_REGISTER_OP(_backward_linalg_trmm) .set_attr("FCompute", LaOpBackward); NNVM_REGISTER_OP(linalg_trsm) -.describe(R"code(Solves matrix equations involving a triangular matrix. +.describe(R"code(Solves matrix equations involving a triangular matrix. Input are two tensors *A*, *B* each of dimension *n >= 2* and each having the same shape on the leading *n-2* dimensions. For every *n-2* dimensional index *i* let *A*\ :sub:`i`\ , *B*\ :sub:`i`\ be the matrices given by the last *2* dimensions. diff --git a/src/operator/tensor/la_op.h b/src/operator/tensor/la_op.h index 488a3edd6bd9..977998855263 100644 --- a/src/operator/tensor/la_op.h +++ b/src/operator/tensor/la_op.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file la_op.h * \brief Operators for advanced linear algebra. */ diff --git a/src/operator/tensor/la_op_inline.h b/src/operator/tensor/la_op_inline.h index b83bf81e6e2d..a032988edb75 100644 --- a/src/operator/tensor/la_op_inline.h +++ b/src/operator/tensor/la_op_inline.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file la_op_inline.h * \brief Operators for advanced linear algebra. */ diff --git a/src/operator/tensor/matrix_op-inl.h b/src/operator/tensor/matrix_op-inl.h index 26f409a43525..af0de593c1be 100644 --- a/src/operator/tensor/matrix_op-inl.h +++ b/src/operator/tensor/matrix_op-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file matrix_op-inl.h * \brief Function definition of matrix related operators */ diff --git a/src/operator/tensor/matrix_op.cc b/src/operator/tensor/matrix_op.cc index 4832b13f56c5..e7e8f5548a1c 100644 --- a/src/operator/tensor/matrix_op.cc +++ b/src/operator/tensor/matrix_op.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file matrix_op.cc * \brief CPU Implementation of matrix operations */ diff --git a/src/operator/tensor/matrix_op.cu b/src/operator/tensor/matrix_op.cu index 8cf656e999b8..ca40419a9367 100644 --- a/src/operator/tensor/matrix_op.cu +++ b/src/operator/tensor/matrix_op.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file matrix_op.cu * \brief GPU Implementation of matrix operations */ diff --git a/src/operator/tensor/ordering_op-inl.h b/src/operator/tensor/ordering_op-inl.h index a8cee5940838..eb28b010cbd3 100644 --- a/src/operator/tensor/ordering_op-inl.h +++ b/src/operator/tensor/ordering_op-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file ordering_op-inl.h * \brief Function definition of matrix related operators */ diff --git a/src/operator/tensor/ordering_op.cc b/src/operator/tensor/ordering_op.cc index 3308836c1840..22712a82b4c9 100644 --- a/src/operator/tensor/ordering_op.cc +++ b/src/operator/tensor/ordering_op.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2016 by Contributors * \file ordering.cc * \brief CPU Implementation of the ordering operations */ diff --git a/src/operator/tensor/ordering_op.cu b/src/operator/tensor/ordering_op.cu index 29df70f9e6b4..8e40b4a350d9 100644 --- a/src/operator/tensor/ordering_op.cu +++ b/src/operator/tensor/ordering_op.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file matrix_op.cu * \brief GPU Implementation of matrix operations */ diff --git a/src/operator/tensor/sort_op-inl.cuh b/src/operator/tensor/sort_op-inl.cuh index 725f9b8c5f9e..5ad31053f92e 100644 --- a/src/operator/tensor/sort_op-inl.cuh +++ b/src/operator/tensor/sort_op-inl.cuh @@ -1,129 +1,148 @@ -/*! - * Copyright (c) 2017 by Contributors - * \file sort_op-inl.cuh - * \brief CUDA implementations for sort_op.h - */ -#ifndef MXNET_OPERATOR_TENSOR_SORT_OP_INL_CUH_ -#define MXNET_OPERATOR_TENSOR_SORT_OP_INL_CUH_ -#include -#include -#if defined(_MSC_VER) && __CUDACC_VER_MAJOR__ == 8 && __CUDACC_VER_BUILD__ != 44 -// Many CUDA 8 compilers other than V8.0.44 crash on Windows -#pragma warning("Potential crash on CUDA compiler detected. Switching sorting from CUB to Thrust") -#define SORT_WITH_THRUST -#else -#include -#undef SORT_WITH_THRUST -#endif -#if CUDA_VERSION >= 7000 -#include -#endif - -namespace mxnet { -namespace op { - -template -inline typename std::enable_if::value, size_t>::type -SortByKeyWorkspaceSize(const size_t num_keys) { -#ifdef SORT_WITH_THRUST - return 0; -#else - size_t sortpairs_bytes = 0; - cub::DeviceRadixSort::SortPairs(NULL, sortpairs_bytes, - NULL, NULL, NULL, NULL, num_keys); - size_t keys_bytes = num_keys*sizeof(KDType); - size_t values_bytes = num_keys*sizeof(VDType); - return (keys_bytes + values_bytes + sortpairs_bytes); -#endif -} - -template -inline void SortByKey(mshadow::Tensor keys, mshadow::Tensor values, - bool is_ascend, mshadow::Tensor* workspace, - const int begin_bit, const int end_bit) { - CHECK_EQ(keys.CheckContiguous(), true); - CHECK_EQ(values.CheckContiguous(), true); -#if CUDA_VERSION >= 7000 - cudaStream_t stream = mshadow::Stream::GetStream(keys.stream_); -#ifndef SORT_WITH_THRUST - if (workspace != NULL) { - // Workspace given, sort using CUB - CHECK_EQ(workspace->CheckContiguous(), true); - // workspace = [keys_out, values_out, temporary_storage] - size_t keys_bytes = keys.size(0)*sizeof(KDType); - size_t values_bytes = keys.size(0)*sizeof(VDType); - // Get the size of internal storage (for checking purposes only) - size_t sortpairs_bytes = 0; - if (is_ascend) { - cub::DeviceRadixSort::SortPairs(NULL, sortpairs_bytes, - NULL, NULL, NULL, NULL, - keys.size(0), begin_bit, end_bit, stream); - } else { - cub::DeviceRadixSort::SortPairsDescending(NULL, sortpairs_bytes, - NULL, NULL, NULL, NULL, - keys.size(0), begin_bit, end_bit, stream); - } - // Check that we have enough storage - CHECK_GE(workspace->size(0), keys_bytes + values_bytes + sortpairs_bytes); - // - KDType* keys_out_ptr = reinterpret_cast(workspace->dptr_); - VDType* values_out_ptr = reinterpret_cast(workspace->dptr_ + keys_bytes); - void* temp_storage = reinterpret_cast(workspace->dptr_ + keys_bytes + values_bytes); - // Sort - if (is_ascend) { - cub::DeviceRadixSort::SortPairs(temp_storage, sortpairs_bytes, - keys.dptr_, keys_out_ptr, values.dptr_, values_out_ptr, - keys.size(0), begin_bit, end_bit, stream); - } else { - cub::DeviceRadixSort::SortPairsDescending(temp_storage, sortpairs_bytes, - keys.dptr_, keys_out_ptr, values.dptr_, values_out_ptr, - keys.size(0), begin_bit, end_bit, stream); - } - // Copy result back to [keys, values] - mshadow::Tensor keys_out(keys_out_ptr, mshadow::Shape1(keys.size(0)), - keys.stream_); - mshadow::Tensor values_out(values_out_ptr, mshadow::Shape1(keys.size(0)), - keys.stream_); - mshadow::Copy(keys, keys_out, keys.stream_); - mshadow::Copy(values, values_out, values.stream_); - } else { -#endif // SORT_WITH_THRUST - // No workspace, sort using thrust - thrust::device_ptr key_iter = thrust::device_pointer_cast(keys.dptr_); - thrust::device_ptr value_iter = thrust::device_pointer_cast(values.dptr_); - if (is_ascend) { - thrust::stable_sort_by_key( - thrust::cuda::par.on(stream), - key_iter, key_iter + keys.size(0), value_iter, thrust::less()); - } else { - thrust::stable_sort_by_key( - thrust::cuda::par.on(stream), - key_iter, key_iter + keys.size(0), value_iter, thrust::greater()); - } -#ifndef SORT_WITH_THRUST - } -#endif // SORT_WITH_THRUST - MSHADOW_CUDA_POST_KERNEL_CHECK(SortByKey); -#else - LOG(FATAL) << "SortByKey is only supported for CUDA version >=7.0!"; -#endif -} - -template -inline void SortByKey(mshadow::Tensor keys, - mshadow::Tensor values, bool is_ascend, - mshadow::Tensor* workspace, const int begin_bit, const int end_bit) { - LOG(FATAL) << "SortByKey for half_t is not implemented!"; -} - -template -inline void SortByKey(mshadow::Tensor keys, - mshadow::Tensor values, bool is_ascend, - mshadow::Tensor* workspace, const int begin_bit, const int end_bit) { - LOG(FATAL) << "SortByKey for half_t is not implemented!"; -} - -} // namespace op -} // namespace mxnet - -#endif // MXNET_OPERATOR_TENSOR_SORT_OP_INL_CUH_ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/*! + * Copyright (c) 2017 by Contributors + * \file sort_op-inl.cuh + * \brief CUDA implementations for sort_op.h + */ +#ifndef MXNET_OPERATOR_TENSOR_SORT_OP_INL_CUH_ +#define MXNET_OPERATOR_TENSOR_SORT_OP_INL_CUH_ +#include +#include +#if defined(_MSC_VER) && __CUDACC_VER_MAJOR__ == 8 && __CUDACC_VER_BUILD__ != 44 +// Many CUDA 8 compilers other than V8.0.44 crash on Windows +#pragma warning("Potential crash on CUDA compiler detected. Switching sorting from CUB to Thrust") +#define SORT_WITH_THRUST +#else +#include +#undef SORT_WITH_THRUST +#endif +#if CUDA_VERSION >= 7000 +#include +#endif + +namespace mxnet { +namespace op { + +template +inline typename std::enable_if::value, size_t>::type +SortByKeyWorkspaceSize(const size_t num_keys) { +#ifdef SORT_WITH_THRUST + return 0; +#else + size_t sortpairs_bytes = 0; + cub::DeviceRadixSort::SortPairs(NULL, sortpairs_bytes, + NULL, NULL, NULL, NULL, num_keys); + size_t keys_bytes = num_keys*sizeof(KDType); + size_t values_bytes = num_keys*sizeof(VDType); + return (keys_bytes + values_bytes + sortpairs_bytes); +#endif +} + +template +inline void SortByKey(mshadow::Tensor keys, mshadow::Tensor values, + bool is_ascend, mshadow::Tensor* workspace, + const int begin_bit, const int end_bit) { + CHECK_EQ(keys.CheckContiguous(), true); + CHECK_EQ(values.CheckContiguous(), true); +#if CUDA_VERSION >= 7000 + cudaStream_t stream = mshadow::Stream::GetStream(keys.stream_); +#ifndef SORT_WITH_THRUST + if (workspace != NULL) { + // Workspace given, sort using CUB + CHECK_EQ(workspace->CheckContiguous(), true); + // workspace = [keys_out, values_out, temporary_storage] + size_t keys_bytes = keys.size(0)*sizeof(KDType); + size_t values_bytes = keys.size(0)*sizeof(VDType); + // Get the size of internal storage (for checking purposes only) + size_t sortpairs_bytes = 0; + if (is_ascend) { + cub::DeviceRadixSort::SortPairs(NULL, sortpairs_bytes, + NULL, NULL, NULL, NULL, + keys.size(0), begin_bit, end_bit, stream); + } else { + cub::DeviceRadixSort::SortPairsDescending(NULL, sortpairs_bytes, + NULL, NULL, NULL, NULL, + keys.size(0), begin_bit, end_bit, stream); + } + // Check that we have enough storage + CHECK_GE(workspace->size(0), keys_bytes + values_bytes + sortpairs_bytes); + // + KDType* keys_out_ptr = reinterpret_cast(workspace->dptr_); + VDType* values_out_ptr = reinterpret_cast(workspace->dptr_ + keys_bytes); + void* temp_storage = reinterpret_cast(workspace->dptr_ + keys_bytes + values_bytes); + // Sort + if (is_ascend) { + cub::DeviceRadixSort::SortPairs(temp_storage, sortpairs_bytes, + keys.dptr_, keys_out_ptr, values.dptr_, values_out_ptr, + keys.size(0), begin_bit, end_bit, stream); + } else { + cub::DeviceRadixSort::SortPairsDescending(temp_storage, sortpairs_bytes, + keys.dptr_, keys_out_ptr, values.dptr_, values_out_ptr, + keys.size(0), begin_bit, end_bit, stream); + } + // Copy result back to [keys, values] + mshadow::Tensor keys_out(keys_out_ptr, mshadow::Shape1(keys.size(0)), + keys.stream_); + mshadow::Tensor values_out(values_out_ptr, mshadow::Shape1(keys.size(0)), + keys.stream_); + mshadow::Copy(keys, keys_out, keys.stream_); + mshadow::Copy(values, values_out, values.stream_); + } else { +#endif // SORT_WITH_THRUST + // No workspace, sort using thrust + thrust::device_ptr key_iter = thrust::device_pointer_cast(keys.dptr_); + thrust::device_ptr value_iter = thrust::device_pointer_cast(values.dptr_); + if (is_ascend) { + thrust::stable_sort_by_key( + thrust::cuda::par.on(stream), + key_iter, key_iter + keys.size(0), value_iter, thrust::less()); + } else { + thrust::stable_sort_by_key( + thrust::cuda::par.on(stream), + key_iter, key_iter + keys.size(0), value_iter, thrust::greater()); + } +#ifndef SORT_WITH_THRUST + } +#endif // SORT_WITH_THRUST + MSHADOW_CUDA_POST_KERNEL_CHECK(SortByKey); +#else + LOG(FATAL) << "SortByKey is only supported for CUDA version >=7.0!"; +#endif +} + +template +inline void SortByKey(mshadow::Tensor keys, + mshadow::Tensor values, bool is_ascend, + mshadow::Tensor* workspace, const int begin_bit, const int end_bit) { + LOG(FATAL) << "SortByKey for half_t is not implemented!"; +} + +template +inline void SortByKey(mshadow::Tensor keys, + mshadow::Tensor values, bool is_ascend, + mshadow::Tensor* workspace, const int begin_bit, const int end_bit) { + LOG(FATAL) << "SortByKey for half_t is not implemented!"; +} + +} // namespace op +} // namespace mxnet + +#endif // MXNET_OPERATOR_TENSOR_SORT_OP_INL_CUH_ diff --git a/src/operator/tensor/sort_op.h b/src/operator/tensor/sort_op.h index ac8a69846ea1..a0425a5afe1e 100644 --- a/src/operator/tensor/sort_op.h +++ b/src/operator/tensor/sort_op.h @@ -1,87 +1,105 @@ -/*! - * Copyright (c) 2017 by Contributors - * \file sort_op.h - * \brief SortByKey function - */ -#ifndef MXNET_OPERATOR_TENSOR_SORT_OP_H_ -#define MXNET_OPERATOR_TENSOR_SORT_OP_H_ - -#include -#include -#include -#include - -namespace mxnet { -namespace op { -/*! - * \brief CPU/GPU: Sort key-value pairs stored in separate places. (Stable sort is performed!) - * \param keys the keys to sort - * \param values the values that sorts w.r.t the key - * \param is_ascend whether to sort key in ascending order - */ -template -inline void SortByKey(mshadow::Tensor keys, mshadow::Tensor values, - bool is_ascend = true, mshadow::Tensor* workspace = NULL, - const int begin_bit = 0, const int end_bit = sizeof(KDType)*8) { - CHECK_EQ(keys.CheckContiguous(), true); - CHECK_EQ(values.CheckContiguous(), true); - CHECK_EQ(keys.size(0), values.size(0)) - << "The sizes of key/value are not equal! keys_size: " << keys.size(0) - << "values_size: " << values.size(0); - std::vector idx(keys.size(0)); - std::vector keys_vec(keys.size(0)); - std::vector values_vec(values.size(0)); - for (index_t i = 0; i < keys.size(0); i++) { - idx[i] = i; - keys_vec[i] = keys[i]; - values_vec[i] = values[i]; - } - if (is_ascend) { - std::stable_sort(idx.begin(), idx.end(), - [&keys_vec](size_t i1, size_t i2) - {return keys_vec[i1] < keys_vec[i2]; }); - } else { - std::stable_sort(idx.begin(), idx.end(), - [&keys_vec](size_t i1, size_t i2) - {return keys_vec[i1] > keys_vec[i2]; }); - } - for (index_t i = 0; i < values.size(0); i++) { - keys[i] = keys_vec[idx[i]]; - values[i] = values_vec[idx[i]]; - } -} - -/*! - * \brief CPU/GPU: Return the amount of temporary storage in bytes required for SortByKey - * \param num_keys number of keys to sort - */ -template -inline typename std::enable_if::value, size_t>::type -SortByKeyWorkspaceSize(const size_t num_keys) { - return 0; -} - -/*! - * \brief CPU/GPU: Sort key-value pairs stored in separate places. (Stable sort is performed!) - * \param keys the keys to sort - * \param values the values that sorts w.r.t the key - * \param is_ascend whether to sort key in ascending order - */ -template -inline void SortByKey(mshadow::Tensor keys, mshadow::Tensor values, - bool is_ascend = true, mshadow::Tensor* workspace = NULL, - const int begin_bit = 0, const int end_bit = sizeof(KDType)*8); -/*! - * \brief CPU/GPU: Return the amount of temporary storage in bytes required for SortByKey - * \param num_keys number of keys to sort - */ -template -inline typename std::enable_if::value, size_t>::type -SortByKeyWorkspaceSize(const size_t num_keys); - -} // namespace op -} // namespace mxnet -#ifdef __CUDACC__ -#include "./sort_op-inl.cuh" -#endif -#endif // MXNET_OPERATOR_TENSOR_SORT_OP_H_ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/*! + * \file sort_op.h + * \brief SortByKey function + */ +#ifndef MXNET_OPERATOR_TENSOR_SORT_OP_H_ +#define MXNET_OPERATOR_TENSOR_SORT_OP_H_ + +#include +#include +#include +#include + +namespace mxnet { +namespace op { +/*! + * \brief CPU/GPU: Sort key-value pairs stored in separate places. (Stable sort is performed!) + * \param keys the keys to sort + * \param values the values that sorts w.r.t the key + * \param is_ascend whether to sort key in ascending order + */ +template +inline void SortByKey(mshadow::Tensor keys, mshadow::Tensor values, + bool is_ascend = true, mshadow::Tensor* workspace = NULL, + const int begin_bit = 0, const int end_bit = sizeof(KDType)*8) { + CHECK_EQ(keys.CheckContiguous(), true); + CHECK_EQ(values.CheckContiguous(), true); + CHECK_EQ(keys.size(0), values.size(0)) + << "The sizes of key/value are not equal! keys_size: " << keys.size(0) + << "values_size: " << values.size(0); + std::vector idx(keys.size(0)); + std::vector keys_vec(keys.size(0)); + std::vector values_vec(values.size(0)); + for (index_t i = 0; i < keys.size(0); i++) { + idx[i] = i; + keys_vec[i] = keys[i]; + values_vec[i] = values[i]; + } + if (is_ascend) { + std::stable_sort(idx.begin(), idx.end(), + [&keys_vec](size_t i1, size_t i2) + {return keys_vec[i1] < keys_vec[i2]; }); + } else { + std::stable_sort(idx.begin(), idx.end(), + [&keys_vec](size_t i1, size_t i2) + {return keys_vec[i1] > keys_vec[i2]; }); + } + for (index_t i = 0; i < values.size(0); i++) { + keys[i] = keys_vec[idx[i]]; + values[i] = values_vec[idx[i]]; + } +} + +/*! + * \brief CPU/GPU: Return the amount of temporary storage in bytes required for SortByKey + * \param num_keys number of keys to sort + */ +template +inline typename std::enable_if::value, size_t>::type +SortByKeyWorkspaceSize(const size_t num_keys) { + return 0; +} + +/*! + * \brief CPU/GPU: Sort key-value pairs stored in separate places. (Stable sort is performed!) + * \param keys the keys to sort + * \param values the values that sorts w.r.t the key + * \param is_ascend whether to sort key in ascending order + */ +template +inline void SortByKey(mshadow::Tensor keys, mshadow::Tensor values, + bool is_ascend = true, mshadow::Tensor* workspace = NULL, + const int begin_bit = 0, const int end_bit = sizeof(KDType)*8); +/*! + * \brief CPU/GPU: Return the amount of temporary storage in bytes required for SortByKey + * \param num_keys number of keys to sort + */ +template +inline typename std::enable_if::value, size_t>::type +SortByKeyWorkspaceSize(const size_t num_keys); + +} // namespace op +} // namespace mxnet +#ifdef __CUDACC__ +#include "./sort_op-inl.cuh" +#endif +#endif // MXNET_OPERATOR_TENSOR_SORT_OP_H_ diff --git a/src/operator/upsampling-inl.h b/src/operator/upsampling-inl.h index a10ccb1f7626..fec0f74f14c8 100644 --- a/src/operator/upsampling-inl.h +++ b/src/operator/upsampling-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file upsampling-inl.h * \brief * \author Bing Xu diff --git a/src/operator/upsampling.cc b/src/operator/upsampling.cc index ad89d4ace137..653b5709f120 100644 --- a/src/operator/upsampling.cc +++ b/src/operator/upsampling.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file upsampling_nearest.cc * \brief * \author Bing Xu diff --git a/src/operator/upsampling.cu b/src/operator/upsampling.cu index 70466d438449..8152535233e4 100644 --- a/src/operator/upsampling.cu +++ b/src/operator/upsampling.cu @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file upsampling_nearest.cc * \brief * \author Bing Xu diff --git a/src/optimizer/sgd-inl.h b/src/optimizer/sgd-inl.h index 36b45c375b95..01a330bece8c 100644 --- a/src/optimizer/sgd-inl.h +++ b/src/optimizer/sgd-inl.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file sgd-inl.h * \brief Operator interface of mxnet. * \author Junyuan Xie diff --git a/src/resource.cc b/src/resource.cc index 60e40d1837a1..4c2dbee33f2b 100644 --- a/src/resource.cc +++ b/src/resource.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file resource.cc * \brief Implementation of resource manager. */ diff --git a/src/storage/cpu_device_storage.h b/src/storage/cpu_device_storage.h index 2afb658bb9c6..ead00dafbf44 100644 --- a/src/storage/cpu_device_storage.h +++ b/src/storage/cpu_device_storage.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file cpu_device_storage.h * \brief CPU storage implementation. */ diff --git a/src/storage/gpu_device_storage.h b/src/storage/gpu_device_storage.h index 10684905a861..3c4f732c80dc 100644 --- a/src/storage/gpu_device_storage.h +++ b/src/storage/gpu_device_storage.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file gpu_device_storage.h * \brief GPU storage implementation. */ diff --git a/src/storage/naive_storage_manager.h b/src/storage/naive_storage_manager.h index 05a8b10c2bb1..731f374bbfd2 100644 --- a/src/storage/naive_storage_manager.h +++ b/src/storage/naive_storage_manager.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file naive_storage_manager.h * \brief Naive storage manager. */ diff --git a/src/storage/pinned_memory_storage.h b/src/storage/pinned_memory_storage.h index 5b0df1041909..69e05f7cf90c 100644 --- a/src/storage/pinned_memory_storage.h +++ b/src/storage/pinned_memory_storage.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file cpu_device_storage.h * \brief CPU storage with pinned memory */ diff --git a/src/storage/pooled_storage_manager.h b/src/storage/pooled_storage_manager.h index 5e0050c04b2f..b2c6633a8082 100644 --- a/src/storage/pooled_storage_manager.h +++ b/src/storage/pooled_storage_manager.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file pooled_storage_manager.h * \brief Storage manager with a memory pool. */ diff --git a/src/storage/storage.cc b/src/storage/storage.cc index 353d72d41cd9..fa15a44b4fb6 100644 --- a/src/storage/storage.cc +++ b/src/storage/storage.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors */ #include #include diff --git a/src/storage/storage_manager.h b/src/storage/storage_manager.h index de08688c5aac..924d2ed48b1a 100644 --- a/src/storage/storage_manager.h +++ b/src/storage/storage_manager.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file storage_manager.h * \brief Storage manager. */ diff --git a/tests/ci_build/ci_build.sh b/tests/ci_build/ci_build.sh index fa2d37ee718f..79fcd86a5df0 100755 --- a/tests/ci_build/ci_build.sh +++ b/tests/ci_build/ci_build.sh @@ -1,4 +1,22 @@ #!/usr/bin/env bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # # Execute command within a docker container # diff --git a/tests/ci_build/install/install_julia.sh b/tests/ci_build/install/install_julia.sh index 80232a10fe53..5007c949537a 100644 --- a/tests/ci_build/install/install_julia.sh +++ b/tests/ci_build/install/install_julia.sh @@ -1,5 +1,23 @@ #!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + set -e wget https://julialang.s3.amazonaws.com/bin/linux/x64/0.5/julia-0.5.0-linux-x86_64.tar.gz diff --git a/tests/ci_build/install/install_library.sh b/tests/ci_build/install/install_library.sh index d65ab21ca4c0..399f6a093793 100644 --- a/tests/ci_build/install/install_library.sh +++ b/tests/ci_build/install/install_library.sh @@ -1,5 +1,23 @@ #!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + yum install graphviz pip install graphviz pip install opencv-python diff --git a/tests/ci_build/install/install_maven.sh b/tests/ci_build/install/install_maven.sh index 66459be8b8d2..666ebde06263 100644 --- a/tests/ci_build/install/install_maven.sh +++ b/tests/ci_build/install/install_maven.sh @@ -1,5 +1,23 @@ #!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + set -e wget http://mirrors.ocf.berkeley.edu/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz diff --git a/tests/ci_build/install/install_openblas.sh b/tests/ci_build/install/install_openblas.sh index 3ac642146026..2ec5eeb4498e 100644 --- a/tests/ci_build/install/install_openblas.sh +++ b/tests/ci_build/install/install_openblas.sh @@ -1,5 +1,23 @@ #!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + set -e git clone https://github.com/xianyi/OpenBLAS diff --git a/tests/ci_build/install/install_opencv.sh b/tests/ci_build/install/install_opencv.sh index 70c7ddbdc382..08a4d9b53cd0 100644 --- a/tests/ci_build/install/install_opencv.sh +++ b/tests/ci_build/install/install_opencv.sh @@ -1,5 +1,23 @@ #!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + set -e yum groupinstall -y "Development Tools" diff --git a/tests/ci_build/install/install_python2.sh b/tests/ci_build/install/install_python2.sh index c818c5d0a7db..ec4bbb9a9b87 100644 --- a/tests/ci_build/install/install_python2.sh +++ b/tests/ci_build/install/install_python2.sh @@ -1,5 +1,23 @@ #!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + set -e yum groupinstall -y "Development Tools" diff --git a/tests/ci_build/install/install_python3.sh b/tests/ci_build/install/install_python3.sh index 5aa1d80bf6f9..ee89161da793 100644 --- a/tests/ci_build/install/install_python3.sh +++ b/tests/ci_build/install/install_python3.sh @@ -1,5 +1,23 @@ #!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + set -e wget https://bootstrap.pypa.io/get-pip.py || exit 1 diff --git a/tests/ci_build/install/install_testdeps.sh b/tests/ci_build/install/install_testdeps.sh index 975eec41b63f..c77734805388 100644 --- a/tests/ci_build/install/install_testdeps.sh +++ b/tests/ci_build/install/install_testdeps.sh @@ -1,5 +1,23 @@ #!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + set -e pip install cpplint 'pylint==1.4.4' 'astroid==1.3.6' diff --git a/tests/ci_build/install/ubuntu_install_core.sh b/tests/ci_build/install/ubuntu_install_core.sh index 9ee76976e9e7..49475740d210 100755 --- a/tests/ci_build/install/ubuntu_install_core.sh +++ b/tests/ci_build/install/ubuntu_install_core.sh @@ -1,4 +1,22 @@ #!/usr/bin/env bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # install libraries for building mxnet c++ core on ubuntu apt-get update && apt-get install -y \ diff --git a/tests/ci_build/install/ubuntu_install_perl.sh b/tests/ci_build/install/ubuntu_install_perl.sh index da4df67a464a..a981746bc18d 100755 --- a/tests/ci_build/install/ubuntu_install_perl.sh +++ b/tests/ci_build/install/ubuntu_install_perl.sh @@ -1,4 +1,22 @@ #!/usr/bin/env bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # install libraries for mxnet's perl package on ubuntu apt-get update && apt-get install -y libmouse-perl pdl cpanminus swig libgraphviz-perl cpanm -q Function::Parameters diff --git a/tests/ci_build/install/ubuntu_install_python.sh b/tests/ci_build/install/ubuntu_install_python.sh index 973523d0c8f3..bb67e3401a89 100755 --- a/tests/ci_build/install/ubuntu_install_python.sh +++ b/tests/ci_build/install/ubuntu_install_python.sh @@ -1,4 +1,22 @@ #!/usr/bin/env bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # install libraries for mxnet's python package on ubuntu apt-get update && apt-get install -y python-dev python3-dev diff --git a/tests/ci_build/install/ubuntu_install_r.sh b/tests/ci_build/install/ubuntu_install_r.sh index 10851a6d0276..38d89a3e4783 100755 --- a/tests/ci_build/install/ubuntu_install_r.sh +++ b/tests/ci_build/install/ubuntu_install_r.sh @@ -1,4 +1,22 @@ #!/usr/bin/env bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # install libraries for mxnet's r package on ubuntu echo "deb http://cran.rstudio.com/bin/linux/ubuntu trusty/" >> /etc/apt/sources.list diff --git a/tests/ci_build/install/ubuntu_install_scala.sh b/tests/ci_build/install/ubuntu_install_scala.sh index dcdd4bc72b5d..712eff98b02a 100755 --- a/tests/ci_build/install/ubuntu_install_scala.sh +++ b/tests/ci_build/install/ubuntu_install_scala.sh @@ -1,4 +1,22 @@ #!/usr/bin/env bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # install libraries for mxnet's scala package on ubuntu apt-get update && apt-get install -y \ diff --git a/tests/cpp/engine/threaded_engine_test.cc b/tests/cpp/engine/threaded_engine_test.cc index 73dc53060b63..58b7e57a509c 100644 --- a/tests/cpp/engine/threaded_engine_test.cc +++ b/tests/cpp/engine/threaded_engine_test.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file threaded_engine_test.cc * \brief threaded engine tests */ diff --git a/tests/cpp/include/test_op.h b/tests/cpp/include/test_op.h index 57fda19e4c9e..d8f90df8447e 100644 --- a/tests/cpp/include/test_op.h +++ b/tests/cpp/include/test_op.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file test_op.h * \brief operator unit test utility functions * \author Chris Olivier diff --git a/tests/cpp/include/test_perf.h b/tests/cpp/include/test_perf.h index 93b7863de694..d74d4d5a8976 100644 --- a/tests/cpp/include/test_perf.h +++ b/tests/cpp/include/test_perf.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file test_perf.h * \brief operator unit test utility functions * \author Chris Olivier diff --git a/tests/cpp/include/test_util.h b/tests/cpp/include/test_util.h index 3fa82688c115..3f5f4ecbb5bb 100644 --- a/tests/cpp/include/test_util.h +++ b/tests/cpp/include/test_util.h @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file test_util.h * \brief unit test performance analysis functions * \author Chris Olivier diff --git a/tests/cpp/operator/batchnorm_test.cc b/tests/cpp/operator/batchnorm_test.cc index 719980b5d4f5..3fef28f79a0a 100644 --- a/tests/cpp/operator/batchnorm_test.cc +++ b/tests/cpp/operator/batchnorm_test.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file batchnorm_test.cc * \brief operator unit test utility functions * \author Chris Olivier diff --git a/tests/cpp/operator/krprod_test.cc b/tests/cpp/operator/krprod_test.cc index 6e10221f7ab3..31b8ab9dd781 100644 --- a/tests/cpp/operator/krprod_test.cc +++ b/tests/cpp/operator/krprod_test.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file krprod_test.cc * \brief Test Khatri-Rao product * \author Jencir Lee diff --git a/tests/cpp/storage/storage_test.cc b/tests/cpp/storage/storage_test.cc index b2bbc4918599..8af3984eb40f 100644 --- a/tests/cpp/storage/storage_test.cc +++ b/tests/cpp/storage/storage_test.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file storage_test.cc * \brief cpu/gpu storage tests */ diff --git a/tests/cpp/test_main.cc b/tests/cpp/test_main.cc index 28cdf7b6ec2a..b8ffbbd0ad04 100644 --- a/tests/cpp/test_main.cc +++ b/tests/cpp/test_main.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2017 by Contributors * \file test_main.cc * \brief operator unit test utility functions * \author Chris Olivier diff --git a/tests/jenkins/run_as_user.sh b/tests/jenkins/run_as_user.sh index db90f0bd0088..7ed3cdf5c937 100755 --- a/tests/jenkins/run_as_user.sh +++ b/tests/jenkins/run_as_user.sh @@ -1,5 +1,23 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + # Exit script with error if any errors occur set -e diff --git a/tests/jenkins/run_test.sh b/tests/jenkins/run_test.sh index a8564326443f..bc69ca1d7f39 100755 --- a/tests/jenkins/run_test.sh +++ b/tests/jenkins/run_test.sh @@ -1,5 +1,23 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + # Exit script with error if any errors occur echo "BUILD make" diff --git a/tests/jenkins/run_test_amzn_linux_gpu.sh b/tests/jenkins/run_test_amzn_linux_gpu.sh index 42c037e67a37..ecfb5211b9e6 100755 --- a/tests/jenkins/run_test_amzn_linux_gpu.sh +++ b/tests/jenkins/run_test_amzn_linux_gpu.sh @@ -1,5 +1,23 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + # Exit script with error if any errors occur echo "BUILD make" diff --git a/tests/jenkins/run_test_installation_docs.sh b/tests/jenkins/run_test_installation_docs.sh index 921c89a16605..90eecb95a325 100755 --- a/tests/jenkins/run_test_installation_docs.sh +++ b/tests/jenkins/run_test_installation_docs.sh @@ -1,5 +1,23 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + set -e # Given an array of numbers, removes any numbers of it that fall outside a given range. @@ -30,9 +48,9 @@ function remove_out_of_range() { echo "Error: Min must be less than or equal to Max" exit 1 fi - + return_arr=() - + for number in "${lineno_array[@]}" do if (( ${number} > ${min} && ${number} < ${max} )) diff --git a/tests/jenkins/run_test_pip_installations.sh b/tests/jenkins/run_test_pip_installations.sh index de235a0a6359..44788bfaf772 100755 --- a/tests/jenkins/run_test_pip_installations.sh +++ b/tests/jenkins/run_test_pip_installations.sh @@ -1,5 +1,23 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + set -e if (( $# < 1 )); then diff --git a/tests/jenkins/run_test_ubuntu.sh b/tests/jenkins/run_test_ubuntu.sh index 2e458b52599a..cdddd2865ddc 100755 --- a/tests/jenkins/run_test_ubuntu.sh +++ b/tests/jenkins/run_test_ubuntu.sh @@ -1,5 +1,23 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + set -e echo "BUILD make" diff --git a/tests/jenkins/set_user_permissions.sh b/tests/jenkins/set_user_permissions.sh index d03a97bfdd73..51034c4365b6 100644 --- a/tests/jenkins/set_user_permissions.sh +++ b/tests/jenkins/set_user_permissions.sh @@ -1,5 +1,23 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + # Exit script with error if any errors occur set -e diff --git a/tests/nightly/TestDoc/doc_spell_checker.py b/tests/nightly/TestDoc/doc_spell_checker.py index 20a5c07afdae..a7b8b250c928 100644 --- a/tests/nightly/TestDoc/doc_spell_checker.py +++ b/tests/nightly/TestDoc/doc_spell_checker.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + #pylint: disable=no-member, too-many-instance-attributes """This script uses pyenchant to check spelling for MXNet documentation website. diff --git a/tests/nightly/TestDoc/doc_spell_grammar.sh b/tests/nightly/TestDoc/doc_spell_grammar.sh index 05b0be138fd6..77c7b86eb7aa 100755 --- a/tests/nightly/TestDoc/doc_spell_grammar.sh +++ b/tests/nightly/TestDoc/doc_spell_grammar.sh @@ -1,4 +1,22 @@ #!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + echo "BUILD make" cp ./make/config.mk . echo "USE_CUDA=0" >> ./config.mk diff --git a/tests/nightly/compilation_warnings/compilation_warnings.sh b/tests/nightly/compilation_warnings/compilation_warnings.sh index 871d849b9bae..a6c4863f4b58 100644 --- a/tests/nightly/compilation_warnings/compilation_warnings.sh +++ b/tests/nightly/compilation_warnings/compilation_warnings.sh @@ -1,4 +1,22 @@ #!/bin/bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + set -e runme() { cmd=$* diff --git a/tests/nightly/compilation_warnings/process_output.py b/tests/nightly/compilation_warnings/process_output.py index 622598d72292..5f85af592f6c 100644 --- a/tests/nightly/compilation_warnings/process_output.py +++ b/tests/nightly/compilation_warnings/process_output.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import re import sys import operator diff --git a/tests/nightly/dist_lenet.py b/tests/nightly/dist_lenet.py index a7ae84cb3200..35f55c8157d2 100644 --- a/tests/nightly/dist_lenet.py +++ b/tests/nightly/dist_lenet.py @@ -1,4 +1,22 @@ #!/usr/bin/env python + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # distributed lenet import os, sys curr_path = os.path.abspath(os.path.dirname(__file__)) diff --git a/tests/nightly/dist_sync_kvstore.py b/tests/nightly/dist_sync_kvstore.py index ebed6c57586d..3fbf9f910879 100644 --- a/tests/nightly/dist_sync_kvstore.py +++ b/tests/nightly/dist_sync_kvstore.py @@ -1,4 +1,22 @@ #!/usr/bin/env python + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file import sys sys.path.insert(0, "../../python/") diff --git a/tests/nightly/download.sh b/tests/nightly/download.sh index 56f822e6ad42..d07fc6f4ab8a 100644 --- a/tests/nightly/download.sh +++ b/tests/nightly/download.sh @@ -1,5 +1,23 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + dmlc_download() { url=http://data.mxnet.io/mxnet/datasets/ dir=$1 diff --git a/tests/nightly/multi_lenet.py b/tests/nightly/multi_lenet.py index 1fb2dfa6377e..687588bacbe9 100644 --- a/tests/nightly/multi_lenet.py +++ b/tests/nightly/multi_lenet.py @@ -1,4 +1,22 @@ #!/usr/bin/env python + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # lenet with multiple gpus # # using different kvstore will get almost identical results diff --git a/tests/nightly/mxnet_keras_integration_tests/assertion_util.py b/tests/nightly/mxnet_keras_integration_tests/assertion_util.py index 1fad6a1eb326..eb3d3bd85fda 100644 --- a/tests/nightly/mxnet_keras_integration_tests/assertion_util.py +++ b/tests/nightly/mxnet_keras_integration_tests/assertion_util.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from nose.tools import assert_true diff --git a/tests/nightly/mxnet_keras_integration_tests/model_util.py b/tests/nightly/mxnet_keras_integration_tests/model_util.py index 9f73ab60b062..bb9d6374af8f 100644 --- a/tests/nightly/mxnet_keras_integration_tests/model_util.py +++ b/tests/nightly/mxnet_keras_integration_tests/model_util.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import os from keras import backend as K from keras.models import Model diff --git a/tests/nightly/mxnet_keras_integration_tests/profiler.py b/tests/nightly/mxnet_keras_integration_tests/profiler.py index 4b6446a9b8cc..b0d39e19aa00 100644 --- a/tests/nightly/mxnet_keras_integration_tests/profiler.py +++ b/tests/nightly/mxnet_keras_integration_tests/profiler.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import os import signal import time diff --git a/tests/nightly/mxnet_keras_integration_tests/test_mnist_mlp.py b/tests/nightly/mxnet_keras_integration_tests/test_mnist_mlp.py index 7a0c6298d736..89bd2805ce78 100644 --- a/tests/nightly/mxnet_keras_integration_tests/test_mnist_mlp.py +++ b/tests/nightly/mxnet_keras_integration_tests/test_mnist_mlp.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + ''' This code is forked from https://github.com/fchollet/keras/blob/master/examples/mnist_mlp.py and modified to use as MXNet-Keras integration testing for functionality and sanity performance diff --git a/tests/nightly/sh2ju.sh b/tests/nightly/sh2ju.sh index 84c1427227e7..4465cd8f843f 100644 --- a/tests/nightly/sh2ju.sh +++ b/tests/nightly/sh2ju.sh @@ -1,4 +1,22 @@ #!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + ### Copyright 2010 Manuel Carrasco Moñino. (manolo at apache.org) ### ### Licensed under the Apache License, Version 2.0. diff --git a/tests/nightly/test_all.sh b/tests/nightly/test_all.sh index 33c39f5f4bd1..32913c9f5f5b 100755 --- a/tests/nightly/test_all.sh +++ b/tests/nightly/test_all.sh @@ -1,5 +1,23 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + # setup export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH cd `pwd`/`dirname $0` diff --git a/tests/nightly/test_kvstore.py b/tests/nightly/test_kvstore.py index c954c1859d64..b39ec89cf728 100644 --- a/tests/nightly/test_kvstore.py +++ b/tests/nightly/test_kvstore.py @@ -1,4 +1,22 @@ #!/usr/bin/env python + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import sys sys.path.insert(0, "../../python/") import mxnet as mx diff --git a/tests/nightly/test_mxnet_keras_integration_cpu.sh b/tests/nightly/test_mxnet_keras_integration_cpu.sh index 25a1da4ddf46..95cc0d0760e2 100755 --- a/tests/nightly/test_mxnet_keras_integration_cpu.sh +++ b/tests/nightly/test_mxnet_keras_integration_cpu.sh @@ -1,4 +1,22 @@ #!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + set -e ### Build MXNet with CPU support echo "BUILD make" diff --git a/tests/nightly/test_mxnet_keras_integration_gpu.sh b/tests/nightly/test_mxnet_keras_integration_gpu.sh index 86fb37acfc47..5d541fa5b7a4 100755 --- a/tests/nightly/test_mxnet_keras_integration_gpu.sh +++ b/tests/nightly/test_mxnet_keras_integration_gpu.sh @@ -1,4 +1,22 @@ #!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + set -e ### Install git diff --git a/tests/nightly/test_tutorial.py b/tests/nightly/test_tutorial.py index 304642c73a23..56b530a59bb4 100644 --- a/tests/nightly/test_tutorial.py +++ b/tests/nightly/test_tutorial.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + #pylint: disable=no-member, too-many-locals, too-many-branches, no-self-use, broad-except, lost-exception, too-many-nested-blocks, too-few-public-methods, invalid-name """ This script converts all python tutorials into python script diff --git a/tests/python/common/get_data.py b/tests/python/common/get_data.py index e385a7186848..35482f8de584 100644 --- a/tests/python/common/get_data.py +++ b/tests/python/common/get_data.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file import os, gzip import pickle as pickle diff --git a/tests/python/common/models.py b/tests/python/common/models.py index 2c998afcd1db..b563adc1d760 100644 --- a/tests/python/common/models.py +++ b/tests/python/common/models.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """This file defines various models used in the test""" import mxnet as mx diff --git a/tests/python/doctest/test_docstring.py b/tests/python/doctest/test_docstring.py index e457e7b9ca55..23a29588c5af 100644 --- a/tests/python/doctest/test_docstring.py +++ b/tests/python/doctest/test_docstring.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import doctest import logging import mxnet diff --git a/tests/python/gpu/test_forward.py b/tests/python/gpu/test_forward.py index dc2c129f5326..cddf9afb9cb2 100644 --- a/tests/python/gpu/test_forward.py +++ b/tests/python/gpu/test_forward.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import os import numpy as np import mxnet as mx diff --git a/tests/python/gpu/test_operator_gpu.py b/tests/python/gpu/test_operator_gpu.py index 6fef4e24a24c..c80b9e375306 100644 --- a/tests/python/gpu/test_operator_gpu.py +++ b/tests/python/gpu/test_operator_gpu.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import sys import os import time diff --git a/tests/python/gpu/test_rtc.py b/tests/python/gpu/test_rtc.py index d38f038ffd26..756c3d752faa 100644 --- a/tests/python/gpu/test_rtc.py +++ b/tests/python/gpu/test_rtc.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file import mxnet as mx import numpy as np @@ -13,4 +30,4 @@ s_rec[threadIdx.x] = x[threadIdx.x]; y[threadIdx.x] = expf(s_rec[threadIdx.x]*5.0);""") rtc.push([x], [y], (1, 1, 1), (10,1,1)) - assert_allclose(y.asnumpy(), np.exp(x.asnumpy()*5.0)) \ No newline at end of file + assert_allclose(y.asnumpy(), np.exp(x.asnumpy()*5.0)) diff --git a/tests/python/predict/mxnet_predict_example.py b/tests/python/predict/mxnet_predict_example.py index 745a1f87b17c..1db3f5c29954 100644 --- a/tests/python/predict/mxnet_predict_example.py +++ b/tests/python/predict/mxnet_predict_example.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import sys, os curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__))) sys.path.append("../../../amalgamation/python/") diff --git a/tests/python/train/common.py b/tests/python/train/common.py index 1622e0294e69..38718fa78175 100644 --- a/tests/python/train/common.py +++ b/tests/python/train/common.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import sys, os curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__))) sys.path.append(os.path.join(curr_path, '../common/')) diff --git a/tests/python/train/test_autograd.py b/tests/python/train/test_autograd.py index 8d67bfb8205a..c9921ecf4f89 100644 --- a/tests/python/train/test_autograd.py +++ b/tests/python/train/test_autograd.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file from __future__ import print_function diff --git a/tests/python/train/test_bucketing.py b/tests/python/train/test_bucketing.py index 85ea107c5ca2..1303db09cb54 100644 --- a/tests/python/train/test_bucketing.py +++ b/tests/python/train/test_bucketing.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file import numpy as np import mxnet as mx diff --git a/tests/python/train/test_conv.py b/tests/python/train/test_conv.py index 039790e5612d..46e06848f8ba 100644 --- a/tests/python/train/test_conv.py +++ b/tests/python/train/test_conv.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file import sys sys.path.insert(0, '../../python') diff --git a/tests/python/train/test_dtype.py b/tests/python/train/test_dtype.py index 3371f4bcaf4e..b0a524815c6c 100644 --- a/tests/python/train/test_dtype.py +++ b/tests/python/train/test_dtype.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file import sys sys.path.insert(0, '../../python') @@ -173,6 +190,6 @@ def test_cifar10(): (train, val) = get_iterator_uint8(kv) run_cifar10(train, val, use_module=False) run_cifar10(train, val, use_module=True) - + if __name__ == "__main__": test_cifar10() diff --git a/tests/python/train/test_mlp.py b/tests/python/train/test_mlp.py index c983b6eeac4f..a0a45b41e19e 100644 --- a/tests/python/train/test_mlp.py +++ b/tests/python/train/test_mlp.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file import mxnet as mx import numpy as np diff --git a/tests/python/unittest/common.py b/tests/python/unittest/common.py index 38b4bd6b0227..12ed60d2bc24 100644 --- a/tests/python/unittest/common.py +++ b/tests/python/unittest/common.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import sys, os curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__))) sys.path.append(os.path.join(curr_path, '../common/')) diff --git a/tests/python/unittest/test_attr.py b/tests/python/unittest/test_attr.py index 4cdecaf9146f..0d7e67dced2d 100644 --- a/tests/python/unittest/test_attr.py +++ b/tests/python/unittest/test_attr.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import os import mxnet as mx from common import models diff --git a/tests/python/unittest/test_autograd.py b/tests/python/unittest/test_autograd.py index 7ee35009a164..5be3d356e34b 100644 --- a/tests/python/unittest/test_autograd.py +++ b/tests/python/unittest/test_autograd.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import functools import mxnet.ndarray as nd from mxnet.ndarray import zeros_like diff --git a/tests/python/unittest/test_contrib_autograd.py b/tests/python/unittest/test_contrib_autograd.py index e7b0ce3af752..a144c3433280 100644 --- a/tests/python/unittest/test_contrib_autograd.py +++ b/tests/python/unittest/test_contrib_autograd.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet.ndarray as nd from mxnet.contrib.autograd import * from mxnet.test_utils import * diff --git a/tests/python/unittest/test_executor.py b/tests/python/unittest/test_executor.py index c1cc013b81c0..e3d977df65de 100644 --- a/tests/python/unittest/test_executor.py +++ b/tests/python/unittest/test_executor.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import numpy as np import mxnet as mx diff --git a/tests/python/unittest/test_gluon.py b/tests/python/unittest/test_gluon.py index 8256c719c386..4fff23f2c5a4 100644 --- a/tests/python/unittest/test_gluon.py +++ b/tests/python/unittest/test_gluon.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx from mxnet import gluon from mxnet.gluon import nn diff --git a/tests/python/unittest/test_gluon_data.py b/tests/python/unittest/test_gluon_data.py index 2407f8e25991..da1de6ba4b58 100644 --- a/tests/python/unittest/test_gluon_data.py +++ b/tests/python/unittest/test_gluon_data.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import os import mxnet as mx import numpy as np diff --git a/tests/python/unittest/test_gluon_model_zoo.py b/tests/python/unittest/test_gluon_model_zoo.py index db26fd4a96ab..6fbcf8b3dac8 100644 --- a/tests/python/unittest/test_gluon_model_zoo.py +++ b/tests/python/unittest/test_gluon_model_zoo.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import print_function import mxnet as mx from mxnet.gluon import nn diff --git a/tests/python/unittest/test_gluon_rnn.py b/tests/python/unittest/test_gluon_rnn.py index c5c941408fef..ac671e5f8840 100644 --- a/tests/python/unittest/test_gluon_rnn.py +++ b/tests/python/unittest/test_gluon_rnn.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx from mxnet import gluon import numpy as np diff --git a/tests/python/unittest/test_image.py b/tests/python/unittest/test_image.py index 638dbf06a683..04b878dc80b0 100644 --- a/tests/python/unittest/test_image.py +++ b/tests/python/unittest/test_image.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx import numpy as np from mxnet.test_utils import * diff --git a/tests/python/unittest/test_infer_shape.py b/tests/python/unittest/test_infer_shape.py index 35598bc55be8..d7f52e216659 100644 --- a/tests/python/unittest/test_infer_shape.py +++ b/tests/python/unittest/test_infer_shape.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file import mxnet as mx from common import models diff --git a/tests/python/unittest/test_init.py b/tests/python/unittest/test_init.py index 79862269795d..e642e65ec3d6 100644 --- a/tests/python/unittest/test_init.py +++ b/tests/python/unittest/test_init.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx import numpy as np diff --git a/tests/python/unittest/test_io.py b/tests/python/unittest/test_io.py index 18326754c851..c0f2acd4ed47 100644 --- a/tests/python/unittest/test_io.py +++ b/tests/python/unittest/test_io.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file import mxnet as mx import numpy as np diff --git a/tests/python/unittest/test_kvstore.py b/tests/python/unittest/test_kvstore.py index 87e5e0027241..f1e10c757fad 100644 --- a/tests/python/unittest/test_kvstore.py +++ b/tests/python/unittest/test_kvstore.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file import mxnet as mx import numpy as np diff --git a/tests/python/unittest/test_loss.py b/tests/python/unittest/test_loss.py index 7d4c586c2aa8..8eced7bc00d1 100644 --- a/tests/python/unittest/test_loss.py +++ b/tests/python/unittest/test_loss.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx import numpy as np from mxnet import gluon diff --git a/tests/python/unittest/test_metric.py b/tests/python/unittest/test_metric.py index 54b58b2b4d73..7ae93bf36299 100644 --- a/tests/python/unittest/test_metric.py +++ b/tests/python/unittest/test_metric.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx import json diff --git a/tests/python/unittest/test_model_parallel.py b/tests/python/unittest/test_model_parallel.py index 96990e72075e..8ff09d5fcb56 100644 --- a/tests/python/unittest/test_model_parallel.py +++ b/tests/python/unittest/test_model_parallel.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import numpy as np import mxnet as mx diff --git a/tests/python/unittest/test_module.py b/tests/python/unittest/test_module.py index 766995dd2ac9..f522f29dae39 100644 --- a/tests/python/unittest/test_module.py +++ b/tests/python/unittest/test_module.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx import mxnet.ndarray as nd import numpy as np diff --git a/tests/python/unittest/test_multi_device_exec.py b/tests/python/unittest/test_multi_device_exec.py index 8956c4edebac..6f8eb17ff34e 100644 --- a/tests/python/unittest/test_multi_device_exec.py +++ b/tests/python/unittest/test_multi_device_exec.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import os import mxnet as mx diff --git a/tests/python/unittest/test_ndarray.py b/tests/python/unittest/test_ndarray.py index 79a022b17ac4..eae364eeaecf 100644 --- a/tests/python/unittest/test_ndarray.py +++ b/tests/python/unittest/test_ndarray.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import os import mxnet as mx import numpy as np diff --git a/tests/python/unittest/test_operator.py b/tests/python/unittest/test_operator.py index 62a064a49e0d..718e3df04871 100644 --- a/tests/python/unittest/test_operator.py +++ b/tests/python/unittest/test_operator.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file from __future__ import print_function import numpy as np diff --git a/tests/python/unittest/test_optimizer.py b/tests/python/unittest/test_optimizer.py index cf7b82eaaa88..3b3b92b372d8 100644 --- a/tests/python/unittest/test_optimizer.py +++ b/tests/python/unittest/test_optimizer.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import numpy as np import mxnet as mx import math diff --git a/tests/python/unittest/test_profiler.py b/tests/python/unittest/test_profiler.py index 9a0deabdd9f8..724ed3a38790 100644 --- a/tests/python/unittest/test_profiler.py +++ b/tests/python/unittest/test_profiler.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from __future__ import print_function import mxnet as mx from mxnet import profiler diff --git a/tests/python/unittest/test_random.py b/tests/python/unittest/test_random.py index 1f88b6b4fbe0..6b8311c145f5 100644 --- a/tests/python/unittest/test_random.py +++ b/tests/python/unittest/test_random.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import os import mxnet as mx import numpy as np diff --git a/tests/python/unittest/test_recordio.py b/tests/python/unittest/test_recordio.py index f4489bdfe641..7de582e236dd 100644 --- a/tests/python/unittest/test_recordio.py +++ b/tests/python/unittest/test_recordio.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file import sys import mxnet as mx @@ -68,4 +85,4 @@ def test_recordio_pack_label(): if __name__ == '__main__': test_recordio_pack_label() test_recordio() - test_indexed_recordio() \ No newline at end of file + test_indexed_recordio() diff --git a/tests/python/unittest/test_rnn.py b/tests/python/unittest/test_rnn.py index e8176bb468c2..9fe22ae72df6 100644 --- a/tests/python/unittest/test_rnn.py +++ b/tests/python/unittest/test_rnn.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx import numpy as np from numpy.testing import assert_allclose diff --git a/tests/python/unittest/test_symbol.py b/tests/python/unittest/test_symbol.py index ee9e9dcf3a55..c570325a6b66 100644 --- a/tests/python/unittest/test_symbol.py +++ b/tests/python/unittest/test_symbol.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import copy import os import re diff --git a/tests/python/unittest/test_viz.py b/tests/python/unittest/test_viz.py index 79c86681035d..73cfa94ba030 100644 --- a/tests/python/unittest/test_viz.py +++ b/tests/python/unittest/test_viz.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import mxnet as mx def test_print_summary(): diff --git a/tests/travis/is_core_changed.sh b/tests/travis/is_core_changed.sh index 1e32d60b2fcc..7b9eb6123847 100755 --- a/tests/travis/is_core_changed.sh +++ b/tests/travis/is_core_changed.sh @@ -1,5 +1,23 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + # this is a util script to test whether the "core" of # mxnet has changed. Please modify the regex patterns here # to ensure the components are covered if you add new "core" diff --git a/tests/travis/run_test.sh b/tests/travis/run_test.sh index cff4196b6043..fb1869f842b1 100755 --- a/tests/travis/run_test.sh +++ b/tests/travis/run_test.sh @@ -1,5 +1,23 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + if ! tests/travis/is_core_changed.sh then exit 0 diff --git a/tests/travis/setup.sh b/tests/travis/setup.sh index ec071009bda5..94d674f3943e 100755 --- a/tests/travis/setup.sh +++ b/tests/travis/setup.sh @@ -1,5 +1,23 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + if ! tests/travis/is_core_changed.sh then exit 0 diff --git a/tests/travis/travis_after_failure.sh b/tests/travis/travis_after_failure.sh index 5a3940a89b7a..50754c9546cd 100755 --- a/tests/travis/travis_after_failure.sh +++ b/tests/travis/travis_after_failure.sh @@ -1,5 +1,23 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + if [ ${TASK} == "r_test" ]; then echo "Print the install log..." cat mxnet.Rcheck/*.out diff --git a/tools/accnn/acc_conv.py b/tools/accnn/acc_conv.py index 095e386beebc..07717c7b47c9 100644 --- a/tools/accnn/acc_conv.py +++ b/tools/accnn/acc_conv.py @@ -1,77 +1,94 @@ -import numpy as np -from scipy import linalg as LA -import mxnet as mx -import argparse -import utils - -def conv_vh_decomposition(model, args): - W = model.arg_params[args.layer+'_weight'].asnumpy() - N, C, y, x = W.shape - b = model.arg_params[args.layer+'_bias'].asnumpy() - W = W.transpose((1,2,0,3)).reshape((C*y, -1)) - - U, D, Q = np.linalg.svd(W, full_matrices=False) - sqrt_D = LA.sqrtm(np.diag(D)) - K = args.K - V = U[:,:K].dot(sqrt_D[:K, :K]) - H = Q.T[:,:K].dot(sqrt_D[:K, :K]) - V = V.T.reshape(K, C, y, 1) - b_1 = np.zeros((K, )) - H = H.reshape(N, x, 1, K).transpose((0,3,2,1)) - b_2 = b - - W1, b1, W2, b2 = V, b_1, H, b_2 - def sym_handle(data, node): - kernel = eval(node['param']['kernel']) - pad = eval(node['param']['pad']) - name = node['name'] - - name1 = name + '_v' - kernel1 = tuple((kernel[0], 1)) - pad1 = tuple((pad[0], 0)) - num_filter = W1.shape[0] - sym1 = mx.symbol.Convolution(data=data, kernel=kernel1, pad=pad1, num_filter=num_filter, name=name1) - - name2 = name + '_h' - kernel2 = tuple((1, kernel[1])) - pad2 = tuple((0, pad[1])) - num_filter = W2.shape[0] - sym2 = mx.symbol.Convolution(data=sym1, kernel=kernel2, pad=pad2, num_filter=num_filter, name=name2) - return sym2 - - def arg_handle(arg_shape_dic, arg_params): - name1 = args.layer + '_v' - name2 = args.layer + '_h' - weight1 = mx.ndarray.array(W1) - bias1 = mx.ndarray.array(b1) - weight2 = mx.ndarray.array(W2) - bias2 = mx.ndarray.array(b2) - assert weight1.shape == arg_shape_dic[name1+'_weight'], 'weight1' - assert weight2.shape == arg_shape_dic[name2+'_weight'], 'weight2' - assert bias1.shape == arg_shape_dic[name1+'_bias'], 'bias1' - assert bias2.shape == arg_shape_dic[name2+'_bias'], 'bias2' - - arg_params[name1 + '_weight'] = weight1 - arg_params[name1 + '_bias'] = bias1 - arg_params[name2 + '_weight'] = weight2 - arg_params[name2 + '_bias'] = bias2 - - new_model = utils.replace_conv_layer(args.layer, model, sym_handle, arg_handle) - return new_model - -def main(): - model = utils.load_model(args) - new_model = conv_vh_decomposition(model, args) - new_model.save(args.save_model) - -if __name__ == '__main__': - parser=argparse.ArgumentParser() - parser.add_argument('-m', '--model', help='the model to speed up') - parser.add_argument('-g', '--gpus', default='0', help='the gpus to be used in ctx') - parser.add_argument('--load-epoch',type=int,default=1) - parser.add_argument('--layer') - parser.add_argument('--K', type=int) - parser.add_argument('--save-model') - args = parser.parse_args() - main() - +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +import numpy as np +from scipy import linalg as LA +import mxnet as mx +import argparse +import utils + +def conv_vh_decomposition(model, args): + W = model.arg_params[args.layer+'_weight'].asnumpy() + N, C, y, x = W.shape + b = model.arg_params[args.layer+'_bias'].asnumpy() + W = W.transpose((1,2,0,3)).reshape((C*y, -1)) + + U, D, Q = np.linalg.svd(W, full_matrices=False) + sqrt_D = LA.sqrtm(np.diag(D)) + K = args.K + V = U[:,:K].dot(sqrt_D[:K, :K]) + H = Q.T[:,:K].dot(sqrt_D[:K, :K]) + V = V.T.reshape(K, C, y, 1) + b_1 = np.zeros((K, )) + H = H.reshape(N, x, 1, K).transpose((0,3,2,1)) + b_2 = b + + W1, b1, W2, b2 = V, b_1, H, b_2 + def sym_handle(data, node): + kernel = eval(node['param']['kernel']) + pad = eval(node['param']['pad']) + name = node['name'] + + name1 = name + '_v' + kernel1 = tuple((kernel[0], 1)) + pad1 = tuple((pad[0], 0)) + num_filter = W1.shape[0] + sym1 = mx.symbol.Convolution(data=data, kernel=kernel1, pad=pad1, num_filter=num_filter, name=name1) + + name2 = name + '_h' + kernel2 = tuple((1, kernel[1])) + pad2 = tuple((0, pad[1])) + num_filter = W2.shape[0] + sym2 = mx.symbol.Convolution(data=sym1, kernel=kernel2, pad=pad2, num_filter=num_filter, name=name2) + return sym2 + + def arg_handle(arg_shape_dic, arg_params): + name1 = args.layer + '_v' + name2 = args.layer + '_h' + weight1 = mx.ndarray.array(W1) + bias1 = mx.ndarray.array(b1) + weight2 = mx.ndarray.array(W2) + bias2 = mx.ndarray.array(b2) + assert weight1.shape == arg_shape_dic[name1+'_weight'], 'weight1' + assert weight2.shape == arg_shape_dic[name2+'_weight'], 'weight2' + assert bias1.shape == arg_shape_dic[name1+'_bias'], 'bias1' + assert bias2.shape == arg_shape_dic[name2+'_bias'], 'bias2' + + arg_params[name1 + '_weight'] = weight1 + arg_params[name1 + '_bias'] = bias1 + arg_params[name2 + '_weight'] = weight2 + arg_params[name2 + '_bias'] = bias2 + + new_model = utils.replace_conv_layer(args.layer, model, sym_handle, arg_handle) + return new_model + +def main(): + model = utils.load_model(args) + new_model = conv_vh_decomposition(model, args) + new_model.save(args.save_model) + +if __name__ == '__main__': + parser=argparse.ArgumentParser() + parser.add_argument('-m', '--model', help='the model to speed up') + parser.add_argument('-g', '--gpus', default='0', help='the gpus to be used in ctx') + parser.add_argument('--load-epoch',type=int,default=1) + parser.add_argument('--layer') + parser.add_argument('--K', type=int) + parser.add_argument('--save-model') + args = parser.parse_args() + main() + diff --git a/tools/accnn/acc_fc.py b/tools/accnn/acc_fc.py index dcc255452b1d..b66b328e5b7b 100644 --- a/tools/accnn/acc_fc.py +++ b/tools/accnn/acc_fc.py @@ -1,57 +1,74 @@ -import numpy as np -from scipy import linalg as LA -import mxnet as mx -import argparse -import utils -import pdb - -def fc_decomposition(model, args): - W = model.arg_params[args.layer+'_weight'].asnumpy() - b = model.arg_params[args.layer+'_bias'].asnumpy() - W = W.reshape((W.shape[0],-1)) - b = b.reshape((b.shape[0],-1)) - u, s, v = LA.svd(W, full_matrices=False) - s = np.diag(s) - t = u.dot(s.dot(v)) - rk = args.K - P = u[:,:rk] - Q = s[:rk,:rk].dot(v[:rk,:]) - - name1 = args.layer + '_red' - name2 = args.layer + '_rec' - def sym_handle(data, node): - W1, W2 = Q, P - sym1 = mx.symbol.FullyConnected(data=data, num_hidden=W1.shape[0], no_bias=True, name=name1) - sym2 = mx.symbol.FullyConnected(data=sym1, num_hidden=W2.shape[0], no_bias=False, name=name2) - return sym2 - - def arg_handle(arg_shape_dic, arg_params): - W1, W2 = Q, P - W1 = W1.reshape(arg_shape_dic[name1+'_weight']) - weight1 = mx.ndarray.array(W1) - W2 = W2.reshape(arg_shape_dic[name2+'_weight']) - b2 = b.reshape(arg_shape_dic[name2+'_bias']) - weight2 = mx.ndarray.array(W2) - bias2 = mx.ndarray.array(b2) - arg_params[name1 + '_weight'] = weight1 - arg_params[name2 + '_weight'] = weight2 - arg_params[name2 + '_bias'] = bias2 - - new_model = utils.replace_conv_layer(args.layer, model, sym_handle, arg_handle) - return new_model - -def main(): - model = utils.load_model(args) - new_model = fc_decomposition(model, args) - new_model.save(args.save_model) - -if __name__ == '__main__': - parser=argparse.ArgumentParser() - parser.add_argument('-m', '--model', help='the model to speed up') - parser.add_argument('-g', '--gpus', default='0', help='the gpus to be used in ctx') - parser.add_argument('--load-epoch',type=int,default=1) - parser.add_argument('--layer') - parser.add_argument('--K', type=int) - parser.add_argument('--save-model') - args = parser.parse_args() - main() +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +import numpy as np +from scipy import linalg as LA +import mxnet as mx +import argparse +import utils +import pdb + +def fc_decomposition(model, args): + W = model.arg_params[args.layer+'_weight'].asnumpy() + b = model.arg_params[args.layer+'_bias'].asnumpy() + W = W.reshape((W.shape[0],-1)) + b = b.reshape((b.shape[0],-1)) + u, s, v = LA.svd(W, full_matrices=False) + s = np.diag(s) + t = u.dot(s.dot(v)) + rk = args.K + P = u[:,:rk] + Q = s[:rk,:rk].dot(v[:rk,:]) + + name1 = args.layer + '_red' + name2 = args.layer + '_rec' + def sym_handle(data, node): + W1, W2 = Q, P + sym1 = mx.symbol.FullyConnected(data=data, num_hidden=W1.shape[0], no_bias=True, name=name1) + sym2 = mx.symbol.FullyConnected(data=sym1, num_hidden=W2.shape[0], no_bias=False, name=name2) + return sym2 + + def arg_handle(arg_shape_dic, arg_params): + W1, W2 = Q, P + W1 = W1.reshape(arg_shape_dic[name1+'_weight']) + weight1 = mx.ndarray.array(W1) + W2 = W2.reshape(arg_shape_dic[name2+'_weight']) + b2 = b.reshape(arg_shape_dic[name2+'_bias']) + weight2 = mx.ndarray.array(W2) + bias2 = mx.ndarray.array(b2) + arg_params[name1 + '_weight'] = weight1 + arg_params[name2 + '_weight'] = weight2 + arg_params[name2 + '_bias'] = bias2 + + new_model = utils.replace_conv_layer(args.layer, model, sym_handle, arg_handle) + return new_model + +def main(): + model = utils.load_model(args) + new_model = fc_decomposition(model, args) + new_model.save(args.save_model) + +if __name__ == '__main__': + parser=argparse.ArgumentParser() + parser.add_argument('-m', '--model', help='the model to speed up') + parser.add_argument('-g', '--gpus', default='0', help='the gpus to be used in ctx') + parser.add_argument('--load-epoch',type=int,default=1) + parser.add_argument('--layer') + parser.add_argument('--K', type=int) + parser.add_argument('--save-model') + args = parser.parse_args() + main() diff --git a/tools/accnn/accnn.py b/tools/accnn/accnn.py index 1af78ef880de..ec5b101838f7 100644 --- a/tools/accnn/accnn.py +++ b/tools/accnn/accnn.py @@ -1,38 +1,55 @@ -import mxnet as mx -import argparse -import utils -import acc_conv -import acc_fc -import rank_selection -import collections -import json -import sys - -parser = argparse.ArgumentParser() -parser.add_argument('-m', '--model', help='the model to speed up') -parser.add_argument('-g', '--gpus', default='0', help='the gpus will be used, e.g "0,1,2,3"') -parser.add_argument('--load-epoch',type=int, default=1, help="load the model on an epoch using the model-prefix") -parser.add_argument('--save-model', type=str, default='new-model', help='output model prefix') -parser.add_argument('--config', default=None, help='specify the config file') -parser.add_argument('--ratio', type=float, default=2, help='speed up ratio') -args = parser.parse_args() - -model = utils.load_model(args) -if args.config: - args.config = json.load(open(args.config, 'r')) -else: - config = {} - config['conv_params'] = rank_selection.get_ranksel(model, args.ratio) - config['fc_params'] = {} - json.dump(config, open('config-rksel-%.1f.json'%(args.ratio), 'w'), indent=2) - args.config = config - -new_model = model -Args = collections.namedtuple('ConvArgs', 'layer K') -for layer, K in args.config['conv_params'].items(): - arg = Args(layer=layer, K=K) - new_model = acc_conv.conv_vh_decomposition(new_model, arg) -for layer, K in args.config['fc_params'].items(): - arg = Args(layer=layer, K=K) - new_model = acc_fc.fc_decomposition(new_model, arg) -new_model.save(args.save_model, 1) +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +import mxnet as mx +import argparse +import utils +import acc_conv +import acc_fc +import rank_selection +import collections +import json +import sys + +parser = argparse.ArgumentParser() +parser.add_argument('-m', '--model', help='the model to speed up') +parser.add_argument('-g', '--gpus', default='0', help='the gpus will be used, e.g "0,1,2,3"') +parser.add_argument('--load-epoch',type=int, default=1, help="load the model on an epoch using the model-prefix") +parser.add_argument('--save-model', type=str, default='new-model', help='output model prefix') +parser.add_argument('--config', default=None, help='specify the config file') +parser.add_argument('--ratio', type=float, default=2, help='speed up ratio') +args = parser.parse_args() + +model = utils.load_model(args) +if args.config: + args.config = json.load(open(args.config, 'r')) +else: + config = {} + config['conv_params'] = rank_selection.get_ranksel(model, args.ratio) + config['fc_params'] = {} + json.dump(config, open('config-rksel-%.1f.json'%(args.ratio), 'w'), indent=2) + args.config = config + +new_model = model +Args = collections.namedtuple('ConvArgs', 'layer K') +for layer, K in args.config['conv_params'].items(): + arg = Args(layer=layer, K=K) + new_model = acc_conv.conv_vh_decomposition(new_model, arg) +for layer, K in args.config['fc_params'].items(): + arg = Args(layer=layer, K=K) + new_model = acc_fc.fc_decomposition(new_model, arg) +new_model.save(args.save_model, 1) diff --git a/tools/accnn/rank_selection.py b/tools/accnn/rank_selection.py index ee3eca91f934..66937b2859b9 100644 --- a/tools/accnn/rank_selection.py +++ b/tools/accnn/rank_selection.py @@ -1,87 +1,104 @@ -import numpy as np -import mxnet as mx -import json -import utils -import math -import sys - -def calc_complexity(ishape, node): - y, x = map(int, eval(node['param']['kernel'])) - N = int(node['param']['num_filter']) - C, Y, X = ishape - return x*(N+C)*X*Y, x*y*N*C*X*Y - -def calc_eigenvalue(model, node): - W = model.arg_params[node['name'] + '_weight'].asnumpy() - N, C, y, x = W.shape - W = W.transpose((1,2,0,3)).reshape((C*y, -1)) - U, D, Q = np.linalg.svd(W, full_matrices=False) - return D - -def get_ranksel(model, ratio): - conf = json.loads(model.symbol.tojson()) - _, output_shapes, _ = model.symbol.get_internals().infer_shape(data=(1,3,224,224)) - out_names = model.symbol.get_internals().list_outputs() - out_shape_dic = dict(zip(out_names, output_shapes)) - nodes = conf['nodes'] - nodes = utils.topsort(nodes) - C = [] - D = [] - S = [] - conv_names = [] - EC = 0 - for node in nodes: - if node['op'] == 'Convolution': - input_nodes = [nodes[int(j[0])] for j in node['inputs']] - data = [input_node for input_node in input_nodes\ - if not input_node['name'].startswith(node['name'])][0] - - if utils.is_input(data): - ishape = (3, 224, 224) - else: - ishape = out_shape_dic[data['name'] + '_output'][1:] - C.append(calc_complexity(ishape, node)) - D.append(int(node['param']['num_filter'])) - S.append(calc_eigenvalue(model, node)) - conv_names.append(node['name']) - EC += C[-1][1] - for s in S: - ss = sum(s) - for i in xrange(1, len(s)): - s[i] += s[i-1] - n = len(C) - EC /= ratio - dp = [{}, {}] - dpc = [{} for _ in xrange(n)] - now, nxt = 0, 1 - dp[now][0] = 0 - for i in xrange(n): - dp[nxt] = {} - sys.stdout.flush() - for now_c, now_v in dp[now].items(): - for d in xrange(min(len(S[i]), D[i])): - nxt_c = now_c + (d+1)*C[i][0] - if nxt_c > EC: - continue - nxt_v = dp[now][now_c] + math.log(S[i][d]) - if dp[nxt].has_key(nxt_c): - if nxt_v > dp[nxt][nxt_c]: - dp[nxt][nxt_c] = nxt_v - dpc[i][nxt_c] = (d,now_c) - else: - dp[nxt][nxt_c] = nxt_v - dpc[i][nxt_c] = (d,now_c) - now, nxt = nxt, now - maxv = -1e9 - target_c = 0 - for c,v in dp[now].items(): - assert c <= EC, 'False' - if v > maxv: - maxv = v - target_c = c - res = [0]*n - nowc = target_c - for i in xrange(n-1,-1,-1): - res[i] = dpc[i][nowc][0] + 1 - nowc = dpc[i][nowc][1] - return dict(zip(conv_names, res)) +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +import numpy as np +import mxnet as mx +import json +import utils +import math +import sys + +def calc_complexity(ishape, node): + y, x = map(int, eval(node['param']['kernel'])) + N = int(node['param']['num_filter']) + C, Y, X = ishape + return x*(N+C)*X*Y, x*y*N*C*X*Y + +def calc_eigenvalue(model, node): + W = model.arg_params[node['name'] + '_weight'].asnumpy() + N, C, y, x = W.shape + W = W.transpose((1,2,0,3)).reshape((C*y, -1)) + U, D, Q = np.linalg.svd(W, full_matrices=False) + return D + +def get_ranksel(model, ratio): + conf = json.loads(model.symbol.tojson()) + _, output_shapes, _ = model.symbol.get_internals().infer_shape(data=(1,3,224,224)) + out_names = model.symbol.get_internals().list_outputs() + out_shape_dic = dict(zip(out_names, output_shapes)) + nodes = conf['nodes'] + nodes = utils.topsort(nodes) + C = [] + D = [] + S = [] + conv_names = [] + EC = 0 + for node in nodes: + if node['op'] == 'Convolution': + input_nodes = [nodes[int(j[0])] for j in node['inputs']] + data = [input_node for input_node in input_nodes\ + if not input_node['name'].startswith(node['name'])][0] + + if utils.is_input(data): + ishape = (3, 224, 224) + else: + ishape = out_shape_dic[data['name'] + '_output'][1:] + C.append(calc_complexity(ishape, node)) + D.append(int(node['param']['num_filter'])) + S.append(calc_eigenvalue(model, node)) + conv_names.append(node['name']) + EC += C[-1][1] + for s in S: + ss = sum(s) + for i in xrange(1, len(s)): + s[i] += s[i-1] + n = len(C) + EC /= ratio + dp = [{}, {}] + dpc = [{} for _ in xrange(n)] + now, nxt = 0, 1 + dp[now][0] = 0 + for i in xrange(n): + dp[nxt] = {} + sys.stdout.flush() + for now_c, now_v in dp[now].items(): + for d in xrange(min(len(S[i]), D[i])): + nxt_c = now_c + (d+1)*C[i][0] + if nxt_c > EC: + continue + nxt_v = dp[now][now_c] + math.log(S[i][d]) + if dp[nxt].has_key(nxt_c): + if nxt_v > dp[nxt][nxt_c]: + dp[nxt][nxt_c] = nxt_v + dpc[i][nxt_c] = (d,now_c) + else: + dp[nxt][nxt_c] = nxt_v + dpc[i][nxt_c] = (d,now_c) + now, nxt = nxt, now + maxv = -1e9 + target_c = 0 + for c,v in dp[now].items(): + assert c <= EC, 'False' + if v > maxv: + maxv = v + target_c = c + res = [0]*n + nowc = target_c + for i in xrange(n-1,-1,-1): + res[i] = dpc[i][nowc][0] + 1 + nowc = dpc[i][nowc][1] + return dict(zip(conv_names, res)) diff --git a/tools/accnn/utils.py b/tools/accnn/utils.py index 4c0290a0643a..25fb18895620 100644 --- a/tools/accnn/utils.py +++ b/tools/accnn/utils.py @@ -1,101 +1,118 @@ -import mxnet as mx -import copy -import json -import ast - -def load_model(args): - devs = mx.cpu() if args.gpus == None else [mx.gpu(int(i)) for i in args.gpus.split(',')] - return mx.model.FeedForward.load(args.model, args.load_epoch, ctx=devs) - -def topsort(nodes): - n = len(nodes) - deg = [0]*n - g = [[] for _ in xrange(n)] - for i,node in enumerate(nodes): - if node.has_key('inputs'): - for j in node['inputs']: - deg[i] += 1 - g[j[0]].append(i) - from collections import deque - q = deque([i for i in xrange(n) if deg[i]==0]) - res = [] - for its in xrange(n): - i = q.popleft() - res.append(nodes[i]) - for j in g[i]: - deg[j] -= 1 - if deg[j] == 0: - q.append(j) - new_ids=dict([(node['name'],i) for i,node in enumerate(res)]) - for node in res: - if node.has_key('inputs'): - for j in node['inputs']: - j[0]=new_ids[nodes[j[0]]['name']] - return res - -def is_input(node): - name = node['name'] - return len(node['inputs']) == 0 and ('weight' not in name) and ('bias' not in name) and ('label' not in name) - -def sym_factory(node, data): - name = node['name'] - params = {} - if 'param' in node: - for k, v in node['param'].items(): - try: - params[k] = ast.literal_eval(v) - except ValueError, e: - params[k] = v - return getattr(mx.symbol, node['op'])(data=data, name=name, **params) - -def replace_conv_layer(layer_name, old_model, sym_handle, arg_handle): - conf = json.loads(old_model.symbol.tojson()) - sym_dict = {} - nodes = conf['nodes'] - nodes = topsort(nodes) - res_sym = None - new_model = old_model - for i,node in enumerate(nodes): - sym = None - if is_input(node): - sym = mx.symbol.Variable(name='data') - elif node['op'] != 'null': - input_nodes = [nodes[int(j[0])] for j in node['inputs']] - datas = [input_node['name'] for input_node in input_nodes\ - if not input_node['name'].startswith(node['name'])] - try: - data=sym_dict[datas[0]] - except Exception, e: - print 'can not find symbol %s'%(datas[0]) - raise e - if node['name'] == layer_name: - sym = sym_handle(data, node) - else: - sym = sym_factory(node, data) - if sym: - sym_dict[node['name']] = sym - res_sym = sym - - arg_params = copy.deepcopy(old_model.arg_params) - if layer_name: - arg_shapes, _, _ = res_sym.infer_shape(data=(1,3,224,224)) - arg_names = res_sym.list_arguments() - arg_shape_dic = dict(zip(arg_names, arg_shapes)) - try: - arg_handle(arg_shape_dic, arg_params) - except Exception, e: - raise Exception('Exception in arg_handle') - - new_model = mx.model.FeedForward( - symbol=res_sym, - ctx=old_model.ctx, - num_epoch=1, - epoch_size=old_model.epoch_size, - optimizer='sgd', - initializer=old_model.initializer, - numpy_batch_size=old_model.numpy_batch_size, - arg_params=arg_params, - aux_params=old_model.aux_params, - allow_extra_params=True, - begin_epoch=old_model.begin_epoch) - return new_model +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +import mxnet as mx +import copy +import json +import ast + +def load_model(args): + devs = mx.cpu() if args.gpus == None else [mx.gpu(int(i)) for i in args.gpus.split(',')] + return mx.model.FeedForward.load(args.model, args.load_epoch, ctx=devs) + +def topsort(nodes): + n = len(nodes) + deg = [0]*n + g = [[] for _ in xrange(n)] + for i,node in enumerate(nodes): + if node.has_key('inputs'): + for j in node['inputs']: + deg[i] += 1 + g[j[0]].append(i) + from collections import deque + q = deque([i for i in xrange(n) if deg[i]==0]) + res = [] + for its in xrange(n): + i = q.popleft() + res.append(nodes[i]) + for j in g[i]: + deg[j] -= 1 + if deg[j] == 0: + q.append(j) + new_ids=dict([(node['name'],i) for i,node in enumerate(res)]) + for node in res: + if node.has_key('inputs'): + for j in node['inputs']: + j[0]=new_ids[nodes[j[0]]['name']] + return res + +def is_input(node): + name = node['name'] + return len(node['inputs']) == 0 and ('weight' not in name) and ('bias' not in name) and ('label' not in name) + +def sym_factory(node, data): + name = node['name'] + params = {} + if 'param' in node: + for k, v in node['param'].items(): + try: + params[k] = ast.literal_eval(v) + except ValueError, e: + params[k] = v + return getattr(mx.symbol, node['op'])(data=data, name=name, **params) + +def replace_conv_layer(layer_name, old_model, sym_handle, arg_handle): + conf = json.loads(old_model.symbol.tojson()) + sym_dict = {} + nodes = conf['nodes'] + nodes = topsort(nodes) + res_sym = None + new_model = old_model + for i,node in enumerate(nodes): + sym = None + if is_input(node): + sym = mx.symbol.Variable(name='data') + elif node['op'] != 'null': + input_nodes = [nodes[int(j[0])] for j in node['inputs']] + datas = [input_node['name'] for input_node in input_nodes\ + if not input_node['name'].startswith(node['name'])] + try: + data=sym_dict[datas[0]] + except Exception, e: + print 'can not find symbol %s'%(datas[0]) + raise e + if node['name'] == layer_name: + sym = sym_handle(data, node) + else: + sym = sym_factory(node, data) + if sym: + sym_dict[node['name']] = sym + res_sym = sym + + arg_params = copy.deepcopy(old_model.arg_params) + if layer_name: + arg_shapes, _, _ = res_sym.infer_shape(data=(1,3,224,224)) + arg_names = res_sym.list_arguments() + arg_shape_dic = dict(zip(arg_names, arg_shapes)) + try: + arg_handle(arg_shape_dic, arg_params) + except Exception, e: + raise Exception('Exception in arg_handle') + + new_model = mx.model.FeedForward( + symbol=res_sym, + ctx=old_model.ctx, + num_epoch=1, + epoch_size=old_model.epoch_size, + optimizer='sgd', + initializer=old_model.initializer, + numpy_batch_size=old_model.numpy_batch_size, + arg_params=arg_params, + aux_params=old_model.aux_params, + allow_extra_params=True, + begin_epoch=old_model.begin_epoch) + return new_model diff --git a/tools/bandwidth/measure.py b/tools/bandwidth/measure.py index 0cac3de26731..66ef7371f11e 100644 --- a/tools/bandwidth/measure.py +++ b/tools/bandwidth/measure.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import os, sys curr_path = os.path.abspath(os.path.dirname(__file__)) sys.path.insert(0, os.path.join(curr_path, "../../python")) diff --git a/tools/bandwidth/test_measure.py b/tools/bandwidth/test_measure.py index b490af1cb75c..375290fe6853 100644 --- a/tools/bandwidth/test_measure.py +++ b/tools/bandwidth/test_measure.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """ test measure.py """ diff --git a/tools/caffe_converter/caffe_parser.py b/tools/caffe_converter/caffe_parser.py index d4abc8eac614..2ff490c7c6aa 100644 --- a/tools/caffe_converter/caffe_parser.py +++ b/tools/caffe_converter/caffe_parser.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """Parse caffe's protobuf """ import re diff --git a/tools/caffe_converter/caffe_proto_utils.py b/tools/caffe_converter/caffe_proto_utils.py index 940e8a47a1d6..8d6183457637 100644 --- a/tools/caffe_converter/caffe_proto_utils.py +++ b/tools/caffe_converter/caffe_proto_utils.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """Helper functions for parsing caffe prototxt into a workable DAG """ diff --git a/tools/caffe_converter/compare_layers.py b/tools/caffe_converter/compare_layers.py index bb4451d1b5fc..12568ed2060a 100644 --- a/tools/caffe_converter/compare_layers.py +++ b/tools/caffe_converter/compare_layers.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """Test converted models layer by layer """ import os diff --git a/tools/caffe_converter/convert_caffe_modelzoo.py b/tools/caffe_converter/convert_caffe_modelzoo.py index cb6d3ba7fc48..ab9042fcc532 100644 --- a/tools/caffe_converter/convert_caffe_modelzoo.py +++ b/tools/caffe_converter/convert_caffe_modelzoo.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """Convert Caffe's modelzoo """ import os diff --git a/tools/caffe_converter/convert_mean.py b/tools/caffe_converter/convert_mean.py index 69cf50c65bd6..3b6dc42a7afc 100644 --- a/tools/caffe_converter/convert_mean.py +++ b/tools/caffe_converter/convert_mean.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """Convert caffe mean """ import argparse diff --git a/tools/caffe_converter/convert_model.py b/tools/caffe_converter/convert_model.py index d1e4cd07c155..c04a2aa63cd2 100644 --- a/tools/caffe_converter/convert_model.py +++ b/tools/caffe_converter/convert_model.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """Convert caffe model """ from __future__ import print_function diff --git a/tools/caffe_converter/convert_symbol.py b/tools/caffe_converter/convert_symbol.py index 100a64fe63c6..dde3c26b5ca2 100644 --- a/tools/caffe_converter/convert_symbol.py +++ b/tools/caffe_converter/convert_symbol.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """Convert caffe prototxt to symbol """ from __future__ import print_function diff --git a/tools/caffe_converter/run.sh b/tools/caffe_converter/run.sh index 65876cc42934..bdf5481624d7 100755 --- a/tools/caffe_converter/run.sh +++ b/tools/caffe_converter/run.sh @@ -1,4 +1,22 @@ #!/bin/bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + if [[ $# -ne 1 ]]; then echo "usage: $0 model_name" echo " model_name: [vgg16|vgg19], ..." diff --git a/tools/caffe_converter/test_converter.py b/tools/caffe_converter/test_converter.py index 7572d2937186..db17c64e54b7 100644 --- a/tools/caffe_converter/test_converter.py +++ b/tools/caffe_converter/test_converter.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """Test converted models """ import os diff --git a/tools/im2rec.cc b/tools/im2rec.cc index a7ccfb667a12..856814024037 100644 --- a/tools/im2rec.cc +++ b/tools/im2rec.cc @@ -1,5 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /*! - * Copyright (c) 2015 by Contributors * \file im2rec.cc * \brief convert images into image recordio format * Image Record Format: zeropad[64bit] imid[64bit] img-binary-content diff --git a/tools/im2rec.py b/tools/im2rec.py index 30ee3ec92a5e..ec6de1969414 100644 --- a/tools/im2rec.py +++ b/tools/im2rec.py @@ -1,307 +1,324 @@ -# -*- coding: utf-8 -*- -from __future__ import print_function -import os -import sys - -curr_path = os.path.abspath(os.path.dirname(__file__)) -sys.path.append(os.path.join(curr_path, "../python")) -import mxnet as mx -import random -import argparse -import cv2 -import time -import traceback -from builtins import range - -try: - import multiprocessing -except ImportError: - multiprocessing = None - -def list_image(root, recursive, exts): - i = 0 - if recursive: - cat = {} - for path, dirs, files in os.walk(root, followlinks=True): - dirs.sort() - files.sort() - for fname in files: - fpath = os.path.join(path, fname) - suffix = os.path.splitext(fname)[1].lower() - if os.path.isfile(fpath) and (suffix in exts): - if path not in cat: - cat[path] = len(cat) - yield (i, os.path.relpath(fpath, root), cat[path]) - i += 1 - for k, v in sorted(cat.items(), key=lambda x: x[1]): - print(os.path.relpath(k, root), v) - else: - for fname in sorted(os.listdir(root)): - fpath = os.path.join(root, fname) - suffix = os.path.splitext(fname)[1].lower() - if os.path.isfile(fpath) and (suffix in exts): - yield (i, os.path.relpath(fpath, root), 0) - i += 1 - -def write_list(path_out, image_list): - with open(path_out, 'w') as fout: - for i, item in enumerate(image_list): - line = '%d\t' % item[0] - for j in item[2:]: - line += '%f\t' % j - line += '%s\n' % item[1] - fout.write(line) - -def make_list(args): - image_list = list_image(args.root, args.recursive, args.exts) - image_list = list(image_list) - if args.shuffle is True: - random.seed(100) - random.shuffle(image_list) - N = len(image_list) - chunk_size = (N + args.chunks - 1) // args.chunks - for i in range(args.chunks): - chunk = image_list[i * chunk_size:(i + 1) * chunk_size] - if args.chunks > 1: - str_chunk = '_%d' % i - else: - str_chunk = '' - sep = int(chunk_size * args.train_ratio) - sep_test = int(chunk_size * args.test_ratio) - if args.train_ratio == 1.0: - write_list(args.prefix + str_chunk + '.lst', chunk) - else: - if args.test_ratio: - write_list(args.prefix + str_chunk + '_test.lst', chunk[:sep_test]) - if args.train_ratio + args.test_ratio < 1.0: - write_list(args.prefix + str_chunk + '_val.lst', chunk[sep_test + sep:]) - write_list(args.prefix + str_chunk + '_train.lst', chunk[sep_test:sep_test + sep]) - -def read_list(path_in): - with open(path_in) as fin: - while True: - line = fin.readline() - if not line: - break - line = [i.strip() for i in line.strip().split('\t')] - line_len = len(line) - if line_len < 3: - print('lst should at least has three parts, but only has %s parts for %s' %(line_len, line)) - continue - try: - item = [int(line[0])] + [line[-1]] + [float(i) for i in line[1:-1]] - except Exception as e: - print('Parsing lst met error for %s, detail: %s' %(line, e)) - continue - yield item - -def image_encode(args, i, item, q_out): - fullpath = os.path.join(args.root, item[1]) - - if len(item) > 3 and args.pack_label: - header = mx.recordio.IRHeader(0, item[2:], item[0], 0) - else: - header = mx.recordio.IRHeader(0, item[2], item[0], 0) - - if args.pass_through: - try: - with open(fullpath, 'rb') as fin: - img = fin.read() - s = mx.recordio.pack(header, img) - q_out.put((i, s, item)) - except Exception as e: - traceback.print_exc() - print('pack_img error:', item[1], e) - q_out.put((i, None, item)) - return - - try: - img = cv2.imread(fullpath, args.color) - except: - traceback.print_exc() - print('imread error trying to load file: %s ' % fullpath) - q_out.put((i, None, item)) - return - if img is None: - print('imread read blank (None) image for file: %s' % fullpath) - q_out.put((i, None, item)) - return - if args.center_crop: - if img.shape[0] > img.shape[1]: - margin = (img.shape[0] - img.shape[1]) // 2; - img = img[margin:margin + img.shape[1], :] - else: - margin = (img.shape[1] - img.shape[0]) // 2; - img = img[:, margin:margin + img.shape[0]] - if args.resize: - if img.shape[0] > img.shape[1]: - newsize = (args.resize, img.shape[0] * args.resize // img.shape[1]) - else: - newsize = (img.shape[1] * args.resize // img.shape[0], args.resize) - img = cv2.resize(img, newsize) - - try: - s = mx.recordio.pack_img(header, img, quality=args.quality, img_fmt=args.encoding) - q_out.put((i, s, item)) - except Exception as e: - traceback.print_exc() - print('pack_img error on file: %s' % fullpath, e) - q_out.put((i, None, item)) - return - -def read_worker(args, q_in, q_out): - while True: - deq = q_in.get() - if deq is None: - break - i, item = deq - image_encode(args, i, item, q_out) - -def write_worker(q_out, fname, working_dir): - pre_time = time.time() - count = 0 - fname = os.path.basename(fname) - fname_rec = os.path.splitext(fname)[0] + '.rec' - fname_idx = os.path.splitext(fname)[0] + '.idx' - record = mx.recordio.MXIndexedRecordIO(os.path.join(working_dir, fname_idx), - os.path.join(working_dir, fname_rec), 'w') - buf = {} - more = True - while more: - deq = q_out.get() - if deq is not None: - i, s, item = deq - buf[i] = (s, item) - else: - more = False - while count in buf: - s, item = buf[count] - del buf[count] - if s is not None: - record.write_idx(item[0], s) - - if count % 1000 == 0: - cur_time = time.time() - print('time:', cur_time - pre_time, ' count:', count) - pre_time = cur_time - count += 1 - -def parse_args(): - parser = argparse.ArgumentParser( - formatter_class=argparse.ArgumentDefaultsHelpFormatter, - description='Create an image list or \ - make a record database by reading from an image list') - parser.add_argument('prefix', help='prefix of input/output lst and rec files.') - parser.add_argument('root', help='path to folder containing images.') - - cgroup = parser.add_argument_group('Options for creating image lists') - cgroup.add_argument('--list', type=bool, default=False, - help='If this is set im2rec will create image list(s) by traversing root folder\ - and output to .lst.\ - Otherwise im2rec will read .lst and create a database at .rec') - cgroup.add_argument('--exts', nargs='+', default=['.jpeg', '.jpg'], - help='list of acceptable image extensions.') - cgroup.add_argument('--chunks', type=int, default=1, help='number of chunks.') - cgroup.add_argument('--train-ratio', type=float, default=1.0, - help='Ratio of images to use for training.') - cgroup.add_argument('--test-ratio', type=float, default=0, - help='Ratio of images to use for testing.') - cgroup.add_argument('--recursive', type=bool, default=False, - help='If true recursively walk through subdirs and assign an unique label\ - to images in each folder. Otherwise only include images in the root folder\ - and give them label 0.') - cgroup.add_argument('--shuffle', type=bool, default=True, help='If this is set as True, \ - im2rec will randomize the image order in .lst') - - rgroup = parser.add_argument_group('Options for creating database') - rgroup.add_argument('--pass-through', type=bool, default=False, - help='whether to skip transformation and save image as is') - rgroup.add_argument('--resize', type=int, default=0, - help='resize the shorter edge of image to the newsize, original images will\ - be packed by default.') - rgroup.add_argument('--center-crop', type=bool, default=False, - help='specify whether to crop the center image to make it rectangular.') - rgroup.add_argument('--quality', type=int, default=95, - help='JPEG quality for encoding, 1-100; or PNG compression for encoding, 1-9') - rgroup.add_argument('--num-thread', type=int, default=1, - help='number of thread to use for encoding. order of images will be different\ - from the input list if >1. the input list will be modified to match the\ - resulting order.') - rgroup.add_argument('--color', type=int, default=1, choices=[-1, 0, 1], - help='specify the color mode of the loaded image.\ - 1: Loads a color image. Any transparency of image will be neglected. It is the default flag.\ - 0: Loads image in grayscale mode.\ - -1:Loads image as such including alpha channel.') - rgroup.add_argument('--encoding', type=str, default='.jpg', choices=['.jpg', '.png'], - help='specify the encoding of the images.') - rgroup.add_argument('--pack-label', type=bool, default=False, - help='Whether to also pack multi dimensional label in the record file') - args = parser.parse_args() - args.prefix = os.path.abspath(args.prefix) - args.root = os.path.abspath(args.root) - return args - -if __name__ == '__main__': - args = parse_args() - if args.list: - make_list(args) - else: - if os.path.isdir(args.prefix): - working_dir = args.prefix - else: - working_dir = os.path.dirname(args.prefix) - files = [os.path.join(working_dir, fname) for fname in os.listdir(working_dir) - if os.path.isfile(os.path.join(working_dir, fname))] - count = 0 - for fname in files: - if fname.startswith(args.prefix) and fname.endswith('.lst'): - print('Creating .rec file from', fname, 'in', working_dir) - count += 1 - image_list = read_list(fname) - # -- write_record -- # - if args.num_thread > 1 and multiprocessing is not None: - q_in = [multiprocessing.Queue(1024) for i in range(args.num_thread)] - q_out = multiprocessing.Queue(1024) - read_process = [multiprocessing.Process(target=read_worker, args=(args, q_in[i], q_out)) \ - for i in range(args.num_thread)] - for p in read_process: - p.start() - write_process = multiprocessing.Process(target=write_worker, args=(q_out, fname, working_dir)) - write_process.start() - - for i, item in enumerate(image_list): - q_in[i % len(q_in)].put((i, item)) - for q in q_in: - q.put(None) - for p in read_process: - p.join() - - q_out.put(None) - write_process.join() - else: - print('multiprocessing not available, fall back to single threaded encoding') - try: - import Queue as queue - except ImportError: - import queue - q_out = queue.Queue() - fname = os.path.basename(fname) - fname_rec = os.path.splitext(fname)[0] + '.rec' - fname_idx = os.path.splitext(fname)[0] + '.idx' - record = mx.recordio.MXIndexedRecordIO(os.path.join(working_dir, fname_idx), - os.path.join(working_dir, fname_rec), 'w') - cnt = 0 - pre_time = time.time() - for i, item in enumerate(image_list): - image_encode(args, i, item, q_out) - if q_out.empty(): - continue - _, s, _ = q_out.get() - record.write_idx(item[0], s) - if cnt % 1000 == 0: - cur_time = time.time() - print('time:', cur_time - pre_time, ' count:', cnt) - pre_time = cur_time - cnt += 1 - if not count: - print('Did not find and list file with prefix %s'%args.prefix) +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# -*- coding: utf-8 -*- +from __future__ import print_function +import os +import sys + +curr_path = os.path.abspath(os.path.dirname(__file__)) +sys.path.append(os.path.join(curr_path, "../python")) +import mxnet as mx +import random +import argparse +import cv2 +import time +import traceback +from builtins import range + +try: + import multiprocessing +except ImportError: + multiprocessing = None + +def list_image(root, recursive, exts): + i = 0 + if recursive: + cat = {} + for path, dirs, files in os.walk(root, followlinks=True): + dirs.sort() + files.sort() + for fname in files: + fpath = os.path.join(path, fname) + suffix = os.path.splitext(fname)[1].lower() + if os.path.isfile(fpath) and (suffix in exts): + if path not in cat: + cat[path] = len(cat) + yield (i, os.path.relpath(fpath, root), cat[path]) + i += 1 + for k, v in sorted(cat.items(), key=lambda x: x[1]): + print(os.path.relpath(k, root), v) + else: + for fname in sorted(os.listdir(root)): + fpath = os.path.join(root, fname) + suffix = os.path.splitext(fname)[1].lower() + if os.path.isfile(fpath) and (suffix in exts): + yield (i, os.path.relpath(fpath, root), 0) + i += 1 + +def write_list(path_out, image_list): + with open(path_out, 'w') as fout: + for i, item in enumerate(image_list): + line = '%d\t' % item[0] + for j in item[2:]: + line += '%f\t' % j + line += '%s\n' % item[1] + fout.write(line) + +def make_list(args): + image_list = list_image(args.root, args.recursive, args.exts) + image_list = list(image_list) + if args.shuffle is True: + random.seed(100) + random.shuffle(image_list) + N = len(image_list) + chunk_size = (N + args.chunks - 1) // args.chunks + for i in range(args.chunks): + chunk = image_list[i * chunk_size:(i + 1) * chunk_size] + if args.chunks > 1: + str_chunk = '_%d' % i + else: + str_chunk = '' + sep = int(chunk_size * args.train_ratio) + sep_test = int(chunk_size * args.test_ratio) + if args.train_ratio == 1.0: + write_list(args.prefix + str_chunk + '.lst', chunk) + else: + if args.test_ratio: + write_list(args.prefix + str_chunk + '_test.lst', chunk[:sep_test]) + if args.train_ratio + args.test_ratio < 1.0: + write_list(args.prefix + str_chunk + '_val.lst', chunk[sep_test + sep:]) + write_list(args.prefix + str_chunk + '_train.lst', chunk[sep_test:sep_test + sep]) + +def read_list(path_in): + with open(path_in) as fin: + while True: + line = fin.readline() + if not line: + break + line = [i.strip() for i in line.strip().split('\t')] + line_len = len(line) + if line_len < 3: + print('lst should at least has three parts, but only has %s parts for %s' %(line_len, line)) + continue + try: + item = [int(line[0])] + [line[-1]] + [float(i) for i in line[1:-1]] + except Exception as e: + print('Parsing lst met error for %s, detail: %s' %(line, e)) + continue + yield item + +def image_encode(args, i, item, q_out): + fullpath = os.path.join(args.root, item[1]) + + if len(item) > 3 and args.pack_label: + header = mx.recordio.IRHeader(0, item[2:], item[0], 0) + else: + header = mx.recordio.IRHeader(0, item[2], item[0], 0) + + if args.pass_through: + try: + with open(fullpath, 'rb') as fin: + img = fin.read() + s = mx.recordio.pack(header, img) + q_out.put((i, s, item)) + except Exception as e: + traceback.print_exc() + print('pack_img error:', item[1], e) + q_out.put((i, None, item)) + return + + try: + img = cv2.imread(fullpath, args.color) + except: + traceback.print_exc() + print('imread error trying to load file: %s ' % fullpath) + q_out.put((i, None, item)) + return + if img is None: + print('imread read blank (None) image for file: %s' % fullpath) + q_out.put((i, None, item)) + return + if args.center_crop: + if img.shape[0] > img.shape[1]: + margin = (img.shape[0] - img.shape[1]) // 2; + img = img[margin:margin + img.shape[1], :] + else: + margin = (img.shape[1] - img.shape[0]) // 2; + img = img[:, margin:margin + img.shape[0]] + if args.resize: + if img.shape[0] > img.shape[1]: + newsize = (args.resize, img.shape[0] * args.resize // img.shape[1]) + else: + newsize = (img.shape[1] * args.resize // img.shape[0], args.resize) + img = cv2.resize(img, newsize) + + try: + s = mx.recordio.pack_img(header, img, quality=args.quality, img_fmt=args.encoding) + q_out.put((i, s, item)) + except Exception as e: + traceback.print_exc() + print('pack_img error on file: %s' % fullpath, e) + q_out.put((i, None, item)) + return + +def read_worker(args, q_in, q_out): + while True: + deq = q_in.get() + if deq is None: + break + i, item = deq + image_encode(args, i, item, q_out) + +def write_worker(q_out, fname, working_dir): + pre_time = time.time() + count = 0 + fname = os.path.basename(fname) + fname_rec = os.path.splitext(fname)[0] + '.rec' + fname_idx = os.path.splitext(fname)[0] + '.idx' + record = mx.recordio.MXIndexedRecordIO(os.path.join(working_dir, fname_idx), + os.path.join(working_dir, fname_rec), 'w') + buf = {} + more = True + while more: + deq = q_out.get() + if deq is not None: + i, s, item = deq + buf[i] = (s, item) + else: + more = False + while count in buf: + s, item = buf[count] + del buf[count] + if s is not None: + record.write_idx(item[0], s) + + if count % 1000 == 0: + cur_time = time.time() + print('time:', cur_time - pre_time, ' count:', count) + pre_time = cur_time + count += 1 + +def parse_args(): + parser = argparse.ArgumentParser( + formatter_class=argparse.ArgumentDefaultsHelpFormatter, + description='Create an image list or \ + make a record database by reading from an image list') + parser.add_argument('prefix', help='prefix of input/output lst and rec files.') + parser.add_argument('root', help='path to folder containing images.') + + cgroup = parser.add_argument_group('Options for creating image lists') + cgroup.add_argument('--list', type=bool, default=False, + help='If this is set im2rec will create image list(s) by traversing root folder\ + and output to .lst.\ + Otherwise im2rec will read .lst and create a database at .rec') + cgroup.add_argument('--exts', nargs='+', default=['.jpeg', '.jpg'], + help='list of acceptable image extensions.') + cgroup.add_argument('--chunks', type=int, default=1, help='number of chunks.') + cgroup.add_argument('--train-ratio', type=float, default=1.0, + help='Ratio of images to use for training.') + cgroup.add_argument('--test-ratio', type=float, default=0, + help='Ratio of images to use for testing.') + cgroup.add_argument('--recursive', type=bool, default=False, + help='If true recursively walk through subdirs and assign an unique label\ + to images in each folder. Otherwise only include images in the root folder\ + and give them label 0.') + cgroup.add_argument('--shuffle', type=bool, default=True, help='If this is set as True, \ + im2rec will randomize the image order in .lst') + + rgroup = parser.add_argument_group('Options for creating database') + rgroup.add_argument('--pass-through', type=bool, default=False, + help='whether to skip transformation and save image as is') + rgroup.add_argument('--resize', type=int, default=0, + help='resize the shorter edge of image to the newsize, original images will\ + be packed by default.') + rgroup.add_argument('--center-crop', type=bool, default=False, + help='specify whether to crop the center image to make it rectangular.') + rgroup.add_argument('--quality', type=int, default=95, + help='JPEG quality for encoding, 1-100; or PNG compression for encoding, 1-9') + rgroup.add_argument('--num-thread', type=int, default=1, + help='number of thread to use for encoding. order of images will be different\ + from the input list if >1. the input list will be modified to match the\ + resulting order.') + rgroup.add_argument('--color', type=int, default=1, choices=[-1, 0, 1], + help='specify the color mode of the loaded image.\ + 1: Loads a color image. Any transparency of image will be neglected. It is the default flag.\ + 0: Loads image in grayscale mode.\ + -1:Loads image as such including alpha channel.') + rgroup.add_argument('--encoding', type=str, default='.jpg', choices=['.jpg', '.png'], + help='specify the encoding of the images.') + rgroup.add_argument('--pack-label', type=bool, default=False, + help='Whether to also pack multi dimensional label in the record file') + args = parser.parse_args() + args.prefix = os.path.abspath(args.prefix) + args.root = os.path.abspath(args.root) + return args + +if __name__ == '__main__': + args = parse_args() + if args.list: + make_list(args) + else: + if os.path.isdir(args.prefix): + working_dir = args.prefix + else: + working_dir = os.path.dirname(args.prefix) + files = [os.path.join(working_dir, fname) for fname in os.listdir(working_dir) + if os.path.isfile(os.path.join(working_dir, fname))] + count = 0 + for fname in files: + if fname.startswith(args.prefix) and fname.endswith('.lst'): + print('Creating .rec file from', fname, 'in', working_dir) + count += 1 + image_list = read_list(fname) + # -- write_record -- # + if args.num_thread > 1 and multiprocessing is not None: + q_in = [multiprocessing.Queue(1024) for i in range(args.num_thread)] + q_out = multiprocessing.Queue(1024) + read_process = [multiprocessing.Process(target=read_worker, args=(args, q_in[i], q_out)) \ + for i in range(args.num_thread)] + for p in read_process: + p.start() + write_process = multiprocessing.Process(target=write_worker, args=(q_out, fname, working_dir)) + write_process.start() + + for i, item in enumerate(image_list): + q_in[i % len(q_in)].put((i, item)) + for q in q_in: + q.put(None) + for p in read_process: + p.join() + + q_out.put(None) + write_process.join() + else: + print('multiprocessing not available, fall back to single threaded encoding') + try: + import Queue as queue + except ImportError: + import queue + q_out = queue.Queue() + fname = os.path.basename(fname) + fname_rec = os.path.splitext(fname)[0] + '.rec' + fname_idx = os.path.splitext(fname)[0] + '.idx' + record = mx.recordio.MXIndexedRecordIO(os.path.join(working_dir, fname_idx), + os.path.join(working_dir, fname_rec), 'w') + cnt = 0 + pre_time = time.time() + for i, item in enumerate(image_list): + image_encode(args, i, item, q_out) + if q_out.empty(): + continue + _, s, _ = q_out.get() + record.write_idx(item[0], s) + if cnt % 1000 == 0: + cur_time = time.time() + print('time:', cur_time - pre_time, ' count:', cnt) + pre_time = cur_time + cnt += 1 + if not count: + print('Did not find and list file with prefix %s'%args.prefix) diff --git a/tools/ipynb2md.py b/tools/ipynb2md.py index 426fa727764a..227174c25eee 100755 --- a/tools/ipynb2md.py +++ b/tools/ipynb2md.py @@ -1,5 +1,23 @@ #!/usr/bin/env python +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + """ Convert jupyter notebook into the markdown format. The notebook outputs will be removed. diff --git a/tools/kill-mxnet.py b/tools/kill-mxnet.py index 2bdf949893b0..2a4a4303400b 100644 --- a/tools/kill-mxnet.py +++ b/tools/kill-mxnet.py @@ -1,5 +1,23 @@ #!/usr/bin/env python +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + import os, sys import subprocess diff --git a/tools/launch.py b/tools/launch.py index f5366657c2cc..de42ea2a7dd3 100755 --- a/tools/launch.py +++ b/tools/launch.py @@ -1,4 +1,22 @@ #!/usr/bin/env python + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """ Launch a distributed job """ @@ -54,7 +72,7 @@ def main(): args.num_servers = args.num_workers args = dmlc_opts(args) - + if args.host_file is None or args.host_file == 'None': if args.cluster == 'yarn': from dmlc_tracker import yarn diff --git a/tools/license_header.py b/tools/license_header.py new file mode 100644 index 000000000000..d0782b2b06fd --- /dev/null +++ b/tools/license_header.py @@ -0,0 +1,157 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +"""Add or check license header + +Usuage: + +- add the default license header to source files that do not contain a valid + license: + + python license_header.py add + +- check if every files has a license header + + python license_header.py check +""" + +import re +import os +import argparse + +# the default apache license +_LICENSE = """Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License.""" + +# if a file contains any str in the list, then consider it has been licensed +_LICENSE_PATTERNS = ['Licensed to the Apache Software Foundation'] + +# the folders or files that will be ignored +_WHITE_LIST = ['R-package/', + 'cub/', + 'dlpack/', + 'dmlc-core/', + 'mshadow/', + 'nnvm', + 'ps-lite', + 'src/operator/mkl/', + 'src/operator/contrib/ctc_include/'] + +# language extensions and the according commment mark +_LANGS = {'.cc':'*', '.h':'*', '.cu':'*', '.cuh':'*', '.py':'#', + '.pm':'#', '.scala':'*', '.cc':'*', '.sh':'#', '.cmake':'#'} + +# Previous license header, which will be removed +_OLD_LICENSE = re.compile('.*Copyright.*by Contributors') + +def _has_license(lines): + return any([any([p in l.decode('utf-8') for p in _LICENSE_PATTERNS]) for l in lines]) + +def _get_license(comment_mark): + if comment_mark == '*': + body = '/*\n' + else: + body = '' + for l in _LICENSE.split('\n'): + if comment_mark == '*': + body += ' ' + body += comment_mark + if len(l): + body += ' ' + l + body += '\n' + + if comment_mark == '*': + body += ' */\n' + body += '\n' + return body + +def _valid_file(fname, verbose=False): + if any([l in fname for l in _WHITE_LIST]): + if verbose: + print('skip ' + fname + ', it matches the white list') + return False + _, ext = os.path.splitext(fname) + if ext not in _LANGS: + if verbose: + print('skip ' + fname + ', unknown file extension') + return False + return True + +def process_file(fname, action, verbose=False): + if not _valid_file(fname, verbose): + return True + with open(fname, 'rb') as f: + lines = f.readlines() + if not lines: + return True + if _has_license(lines): + return True + elif action == 'check': + return False + _, ext = os.path.splitext(fname) + # remove old license + if ext == '.h' or ext == '.cc' or ext == '.cu': + for i, l in enumerate(lines): + if _OLD_LICENSE.match(l.decode('utf-8')): + del lines[i] + break + with open(fname, 'wb') as f: + # shebang line + if lines[0].startswith(b'#!'): + f.write(lines[0].rstrip()+b'\n\n') + del lines[0] + f.write(str.encode(_get_license(_LANGS[ext]))) + for l in lines: + f.write(l.rstrip()+b'\n') + print('added license header to ' + fname) + return False + +def process_folder(root, action): + excepts = [] + for root, _, files in os.walk(root): + for f in files: + fname = os.path.normpath(os.path.join(root, f)) + if not process_file(fname, action): + excepts.append(fname) + if action == 'check' and excepts: + raise Exception('The following files do not contain a valid license, '+ + 'you can use `python tools/license_header.py add` to add'+ + 'them automatically', excepts) + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description='Add or check source license header') + parser.add_argument( + 'action', nargs=1, type=str, + choices=['add', 'check'], default='add', + help = 'add or check') + args = parser.parse_args() + process_folder(os.path.join(os.path.dirname(__file__), '..'), args.action[0]) diff --git a/tools/parse_log.py b/tools/parse_log.py index 070f770b8cf6..f0ce53dbe76f 100755 --- a/tools/parse_log.py +++ b/tools/parse_log.py @@ -1,4 +1,22 @@ #!/usr/bin/env python + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + """ parse mxnet output log into a markdown table """ diff --git a/tools/pip_package/make_pip_package.sh b/tools/pip_package/make_pip_package.sh index a1af18bad528..46b4938b0785 100755 --- a/tools/pip_package/make_pip_package.sh +++ b/tools/pip_package/make_pip_package.sh @@ -1,5 +1,23 @@ #!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + # Assuming the script is run at mxnet/tools/pip_package # This script builds from scratch the dependencies of mxnet into static # librareis and statically links them to produce a (mostly) standalone diff --git a/tools/pip_package/setup.py b/tools/pip_package/setup.py index 45d761e53dea..e4bf48236bde 100644 --- a/tools/pip_package/setup.py +++ b/tools/pip_package/setup.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: disable=invalid-name, exec-used """Setup mxnet package.""" from __future__ import absolute_import