Skip to content

Commit

Permalink
update comment and revert format
Browse files Browse the repository at this point in the history
  • Loading branch information
ScXfjiang committed Oct 1, 2024
1 parent b4b5462 commit 8ecf02f
Show file tree
Hide file tree
Showing 14 changed files with 65 additions and 68 deletions.
7 changes: 3 additions & 4 deletions tensorflow/c/tf_datatype.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,11 @@ typedef enum TF_DataType {
TF_UINT32 = 22,
TF_UINT64 = 23,
TF_FLOAT8_E5M2 = 24, // 5 exponent bits, 2 mantissa bits.
TF_FLOAT8_E4M3FN = 25, // 4 exponent bits, 3 mantissa bits, finite-only, with
// 2 NaNs (0bS1111111).
TF_FLOAT8_E4M3FNUZ = 26, // 4 exponent bits, 3 mantissa bits, Finite, NaN, Unique Zero
TF_FLOAT8_E4M3FN = 25, // 4 exponent bits, 3 mantissa bits, finite-only, with two NaNs and two Zeros.
TF_FLOAT8_E4M3FNUZ = 26, // 4 exponent bits, 3 mantissa bits, finite-only, with one NaN and one Zero.
// TODO - b/299182407: Leaving room for remaining float8 types.
// TF_FLOAT8_E4M3B11FNUZ = 27,
TF_FLOAT8_E5M2FNUZ = 28, // 5 exponent bits, 2 mantissa bits, Finite, NaN, Unique Zero
TF_FLOAT8_E5M2FNUZ = 28, // 5 exponent bits, 2 mantissa bits, finite-only, with one NaN and one Zero.
TF_INT4 = 29,
TF_UINT4 = 30,
} TF_DataType;
Expand Down
4 changes: 2 additions & 2 deletions tensorflow/compiler/jit/xla_gpu_device.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ limitations under the License.
#include "tensorflow/compiler/jit/xla_platform_info.h"
#include "tensorflow/compiler/tf2xla/layout_util.h"
#include "tensorflow/compiler/tf2xla/xla_op_registry.h"
#include "tensorflow/core/common_runtime/device_factory.h"
#include "tensorflow/core/lib/core/status.h"
#include "xla/stream_executor/gpu/gpu_init.h"
#include "xla/stream_executor/platform_manager.h"
#include "tensorflow/core/common_runtime/device_factory.h"
#include "tensorflow/core/lib/core/status.h"

