1/**
2 * Copyright (c) Glow Contributors. See CONTRIBUTORS file.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef GLOW_OPTIMIZER_GRAPHOPTIMIZER_TRAININGPREPARATION_H
18#define GLOW_OPTIMIZER_GRAPHOPTIMIZER_TRAININGPREPARATION_H
19
20#include "glow/Graph/Graph.h"
21#include "glow/Support/Error.h"
22
23#include <functional>
24
25namespace glow {
26
27/// Forward declaration.
28class Tensor;
29
30/// Function for \p tensor initialization.
31/// Method gets following parameters Glow Function \p F, current \p node,
32/// \p inputIdx, and fills out \p tensor.
33using TensorInitializer = std::function<void(
34 Function *F, Node *node, unsigned inputIdx, Tensor *tensor)>;
35
36/// Method generates and returns the default tensor initializer.
37TensorInitializer getDefaultTensorInitializer();
38
39/// Function takes glow::Function \p F, \p bindings, \p selected placeholder,
40// and \p initializer for the input weights.
41Error prepareFunctionForTraining(
42 Function *F, PlaceholderBindings &bindings, Placeholder *&selected,
43 TensorInitializer &&initializer = getDefaultTensorInitializer());
44} // namespace glow
45
46#endif // GLOW_OPTIMIZER_GRAPHOPTIMIZER_TRAININGPREPARATION_H
47