Caffe2 - C++ API
A deep learning, cross platform ML framework
support.h
1 #pragma once
2 
3 #include <test/cpp/common/support.h>
4 
5 #include <gtest/gtest.h>
6 
7 #include <torch/nn/cloneable.h>
8 #include <torch/types.h>
9 #include <torch/utils.h>
10 
11 #include <string>
12 #include <utility>
13 
14 namespace torch {
15 namespace test {
16 
17 // Lets you use a container without making a new class,
18 // for experimental implementations
19 class SimpleContainer : public nn::Cloneable<SimpleContainer> {
20  public:
21  void reset() override {}
22 
23  template <typename ModuleHolder>
24  ModuleHolder add(
25  ModuleHolder module_holder,
26  std::string name = std::string()) {
27  return Module::register_module(std::move(name), module_holder);
28  }
29 };
30 
31 inline bool pointer_equal(at::Tensor first, at::Tensor second) {
32  return first.data<float>() == second.data<float>();
33 }
34 
35 struct SeedingFixture : public ::testing::Test {
36  SeedingFixture() {
37  torch::manual_seed(0);
38  }
39 };
40 
41 } // namespace test
42 } // namespace torch
Definition: module.cpp:17
const std::string & name() const noexcept
Returns the name of the Module.
Definition: module.cpp:53
The clone() method in the base Module class does not have knowledge of the concrete runtime type of i...
Definition: cloneable.h:23
Definition: jit_type.h:17
void reset() override
reset() must perform initialization of all members with reference semantics, most importantly paramet...
Definition: support.h:21