namespace tensorflow {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ limitations under the License.
==============================================================================*/
#include "tensorflow/compiler/mlir/quantization/stablehlo/utils/bfloat16_type.h"

#include <gtest/gtest.h>

#include <memory>

#include <gtest/gtest.h>
#include "mlir/IR/BuiltinTypes.h" // from @llvm-project
#include "mlir/IR/MLIRContext.h" // from @llvm-project
#include "mlir/IR/MLIRContext.h" // from @llvm-project
#include "tensorflow/compiler/mlir/register_common_dialects.h"

namespace mlir::quant::stablehlo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,30 @@ limitations under the License.

#include "tensorflow/compiler/mlir/quantization/stablehlo/utils/tf_type_utils.h"

#include <gmock/gmock.h>
#include <gtest/gtest.h>

#include <cstdint>
#include <memory>
#include <string>

#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "llvm/Support/Casting.h"
#include "mlir/Dialect/Quant/QuantOps.h" // from @llvm-project
#include "mlir/Dialect/Quant/QuantTypes.h" // from @llvm-project
#include "mlir/Dialect/Quant/QuantOps.h" // from @llvm-project
#include "mlir/Dialect/Quant/QuantTypes.h" // from @llvm-project
#include "mlir/Dialect/SparseTensor/IR/SparseTensor.h" // from @llvm-project
#include "mlir/IR/BuiltinTypes.h" // from @llvm-project
#include "mlir/IR/MLIRContext.h" // from @llvm-project
#include "mlir/Pass/PassManager.h" // from @llvm-project
#include "mlir/Support/LLVM.h" // from @llvm-project
#include "mlir/Support/LogicalResult.h" // from @llvm-project
#include "mlir/IR/BuiltinTypes.h" // from @llvm-project
#include "mlir/IR/MLIRContext.h" // from @llvm-project
#include "mlir/Pass/PassManager.h" // from @llvm-project
#include "mlir/Support/LLVM.h" // from @llvm-project
#include "mlir/Support/LogicalResult.h" // from @llvm-project
#include "tensorflow/compiler/mlir/register_common_dialects.h"
#include "tensorflow/compiler/mlir/tensorflow/ir/tf_types.h"
#include "tensorflow/compiler/mlir/tensorflow/utils/mangling_util.h"
#include "xla/mlir_hlo/mhlo/IR/hlo_ops.h"
#include "xla/tsl/framework/numeric_types.h"
#include "tensorflow/core/framework/tensor.h"
#include "tensorflow/core/framework/tensor.pb.h"
#include "tensorflow/core/framework/types.pb.h"
#include "tensorflow/core/ir/types/dialect.h"
#include "xla/mlir_hlo/mhlo/IR/hlo_ops.h"
#include "xla/tsl/framework/numeric_types.h"

namespace mlir::quant::tensorflow {
namespace {
Expand Down
12 changes: 6 additions & 6 deletions tensorflow/compiler/mlir/tensorflow/utils/convert_tensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ limitations under the License.
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
#include "mlir/IR/Attributes.h" // from @llvm-project
#include "mlir/IR/Builders.h" // from @llvm-project
#include "mlir/IR/BuiltinTypeInterfaces.h" // from @llvm-project
#include "mlir/IR/BuiltinTypes.h" // from @llvm-project
#include "mlir/IR/Types.h" // from @llvm-project
#include "mlir/IR/Attributes.h" // from @llvm-project
#include "mlir/IR/Builders.h" // from @llvm-project
#include "mlir/IR/BuiltinTypeInterfaces.h" // from @llvm-project
#include "mlir/IR/BuiltinTypes.h" // from @llvm-project
#include "mlir/IR/Types.h" // from @llvm-project
#include "mlir/Support/DebugStringHelper.h" // from @llvm-project
#include "mlir/Support/LLVM.h" // from @llvm-project
#include "mlir/Support/LLVM.h" // from @llvm-project
#include "tensorflow/compiler/mlir/tensorflow/ir/tf_attributes.h"
#include "tensorflow/compiler/mlir/tensorflow/ir/tf_types.h"
#include "tensorflow/compiler/mlir/tensorflow/utils/convert_type.h"
Expand Down
14 changes: 7 additions & 7 deletions tensorflow/compiler/mlir/tensorflow/utils/convert_tensor_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ limitations under the License.
#include <cstring>
#include <initializer_list>

#include "mlir/IR/Attributes.h" // from @llvm-project
#include "mlir/IR/Builders.h" // from @llvm-project
#include "mlir/IR/Attributes.h" // from @llvm-project
#include "mlir/IR/Builders.h" // from @llvm-project
#include "mlir/IR/BuiltinTypes.h" // from @llvm-project
#include "mlir/IR/Dialect.h" // from @llvm-project
#include "mlir/IR/MLIRContext.h" // from @llvm-project
#include "mlir/Support/LLVM.h" // from @llvm-project
#include "mlir/IR/Dialect.h" // from @llvm-project
#include "mlir/IR/MLIRContext.h" // from @llvm-project
#include "mlir/Support/LLVM.h" // from @llvm-project
#include "tensorflow/compiler/mlir/tensorflow/ir/tf_ops.h"
#include "tensorflow/compiler/mlir/tensorflow/utils/dynamic_shape_utils.h"
#include "xla/test.h"
#include "tensorflow/core/framework/tensor_testutil.h"
#include "tensorflow/core/framework/tensor_util.h"
#include "tensorflow/core/framework/types.pb.h"
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/lib/core/status_test_util.h"
#include "tensorflow/core/platform/types.h"
#include "tsl/platform/ml_dtypes.h"
#include "xla/test.h"

namespace tensorflow {
namespace {
Expand All @@ -42,7 +42,7 @@ using ::testing::Eq;
using ::testing::IsFalse;
using ::testing::IsTrue;

static void RegisterDialects(mlir::MLIRContext& context) {
static void RegisterDialects(mlir::MLIRContext &context) {
context.loadDialect<mlir::TF::TensorFlowDialect>();
}

Expand Down
10 changes: 5 additions & 5 deletions tensorflow/compiler/tests/unary_ops_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ def quantize_and_dequantize_v2_round_half_up(x):
-128.0 / 127,
1,
],
dtype=dtype))
dtype=dtype))

def quantize_and_dequantize_v2_round_half_to_even(x):
return array_ops.quantize_and_dequantize(
Expand All @@ -601,7 +601,7 @@ def quantize_and_dequantize_v2_round_half_to_even(x):
-128.0 / 127,
1,
],
dtype=dtype))
dtype=dtype))

def testComplexOps(self):
for dtype in self.complex_types:
Expand Down Expand Up @@ -1022,7 +1022,7 @@ def invert_twice(x):
expected=np.array([1, 2, 0], dtype=np_dtype))

