diff --git a/src/chainable.h b/src/chainable.h index fa4d1452..a3b6391e 100644 --- a/src/chainable.h +++ b/src/chainable.h @@ -1,5 +1,26 @@ #pragma once +// This file is part of the Marian toolkit. +// Marian is copyright (c) 2016 Marcin Junczys-Dowmunt. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + #include #include @@ -29,6 +50,12 @@ struct Chainable { }; }; +// XXX Marcin, is ChainableStack the most appropriate name? +// AFAIK, this is never used as a FILO data structure. +// If so, perhaps "Tape" or "ChainLinks" or "ChainableList" might be more apropos? +// +// Naumann (2012) uses "tape" to refer to this data structure. +// -- The Art of Differentiating Computer Programs: An Introduction to Algorithmic Differentiation, Naumann (2012) typedef std::vector*> ChainableStack; typedef std::shared_ptr ChainableStackPtr; typedef std::shared_ptr> ChainPtr; diff --git a/src/compile_time_crc32.h b/src/compile_time_crc32.h index f564d33c..62c27ebd 100644 --- a/src/compile_time_crc32.h +++ b/src/compile_time_crc32.h @@ -1,5 +1,27 @@ #pragma once - + +// This file is part of the Marian toolkit. +// Marian is copyright (c) 2016 Marcin Junczys-Dowmunt. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + + static constexpr uint32_t crc_table[256] = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, diff --git a/src/definitions.h b/src/definitions.h index c1f24663..661b3add 100644 --- a/src/definitions.h +++ b/src/definitions.h @@ -1,5 +1,26 @@ #pragma once +// This file is part of the Marian toolkit. +// Marian is copyright (c) 2016 Marcin Junczys-Dowmunt. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + #include #include #include diff --git a/src/exception.cpp b/src/exception.cpp index 453fcf66..cd4c0a25 100644 --- a/src/exception.cpp +++ b/src/exception.cpp @@ -1,5 +1,26 @@ #include "exception.h" +// This file is part of the Marian toolkit. +// Marian is copyright (c) 2016 Marcin Junczys-Dowmunt. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + #ifdef __GXX_RTTI #include #endif diff --git a/src/exception.h b/src/exception.h index 85827d8c..9eb92410 100644 --- a/src/exception.h +++ b/src/exception.h @@ -1,5 +1,26 @@ #pragma once +// This file is part of the Marian toolkit. +// Marian is copyright (c) 2016 Marcin Junczys-Dowmunt. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + #include #include #include diff --git a/src/expression_graph.cu b/src/expression_graph.cu index fbdaa084..204f454b 100644 --- a/src/expression_graph.cu +++ b/src/expression_graph.cu @@ -1,3 +1,24 @@ +// This file is part of the Marian toolkit. +// Marian is copyright (c) 2016 Marcin Junczys-Dowmunt. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + #include #include "expression_graph.h" diff --git a/src/expression_graph.h b/src/expression_graph.h index 29d89e65..58469840 100644 --- a/src/expression_graph.h +++ b/src/expression_graph.h @@ -1,5 +1,26 @@ #pragma once +// This file is part of the Marian toolkit. +// Marian is copyright (c) 2016 Marcin Junczys-Dowmunt. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + #include #include "definitions.h" @@ -9,7 +30,10 @@ namespace marian { +// Forward declaration of ExpressionGraph class; this enables it to be used in the following typedef of ExpressionGraphPtr class ExpressionGraph; + +/** @brief A pointer to an expression graph. */ typedef ExpressionGraph* ExpressionGraphPtr; class Expr { @@ -36,15 +60,43 @@ class Expr { ChainPtr pimpl_; }; +/** + * @brief Represents a computation graph of expressions, over which algorithmic differentiation may be performed. + */ class ExpressionGraph { public: + + /** @brief Constructs a new expression graph */ ExpressionGraph() : stack_(new ChainableStack) {} - + + /** + * @brief Performs backpropogation on this expression graph. + * + * Backpropogation is implemented by performing first the forward pass + * and then the backward pass of algorithmic differentiation (AD) on the nodes of the graph. + * + * @param batchSize XXX Marcin, could you provide a description of this param? + */ void backprop(int batchSize) { forward(batchSize); backward(); } - + + /** + * @brief Perform the forward pass of algorithmic differentiation (AD) on this graph. + * + * This pass traverses the nodes of this graph in the order they were created; + * as each node is traversed, its allocate() method is called. + * + * Once allocation is complete for all nodes, this pass again traverses the nodes, in creation order; + * as each node is traversed, its forward() method is called. + * + * After this method has successfully completed, + * it is guaranteed that all node allocation has been completed, + * and that all forward pass computations have been performed. + * + * @param batchSize XXX Marcin, could you provide a description of this param? + */ void forward(int batchSize) { for(auto&& v : *stack_) { v->allocate(batchSize); @@ -52,7 +104,19 @@ class ExpressionGraph { for(auto&& v : *stack_) v->forward(); } - + + /** + * @brief Perform the backward pass of algorithmic differentiation (AD) on this graph. + * + * This pass traverses the nodes of this graph in reverse of the order they were created; + * as each node is traversed, its set_zero_adjoint() method is called. + * + * Once this has been performed for all nodes, this pass again traverses the nodes, again in reverse creation order; + * as each node is traversed, its backward() method is called. + * + * After this method has successfully completed, + * and that all backward pass computations have been performed. + */ void backward() { for(auto&& v : *stack_) v->set_zero_adjoint(); @@ -62,7 +126,14 @@ class ExpressionGraph { for(It it = stack_->rbegin(); it != stack_->rend(); ++it) (*it)->backward(); } - + + /** + * @brief Returns a string representing this expression graph in graphviz notation. + * + * This string can be used by graphviz tools to visualize the expression graph. + * + * @return a string representing this expression graph in graphviz notation + */ std::string graphviz() { std::stringstream ss; ss << "digraph ExpressionGraph {" << std::endl; @@ -76,69 +147,165 @@ class ExpressionGraph { } /*********************************************************/ - + + /** + * @brief Constructs a new node representing an input in an expression graph. + * + * This method records the input node in a list of input nodes, + * but does not attach the new input node to any existing expression graph. + * + * @param args XXX Marcin, what are args here? + * + * @return a newly constructed input node + */ template inline Expr input(Args ...args) { Expr e(this, new InputNode(args...)); inputs_.emplace_back(e); return e; } - + + /** + * @brief Constructs a new node representing a parameter in an expression graph. + * + * This method records the parameter node in a list of parameter nodes, + * but does not attach the new parameter node to any existing expression graph. + * + * @param args XXX Marcin, what are args here? + * + * @return a newly constructed parameter node + */ template inline Expr param(Args ...args) { Expr e(this, new ParamNode(args...)); params_.emplace_back(e); return e; } - + + /** + * @brief Constructs a new node representing a constant in an expression graph. + * + * This method does not attach the new constant node to any existing expression graph. + * + * @param args XXX Marcin, what are args here? + * + * @return a newly constructed constant node + */ template inline Expr constant(Args ...args) { return Expr(this, new ConstantNode(args...)); } - + + /** + * @brief Constructs a new node representing a constant (with value 1) in an expression graph. + * + * This method does not attach the new constant node to any existing expression graph. + * + * @param args XXX Marcin, what are args here? + * + * @return a newly constructed constant node + */ template inline Expr ones(Args ...args) { return Expr(this, new ConstantNode(keywords::value=1, args...)); } - + + /** + * @brief Constructs a new node representing a constant (with value 0) in an expression graph. + * + * This method does not attach the new constant node to any existing expression graph. + * + * @param args XXX Marcin, what are args here? + * + * @return a newly constructed constant node + */ template inline Expr zeroes(Args ...args) { return Expr(this, new ConstantNode(keywords::value=0, args...)); } /*********************************************************/ - + + /** + * @brief Returns a pointer to the list of items contained in this graph. + * + * The items in the list will be in the order they were created. + * + * @return a pointer to the list of items contained in this graph + */ ChainableStackPtr stack() { return stack_; } - + + /** + * @brief Returns the first item in the list with the specified name, if such an item exists. + * + * If no item with the specified name is found in the graph, this method throws an exception. + * + * @param name Name of the desired expression node + * + * @return the first item in the list with the specified name, if such an item exists + */ Expr& operator[](const std::string& name) { auto it = named_.find(name); UTIL_THROW_IF2(it == named_.end(), "No such named node in graph: " << name); return it->second; } + /** + * @brief Determines whether the graph contains a node with a specified name. + * + * @param name Name of the desired expression node + * + * @return true if the graph contains a node with a specified name, + * false otherwise + */ bool has_node(const std::string& name) const { return named_.count(name) > 0; } - + + /** + * @brief Inserts an expression node with a specified name into the expression graph. + * + * @param e an expression node + * @param name name of the expression node + * + * @return the expression node that was added to the expression graph + */ void add_named_node(Expr e, const std::string& name) { named_.emplace(name, e); } - + + /** + * @brief Gets the list of all input nodes of this expression graph + * + * @return the list of all input nodes of this expression graph + */ std::vector& inputs() { return inputs_; } - + + /** + * @brief Gets the list of all parameter nodes of this expression graph + * + * @return the list of all parameter nodes of this expression graph + */ std::vector& params() { return params_; } private: + + /** @brief Pointer to the list of nodes */ ChainableStackPtr stack_; - + + /** @brief Maps from name to expression node. */ std::map named_; + + /** @brief List of all parameter nodes of this expression graph. */ std::vector params_; + + /** @brief List of all input nodes of this expression graph. */ std::vector inputs_; }; diff --git a/src/expression_operators.cu b/src/expression_operators.cu index 19cb1fa9..2f14c34e 100644 --- a/src/expression_operators.cu +++ b/src/expression_operators.cu @@ -1,3 +1,23 @@ +// This file is part of the Marian toolkit. +// Marian is copyright (c) 2016 Marcin Junczys-Dowmunt. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. #include "expression_operators.h" #include "node_operators.h" diff --git a/src/expression_operators.h b/src/expression_operators.h index 8da89824..4bd41565 100644 --- a/src/expression_operators.h +++ b/src/expression_operators.h @@ -1,5 +1,26 @@ #pragma once +// This file is part of the Marian toolkit. +// Marian is copyright (c) 2016 Marcin Junczys-Dowmunt. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + #include "expression_graph.h" namespace marian { diff --git a/src/keywords.h b/src/keywords.h index e72cdb9a..bf37ea10 100644 --- a/src/keywords.h +++ b/src/keywords.h @@ -1,5 +1,26 @@ #pragma once +// This file is part of the Marian toolkit. +// Marian is copyright (c) 2016 Marcin Junczys-Dowmunt. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + #include #include #include @@ -125,4 +146,4 @@ namespace keywords { name ## _k name(#name); } -} \ No newline at end of file +} diff --git a/src/marian.h b/src/marian.h index 5cc06dd7..aae88fc5 100644 --- a/src/marian.h +++ b/src/marian.h @@ -1,5 +1,26 @@ #pragma once +// This file is part of the Marian toolkit. +// Marian is copyright (c) 2016 Marcin Junczys-Dowmunt. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + #include "definitions.h" #include "expression_graph.h" #include "param_initializers.h" diff --git a/src/mnist.h b/src/mnist.h index 43931ed2..05e11b6e 100644 --- a/src/mnist.h +++ b/src/mnist.h @@ -1,5 +1,26 @@ //#pragma once +// This file is part of the Marian toolkit. +// Marian is copyright (c) 2016 Marcin Junczys-Dowmunt. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + #include #include #include diff --git a/src/mnist_benchmark.cu b/src/mnist_benchmark.cu index 2b7bd0cd..920e3d79 100644 --- a/src/mnist_benchmark.cu +++ b/src/mnist_benchmark.cu @@ -50,6 +50,9 @@ ExpressionGraph build_graph(const std::vector& dims) { cost, "cost" ); + // If we uncomment the line below, this will just horribly diverge. + // auto dummy_probs = named(softmax(scores), "dummy_probs"); + std::cerr << timer.format(5, "%ws") << std::endl; return g; } diff --git a/src/node.h b/src/node.h index dfdaca00..f32ca2fd 100644 --- a/src/node.h +++ b/src/node.h @@ -1,5 +1,26 @@ #pragma once +// This file is part of the Marian toolkit. +// Marian is copyright (c) 2016 Marcin Junczys-Dowmunt. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + #include "keywords.h" #include "tensor.h" #include "chainable.h" diff --git a/src/node_operators.h b/src/node_operators.h index 9d6a6e25..4fbb3b6e 100644 --- a/src/node_operators.h +++ b/src/node_operators.h @@ -1,5 +1,26 @@ #pragma once +// This file is part of the Marian toolkit. +// Marian is copyright (c) 2016 Marcin Junczys-Dowmunt. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + #include "node.h" #include "tensor_operators.h" diff --git a/src/npz_converter.cpp b/src/npz_converter.cpp index 771ff11c..006160c2 100644 --- a/src/npz_converter.cpp +++ b/src/npz_converter.cpp @@ -1,3 +1,24 @@ +// This file is part of the Marian toolkit. +// Marian is copyright (c) 2016 Marcin Junczys-Dowmunt. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + #include "npz_converter.h" @@ -17,6 +38,7 @@ void NpzConverter::Destruct() { destructed_ = true; } +/** TODO: Marcin, what does this function do? Why isn't it a method? */ mblas::Matrix NpzConverter::operator[](const std::string& key) const { typedef blaze::CustomMatrix BlazeWrapper; diff --git a/src/npz_converter.h b/src/npz_converter.h index 96060cfc..f27b7a35 100644 --- a/src/npz_converter.h +++ b/src/npz_converter.h @@ -1,31 +1,110 @@ #pragma once -#include "cnpy/cnpy.h" -#include "tensor.h" +// This file is part of the Marian toolkit. +// Marian is copyright (c) 2016 Marcin Junczys-Dowmunt. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +#include "cnpy/cnpy.h" +#include "tensor.h" //XXX Marcin, is this include actually needed? It appears to not be used. + +/** + * @brief Loads model data stored in a npz file. + * + * Use of this class enables such data to later be stored in standard Marian data structures. + * + * Note: this class makes use of the 3rd-party class npy. + */ class NpzConverter { + + // Private inner classes of the NpzConverter class private: + + /** + * Wraps npy data such that the underlying matrix shape and + * matrix data are made accessible. + */ class NpyMatrixWrapper { + public: + + /** + * Constructs a wrapper around an underlying npy data structure, + * enabling the underlying data to be accessed as a matrix. + * + * @param npy the underlying data + */ NpyMatrixWrapper(const cnpy::NpyArray& npy) : npy_(npy) {} + /** + * Returns the total number of elements in the underlying matrix. + * + * @return the total number of elements in the underlying matrix + */ size_t size() const { return size1() * size2(); } + /** + * Returns a pointer to the raw data that underlies the matrix. + * + * @return a pointer to the raw data that underlies the matrix + */ float* data() const { return (float*)npy_.data; } + /** + * Given the index (i, j) of a matrix element, + * this operator returns the float value from the underlying npz data + * that is stored in the matrix. + * + * XXX: Marcin, is the following correct? Or do I have the row/column labels swapped? + * + * @param i Index of a column in the matrix + * @param j Index of a row in the matrix + * + * @return the float value stored at column i, row j of the matrix + */ float operator()(size_t i, size_t j) const { return ((float*)npy_.data)[i * size2() + j]; } + /** + * Returns the number of columns in the matrix. + * + * XXX: Marcin, is this following correct? Or do I have the row/column labels swapped? + * + * @return the number of columns in the matrix + */ size_t size1() const { return npy_.shape[0]; } + /** + * Returns the number of rows in the matrix. + * + * XXX: Marcin, is this following correct? Or do I have the row/column labels swapped? + * + * @return the number of rows in the matrix + */ size_t size2() const { if(npy_.shape.size() == 1) return 1; @@ -34,25 +113,50 @@ class NpzConverter { } private: - const cnpy::NpyArray& npy_; - }; + /** Instance of the underlying (3rd party) data structure. */ + const cnpy::NpyArray& npy_; + + }; // End of NpyMatrixWrapper class + + // Public methods of the NpzConverter class public: + + /** + * Constructs an object that reads npz data from a file. + * + * @param file Path to file containing npz data + */ NpzConverter(const std::string& file) : model_(cnpy::npz_load(file)), destructed_(false) { } + /** + * Destructs the model that underlies this NpzConverter object, + * if that data has not already been destructed. + */ ~NpzConverter() { if(!destructed_) model_.destruct(); } + /** + * Destructs the model that underlies this NpzConverter object, + * and marks that data as having been destructed. + */ void Destruct() { model_.destruct(); destructed_ = true; } + /** + * Loads data corresponding to a search key into the provided vector. + * + * @param key Search key XXX Marcin, what type of thing is "key"? What are we searching for here? + * @param data Container into which data will be loaded XXX Lane, is there a way in Doxygen to mark and inout variable? + * @param shape Shape object into which the number of rows and columns of the vectors will be stored + */ void Load(const std::string& key, std::vector& data, marian::Shape& shape) const { auto it = model_.find(key); if(it != model_.end()) { @@ -71,7 +175,13 @@ class NpzConverter { } } + // Private member data of the NpzConverter class private: + + /** Underlying npz data */ cnpy::npz_t model_; + + /** Indicates whether the underlying data has been destructed. */ bool destructed_; -}; + +}; // End of NpzConverter class diff --git a/src/optimizers.h b/src/optimizers.h index 8a067f90..de4d91d3 100644 --- a/src/optimizers.h +++ b/src/optimizers.h @@ -1,5 +1,26 @@ #pragma once +// This file is part of the Marian toolkit. +// Marian is copyright (c) 2016 Marcin Junczys-Dowmunt. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + #include #include #include "tensor_operators.h" diff --git a/src/param_initializers.h b/src/param_initializers.h index dba7f87c..99013432 100644 --- a/src/param_initializers.h +++ b/src/param_initializers.h @@ -1,5 +1,26 @@ #pragma once +// This file is part of the Marian toolkit. +// Marian is copyright (c) 2016 Marcin Junczys-Dowmunt. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + #include #include #include diff --git a/src/tensor.cu b/src/tensor.cu index 3ec4e71e..88180adb 100644 --- a/src/tensor.cu +++ b/src/tensor.cu @@ -1,3 +1,24 @@ +// This file is part of the Marian toolkit. +// Marian is copyright (c) 2016 Marcin Junczys-Dowmunt. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + #include #include "tensor.h" diff --git a/src/tensor.h b/src/tensor.h index d083435e..3540bfdd 100644 --- a/src/tensor.h +++ b/src/tensor.h @@ -1,21 +1,25 @@ #pragma once -/* Copyright (C) - * 2016 - MLAMU & friends - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - */ + +// This file is part of the Marian toolkit. +// Marian is copyright (c) 2016 Marcin Junczys-Dowmunt. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. #include #include diff --git a/src/tensor_operators.cu b/src/tensor_operators.cu index 874b91ce..06502570 100644 --- a/src/tensor_operators.cu +++ b/src/tensor_operators.cu @@ -1,3 +1,24 @@ +// This file is part of the Marian toolkit. +// Marian is copyright (c) 2016 Marcin Junczys-Dowmunt. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + #include "tensor_operators.h" using namespace std; diff --git a/src/tensor_operators.h b/src/tensor_operators.h index 077f36a5..316ad5eb 100644 --- a/src/tensor_operators.h +++ b/src/tensor_operators.h @@ -1,5 +1,26 @@ #pragma once +// This file is part of the Marian toolkit. +// Marian is copyright (c) 2016 Marcin Junczys-Dowmunt. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + #include "tensor.h" namespace marian { diff --git a/src/test.cu b/src/test.cu index 5aa7de8f..b1268f38 100644 --- a/src/test.cu +++ b/src/test.cu @@ -1,3 +1,24 @@ +// This file is part of the Marian toolkit. +// Marian is copyright (c) 2016 Marcin Junczys-Dowmunt. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + #include #include "marian.h" #include "mnist.h" diff --git a/src/thrust_functions.h b/src/thrust_functions.h index eee3b4ae..7f22a239 100644 --- a/src/thrust_functions.h +++ b/src/thrust_functions.h @@ -1,5 +1,26 @@ #pragma once +// This file is part of the Marian toolkit. +// Marian is copyright (c) 2016 Marcin Junczys-Dowmunt. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + #include #include #include @@ -93,4 +114,4 @@ namespace thrust } } } -} \ No newline at end of file +} diff --git a/src/validate_encoder_decoder.cu b/src/validate_encoder_decoder.cu index 15159ba6..4821aa7f 100644 --- a/src/validate_encoder_decoder.cu +++ b/src/validate_encoder_decoder.cu @@ -1,3 +1,24 @@ +// This file is part of the Marian toolkit. +// Marian is copyright (c) 2016 Marcin Junczys-Dowmunt. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + #include "marian.h" #include "mnist.h" #include "vocab.h" diff --git a/src/validate_mnist_batch.cu b/src/validate_mnist_batch.cu index 76379eda..53242e65 100644 --- a/src/validate_mnist_batch.cu +++ b/src/validate_mnist_batch.cu @@ -1,3 +1,23 @@ +// This file is part of the Marian toolkit. +// Marian is copyright (c) 2016 Marcin Junczys-Dowmunt. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. #include "marian.h" #include "mnist.h" diff --git a/src/vocab.cpp b/src/vocab.cpp index 25c28386..13711723 100644 --- a/src/vocab.cpp +++ b/src/vocab.cpp @@ -1,3 +1,24 @@ +// This file is part of the Marian toolkit. +// Marian is copyright (c) 2016 Marcin Junczys-Dowmunt. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + #include #include "vocab.h" diff --git a/src/vocab.h b/src/vocab.h index 3127083d..5c34674a 100644 --- a/src/vocab.h +++ b/src/vocab.h @@ -1,5 +1,26 @@ #pragma once +// This file is part of the Marian toolkit. +// Marian is copyright (c) 2016 Marcin Junczys-Dowmunt. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + #include #include #include