1 /* Copyright 2015 The TensorFlow Authors. All Rights Reserved. 2 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 ==============================================================================*/ 15 16 #include "tensorflow/stream_executor/rng.h" 17 18 #include "tensorflow/stream_executor/platform/logging.h" 19 20 namespace perftools { 21 namespace gputools { 22 namespace rng { 23 24 bool RngSupport::CheckSeed(const uint8 *seed, uint64 seed_bytes) { 25 CHECK(seed != nullptr); 26 27 if (seed_bytes < kMinSeedBytes) { 28 LOG(INFO) << "Insufficient RNG seed data specified: " << seed_bytes 29 << ". At least " << RngSupport::kMinSeedBytes 30 << " bytes are required."; 31 return false; 32 } 33 34 if (seed_bytes > kMaxSeedBytes) { 35 LOG(INFO) << "Too much RNG seed data specified: " << seed_bytes 36 << ". At most " << RngSupport::kMaxSeedBytes 37 << " bytes may be provided."; 38 return false; 39 } 40 41 return true; 42 } 43 44 #if defined(__APPLE__) || defined(__FreeBSD__) 45 const int RngSupport::kMinSeedBytes; 46 const int RngSupport::kMaxSeedBytes; 47 #endif 48 49 } // namespace rng 50 } // namespace gputools 51 } // namespace perftools 52