def testRank(self):
def rank_op(x): return array_ops.rank_internal(x, optimize=False)
rank_op = lambda x: array_ops.rank_internal(x, optimize=False)
for dtype in self.numeric_types:
self._assertOpOutputMatchesExpected(
rank_op, dtype(7), expected=np.int32(0))
Expand All @@ -1038,7 +1038,7 @@ def rank_op(x): return array_ops.rank_internal(x, optimize=False)
expected=np.int32(2))

def testShape(self):
def shape_op(x): return array_ops.shape_internal(x, optimize=False)
shape_op = lambda x: array_ops.shape_internal(x, optimize=False)
for dtype in self.numeric_types:
self._assertOpOutputMatchesExpected(
shape_op, dtype(7), expected=np.array([], dtype=np.int32))
Expand All @@ -1060,7 +1060,7 @@ def shape_op(x): return array_ops.shape_internal(x, optimize=False)
expected=np.array([3, 1], dtype=np.int32))

def testSize(self):
def size_op(x): return array_ops.size_internal(x, optimize=False)
size_op = lambda x: array_ops.size_internal(x, optimize=False)
for dtype in self.numeric_types:
self._assertOpOutputMatchesExpected(
size_op, dtype(7), expected=np.int32(1))
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/core/framework/tensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ limitations under the License.
#include <utility>

#include "absl/strings/escaping.h"
#include "xla/tsl/util/byte_swap_array.h"
#include "tensorflow/core/framework/allocation_description.pb.h"
#include "tensorflow/core/framework/log_memory.h"
#include "tensorflow/core/framework/resource_handle.h"
Expand Down Expand Up @@ -65,7 +66,6 @@ limitations under the License.
#include "tensorflow/core/platform/protobuf.h"
#include "tensorflow/core/platform/tensor_coding.h"
#include "tensorflow/core/platform/types.h"
#include "xla/tsl/util/byte_swap_array.h"

