https://mooseframework.inl.gov
Loading...
Searching...
No Matches
LibtorchRandomUtils.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#ifdef MOOSE_LIBTORCH_ENABLED
11
12#pragma once
13
14#include <torch/torch.h>
15
16#include "MooseTypes.h"
17
18namespace Moose
19{
20
24at::Generator makeLibtorchCPUGenerator();
25
30at::Generator makeLibtorchCPUGenerator(uint64_t seed);
31
39void orthogonalInitializeTensor(torch::Tensor & tensor,
40 Real gain = 1.0,
41 c10::optional<at::Generator> generator = c10::nullopt);
42
43} // namespace Moose
44
45#endif
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
void orthogonalInitializeTensor(torch::Tensor &tensor, Real gain=1.0, c10::optional< at::Generator > generator=c10::nullopt)
Fill a tensor with a (semi) orthogonal matrix using the provided generator.
at::Generator makeLibtorchCPUGenerator()
Create an owned CPU generator using libtorch's default seed behavior.