# Path: t3f/variables.py
# def get_variable(name,
#                  dtype=None,
#                  initializer=None,
#                  regularizer=None,
#                  trainable=True,
#                  collections=None,
#                  caching_device=None,
#                  validate_shape=True):
# def assign(ref, value, validate_shape=None, use_locking=None, name=None):
# 
# Path: t3f/ops.py
# def full(tt, name='t3f_full'):
# def _full_tt(tt):
# def _full_tt_batch(tt):
# def tt_tt_matmul(tt_matrix_a, tt_matrix_b):
# def tt_dense_matmul(tt_matrix_a, matrix_b):
# def dense_tt_matmul(matrix_a, tt_matrix_b):
# def sparse_tt_matmul(sparse_matrix_a, tt_matrix_b):
# def tt_sparse_matmul(tt_matrix_a, sparse_matrix_b):
# def matmul(a, b, name='t3f_matmul'):
# def tt_tt_flat_inner(tt_a, tt_b):
# def tt_dense_flat_inner(tt_a, dense_b):
# def tt_sparse_flat_inner(tt_a, sparse_b):
# def dense_tt_flat_inner(dense_a, tt_b):
# def sparse_tt_flat_inner(sparse_a, tt_b):
# def flat_inner(a, b, name='t3f_flat_inner'):
# def _add_tensor_cores(tt_a, tt_b):
# def _add_batch_tensor_cores(tt_a, tt_b):
# def _add_matrix_cores(tt_a, tt_b):
# def _add_batch_matrix_cores(tt_a, tt_b):
# def add(tt_a, tt_b, name='t3f_add'):
# def multiply(tt_left, right, name='t3f_multiply'):
# def frobenius_norm_squared(tt, differentiable=False,
#                            name='t3f_frobenius_norm_squared'):
# def frobenius_norm(tt, epsilon=1e-5, differentiable=False,
#                    name='t3f_frobenius_norm'):
# def transpose(tt_matrix, name='t3f_transpose'):
# def quadratic_form(A, b, c, name='t3f_bilinear_form'):
# def bilinear_form(A, b, c, name='t3f_bilinear_form'):
# def bilinear_form_two_mat(x, A, B, y, name='t3f_bilinear_xaby'):
# def cast(tt, dtype, name='t3f_cast'):
# def gather_nd(tt, indices, name='t3f_gather_nd'):
# def renormalize_tt_cores(tt, epsilon=1e-8, name='t3f_renormalize_tt_cores'):
# 
# Path: t3f/initializers.py
# def _validate_input_parameters(is_tensor, shape, **params):
# def tensor_ones(shape, dtype=tf.float32, name='t3f_tensor_ones'):
# def tensor_zeros(shape, dtype=tf.float32, name='t3f_tensor_zeros'):
# def eye(shape, dtype=tf.float32, name='t3f_eye'):
# def matrix_ones(shape, dtype=tf.float32, name='t3f_matrix_ones'):
# def matrix_zeros(shape, dtype=tf.float32, name='t3f_matrix_zeros'):
# def tensor_with_random_cores(shape, tt_rank=2, mean=0., stddev=1.,
#                              dtype=tf.float32,
#                              name='t3f_tensor_with_random_cores'):
# def tensor_batch_with_random_cores(shape, tt_rank=2, batch_size=1,
#                                    mean=0., stddev=1., dtype=tf.float32,
#                                    name='t3f_tensor_batch_with_random_cores'):
# def matrix_with_random_cores(shape, tt_rank=2, mean=0., stddev=1.,
#                              dtype=tf.float32,
#                              name='t3f_matrix_with_random_cores'):
# def matrix_batch_with_random_cores(shape, tt_rank=2, batch_size=1,
#                                    mean=0., stddev=1., dtype=tf.float32,
#                                    name='t3f_matrix_batch_with_random_cores'):
# def ones_like(tt, name='t3f_ones_like'):
# def zeros_like(tt, name='t3f_zeros_like'):
# def random_tensor(shape, tt_rank=2, mean=0., stddev=1., dtype=tf.float32,
#                   name='t3f_random_tensor'):
# def random_tensor_batch(shape, tt_rank=2, batch_size=1, mean=0., stddev=1.,
#                         dtype=tf.float32, name='t3f_random_tensor_batch'):
# def random_matrix(shape, tt_rank=2, mean=0., stddev=1.,
#                   dtype=tf.float32, name='t3f_random_matrix'):
# def random_matrix_batch(shape, tt_rank=2, batch_size=1, mean=0., stddev=1.,
#                         dtype=tf.float32, name='t3f_random_matrix_batch'):
# def glorot_initializer(shape, tt_rank=2, dtype=tf.float32,
#                        name='t3f_glorot_initializer'):
# def he_initializer(shape, tt_rank=2, dtype=tf.float32,
#                    name='t3f_he_initializer'):
# def lecun_initializer(shape, tt_rank=2, dtype=tf.float32,
#                       name='t3f_lecun_initializer'):


import numpy as np
import tensorflow as tf
from t3f import variables
from t3f import ops
from t3f import initializers
tf.compat.v1.enable_eager_execution()



class _VariablesTest():

  def testAttributes(self):
    # Test that after converting an initializer into a variable all the
    # attributes stays the same.
    tens = initializers.random_tensor([2, 3, 2], tt_rank=2, dtype=self.dtype)
    tens_v = variables.get_variable('tt_tens', initializer=tens)
    mat = initializers.random_matrix([[3, 2, 2], [3, 3, 3]], tt_rank=3,
                                     dtype=self.dtype)