namespace tensorflow {

Expand Down
4 changes: 2 additions & 2 deletions tensorflow/core/framework/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ limitations under the License.
#include <string>

#include "absl/numeric/bits.h"
#include "unsupported/Eigen/CXX11/Tensor" // from @eigen_archive
#include "xla/tsl/framework/device_type.h"
#include "tensorflow/core/framework/bfloat16.h"
#include "tensorflow/core/framework/full_type.pb.h"
#include "tensorflow/core/framework/numeric_types.h"
Expand All @@ -32,8 +34,6 @@ limitations under the License.
#include "tensorflow/core/lib/gtl/inlined_vector.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/types.h"
#include "unsupported/Eigen/CXX11/Tensor" // from @eigen_archive
#include "xla/tsl/framework/device_type.h"

namespace tensorflow {

Expand Down
6 changes: 3 additions & 3 deletions tensorflow/core/framework/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ enum DataType {
DT_UINT32 = 22;
DT_UINT64 = 23;
DT_FLOAT8_E5M2 = 24; // 5 exponent bits, 2 mantissa bits.
DT_FLOAT8_E4M3FN = 25; // 4 exponent bits, 3 mantissa bits, finite-only, with 2 NaNs (0bS1111111).
DT_FLOAT8_E4M3FNUZ = 26; // 4 exponent bits, 3 mantissa bits, Finite, NaN, Unique Zero
DT_FLOAT8_E4M3FN = 25; // 4 exponent bits, 3 mantissa bits, finite-only, with two NaNs and two Zeros.
DT_FLOAT8_E4M3FNUZ = 26; // 4 exponent bits, 3 mantissa bits, finite-only, with one NaN and one Zero.
// TODO - b/299182407: Leaving room for remaining float8 types.
// DT_FLOAT8_E4M3B11FNUZ = 27;
DT_FLOAT8_E5M2FNUZ = 28; // 5 exponent bits, 2 mantissa bits, Finite, NaN, Unique Zero
DT_FLOAT8_E5M2FNUZ = 28; // 5 exponent bits, 2 mantissa bits, finite-only, with one NaN and one Zero.
DT_INT4 = 29;
DT_UINT4 = 30;

Expand Down
8 changes: 4 additions & 4 deletions tensorflow/core/ir/dialect.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ limitations under the License.
#ifndef TENSORFLOW_CORE_IR_DIALECT_H_
#define TENSORFLOW_CORE_IR_DIALECT_H_

#include "mlir/IR/BuiltinTypes.h" // from @llvm-project
#include "mlir/IR/Diagnostics.h" // from @llvm-project
#include "mlir/IR/Dialect.h" // from @llvm-project
#include "mlir/IR/BuiltinTypes.h" // from @llvm-project
#include "mlir/IR/Diagnostics.h" // from @llvm-project
#include "mlir/IR/Dialect.h" // from @llvm-project
#include "mlir/IR/OpImplementation.h" // from @llvm-project
#include "mlir/IR/TypeUtilities.h" // from @llvm-project
#include "mlir/IR/TypeUtilities.h" // from @llvm-project
#include "tensorflow/core/ir/types/dialect.h"

namespace mlir {
Expand Down
8 changes: 4 additions & 4 deletions tensorflow/core/ir/importexport/convert_tensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ limitations under the License.
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
#include "mlir/IR/Attributes.h" // from @llvm-project
#include "mlir/IR/Builders.h" // from @llvm-project
#include "mlir/IR/Attributes.h" // from @llvm-project
#include "mlir/IR/Builders.h" // from @llvm-project
#include "mlir/IR/BuiltinTypes.h" // from @llvm-project
#include "mlir/IR/Types.h" // from @llvm-project
#include "mlir/Support/LLVM.h" // from @llvm-project
#include "mlir/IR/Types.h" // from @llvm-project
#include "mlir/Support/LLVM.h" // from @llvm-project
#include "tensorflow/core/framework/tensor.h"
#include "tensorflow/core/framework/tensor.pb.h"
#include "tensorflow/core/framework/tensor_shape.pb.h"
Expand Down
6 changes: 3 additions & 3 deletions tensorflow/core/ir/importexport/convert_types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ limitations under the License.

#include "absl/strings/str_cat.h"
#include "llvm/Support/Casting.h"
#include "mlir/IR/BuiltinTypes.h" // from @llvm-project
#include "mlir/IR/Types.h" // from @llvm-project
#include "mlir/IR/BuiltinTypes.h" // from @llvm-project
#include "mlir/IR/Types.h" // from @llvm-project
#include "mlir/Support/DebugStringHelper.h" // from @llvm-project
#include "mlir/Support/LLVM.h" // from @llvm-project
#include "mlir/Support/LLVM.h" // from @llvm-project
#include "tensorflow/core/framework/types.h"
#include "tensorflow/core/framework/types.pb.h"
#include "tensorflow/core/ir/dialect.h"
Expand Down
24 changes: 12 additions & 12 deletions tensorflow/core/ir/types/dialect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ limitations under the License.
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/SMLoc.h"
#include "llvm/Support/raw_ostream.h"
#include "mlir/Dialect/Traits.h" // from @llvm-project
#include "mlir/IR/Attributes.h" // from @llvm-project
#include "mlir/IR/Builders.h" // from @llvm-project
#include "mlir/IR/BuiltinAttributes.h" // from @llvm-project
#include "mlir/IR/BuiltinOps.h" // from @llvm-project
#include "mlir/Dialect/Traits.h" // from @llvm-project
#include "mlir/IR/Attributes.h" // from @llvm-project
#include "mlir/IR/Builders.h" // from @llvm-project
#include "mlir/IR/BuiltinAttributes.h" // from @llvm-project
#include "mlir/IR/BuiltinOps.h" // from @llvm-project
#include "mlir/IR/BuiltinTypeInterfaces.h" // from @llvm-project
#include "mlir/IR/BuiltinTypes.h" // from @llvm-project
#include "mlir/IR/Dialect.h" // from @llvm-project
#include "mlir/IR/BuiltinTypes.h" // from @llvm-project
#include "mlir/IR/Dialect.h" // from @llvm-project
#include "mlir/IR/DialectImplementation.h" // from @llvm-project
#include "mlir/IR/MLIRContext.h" // from @llvm-project
#include "mlir/IR/OpImplementation.h" // from @llvm-project
#include "mlir/IR/OperationSupport.h" // from @llvm-project
#include "mlir/Support/LLVM.h" // from @llvm-project
#include "mlir/Support/LogicalResult.h" // from @llvm-project
#include "mlir/IR/MLIRContext.h" // from @llvm-project
#include "mlir/IR/OpImplementation.h" // from @llvm-project
#include "mlir/IR/OperationSupport.h" // from @llvm-project
#include "mlir/Support/LLVM.h" // from @llvm-project
#include "mlir/Support/LogicalResult.h" // from @llvm-project

#define GET_ATTRDEF_CLASSES
#include "tensorflow/core/ir/types/attributes.cc.inc"
Expand Down

0 comments on commit 8ecf02f

Please sign in to comment.