MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / ThreeFryRngBit64

Function ThreeFryRngBit64

tensorflow/compiler/xla/client/lib/prng.cc:169–178  ·  view source on GitHub ↗

Generates random 64bits with the given shape using the Three Fry implementation. Returns the random bits and the new state.

Source from the content-addressed store, hash-verified

167// Generates random 64bits with the given shape using the Three Fry
168// implementation. Returns the random bits and the new state.
169RngOutput ThreeFryRngBit64(XlaOp key, XlaOp initial_state, const Shape& shape) {
170 const int64 size = ShapeUtil::ElementsIn(shape);
171 std::pair<ThreeFry2x32State, XlaOp> inputs_state =
172 GetThreeFryInputsAndUpdatedState(initial_state, size);
173 ThreeFry2x32State inputs = inputs_state.first;
174 ThreeFry2x32State outputs = ThreeFry2x32(inputs, Uint64ToUint32s(key));
175 XlaOp result = Uint32sToUint64(outputs);
176 return {Reshape(result, AsInt64Slice(shape.dimensions())),
177 inputs_state.second};
178}
179
180// The key of the Philox random number generator.
181using Philox4x32Key = std::array<XlaOp, 2>;

Callers 1

ThreeFryBitGeneratorFunction · 0.85

Calls 7

ThreeFry2x32Function · 0.85
Uint64ToUint32sFunction · 0.85
Uint32sToUint64Function · 0.85
ReshapeFunction · 0.50
AsInt64SliceFunction · 0.50
dimensionsMethod · 0.45

Tested by

no test coverage detected