# Path: t3f/variables.py
# def get_variable(name,
#                  dtype=None,
#                  initializer=None,
#                  regularizer=None,
#                  trainable=True,
#                  collections=None,
#                  caching_device=None,
#                  validate_shape=True):
# def assign(ref, value, validate_shape=None, use_locking=None, name=None):
# 
# Path: t3f/ops.py
# def full(tt, name='t3f_full'):
# def _full_tt(tt):
# def _full_tt_batch(tt):
# def tt_tt_matmul(tt_matrix_a, tt_matrix_b):
# def tt_dense_matmul(tt_matrix_a, matrix_b):
# def dense_tt_matmul(matrix_a, tt_matrix_b):
# def sparse_tt_matmul(sparse_matrix_a, tt_matrix_b):
# def tt_sparse_matmul(tt_matrix_a, sparse_matrix_b):
# def matmul(a, b, name='t3f_matmul'):
# def tt_tt_flat_inner(tt_a, tt_b):
# def tt_dense_flat_inner(tt_a, dense_b):
# def tt_sparse_flat_inner(tt_a, sparse_b):
# def dense_tt_flat_inner(dense_a, tt_b):
# def sparse_tt_flat_inner(sparse_a, tt_b):
# def flat_inner(a, b, name='t3f_flat_inner'):
# def _add_tensor_cores(tt_a, tt_b):
# def _add_batch_tensor_cores(tt_a, tt_b):
# def _add_matrix_cores(tt_a, tt_b):
# def _add_batch_matrix_cores(tt_a, tt_b):
# def add(tt_a, tt_b, name='t3f_add'):
# def multiply(tt_left, right, name='t3f_multiply'):
# def frobenius_norm_squared(tt, differentiable=False,
#                            name='t3f_frobenius_norm_squared'):
# def frobenius_norm(tt, epsilon=1e-5, differentiable=False,
#                    name='t3f_frobenius_norm'):
# def transpose(tt_matrix, name='t3f_transpose'):
# def quadratic_form(A, b, c, name='t3f_bilinear_form'):
# def bilinear_form(A, b, c, name='t3f_bilinear_form'):
# def bilinear_form_two_mat(x, A, B, y, name='t3f_bilinear_xaby'):
# def cast(tt, dtype, name='t3f_cast'):
# def gather_nd(tt, indices, name='t3f_gather_nd'):
# def renormalize_tt_cores(tt, epsilon=1e-8, name='t3f_renormalize_tt_cores'):
# 
# Path: t3f/initializers.py
# def _validate_input_parameters(is_tensor, shape, **params):
# def tensor_ones(shape, dtype=tf.float32, name='t3f_tensor_ones'):
# def tensor_zeros(shape, dtype=tf.float32, name='t3f_tensor_zeros'):
# def eye(shape, dtype=tf.float32, name='t3f_eye'):
# def matrix_ones(shape, dtype=tf.float32, name='t3f_matrix_ones'):
# def matrix_zeros(shape, dtype=tf.float32, name='t3f_matrix_zeros'):
# def tensor_with_random_cores(shape, tt_rank=2, mean=0., stddev=1.,
#                              dtype=tf.float32,
#                              name='t3f_tensor_with_random_cores'):
# def tensor_batch_with_random_cores(shape, tt_rank=2, batch_size=1,
#                                    mean=0., stddev=1., dtype=tf.float32,
#                                    name='t3f_tensor_batch_with_random_cores'):
# def matrix_with_random_cores(shape, tt_rank=2, mean=0., stddev=1.,
#                              dtype=tf.float32,
#                              name='t3f_matrix_with_random_cores'):
# def matrix_batch_with_random_cores(shape, tt_rank=2, batch_size=1,
#                                    mean=0., stddev=1., dtype=tf.float32,
#                                    name='t3f_matrix_batch_with_random_cores'):
# def ones_like(tt, name='t3f_ones_like'):
# def zeros_like(tt, name='t3f_zeros_like'):
# def random_tensor(shape, tt_rank=2, mean=0., stddev=1., dtype=tf.float32,
#                   name='t3f_random_tensor'):
# def random_tensor_batch(shape, tt_rank=2, batch_size=1, mean=0., stddev=1.,
#                         dtype=tf.float32, name='t3f_random_tensor_batch'):
# def random_matrix(shape, tt_rank=2, mean=0., stddev=1.,
#                   dtype=tf.float32, name='t3f_random_matrix'):
# def random_matrix_batch(shape, tt_rank=2, batch_size=1, mean=0., stddev=1.,
#                         dtype=tf.float32, name='t3f_random_matrix_batch'):
# def glorot_initializer(shape, tt_rank=2, dtype=tf.float32,
#                        name='t3f_glorot_initializer'):
# def he_initializer(shape, tt_rank=2, dtype=tf.float32,
#                    name='t3f_he_initializer'):
# def lecun_initializer(shape, tt_rank=2, dtype=tf.float32,
#                       name='t3f_lecun_initializer'):


# Path: t3f/variables_test.py
import numpy as np
import tensorflow as tf
from t3f import variables
from t3f import ops
from t3f import initializers

tf.compat.v1.enable_eager_execution()



class _VariablesTest():

  def testAttributes(self):
    # Test that after converting an initializer into a variable all the
    # attributes stays the same.
    tens = initializers.random_tensor([2, 3, 2], tt_rank=2, dtype=self.dtype)
    tens_v = variables.get_variable('tt_tens', initializer=tens)
    mat = initializers.random_matrix([[3, 2, 2], [3, 3, 3]], tt_rank=3,
                                     dtype=self.dtype)

    mat_v = variables.get_variable('tt_mat', initializer=mat)