Add specialization of method Array::FillRandom() for complex64 type.

Fix comments.

PiperOrigin-RevId: 285447090
Change-Id: I6a328bedbdd19f7892a6cbe2dbde42067e252880
This commit is contained in:
A. Unique TensorFlower 2019-12-13 12:13:49 -08:00 committed by TensorFlower Gardener
parent 73762ec50e
commit 161efd5153
4 changed files with 41 additions and 4 deletions

View File

@ -522,6 +522,7 @@ cc_library(
cc_library(
name = "array",
srcs = ["array.cc"],
hdrs = ["array.h"],
deps = [
":status",

View File

@ -0,0 +1,32 @@
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include "tensorflow/compiler/xla/array.h"
namespace xla {
// Specialization of FillRandom() method for complex64 type. Uses real part of
// the stddev parameter as the standard deviation value.
template <>
void Array<complex64>::FillRandom(const complex64& stddev, const double mean,
const int seed) {
std::mt19937 g(seed);
std::normal_distribution<double> distribution(mean, std::real(stddev));
for (int64 i = 0; i < num_elements(); ++i) {
values_[i] = complex64(distribution(g), distribution(g));
}
}
} // namespace xla

View File

@ -575,6 +575,12 @@ class Array {
std::unique_ptr<T[]> values_;
};
// Specialization of FillRandom() method for complex64 type. Uses real part of
// the stddev parameter as the standard deviation value.
template <>
void Array<complex64>::FillRandom(const complex64& stddev, const double mean,
const int seed);
} // namespace xla
#endif // TENSORFLOW_COMPILER_XLA_ARRAY_H_

View File

@ -1103,8 +1103,7 @@ class HloConvolutionInstruction : public HloInstruction {
void set_feature_group_count(int64 num_feature_groups) {
feature_group_count_ = num_feature_groups;
}
// The number of feature groups. Must be a divisor of the input batch
// dimension.
// The number of batch groups. Must be a divisor of the input batch dimension.
int64 batch_group_count() const { return batch_group_count_; }
void set_batch_group_count(int64 num_batch_groups) {
batch_group_count_ = num_batch_groups;
@ -1138,8 +1137,7 @@ class HloConvolutionInstruction : public HloInstruction {
// The number of feature groups. Must be a divisor of the input feature
// dimension and output feature dimension.
int64 feature_group_count_;
// The number of feature groups. Must be a divisor of the input batch
// dimension.
// The number of batch groups. Must be a divisor of the input batch dimension.
int64 batch_group_count_;
// Describes the window used for a convolution.
Window window_;