(self)
| 125 | |
| 126 | @test_util.run_v1_only("b/120545219") |
| 127 | def Test(self): |
| 128 | np.random.seed(1) |
| 129 | x_np = np.random.uniform( |
| 130 | low=-1.0, high=1.0, size=np.prod(shape_)).reshape(shape_).astype(dtype_) |
| 131 | if is_complex: |
| 132 | x_np += 1j * np.random.uniform( |
| 133 | low=-1.0, high=1.0, |
| 134 | size=np.prod(shape_)).reshape(shape_).astype(dtype_) |
| 135 | |
| 136 | with self.session(use_gpu=True) as sess: |
| 137 | if use_static_shape_: |
| 138 | x_tf = constant_op.constant(x_np) |
| 139 | else: |
| 140 | x_tf = array_ops.placeholder(dtype_) |
| 141 | q_tf, r_tf = linalg_ops.qr(x_tf, full_matrices=full_matrices_) |
| 142 | |
| 143 | if use_static_shape_: |
| 144 | q_tf_val, r_tf_val = self.evaluate([q_tf, r_tf]) |
| 145 | else: |
| 146 | q_tf_val, r_tf_val = sess.run([q_tf, r_tf], feed_dict={x_tf: x_np}) |
| 147 | |
| 148 | q_dims = q_tf_val.shape |
| 149 | np_q = np.ndarray(q_dims, dtype_) |
| 150 | np_q_reshape = np.reshape(np_q, (-1, q_dims[-2], q_dims[-1])) |
| 151 | new_first_dim = np_q_reshape.shape[0] |
| 152 | |
| 153 | x_reshape = np.reshape(x_np, (-1, x_np.shape[-2], x_np.shape[-1])) |
| 154 | for i in range(new_first_dim): |
| 155 | if full_matrices_: |
| 156 | np_q_reshape[i, :, :], _ = np.linalg.qr( |
| 157 | x_reshape[i, :, :], mode="complete") |
| 158 | else: |
| 159 | np_q_reshape[i, :, :], _ = np.linalg.qr( |
| 160 | x_reshape[i, :, :], mode="reduced") |
| 161 | np_q = np.reshape(np_q_reshape, q_dims) |
| 162 | CompareOrthogonal(self, np_q, q_tf_val, min(shape_[-2:])) |
| 163 | CheckApproximation(self, x_np, q_tf_val, r_tf_val) |
| 164 | CheckUnitary(self, q_tf_val) |
| 165 | |
| 166 | return Test |
| 167 |
nothing calls this directly
no test coverage detected